use of com.adaptris.core.Service 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));
}
use of com.adaptris.core.Service 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());
}
use of com.adaptris.core.Service in project interlok by adaptris.
the class DynamicServiceExecutor method doService.
@Override
public void doService(AdaptrisMessage msg) throws ServiceException {
try {
Service service = createService(msg);
log.trace("Created service [{}]", friendlyName(service));
LifecycleHelper.registerEventHandler(service, eventHandler);
LifecycleHelper.initAndStart(service, false);
service.doService(msg);
LifecycleHelper.stopAndClose(service, false);
} catch (Exception e) {
throw ExceptionHelper.wrapServiceException(e);
}
}
use of com.adaptris.core.Service in project interlok by adaptris.
the class ServiceUtil method rewriteConnectionsForTesting.
public static Service rewriteConnectionsForTesting(Service service) throws CoreException {
Service rewritten = service;
if (rewritten instanceof ConnectedService) {
ConnectedService connectedService = (ConnectedService) rewritten;
connectedService.setConnection(cloneForTesting(connectedService.getConnection()));
}
if (rewritten instanceof ServiceCollection) {
rewriteConnectionsForTesting((ServiceCollection) rewritten);
}
if (rewritten instanceof ServiceWrapper) {
rewriteConnectionsForTesting((ServiceWrapper) rewritten);
}
return rewritten;
}
Aggregations