Search in sources :

Example 11 with ServiceCollectionImp

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

the class ServiceCollectionCase method testCollectionConstructor.

@Test
public void testCollectionConstructor() {
    ServiceCollectionImp sc = createServiceCollection();
    sc.addService(new NullService(UUID.randomUUID().toString()));
    sc.addService(new NullService(UUID.randomUUID().toString()));
    ServiceCollectionImp sc2 = createServiceCollection(sc);
    assertEquals(sc.size(), sc2.size());
}
Also used : ServiceCollectionImp(com.adaptris.core.ServiceCollectionImp) NullService(com.adaptris.core.NullService) Test(org.junit.Test)

Example 12 with ServiceCollectionImp

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

the class ServiceCollectionCase method testIterator.

@Test
public void testIterator() throws Exception {
    ServiceCollectionImp sc = createServiceCollection();
    sc.addAll(Arrays.asList(new Service[] { new NullService(UUID.randomUUID().toString()), new NullService(UUID.randomUUID().toString()) }));
    assertEquals(2, sc.size());
    assertNotNull(sc.iterator());
    int count = 0;
    for (Iterator<Service> i = sc.iterator(); i.hasNext(); ) {
        assertNotNull(i.next());
        count++;
    }
    assertEquals(2, count);
    assertNotNull(sc.listIterator(0));
    count = 0;
    for (ListIterator<Service> i = sc.listIterator(0); i.hasNext(); ) {
        assertNotNull(i.next());
        count++;
    }
    assertEquals(2, count);
    assertNotNull(sc.listIterator());
    count = 0;
    for (ListIterator<Service> i = sc.listIterator(); i.hasNext(); ) {
        assertNotNull(i.next());
        count++;
    }
    assertEquals(2, count);
}
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 13 with ServiceCollectionImp

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

the class ServiceCollectionCase method testIndexOf.

@Test
public void testIndexOf() throws Exception {
    ServiceCollectionImp sc = createServiceCollection();
    sc.addService(new NullService(UUID.randomUUID().toString()));
    WaitService s = new WaitService(UUID.randomUUID().toString());
    sc.addService(s);
    sc.addService(new NullService(UUID.randomUUID().toString()));
    assertEquals(1, sc.indexOf(s));
}
Also used : WaitService(com.adaptris.core.services.WaitService) ServiceCollectionImp(com.adaptris.core.ServiceCollectionImp) NullService(com.adaptris.core.NullService) Test(org.junit.Test)

Example 14 with ServiceCollectionImp

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

the class ServiceCollectionCase method testGet.

@Test
public void testGet() throws Exception {
    ServiceCollectionImp sc = createServiceCollection();
    sc.addService(new NullService(UUID.randomUUID().toString()));
    sc.addService(new WaitService(UUID.randomUUID().toString()));
    sc.addService(new NullService(UUID.randomUUID().toString()));
    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 15 with ServiceCollectionImp

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

the class ServiceCollectionCase method testRemove.

@Test
public void testRemove() 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.remove(1);
    assertEquals(WaitService.class, s.getClass());
    assertEquals(wait, s);
    assertEquals(2, 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)

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