use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class MarshallingBaseCase method testUncheckedMarshal_ToOutputStream.
@Test
public void testUncheckedMarshal_ToOutputStream() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
Adapter adapter = createMarshallingObject();
AdaptrisMarshaller.uncheckedMarshal(marshaller, adapter, () -> {
return new ByteArrayOutputStream();
});
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class MarshallingBaseCase method testUnmarshalFromUrl.
@Test
public void testUnmarshalFromUrl() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
Adapter adapter = createMarshallingObject();
File f = new File(testOutputDir, new GuidGenerator().getUUID());
URL url = f.toURI().toURL();
marshaller.marshal(adapter, url);
try {
marshaller.unmarshal((URL) null);
fail();
} catch (IllegalArgumentException e) {
}
Adapter adapter2 = (Adapter) marshaller.unmarshal(url);
assertRoundtripEquality(adapter, adapter2);
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class MarshallingBaseCase method testRoundTripToFilename.
@Test
public void testRoundTripToFilename() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
Adapter adapter = createMarshallingObject();
File f = new File(testOutputDir, new GuidGenerator().getUUID());
marshaller.marshal(adapter, f.getCanonicalPath());
assertRoundtripEquality(adapter, marshaller.unmarshal(f));
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class MarshallingBaseCase method testUncheckedMarshal_ToOutputStreamWithException.
@Test
public void testUncheckedMarshal_ToOutputStreamWithException() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
Adapter adapter = createMarshallingObject();
try {
AdaptrisMarshaller.uncheckedMarshal(marshaller, adapter, () -> {
return new OutputStream() {
@Override
public void write(int c) throws IOException {
throw new IOException("testUncheckedMarshal_ToOutputStreamWithException");
}
};
});
fail();
} catch (RuntimeException expected) {
}
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class MarshallingBaseCase method testUnmarshalFromInputStream.
@Test
public void testUnmarshalFromInputStream() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
Adapter adapter = createMarshallingObject();
String s = marshaller.marshal(adapter);
try (ByteArrayInputStream in = new ByteArrayInputStream(s.getBytes())) {
assertRoundtripEquality(adapter, marshaller.unmarshal(in));
}
}
Aggregations