use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class MarshallingBaseCase method testMarshalToFile_NonExistent.
@Test
public void testMarshalToFile_NonExistent() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
Adapter adapter = createMarshallingObject();
File dir = File.createTempFile("pfx", ".sfx");
File nonExistent = new File(dir, new GuidGenerator().getUUID());
try {
marshaller.marshal(adapter, nonExistent);
fail();
} catch (CoreException expected) {
} finally {
FileUtils.deleteQuietly(dir);
}
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class MarshallingBaseCase method testUnmarshal_NonExistent.
@Test
public void testUnmarshal_NonExistent() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
File dir = File.createTempFile("pfx", ".sfx");
File nonExistent = new File(dir, new GuidGenerator().getUUID());
try {
marshaller.unmarshal(nonExistent);
fail();
} catch (CoreException expected) {
} finally {
FileUtils.deleteQuietly(dir);
}
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class MarshallingBaseCase method testUnmarshalFromInputStream_WithException.
@Test
public void testUnmarshalFromInputStream_WithException() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
Adapter adapter = createMarshallingObject();
String s = marshaller.marshal(adapter);
InputStream fail = new InputStream() {
@Override
public int read() throws IOException {
throw new IOException("testUnmarshalFromInputStream_WithException");
}
};
try (InputStream in = fail) {
Adapter adapter2 = (Adapter) marshaller.unmarshal(in);
fail();
} catch (CoreException e) {
assertNotNull(e.getCause());
assertRootCause("testUnmarshalFromInputStream_WithException", e);
}
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class MarshallingBaseCase method testUnmarshalString_InvalidXML.
@Test
public void testUnmarshalString_InvalidXML() throws Exception {
String xml = "This isn't XML";
AdaptrisMarshaller marshaller = createMarshaller();
try {
marshaller.unmarshal(xml);
fail();
} catch (CoreException expected) {
}
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class MarshallingBaseCase method testMarshalToURL.
@Test
public void testMarshalToURL() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
Adapter adapter = createMarshallingObject();
File f = new File(testOutputDir, new GuidGenerator().getUUID());
URL url = f.toURI().toURL();
try {
marshaller.marshal(null, (URL) null);
fail();
} catch (IllegalArgumentException e) {
}
try {
marshaller.marshal(adapter, (URL) null);
fail();
} catch (IllegalArgumentException e) {
}
try {
marshaller.marshal(null, url);
fail();
} catch (IllegalArgumentException e) {
}
try {
marshaller.marshal(adapter, new URL("http://development.adaptris.com/bugs"));
fail();
} catch (CoreException e) {
assertEquals("URL protocol must be file:", e.getMessage());
}
marshaller.marshal(adapter, url);
}
Aggregations