Search in sources :

Example 1 with CoreException

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

the class JettyAsyncWorkflowInterceptorTest method retrieveObjectForSampleConfig.

@Override
protected Channel retrieveObjectForSampleConfig() {
    try {
        Channel c = new Channel("JettyHandler");
        PoolingWorkflow wf1 = new PoolingWorkflow("receiveJettyRequest");
        wf1.addInterceptor(new JettyAsyncWorkflowInterceptor().withMode(JettyAsyncWorkflowInterceptor.Mode.REQUEST));
        PoolingWorkflow wf2 = new PoolingWorkflow("respondToJetty");
        wf2.addInterceptor(new JettyAsyncWorkflowInterceptor().withMode(JettyAsyncWorkflowInterceptor.Mode.RESPONSE));
        wf2.getServiceCollection().add(new JettyResponseService(200, "text/plain"));
        c.getWorkflowList().add(wf1);
        c.getWorkflowList().add(wf2);
        return c;
    } catch (CoreException e) {
        throw new RuntimeException(e);
    }
}
Also used : CoreException(com.adaptris.core.CoreException) Channel(com.adaptris.core.Channel) PoolingWorkflow(com.adaptris.core.PoolingWorkflow)

Example 2 with CoreException

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

the class PasswordProtectedDatabaseConnectionTest method testConnect_WithPoorlyEncryptedPassword.

@Test
public void testConnect_WithPoorlyEncryptedPassword() throws Exception {
    if (Boolean.parseBoolean(PROPERTIES.getProperty(KEY_TESTS_ENABLED, "false"))) {
        DatabaseConnection con = createConnection();
        con.setPassword("PW:ABCDEFG");
        // We expect to see a SQL Exception after probbably 1 attempt.
        try {
            LifecycleHelper.init(con);
            Connection sqlConnection = con.connect();
            fail("Successful connection with bad password");
        } catch (SQLException expected) {
        } catch (CoreException expected) {
        }
    }
}
Also used : CoreException(com.adaptris.core.CoreException) SQLException(java.sql.SQLException) Connection(java.sql.Connection) Test(org.junit.Test)

Example 3 with CoreException

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

the class PasswordProtectedDatabaseConnectionTest method testConnect_WithIncorrectPassword.

@Test
public void testConnect_WithIncorrectPassword() throws Exception {
    if (Boolean.parseBoolean(PROPERTIES.getProperty(KEY_TESTS_ENABLED, "false"))) {
        DatabaseConnection con = createConnection();
        con.setPassword(String.valueOf(System.currentTimeMillis()));
        // We expect to see a SQL Exception after probbably 1 attempt.
        try {
            LifecycleHelper.init(con);
            Connection sqlConnection = con.connect();
            fail("Successful connection with bad password");
        } catch (SQLException expected) {
        } catch (CoreException expected) {
        }
    }
}
Also used : CoreException(com.adaptris.core.CoreException) SQLException(java.sql.SQLException) Connection(java.sql.Connection) Test(org.junit.Test)

Example 4 with CoreException

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

the class JmsTransactedWorkflowTest method testInit_UnsupportedConsumer.

@Test
public void testInit_UnsupportedConsumer() throws Exception {
    Channel channel = createStartableChannel(activeMqBroker);
    JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
    workflow.setConsumer(new FsConsumer().withBaseDirectoryUrl("file:////path/to/directory"));
    try {
        channel.requestInit();
    } catch (CoreException expected) {
        assertEquals("JmsTransactedWorkflow must be used with a JMSConsumer", expected.getMessage());
    } finally {
        channel.requestClose();
    }
}
Also used : CoreException(com.adaptris.core.CoreException) FsConsumer(com.adaptris.core.fs.FsConsumer) MockChannel(com.adaptris.core.stubs.MockChannel) Channel(com.adaptris.core.Channel) Test(org.junit.Test)

Example 5 with CoreException

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

the class ActiveMqPasPollingConsumerTest method testInitSubscriptionOnly.

@Test
public void testInitSubscriptionOnly() throws Exception {
    PasPollingConsumer consumer = create();
    consumer.setSubscriptionId("xxxx");
    try {
        consumer.init();
        fail("Should fail due to missing client Id");
    } catch (CoreException e) {
    // expected
    }
}
Also used : PasPollingConsumer(com.adaptris.core.jms.PasPollingConsumer) CoreException(com.adaptris.core.CoreException) 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