Search in sources :

Example 16 with AdaptrisMarshaller

use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.

the class IdentityBuilderTest method testMetadataIdentityBuilder_RoundTrip.

@Test
public void testMetadataIdentityBuilder_RoundTrip() throws Exception {
    MetadataIdentityBuilder builder = new MetadataIdentityBuilder(MetadataSource.Standard, Arrays.asList(USER, PASSWORD, ROLE));
    AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
    assertRoundtripEquality(builder, m.unmarshal(m.marshal(builder)));
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Test(org.junit.Test)

Example 17 with AdaptrisMarshaller

use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.

the class IdentityBuilderTest method testEmptyIdentityBuilder_RoundTrip.

@Test
public void testEmptyIdentityBuilder_RoundTrip() throws Exception {
    EmptyIdentityBuilder builder = new EmptyIdentityBuilder();
    AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
    assertRoundtripEquality(builder, m.unmarshal(m.marshal(builder)));
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Test(org.junit.Test)

Example 18 with AdaptrisMarshaller

use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.

the class ExampleEventHandlerCase method doAssertions.

protected void doAssertions(T eh, int msgCount, Class expectedEventClass) throws Exception {
    AdaptrisMarshaller cm = DefaultMarshaller.getDefaultMarshaller();
    MockMessageProducer producer = getProducer(eh);
    waitForMessages(producer, msgCount);
    assertEquals("Should have " + msgCount + " produced message", msgCount, producer.getMessages().size());
    for (Iterator i = producer.getMessages().iterator(); i.hasNext(); ) {
        AdaptrisMessage m = (AdaptrisMessage) i.next();
        Object o = cm.unmarshal(m.getContent());
        assertEquals("Classname", expectedEventClass, o.getClass());
    }
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Iterator(java.util.Iterator)

Example 19 with AdaptrisMarshaller

use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.

the class MarshallingBaseCase method testUnmarshalFromUrlStringLocalFile.

@Test
public void testUnmarshalFromUrlStringLocalFile() throws Exception {
    AdaptrisMarshaller marshaller = createMarshaller();
    Adapter adapter = createMarshallingObject();
    File f = new File(testOutputDir, new GuidGenerator().getUUID());
    String fname = f.getCanonicalPath();
    if (Os.isFamily(Os.WINDOWS_FAMILY)) {
        // THis is juist to remove c: and leave us with \blah.
        fname = f.getCanonicalPath().substring(2).replaceAll("\\\\", "/");
    }
    marshaller.marshal(adapter, f);
    Adapter o2 = (Adapter) marshaller.unmarshal(new URLString(fname));
    assertRoundtripEquality(adapter, o2);
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Adapter(com.adaptris.core.Adapter) GuidGenerator(com.adaptris.util.GuidGenerator) URLString(com.adaptris.util.URLString) File(java.io.File) URLString(com.adaptris.util.URLString) Test(org.junit.Test)

Example 20 with AdaptrisMarshaller

use of com.adaptris.core.AdaptrisMarshaller in project interlok by adaptris.

the class MarshallingBaseCase method testUncheckedUnmarshalFromInputStream.

@Test
public void testUncheckedUnmarshalFromInputStream() throws Exception {
    AdaptrisMarshaller marshaller = createMarshaller();
    Adapter adapter = createMarshallingObject();
    String s = marshaller.marshal(adapter);
    assertRoundtripEquality(adapter, AdaptrisMarshaller.uncheckedUnmarshal(marshaller, adapter, () -> {
        return new ByteArrayInputStream(s.getBytes());
    }));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Adapter(com.adaptris.core.Adapter) URLString(com.adaptris.util.URLString) 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