use of com.helger.jaxb.mock.MockMarshallerExternal in project ph-commons by phax.
the class JAXBMarshallerHelperTest method testCloseInternalOnWriteToOutputStream.
@Test
public void testCloseInternalOnWriteToOutputStream() {
final MockMarshallerExternal m = new MockMarshallerExternal();
final MutableBoolean aClosed = new MutableBoolean(false);
final NonBlockingByteArrayOutputStream aBAOS = new NonBlockingByteArrayOutputStream() {
@Override
public void close() {
super.close();
aClosed.set(true);
}
};
{
final MockJAXBArchive aArc = new MockJAXBArchive();
aArc.setVersion("1.24");
m.write(aArc, aBAOS);
}
LOGGER.info(aBAOS.getAsString(StandardCharsets.UTF_8));
// Must be closed!
assertTrue("Not closed!", aClosed.booleanValue());
}
use of com.helger.jaxb.mock.MockMarshallerExternal in project ph-commons by phax.
the class JAXBMarshallerHelperTest method testCloseExternalOnWriteToOutputStream.
@Test
public void testCloseExternalOnWriteToOutputStream() {
final MockMarshallerExternal m = new MockMarshallerExternal();
assertNotNull(m.toString());
final MutableBoolean aClosed = new MutableBoolean(false);
final NonBlockingByteArrayOutputStream aBAOS = new NonBlockingByteArrayOutputStream() {
@Override
public void close() {
super.close();
aClosed.set(true);
}
};
{
final com.helger.jaxb.mock.external.MockJAXBArchive aArc = new com.helger.jaxb.mock.external.MockJAXBArchive();
aArc.setVersion("1.23");
m.write(aArc, aBAOS);
}
LOGGER.info(aBAOS.getAsString(StandardCharsets.UTF_8));
// Must be closed!
assertTrue("Not closed!", aClosed.booleanValue());
}
use of com.helger.jaxb.mock.MockMarshallerExternal 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);
}
Aggregations