Search in sources :

Example 26 with NullService

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

the class SharedServiceConfigurationCheckerTest method testServiceConnectionDoesNotExist.

@Test
public void testServiceConnectionDoesNotExist() throws Exception {
    BootstrapProperties mockBootProperties = new MockBootProperties(createAdapterConfig(new NullService("SharedNullConnection"), new SharedService("DoesNotExist")));
    ConfigurationCheckReport report = checker.performConfigCheck(mockBootProperties);
    assertFalse(report.isCheckPassed());
    assertTrue(report.getFailureExceptions().size() > 0);
    assertNotNull(report.toString());
}
Also used : SharedService(com.adaptris.core.SharedService) BootstrapProperties(com.adaptris.core.management.BootstrapProperties) NullService(com.adaptris.core.NullService) Test(org.junit.Test)

Example 27 with NullService

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

the class SharedServiceConfigurationCheckerTest method testSharedNotUsed.

@Test
public void testSharedNotUsed() throws Exception {
    BootstrapProperties mockBootProperties = new MockBootProperties(createAdapterConfig(new NullService("SharedNullService"), null));
    ConfigurationCheckReport report = checker.performConfigCheck(mockBootProperties);
    assertFalse(report.isCheckPassed());
}
Also used : BootstrapProperties(com.adaptris.core.management.BootstrapProperties) NullService(com.adaptris.core.NullService) Test(org.junit.Test)

Example 28 with NullService

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

the class IfElseTest method testNoThenService.

@Test
public void testNoThenService() throws Exception {
    logicalExpression.getThen().setService(new NullService());
    when(mockCondition.evaluate(message)).thenReturn(true);
    // purely to re-initiate the NoOpService
    LifecycleHelper.stopAndClose(logicalExpression);
    LifecycleHelper.initAndStart(logicalExpression);
    logicalExpression.doService(message);
    verify(mockElseService, times(0)).doService(message);
}
Also used : NullService(com.adaptris.core.NullService) Test(org.junit.Test)

Example 29 with NullService

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

the class JdbcServiceListTest method testServiceList_NoConnectionInObjectMetadata_WithException.

@Test
public void testServiceList_NoConnectionInObjectMetadata_WithException() throws Exception {
    createDatabase();
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    JdbcServiceList list = new JdbcServiceList();
    list.add(createSequenceNumberService(createJdbcConnection(), getName(), SequenceNumberCase.DEFAULT_ID));
    list.add(new NullService() {

        @Override
        public void doService(AdaptrisMessage msg) throws ServiceException {
            throw new ServiceException("testServiceList_NoConnectionInObjectMetadata_WithException throws an Exception");
        }
    });
    try {
        execute(list, msg);
    } catch (ServiceException expected) {
    // 
    }
    // This checks the database has been commited, as the next seq_no == 2.
    doStandardAssertions(msg);
    assertFalse(msg.getObjectHeaders().containsKey(JdbcConstants.OBJ_METADATA_DATABASE_CONNECTION_KEY));
}
Also used : ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) NullService(com.adaptris.core.NullService) Test(org.junit.Test)

Example 30 with NullService

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

the class JdbcServiceListTest method testServiceList_ExceptionRollsback.

@Test
public void testServiceList_ExceptionRollsback() throws Exception {
    createDatabase();
    JdbcServiceList service = createServiceCollection();
    DatabaseConnection c = createJdbcConnection();
    c.setAutoCommit(false);
    c.setDebugMode(true);
    service.setConnection(c);
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    String oldName = Thread.currentThread().getName();
    Thread.currentThread().setName("testServiceList_ExceptionRollsback");
    try {
        service.add(createSequenceNumberService(null, getName(), SequenceNumberCase.DEFAULT_ID));
        service.add(new NullService() {

            @Override
            public void doService(AdaptrisMessage msg) throws ServiceException {
                throw new ServiceException("testServiceList_ExceptionRollsback throws an Exception");
            }
        });
        try {
            execute(service, msg);
        } catch (ServiceException expected) {
        }
        assertTrue(msg.getObjectHeaders().containsKey(JdbcConstants.OBJ_METADATA_DATABASE_CONNECTION_KEY));
        Connection conn = (Connection) msg.getObjectHeaders().get(JdbcConstants.OBJ_METADATA_DATABASE_CONNECTION_KEY);
        assertTrue(conn.isClosed());
        // Here, we will expect there to be in row inserted.
        // getCurrentSequenceNumber returns -1 in that instance, C-Styley
        assertEquals(-1, getCurrentSequenceNumber(SequenceNumberCase.DEFAULT_ID));
    } finally {
        Thread.currentThread().setName(oldName);
    }
}
Also used : ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) NullService(com.adaptris.core.NullService) Connection(java.sql.Connection) AdvancedJdbcPooledConnection(com.adaptris.core.jdbc.AdvancedJdbcPooledConnection) DatabaseConnection(com.adaptris.core.jdbc.DatabaseConnection) JdbcPooledConnection(com.adaptris.core.jdbc.JdbcPooledConnection) JdbcConnection(com.adaptris.core.jdbc.JdbcConnection) DatabaseConnection(com.adaptris.core.jdbc.DatabaseConnection) Test(org.junit.Test)

Aggregations

NullService (com.adaptris.core.NullService)54 Test (org.junit.Test)53 ServiceCollectionImp (com.adaptris.core.ServiceCollectionImp)16 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)15 WaitService (com.adaptris.core.services.WaitService)9 PooledSplitJoinService (com.adaptris.core.services.splitter.PooledSplitJoinService)9 TimeInterval (com.adaptris.util.TimeInterval)9 Service (com.adaptris.core.Service)5 XpathMessageSplitter (com.adaptris.core.services.splitter.XpathMessageSplitter)5 EventHandlerAwareService (com.adaptris.core.stubs.EventHandlerAwareService)5 InsertNode (com.adaptris.util.text.xml.InsertNode)5 XPath (com.adaptris.util.text.xml.XPath)5 Adapter (com.adaptris.core.Adapter)4 AdaptrisMarshaller (com.adaptris.core.AdaptrisMarshaller)4 ServiceException (com.adaptris.core.ServiceException)4 BootstrapProperties (com.adaptris.core.management.BootstrapProperties)4 BodyPartIterator (com.adaptris.util.text.mime.BodyPartIterator)4 ObjectName (javax.management.ObjectName)4 SharedService (com.adaptris.core.SharedService)3 ComponentLifecycle (com.adaptris.core.ComponentLifecycle)2