Search in sources :

Example 36 with AdaptrisMarshaller

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());
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Adapter(com.adaptris.core.Adapter) Test(org.junit.Test)

Example 37 with AdaptrisMarshaller

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());
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Iterator(java.util.Iterator)

Example 38 with AdaptrisMarshaller

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);
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) XStreamMarshaller(com.adaptris.core.XStreamMarshaller)

Example 39 with AdaptrisMarshaller

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);
    }
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Test(org.junit.Test)

Example 40 with AdaptrisMarshaller

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);
    }
}
Also used : CoreException(com.adaptris.core.CoreException) AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) Adapter(com.adaptris.core.Adapter) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

AdaptrisMarshaller (com.adaptris.core.AdaptrisMarshaller)64 Test (org.junit.Test)57 Adapter (com.adaptris.core.Adapter)43 ObjectName (javax.management.ObjectName)21 NullConnection (com.adaptris.core.NullConnection)17 URLString (com.adaptris.util.URLString)11 CoreException (com.adaptris.core.CoreException)10 GuidGenerator (com.adaptris.util.GuidGenerator)9 File (java.io.File)9 ArrayList (java.util.ArrayList)9 IOException (java.io.IOException)7 Channel (com.adaptris.core.Channel)4 NullService (com.adaptris.core.NullService)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)3 SharedConnection (com.adaptris.core.SharedConnection)3 StandardWorkflow (com.adaptris.core.StandardWorkflow)3 MockServiceWithConnection (com.adaptris.core.stubs.MockServiceWithConnection)3 URL (java.net.URL)3