Search in sources :

Example 6 with ServiceCollectionImp

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

the class ServiceCollectionCase method testAdd.

@Test
public void testAdd() throws Exception {
    ServiceCollectionImp sc = createServiceCollection();
    assertTrue(sc.add(new NullService(UUID.randomUUID().toString())));
    try {
        sc.add(null);
        fail();
    } catch (IllegalArgumentException e) {
    }
    assertEquals(1, sc.size());
}
Also used : ServiceCollectionImp(com.adaptris.core.ServiceCollectionImp) NullService(com.adaptris.core.NullService) Test(org.junit.Test)

Example 7 with ServiceCollectionImp

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

the class ServiceCollectionCase method testAddAtPosition.

@Test
public void testAddAtPosition() throws Exception {
    ServiceCollectionImp sc = createServiceCollection();
    sc.addService(new NullService(UUID.randomUUID().toString()));
    sc.addService(new NullService(UUID.randomUUID().toString()));
    sc.add(1, new WaitService(UUID.randomUUID().toString()));
    assertEquals(3, sc.size());
    assertEquals(WaitService.class, sc.get(1).getClass());
}
Also used : WaitService(com.adaptris.core.services.WaitService) ServiceCollectionImp(com.adaptris.core.ServiceCollectionImp) NullService(com.adaptris.core.NullService) Test(org.junit.Test)

Example 8 with ServiceCollectionImp

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

the class ServiceCollectionCase method testAddAllAtPosition.

@Test
public void testAddAllAtPosition() throws Exception {
    ServiceCollectionImp sc = createServiceCollection();
    sc.addService(new NullService(UUID.randomUUID().toString()));
    sc.addService(new NullService(UUID.randomUUID().toString()));
    ServiceCollectionImp sc2 = createServiceCollection();
    sc2.addService(new WaitService(UUID.randomUUID().toString()));
    sc2.addService(new WaitService(UUID.randomUUID().toString()));
    sc.addAll(1, sc2);
    assertEquals(4, sc.size());
    assertEquals(WaitService.class, sc.get(1).getClass());
    assertEquals(WaitService.class, sc.get(2).getClass());
}
Also used : WaitService(com.adaptris.core.services.WaitService) ServiceCollectionImp(com.adaptris.core.ServiceCollectionImp) NullService(com.adaptris.core.NullService) Test(org.junit.Test)

Example 9 with ServiceCollectionImp

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

the class ExampleServiceCase method assertDefaults.

protected void assertDefaults(Service s, boolean assertBranching) throws Exception {
    if (assertBranching) {
        if (s instanceof BranchingServiceImp) {
            assertTrue(s.getClass().getName(), s.isBranching());
        } else {
            assertFalse(s.getClass().getName(), s.isBranching());
        }
    }
    assertFalse(s.getClass().getName(), s.isTrackingEndpoint());
    assertFalse(s.getClass().getName(), s.continueOnFailure());
    if (s instanceof ServiceImp) {
        ((ServiceImp) s).setIsTrackingEndpoint(true);
        assertEquals(Boolean.TRUE, ((ServiceImp) s).getIsTrackingEndpoint());
        ((ServiceImp) s).setContinueOnFail(true);
        assertEquals(Boolean.TRUE, ((ServiceImp) s).getContinueOnFail());
    }
    if (s instanceof ServiceCollectionImp) {
        ((ServiceCollectionImp) s).setContinueOnFail(true);
        assertEquals(Boolean.TRUE, ((ServiceCollectionImp) s).getContinueOnFail());
        ((ServiceCollectionImp) s).setIsTrackingEndpoint(true);
        assertEquals(Boolean.TRUE, ((ServiceCollectionImp) s).getIsTrackingEndpoint());
        ((ServiceCollectionImp) s).setRestartAffectedServiceOnException(Boolean.TRUE);
        assertEquals(Boolean.TRUE, ((ServiceCollectionImp) s).getRestartAffectedServiceOnException());
        OutOfStateHandler handler = new RaiseExceptionOutOfStateHandler();
        ((ServiceCollectionImp) s).setOutOfStateHandler(handler);
        assertEquals(handler, ((ServiceCollectionImp) s).getOutOfStateHandler());
    }
}
Also used : RaiseExceptionOutOfStateHandler(com.adaptris.core.RaiseExceptionOutOfStateHandler) BranchingServiceImp(com.adaptris.core.BranchingServiceImp) ServiceImp(com.adaptris.core.ServiceImp) ServiceCollectionImp(com.adaptris.core.ServiceCollectionImp) BranchingServiceImp(com.adaptris.core.BranchingServiceImp) RaiseExceptionOutOfStateHandler(com.adaptris.core.RaiseExceptionOutOfStateHandler) OutOfStateHandler(com.adaptris.core.OutOfStateHandler)

Example 10 with ServiceCollectionImp

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

the class ServiceCollectionCase method testSize.

@Test
public void testSize() throws Exception {
    ServiceCollectionImp sc = createServiceCollection();
    sc.add(new NullService(UUID.randomUUID().toString()));
    assertEquals(1, sc.size());
}
Also used : ServiceCollectionImp(com.adaptris.core.ServiceCollectionImp) NullService(com.adaptris.core.NullService) Test(org.junit.Test)

Aggregations

ServiceCollectionImp (com.adaptris.core.ServiceCollectionImp)19 Test (org.junit.Test)18 NullService (com.adaptris.core.NullService)16 WaitService (com.adaptris.core.services.WaitService)9 EventHandlerAwareService (com.adaptris.core.stubs.EventHandlerAwareService)5 Service (com.adaptris.core.Service)4 BranchingServiceImp (com.adaptris.core.BranchingServiceImp)1 DefaultEventHandler (com.adaptris.core.DefaultEventHandler)1 OutOfStateHandler (com.adaptris.core.OutOfStateHandler)1 RaiseExceptionOutOfStateHandler (com.adaptris.core.RaiseExceptionOutOfStateHandler)1 ServiceImp (com.adaptris.core.ServiceImp)1