DispatcherFactory { public Dispatcher createNew() { return new Dispatcher(new HandlerRegistry(LOGGER), envelopePayloadTypeConverter, jsonEnvelopeRepacker); } @Inject  DispatcherFactory(final EnvelopePayloadTypeConverter envelopePayloadTypeConverter, final JsonEnvelopeRepacker jsonEnvelopeRepacker); Dispatcher createNew();  }
@Test public void shouldCreateNewDispatcher() throws Exception { assertThat(dispatcherFactory.createNew(), instanceOf(Dispatcher.class)); }
@Test public void shouldCreateANewHandlerRegistryForEachDispatcherInstance() throws Exception { final Dispatcher dispatcher1 = dispatcherFactory.createNew(); final Dispatcher dispatcher2 = dispatcherFactory.createNew(); final HandlerRegistry handlerRegistry1 = getHandlerRegistryFrom(dispatcher1); final HandlerRegistry handlerRegistry2 = getHandlerRegistryFrom(dispatcher2); assertThat(handlerRegistry1, is(not(sameInstance(handlerRegistry2)))); assertThat(getLoggerFieldFrom(handlerRegistry1), is(notNullValue())); assertThat(getLoggerFieldFrom(handlerRegistry2), is(notNullValue())); }