@Override public void setUp() throws Exception { RUDPMessageFactory factory = new DefaultMessageFactory(); stubService = new UDPServiceStub(factory); Executor executor = ExecutorsHelper.newProcessingQueue("TestEventThread"); udpSelectorProvider = new UDPSelectorProvider( new DefaultRUDPContext( factory, NIODispatcher.instance().getTransportListener(), stubService, new DefaultRUDPSettings()), new AsynchronousMulticasterImpl<UDPSocketChannelConnectionEvent>(executor)); udpMultiplexor = udpSelectorProvider.openSelector(); stubService.setUDPMultiplexor(udpMultiplexor); NIODispatcher.instance() .registerSelector(udpMultiplexor, udpSelectorProvider.getUDPSocketChannelClass()); // Add some simulated connections to the UDPServiceStub stubService.addReceiver(PORT_1, PORT_2, 10, 0); stubService.addReceiver(PORT_2, PORT_1, 10, 0); }
@Override public void tearDown() throws Exception { // Clear out the receiver parameters for the UDPServiceStub stubService.clearReceivers(); NIODispatcher.instance().removeSelector(udpMultiplexor); }