Search in sources :

Example 51 with CoreException

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

the class MarshallingBaseCase method testMarshalToFile_NonExistent.

@Test
public void testMarshalToFile_NonExistent() throws Exception {
    AdaptrisMarshaller marshaller = createMarshaller();
    Adapter adapter = createMarshallingObject();
    File dir = File.createTempFile("pfx", ".sfx");
    File nonExistent = new File(dir, new GuidGenerator().getUUID());
    try {
        marshaller.marshal(adapter, nonExistent);
        fail();
    } catch (CoreException expected) {
    } finally {
        FileUtils.deleteQuietly(dir);
    }
}
Also used : CoreException(com.adaptris.core.CoreException) AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Adapter(com.adaptris.core.Adapter) GuidGenerator(com.adaptris.util.GuidGenerator) File(java.io.File) Test(org.junit.Test)

Example 52 with CoreException

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

the class MarshallingBaseCase method testUnmarshal_NonExistent.

@Test
public void testUnmarshal_NonExistent() throws Exception {
    AdaptrisMarshaller marshaller = createMarshaller();
    File dir = File.createTempFile("pfx", ".sfx");
    File nonExistent = new File(dir, new GuidGenerator().getUUID());
    try {
        marshaller.unmarshal(nonExistent);
        fail();
    } catch (CoreException expected) {
    } finally {
        FileUtils.deleteQuietly(dir);
    }
}
Also used : CoreException(com.adaptris.core.CoreException) AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) GuidGenerator(com.adaptris.util.GuidGenerator) File(java.io.File) Test(org.junit.Test)

Example 53 with CoreException

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

the class MarshallingBaseCase method testUnmarshalFromInputStream_WithException.

@Test
public void testUnmarshalFromInputStream_WithException() throws Exception {
    AdaptrisMarshaller marshaller = createMarshaller();
    Adapter adapter = createMarshallingObject();
    String s = marshaller.marshal(adapter);
    InputStream fail = new InputStream() {

        @Override
        public int read() throws IOException {
            throw new IOException("testUnmarshalFromInputStream_WithException");
        }
    };
    try (InputStream in = fail) {
        Adapter adapter2 = (Adapter) marshaller.unmarshal(in);
        fail();
    } catch (CoreException e) {
        assertNotNull(e.getCause());
        assertRootCause("testUnmarshalFromInputStream_WithException", e);
    }
}
Also used : CoreException(com.adaptris.core.CoreException) AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Adapter(com.adaptris.core.Adapter) URLString(com.adaptris.util.URLString) IOException(java.io.IOException) Test(org.junit.Test)

Example 54 with CoreException

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

the class MarshallingBaseCase method testUnmarshalString_InvalidXML.

@Test
public void testUnmarshalString_InvalidXML() throws Exception {
    String xml = "This isn't XML";
    AdaptrisMarshaller marshaller = createMarshaller();
    try {
        marshaller.unmarshal(xml);
        fail();
    } catch (CoreException expected) {
    }
}
Also used : CoreException(com.adaptris.core.CoreException) AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) URLString(com.adaptris.util.URLString) Test(org.junit.Test)

Example 55 with CoreException

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

the class MarshallingBaseCase method testMarshalToURL.

@Test
public void testMarshalToURL() throws Exception {
    AdaptrisMarshaller marshaller = createMarshaller();
    Adapter adapter = createMarshallingObject();
    File f = new File(testOutputDir, new GuidGenerator().getUUID());
    URL url = f.toURI().toURL();
    try {
        marshaller.marshal(null, (URL) null);
        fail();
    } catch (IllegalArgumentException e) {
    }
    try {
        marshaller.marshal(adapter, (URL) null);
        fail();
    } catch (IllegalArgumentException e) {
    }
    try {
        marshaller.marshal(null, url);
        fail();
    } catch (IllegalArgumentException e) {
    }
    try {
        marshaller.marshal(adapter, new URL("http://development.adaptris.com/bugs"));
        fail();
    } catch (CoreException e) {
        assertEquals("URL protocol must be file:", e.getMessage());
    }
    marshaller.marshal(adapter, url);
}
Also used : CoreException(com.adaptris.core.CoreException) 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)

Aggregations

CoreException (com.adaptris.core.CoreException)186 Test (org.junit.Test)110 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)44 Adapter (com.adaptris.core.Adapter)32 ObjectName (javax.management.ObjectName)29 Channel (com.adaptris.core.Channel)27 ArrayList (java.util.ArrayList)24 IOException (java.io.IOException)20 File (java.io.File)19 ServiceException (com.adaptris.core.ServiceException)14 TimeInterval (com.adaptris.util.TimeInterval)13 Document (org.w3c.dom.Document)12 MalformedObjectNameException (javax.management.MalformedObjectNameException)11 AdaptrisMarshaller (com.adaptris.core.AdaptrisMarshaller)10 StandardWorkflow (com.adaptris.core.StandardWorkflow)9 URLString (com.adaptris.util.URLString)9 TimeoutException (java.util.concurrent.TimeoutException)9 PoolingWorkflow (com.adaptris.core.PoolingWorkflow)8 Workflow (com.adaptris.core.Workflow)8 XPath (com.adaptris.util.text.xml.XPath)8