@Test
public void shouldCreateJaxbInstanceForFirstCallFromInstanceOfClassesAndReuseItForMarshallCallWithSameObjectType() throws Exception {

    Object toMarshal1 = new Object();
    Object toMarshal12 = new Object();
    MyObject toMarshal2 = new MyObject();
    MyObject toMarshal22 = new MyObject();
    OutputStream outputStream = mock(OutputStream.class);
    Charset charset = Values.UTF8;
    final Jaxb mockJaxb2 = mock(Jaxb.class);
    Jaxb mockJaxb1 = mock(Jaxb.class);
    Set<Class<?>> expected = MyObject.classes();
    mockStatic(JaxbFactory.class);
    when(JaxbFactory.create(mockCRestConfig, getClass(), new Class<?>[]{Object.class})).thenReturn(mockJaxb1);
    when(JaxbFactory.create(mockCRestConfig, getClass(),expected.toArray(new Class<?>[expected.size()]))).thenReturn(mockJaxb2);
    toTest.marshal(toMarshal1,outputStream,charset);
    toTest.marshal(toMarshal2,outputStream,charset);
    toTest.marshal(toMarshal12,outputStream,charset);
    toTest.marshal(toMarshal22,outputStream,charset);
    verify(mockJaxb1).marshal(toMarshal1,outputStream,charset);
    verify(mockJaxb2).marshal(toMarshal2,outputStream,charset);
    verify(mockJaxb1).marshal(toMarshal12,outputStream,charset);
    verify(mockJaxb2).marshal(toMarshal22,outputStream,charset);
}