use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class MarshallingBaseCase method testRoundTripToFile.
@Test
public void testRoundTripToFile() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
Adapter adapter = createMarshallingObject();
File f = new File(testOutputDir, new GuidGenerator().getUUID());
marshaller.marshal(adapter, f);
assertRoundtripEquality(adapter, marshaller.unmarshal(f));
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class MarshallingBaseCase method testRoundTripToURL.
@Test
public void testRoundTripToURL() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
Adapter adapter = createMarshallingObject();
File f = new File(testOutputDir, new GuidGenerator().getUUID());
marshaller.marshal(adapter, f.toURI().toURL());
assertRoundtripEquality(adapter, marshaller.unmarshal(f.toURI().toURL()));
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class MarshallingBaseCase method testMarshalToWriter_WithException.
@Test
public void testMarshalToWriter_WithException() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
Adapter adapter = createMarshallingObject();
Writer fail = new Writer() {
@Override
public void write(char[] cbuf, int off, int len) throws IOException {
throw new IOException("testMarshalToWriter_WithException");
}
@Override
public void flush() throws IOException {
throw new IOException("testMarshalToWriter_WithException");
}
@Override
public void close() throws IOException {
}
};
try (Writer out = fail) {
marshaller.marshal(adapter, out);
fail();
} catch (CoreException e) {
assertNotNull(e.getCause());
// assertEquals(IOException.class, e.getCause().getClass());
assertRootCause("testMarshalToWriter_WithException", e);
}
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class MarshallingBaseCase method testUnmarshalFromUrlWithException.
@Test
public void testUnmarshalFromUrlWithException() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
// Ha, anonymous URLStreamHandler to the rescue.
URL failingUrl = new URL("http", "development.adaptris.com", 80, "index.html", new URLStreamHandler() {
@Override
protected URLConnection openConnection(URL u) throws IOException {
throw new IOException("testUnmarshalFromUrl");
}
});
try {
marshaller.unmarshal(failingUrl);
fail();
} catch (CoreException e) {
assertNotNull(e.getCause());
assertEquals(IOException.class, e.getCause().getClass());
assertEquals("testUnmarshalFromUrl", e.getCause().getMessage());
}
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class MarshallingBaseCase method testMarshalToOutputStream.
@Test
public void testMarshalToOutputStream() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
Adapter adapter = createMarshallingObject();
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
marshaller.marshal(adapter, out);
}
}
Aggregations