package javaflow.network.impl;
import javaflow.components.api.Component;
import javaflow.components.api.InputPort;
import javaflow.components.api.OutputPort;
import javaflow.components.api.Packet;
import javaflow.components.api.PortIsClosed;
public class TestSendingThrowsException implements Component {
InputPort in;
OutputPort out;
OutputPort result;
@Override
public void execute() {
Packet packet = in.receive();
result.createPacket("testing").send();
try {
out.send(packet);
// Expect exception to be thrown from sending dropped packet
result.createPacket("failed").send();
} catch (PortIsClosed e) {
packet.drop();
result.createPacket("success").send();
}
}
}