Search in sources :

Example 56 with AdaptrisMarshaller

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

the class MarshallingBaseCase method testUncheckedMarshal_ToOutputStream.

@Test
public void testUncheckedMarshal_ToOutputStream() throws Exception {
    AdaptrisMarshaller marshaller = createMarshaller();
    Adapter adapter = createMarshallingObject();
    AdaptrisMarshaller.uncheckedMarshal(marshaller, adapter, () -> {
        return new ByteArrayOutputStream();
    });
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Adapter(com.adaptris.core.Adapter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 57 with AdaptrisMarshaller

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

the class MarshallingBaseCase method testUnmarshalFromUrl.

@Test
public void testUnmarshalFromUrl() throws Exception {
    AdaptrisMarshaller marshaller = createMarshaller();
    Adapter adapter = createMarshallingObject();
    File f = new File(testOutputDir, new GuidGenerator().getUUID());
    URL url = f.toURI().toURL();
    marshaller.marshal(adapter, url);
    try {
        marshaller.unmarshal((URL) null);
        fail();
    } catch (IllegalArgumentException e) {
    }
    Adapter adapter2 = (Adapter) marshaller.unmarshal(url);
    assertRoundtripEquality(adapter, adapter2);
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Adapter(com.adaptris.core.Adapter) GuidGenerator(com.adaptris.util.GuidGenerator) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 58 with AdaptrisMarshaller

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

the class MarshallingBaseCase method testRoundTripToFilename.

@Test
public void testRoundTripToFilename() throws Exception {
    AdaptrisMarshaller marshaller = createMarshaller();
    Adapter adapter = createMarshallingObject();
    File f = new File(testOutputDir, new GuidGenerator().getUUID());
    marshaller.marshal(adapter, f.getCanonicalPath());
    assertRoundtripEquality(adapter, marshaller.unmarshal(f));
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Adapter(com.adaptris.core.Adapter) GuidGenerator(com.adaptris.util.GuidGenerator) File(java.io.File) Test(org.junit.Test)

Example 59 with AdaptrisMarshaller

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

the class MarshallingBaseCase method testUncheckedMarshal_ToOutputStreamWithException.

@Test
public void testUncheckedMarshal_ToOutputStreamWithException() throws Exception {
    AdaptrisMarshaller marshaller = createMarshaller();
    Adapter adapter = createMarshallingObject();
    try {
        AdaptrisMarshaller.uncheckedMarshal(marshaller, adapter, () -> {
            return new OutputStream() {

                @Override
                public void write(int c) throws IOException {
                    throw new IOException("testUncheckedMarshal_ToOutputStreamWithException");
                }
            };
        });
        fail();
    } catch (RuntimeException expected) {
    }
}
Also used : 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)

Example 60 with AdaptrisMarshaller

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

the class MarshallingBaseCase method testUnmarshalFromInputStream.

@Test
public void testUnmarshalFromInputStream() throws Exception {
    AdaptrisMarshaller marshaller = createMarshaller();
    Adapter adapter = createMarshallingObject();
    String s = marshaller.marshal(adapter);
    try (ByteArrayInputStream in = new ByteArrayInputStream(s.getBytes())) {
        assertRoundtripEquality(adapter, marshaller.unmarshal(in));
    }
}
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