Search in sources :

Example 1 with CheckComponentStateService

use of com.adaptris.core.stubs.CheckComponentStateService in project interlok by adaptris.

the class ServiceListTest method testBug2055.

@Test
public void testBug2055() throws Exception {
    String name = Thread.currentThread().getName();
    Thread.currentThread().setName("testBug2055");
    final ServiceList services = new ServiceList();
    MarkerService marker = new MarkerService();
    services.addService(marker);
    services.addService(new WaitService(new TimeInterval(3L, TimeUnit.SECONDS)));
    services.addService(new CheckComponentStateService());
    start(services);
    final ExceptionContainer c = new ExceptionContainer();
    Thread t = new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
                services.doService(msg);
            } catch (ServiceException e) {
                c.setException(e);
            }
        }
    });
    t.start();
    while (!marker.hasTriggered) {
        Thread.sleep(10);
    }
    stop(services);
    t.join();
    if (c.getException() != null) {
        fail("Services failed, " + c.getException().getMessage());
    }
    Thread.currentThread().setName(name);
}
Also used : WaitService(com.adaptris.core.services.WaitService) TimeInterval(com.adaptris.util.TimeInterval) CheckComponentStateService(com.adaptris.core.stubs.CheckComponentStateService) Test(org.junit.Test)

Aggregations

WaitService (com.adaptris.core.services.WaitService)1 CheckComponentStateService (com.adaptris.core.stubs.CheckComponentStateService)1 TimeInterval (com.adaptris.util.TimeInterval)1 Test (org.junit.Test)1