Search in sources :

Example 46 with CoreException

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

the class JndiHelperTest method testBindObject_AlreadyBound.

@Test
public void testBindObject_AlreadyBound() throws Exception {
    NullConnection connection = new NullConnection();
    connection.setUniqueId(getName());
    InitialContext initialContext = new InitialContext(env);
    JndiHelper.bind(initialContext, connection, false);
    try {
        JndiHelper.bind(initialContext, connection, true);
        fail();
    } catch (CoreException expected) {
        ;
    }
    try {
        JndiHelper.bind(initialContext, connection, false);
        fail();
    } catch (CoreException expected) {
        ;
    }
    JndiHelper.unbindQuietly(initialContext, connection, false);
}
Also used : CoreException(com.adaptris.core.CoreException) NullConnection(com.adaptris.core.NullConnection) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Example 47 with CoreException

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

the class JndiHelperTest method testUnbindCollection_WithContext.

@Test
public void testUnbindCollection_WithContext() throws Exception {
    NullConnection connection = new NullConnection();
    connection.setUniqueId(getName());
    ArrayList<AdaptrisConnection> connectionList = new ArrayList<AdaptrisConnection>();
    connectionList.add(connection);
    InitialContext initialContext = new InitialContext(env);
    JndiHelper.bind(initialContext, connectionList, true);
    JndiHelper.unbind(initialContext, connectionList, true);
    try {
        JndiHelper.unbind(initialContext, connectionList, true);
        fail();
    } catch (CoreException expected) {
    }
}
Also used : CoreException(com.adaptris.core.CoreException) AdaptrisConnection(com.adaptris.core.AdaptrisConnection) ArrayList(java.util.ArrayList) NullConnection(com.adaptris.core.NullConnection) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Example 48 with CoreException

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

the class JndiHelperTest method testUnbindUnboundTransactionManager_Debug.

@Test
public void testUnbindUnboundTransactionManager_Debug() throws Exception {
    TransactionManager transactionManager = new DummyTransactionManager(getName());
    try {
        JndiHelper.unbind(transactionManager, true);
        fail();
    } catch (CoreException expected) {
    // not previously bound, so should error.
    }
}
Also used : DummyTransactionManager(com.adaptris.core.transaction.DummyTransactionManager) CoreException(com.adaptris.core.CoreException) DummyTransactionManager(com.adaptris.core.transaction.DummyTransactionManager) TransactionManager(com.adaptris.core.transaction.TransactionManager) Test(org.junit.Test)

Example 49 with CoreException

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

the class MarshallingBaseCase method testMarshalToWriter_WithException.

@Test
public void testMarshalToWriter_WithException() throws Exception {
    AdaptrisMarshaller marshaller = createMarshaller();
    Adapter adapter = createMarshallingObject();
    Writer fail = new Writer() {

        @Override
        public void write(char[] cbuf, int off, int len) throws IOException {
            throw new IOException("testMarshalToWriter_WithException");
        }

        @Override
        public void flush() throws IOException {
            throw new IOException("testMarshalToWriter_WithException");
        }

        @Override
        public void close() throws IOException {
        }
    };
    try (Writer out = fail) {
        marshaller.marshal(adapter, out);
        fail();
    } catch (CoreException e) {
        assertNotNull(e.getCause());
        // assertEquals(IOException.class, e.getCause().getClass());
        assertRootCause("testMarshalToWriter_WithException", e);
    }
}
Also used : CoreException(com.adaptris.core.CoreException) AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) Adapter(com.adaptris.core.Adapter) IOException(java.io.IOException) StringWriter(java.io.StringWriter) Writer(java.io.Writer) Test(org.junit.Test)

Example 50 with CoreException

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

the class MarshallingBaseCase method testUnmarshalFromUrlWithException.

@Test
public void testUnmarshalFromUrlWithException() throws Exception {
    AdaptrisMarshaller marshaller = createMarshaller();
    // Ha, anonymous URLStreamHandler to the rescue.
    URL failingUrl = new URL("http", "development.adaptris.com", 80, "index.html", new URLStreamHandler() {

        @Override
        protected URLConnection openConnection(URL u) throws IOException {
            throw new IOException("testUnmarshalFromUrl");
        }
    });
    try {
        marshaller.unmarshal(failingUrl);
        fail();
    } catch (CoreException e) {
        assertNotNull(e.getCause());
        assertEquals(IOException.class, e.getCause().getClass());
        assertEquals("testUnmarshalFromUrl", e.getCause().getMessage());
    }
}
Also used : URLStreamHandler(java.net.URLStreamHandler) CoreException(com.adaptris.core.CoreException) AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) IOException(java.io.IOException) URL(java.net.URL) URLConnection(java.net.URLConnection) 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