EncodingHandlerFactory implements ComponentFactory<EncodingHandler> { public EncodingHandler getInstance() { return handler; } EncodingHandlerFactory(ServletContext context); EncodingHandler getInstance();  }
@Test public void shouldReturnANullHandlerWhenThereIsNoEncodingInitParameter() throws Exception { when(context.getInitParameter(ENCODING)).thenReturn(null); EncodingHandlerFactory handlerFactory = new EncodingHandlerFactory(context); assertThat(handlerFactory.getInstance(), is(instanceOf(NullEncodingHandler.class))); }
@Test public void shouldReturnAWebXmlHandlerWhenThereIsAnEncodingInitParameter() throws Exception { when(context.getInitParameter(ENCODING)).thenReturn("UTF-8"); EncodingHandlerFactory handlerFactory = new EncodingHandlerFactory(context); assertThat(handlerFactory.getInstance(), is(instanceOf(WebXmlEncodingHandler.class))); }