Search in sources :

Example 16 with ServiceCollectionImp

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

the class ServiceCollectionCase method testSetAtPosition.

@Test
public void testSetAtPosition() throws Exception {
    ServiceCollectionImp sc = createServiceCollection();
    sc.addService(new NullService(UUID.randomUUID().toString()));
    WaitService wait = new WaitService(UUID.randomUUID().toString());
    sc.addService(wait);
    sc.addService(new NullService(UUID.randomUUID().toString()));
    Service s = sc.set(1, new NullService(UUID.randomUUID().toString()));
    assertEquals(WaitService.class, s.getClass());
    assertEquals(wait, s);
    assertEquals(3, sc.size());
    assertFalse(sc.contains(wait));
}
Also used : WaitService(com.adaptris.core.services.WaitService) ServiceCollectionImp(com.adaptris.core.ServiceCollectionImp) NullService(com.adaptris.core.NullService) NullService(com.adaptris.core.NullService) Service(com.adaptris.core.Service) EventHandlerAwareService(com.adaptris.core.stubs.EventHandlerAwareService) WaitService(com.adaptris.core.services.WaitService) Test(org.junit.Test)

Example 17 with ServiceCollectionImp

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

the class ServiceCollectionCase method testClear.

@Test
public void testClear() {
    ServiceCollectionImp list = createServiceCollection();
    list.add(new NullService(UUID.randomUUID().toString()));
    list.add(new NullService(UUID.randomUUID().toString()));
    list.add(new NullService(UUID.randomUUID().toString()));
    list.add(new NullService(UUID.randomUUID().toString()));
    assertEquals(4, list.size());
    list.clear();
    assertEquals(0, list.size());
}
Also used : ServiceCollectionImp(com.adaptris.core.ServiceCollectionImp) NullService(com.adaptris.core.NullService) Test(org.junit.Test)

Example 18 with ServiceCollectionImp

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

the class ServiceCollectionCase method testSetServices.

@Test
public void testSetServices() throws Exception {
    ServiceCollectionImp sc = createServiceCollection();
    List<Service> services = Arrays.asList(new Service[] { new NullService(UUID.randomUUID().toString()), new NullService(UUID.randomUUID().toString()) });
    sc.setServices(services);
    assertEquals(2, sc.size());
    assertEquals(services, sc.getServices());
    try {
        sc.setServices(null);
        fail();
    } catch (IllegalArgumentException e) {
    }
    assertEquals(2, sc.size());
    assertEquals(services, sc.getServices());
}
Also used : ServiceCollectionImp(com.adaptris.core.ServiceCollectionImp) NullService(com.adaptris.core.NullService) NullService(com.adaptris.core.NullService) Service(com.adaptris.core.Service) EventHandlerAwareService(com.adaptris.core.stubs.EventHandlerAwareService) WaitService(com.adaptris.core.services.WaitService) Test(org.junit.Test)

Example 19 with ServiceCollectionImp

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

the class ServiceCollectionCase method testSubList.

@Test
public void testSubList() {
    ServiceCollectionImp list = createServiceCollection();
    list.add(new NullService(UUID.randomUUID().toString()));
    list.add(new NullService(UUID.randomUUID().toString()));
    list.add(new NullService(UUID.randomUUID().toString()));
    list.add(new NullService(UUID.randomUUID().toString()));
    assertNotNull(list.subList(0, 2));
    assertEquals(2, list.subList(0, 2).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