Search in sources :

Example 1 with MockJAXBCollection

use of com.helger.jaxb.mock.external.MockJAXBCollection in project ph-commons by phax.

the class JAXBMarshallerHelperTest method testGetAsBytes.

@Test
public void testGetAsBytes() {
    final MockMarshallerExternal m = new MockMarshallerExternal();
    final NonBlockingByteArrayOutputStream aBAOS = new NonBlockingByteArrayOutputStream();
    byte[] aDirectBytes;
    {
        final MockJAXBArchive aArc = new MockJAXBArchive();
        aArc.setVersion("1.24");
        for (int i = 0; i < 100; ++i) {
            final MockJAXBCollection aCollection = new MockJAXBCollection();
            aCollection.setDescription("Internal bla foo");
            aCollection.setID(i);
            aArc.getCollection().add(aCollection);
        }
        m.write(aArc, aBAOS);
        aDirectBytes = m.getAsBytes(aArc);
    }
    assertArrayEquals(aBAOS.toByteArray(), aDirectBytes);
}
Also used : NonBlockingByteArrayOutputStream(com.helger.commons.io.stream.NonBlockingByteArrayOutputStream) MockJAXBArchive(com.helger.jaxb.mock.external.MockJAXBArchive) MockJAXBCollection(com.helger.jaxb.mock.external.MockJAXBCollection) MockMarshallerExternal(com.helger.jaxb.mock.MockMarshallerExternal) Test(org.junit.Test)

Aggregations

NonBlockingByteArrayOutputStream (com.helger.commons.io.stream.NonBlockingByteArrayOutputStream)1 MockMarshallerExternal (com.helger.jaxb.mock.MockMarshallerExternal)1 MockJAXBArchive (com.helger.jaxb.mock.external.MockJAXBArchive)1 MockJAXBCollection (com.helger.jaxb.mock.external.MockJAXBCollection)1 Test (org.junit.Test)1