@Test
public void shouldUseFactoryWithGivenConfigAndDeserializeAccordingly() throws Exception {

    Serializer mock = mock(Serializer.class);
    String str = "hello";
    mockStatic(SimpleXmlFactory.class);
    when(SimpleXmlFactory.createSerializer(any(CRestConfig.class), any(Class.class))).thenReturn(mock);
    when(mock.read(any(Class.class),any(Reader.class),anyBoolean())).thenReturn(str);
    SimpleXmlDeserializer toTest = new SimpleXmlDeserializer(config);
    verify(config).get(SimpleXmlDeserializer.STRICT_PROP, true);
    verifyStatic();
    SimpleXmlFactory.createSerializer(config, SimpleXmlDeserializer.class);
    assertEquals(str, toTest.deserialize(String.class, String.class, mock(InputStream.class), UTF8));
    ArgumentCaptor<Reader> reader = ArgumentCaptor.forClass(Reader.class);
    verify(mock).read(eq(String.class), reader.capture(), eq(true));
    assertEquals(InputStreamReader.class, reader.getValue().getClass());
    assertEquals("UTF8", InputStreamReader.class.cast(reader.getValue()).getEncoding());
}