use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class StandardAdapterStartUpEventTest method testMarshalledHasNoAdapter.
@Test
public void testMarshalledHasNoAdapter() throws Exception {
StandardAdapterStartUpEvent event = new StandardAdapterStartUpEvent();
Adapter adapter = new Adapter();
event.setAdapter(adapter);
AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
String s = m.marshal(event);
System.out.println("Event marshalled - " + s);
StandardAdapterStartUpEvent mEvent = (StandardAdapterStartUpEvent) m.unmarshal(s);
System.out.println("mEvent unmarshalled - " + mEvent.toString());
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class AdvancedMessageSplitterServiceTest method assertEvents.
private void assertEvents(MockMessageProducer eh, int msgCount, Class expectedEventClass) throws Exception {
AdaptrisMarshaller cm = DefaultMarshaller.getDefaultMarshaller();
assertEquals("Should have " + msgCount + " produced message", msgCount, eh.getMessages().size());
for (Iterator i = eh.getMessages().iterator(); i.hasNext(); ) {
AdaptrisMessage m = (AdaptrisMessage) i.next();
Object o = cm.unmarshal(m.getContent());
assertEquals("Classname", expectedEventClass, o.getClass());
}
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class XmlExceptionReport method create.
@Override
public Document create(Exception e, String workflow, String location) throws Exception {
// Just use XStream as the marshaller, if we let them configure it, someone might configure
// a XStreamJSON which would be quite bad.
AdaptrisMarshaller m = new XStreamMarshaller();
ExceptionReport report = createReportObject(e, workflow, location);
return createDocument(m.marshal(report), (DocumentBuilderFactoryBuilder) null);
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class MarshallingCacheCase method testRoundTripAfterFlush.
@Test
public void testRoundTripAfterFlush() throws Exception {
String oldName = Thread.currentThread().getName();
MarshallingItemCache cache = createCache();
try {
Thread.currentThread().setName("testRoundTripAfterFlush");
start(cache);
int count = 100;
cache.update(createCacheEntries(count));
cache.evict();
cache.save();
AdaptrisMarshaller marshaller = createMarshaller();
ProcessedItemList list = (ProcessedItemList) marshaller.unmarshal(persistentStore);
assertEquals(100, list.getProcessedItems().size());
for (ProcessedItem item : list.getProcessedItems()) {
ProcessedItem cachedItem = cache.get(item.getAbsolutePath());
assertNotNull("Cache item " + item.getAbsolutePath() + "should not be null", cachedItem);
assertEquals(cachedItem.getAbsolutePath(), item.getAbsolutePath());
assertEquals(cachedItem.getFilesize(), item.getFilesize());
assertEquals(cachedItem.getLastModified(), item.getLastModified());
assertEquals(cachedItem.getLastProcessed(), item.getLastProcessed());
}
} finally {
Thread.currentThread().setName(oldName);
stop(cache);
}
}
use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.
the class MarshallingBaseCase method testMarshalToOutputStream_WithException.
@Test
public void testMarshalToOutputStream_WithException() throws Exception {
AdaptrisMarshaller marshaller = createMarshaller();
Adapter adapter = createMarshallingObject();
OutputStream fail = new OutputStream() {
@Override
public void write(int c) throws IOException {
throw new IOException("testMarshalToOutputStream_WithException");
}
};
try (OutputStream out = fail) {
marshaller.marshal(adapter, out);
fail();
} catch (CoreException e) {
assertNotNull(e.getCause());
// assertEquals(IOException.class, e.getCause().getClass());
assertRootCause("testMarshalToOutputStream_WithException", e);
}
}
Aggregations