OSCPacketDispatcher implements OSCPacketListener { @Override public void handlePacket(final OSCPacketEvent event) { dispatchPacket(event.getSource(), event.getPacket(), OSCTimeTag64.IMMEDIATE); } @SuppressWarnings("WeakerAccess")  OSCPacketDispatcher(
			final OSCSerializerAndParserBuilder serializerBuilder,
			final ScheduledExecutorService dispatchScheduler); @SuppressWarnings("WeakerAccess")  OSCPacketDispatcher(final OSCSerializerAndParserBuilder serializerBuilder);  OSCPacketDispatcher(); @SuppressWarnings("WeakerAccess") static ScheduledExecutorService createDefaultDispatchScheduler(); void setAlwaysDispatchingImmediately(final boolean alwaysDispatchingImmediately); @SuppressWarnings("WeakerAccess") boolean isAlwaysDispatchingImmediately(); @SuppressWarnings("WeakerAccess") boolean isMetaInfoRequired(); void addListener(
			final MessageSelector messageSelector,
			final OSCMessageListener listener); @SuppressWarnings("WeakerAccess") void removeListener(
			final MessageSelector messageSelector,
			final OSCMessageListener listener); @SuppressWarnings("WeakerAccess") void addBadDataListener(final OSCBadDataListener listener); @SuppressWarnings("unused") void removeBadDataListener(final OSCBadDataListener listener); @Override void handleBadData(final OSCBadDataEvent event); @Override void handlePacket(final OSCPacketEvent event); @SuppressWarnings("WeakerAccess")
	static final int MAX_ARGUMENTS; }
@Test public void testDispatchToListener1() { OSCMessage message = new OSCMessage("/listener1"); dispatcher.handlePacket(new OSCPacketEvent(this, message)); if (!listener1.isMessageReceived()) { Assert.fail("Message to listener1 didn't get sent to listener1"); } if (listener2.isMessageReceived()) { Assert.fail("Message to listener1 got sent to listener2"); } }
@Test public void testDispatchToListener2() { OSCMessage message = new OSCMessage("/listener2"); dispatcher.handlePacket(new OSCPacketEvent(this, message)); if (listener1.isMessageReceived()) { Assert.fail("Message to listener2 got sent to listener1"); } if (!listener2.isMessageReceived()) { Assert.fail("Message to listener2 didn't get sent to listener2"); } }
@Test public void testDispatchToNobody() { OSCMessage message = new OSCMessage("/nobody"); dispatcher.handlePacket(new OSCPacketEvent(this, message)); if (listener1.isMessageReceived() || listener2.isMessageReceived()) { Assert.fail("Message to nobody got dispatched incorrectly"); } }
@Test public void testDispatchManyArguments() { final int numArguments = OSCPacketDispatcher.MAX_ARGUMENTS + 1; final List<Object> arguments = new ArrayList<>(numArguments); for (int ai = 0; ai < numArguments; ai++) { arguments.add(ai); } OSCMessage message = new OSCMessage("/listener1", arguments); dispatcher.handlePacket(new OSCPacketEvent(this, message)); Assert.assertEquals(numArguments, listener1.getReceivedEvent().getMessage().getArguments().size()); }