Search in sources :

Example 31 with AdaptrisMarshaller

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

the class MarshallingBaseCase method testUncheckedUnmarshalFromInputStream_WithException.

@Test
public void testUncheckedUnmarshalFromInputStream_WithException() throws Exception {
    AdaptrisMarshaller marshaller = createMarshaller();
    Adapter adapter = createMarshallingObject();
    try {
        Object o = AdaptrisMarshaller.uncheckedUnmarshal(marshaller, adapter, () -> {
            return new InputStream() {

                @Override
                public int read() throws IOException {
                    throw new IOException("testUncheckedUnmarshalFromInputStream_WithException");
                }

                @Override
                public int read(byte[] cbuf, int off, int len) throws IOException {
                    throw new IOException("testUncheckedUnmarshalFromInputStream_WithException");
                }
            };
        });
        fail();
    } catch (RuntimeException expected) {
    }
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Adapter(com.adaptris.core.Adapter) IOException(java.io.IOException) Test(org.junit.Test)

Example 32 with AdaptrisMarshaller

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

the class AdapterComponentChecker method applyService.

@Override
public SerializableMessage applyService(String xml, SerializableMessage serializedMsg, boolean rewriteConnections) throws CoreException {
    AdaptrisMarshaller marshaller = DefaultMarshaller.getDefaultMarshaller();
    Service service = (Service) marshaller.unmarshal(xml);
    if (rewriteConnections) {
        service = rewriteConnectionsForTesting(service);
    }
    AdaptrisMessage msg = messageTranslator.translate(serializedMsg);
    try {
        initAndStart(service);
        service.doService(msg);
    } finally {
        stopAndClose(service);
    }
    return messageTranslator.translate(msg);
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Service(com.adaptris.core.Service)

Example 33 with AdaptrisMarshaller

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

the class AdapterComponentChecker method checkInitialise.

@Override
public void checkInitialise(String xml) throws CoreException {
    AdaptrisMarshaller marshaller = DefaultMarshaller.getDefaultMarshaller();
    AdaptrisComponent component = (AdaptrisComponent) marshaller.unmarshal(xml);
    prepare(component);
    if (component instanceof AllowsRetriesConnection) {
        AllowsRetriesConnection retry = (AllowsRetriesConnection) component;
        if (retry.connectionAttempts() == -1) {
            retry.setConnectionAttempts(0);
        }
    }
    try {
        init(component);
    } finally {
        close(component);
    }
}
Also used : AllowsRetriesConnection(com.adaptris.core.AllowsRetriesConnection) AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) AdaptrisComponent(com.adaptris.core.AdaptrisComponent)

Example 34 with AdaptrisMarshaller

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

the class LicenseExpiryWarningEventTest method testLegacyUnmarshal.

@Test
public void testLegacyUnmarshal() throws Exception {
    AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
    LicenseExpiryWarningEvent evt = (LicenseExpiryWarningEvent) m.unmarshal(LEGACY_LICENSE_EVENT);
    assertTrue(DateUtils.isSameDay(new Date(), evt.getExpiryDate()));
    // Legacy Unmarshal will of course, change then "when()".
    assertFalse(DateUtils.isSameDay(new Date(), evt.when()));
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Date(java.util.Date) Test(org.junit.Test)

Example 35 with AdaptrisMarshaller

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

the class StandardAdapterStartUpEventTest method testLegacyUnmarshal.

@Test
public void testLegacyUnmarshal() throws Exception {
    AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
    StandardAdapterStartUpEvent evt = (StandardAdapterStartUpEvent) m.unmarshal(LEGACY_EVENT_XML);
    assertEquals("123456", evt.getUniqueId());
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) 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