use of com.adaptris.core.stubs.MockService in project interlok by adaptris.
the class WorkflowWithObjectPoolTest method testPopulatePool_FailToInit.
@Test(expected = CoreException.class)
public void testPopulatePool_FailToInit() throws Exception {
setMinIdle(10);
setServiceCollection(new ServiceList(new MockService(MockService.FailureCondition.Lifecycle)));
setInitWaitTime(new TimeInterval(1L, TimeUnit.SECONDS));
GenericObjectPool<Worker> pool = (GenericObjectPool<Worker>) createObjectPool();
try {
populatePool(pool);
} finally {
Closer.closeQuietly(pool);
}
}
use of com.adaptris.core.stubs.MockService in project interlok by adaptris.
the class SharedComponentListTest method testRemoveService_unbindsJNDI.
@Test
public void testRemoveService_unbindsJNDI() throws Exception {
Adapter adapter = new Adapter();
adapter.setUniqueId(getName());
MockService mockService = new MockService();
adapter.getSharedComponents().addService(mockService);
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, JndiContextFactory.class.getName());
InitialContext initialContext = new InitialContext(env);
try {
start(adapter);
Service lookedup = (Service) initialContext.lookup("adapter:comp/env/" + mockService.getUniqueId());
assertNotNull(lookedup);
assertEquals(mockService.getUniqueId(), lookedup.getUniqueId());
adapter.getSharedComponents().removeService(mockService.getUniqueId());
try {
initialContext.lookup("adapter:comp/env/" + mockService.getUniqueId());
fail();
} catch (NamingException expected) {
}
} finally {
stop(adapter);
}
}
use of com.adaptris.core.stubs.MockService in project interlok by adaptris.
the class ServiceWorkerPoolTest method testWarmup_WithException.
@Test
public void testWarmup_WithException() throws Exception {
GenericObjectPool<ServiceWorkerPool.Worker> objPool = null;
try {
ServiceWorkerPool worker = new ServiceWorkerPool(new MockService(FailureCondition.Lifecycle), null, 10);
objPool = worker.createCommonsObjectPool();
worker.warmup(objPool);
fail();
} catch (CoreException expected) {
} finally {
Closer.closeQuietly(objPool);
}
}
use of com.adaptris.core.stubs.MockService in project interlok by adaptris.
the class SharedServiceTest method testDoService.
@Test
public void testDoService() throws Exception {
MockService mockService = new MockService(getName());
SharedService sharedService = new SharedService(getName());
Adapter adapter = createAdapterForSharedService(sharedService, mockService);
try {
LifecycleHelper.initAndStart(adapter);
AdaptrisMessage msg = DefaultMessageFactory.getDefaultInstance().newMessage();
sharedService.doService(msg);
assertEquals(1, ((MockService) sharedService.getClonedService()).callCount);
MleMarker marker = msg.getMessageLifecycleEvent().getMleMarkers().get(0);
assertEquals(MockService.class.getName(), marker.getName());
assertEquals(getName(), marker.getQualifier());
assertEquals(true, marker.getWasSuccessful());
} finally {
LifecycleHelper.stopAndClose(adapter);
}
}
use of com.adaptris.core.stubs.MockService in project interlok by adaptris.
the class SharedComponentListTest method testAddServices.
@Test
public void testAddServices() throws Exception {
SharedComponentList list = new SharedComponentList();
try {
list.addServices(null);
fail();
} catch (IllegalArgumentException expected) {
}
assertEquals(0, list.getConnections().size());
// This is valid, we don't check for duplicates until later.
MockService service1 = new MockService();
MockService service2 = new MockService();
service2.setUniqueId(service1.getUniqueId());
Collection<Service> rejected = list.addServices(Arrays.asList(new Service[] { service1, service2 }));
assertEquals(1, list.getServices().size());
assertEquals(1, rejected.size());
}
Aggregations