use of org.jboss.marshalling.river.RiverUnmarshaller in project eap-additional-testsuite by jboss-set.
the class MarshallingTestCase method deserializationTest.
@ATTest({ "modules/testcases/jdkAll/Wildfly/core/src/main/java#10.0.0.Final*11.0.0.Beta1" })
public void deserializationTest() throws Exception {
RiverMarshallerFactory factory = new RiverMarshallerFactory();
MarshallingConfiguration configuration = new MarshallingConfiguration();
configuration.setVersion(2);
// Create a marshaller on some stream we have
RiverMarshaller marshaller = (RiverMarshaller) factory.createMarshaller(configuration);
final ByteArrayOutputStream fileOutputStream = new ByteArrayOutputStream();
marshaller.start(new OutputStreamByteOutput(fileOutputStream));
Bar bar = new Bar("Hello");
Foo foo = new Foo(bar);
// Write lots of stuff
marshaller.writeObject(foo);
// Done
marshaller.finish();
RiverUnmarshaller unmarshaller = (RiverUnmarshaller) factory.createUnmarshaller(configuration);
ByteArrayInputStream fileInputStream = new ByteArrayInputStream(fileOutputStream.toByteArray());
unmarshaller.start(new InputStreamByteInput(fileInputStream));
try {
Foo f = unmarshaller.readObject(Foo.class);
Assert.assertEquals(f.bar.aString, "Hello");
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
unmarshaller.finish();
}
Aggregations