use of com.adaptris.core.stubs.MockService in project interlok by adaptris.
the class SharedComponentListTest method testAddService.
@Test
public void testAddService() throws Exception {
SharedComponentList list = new SharedComponentList();
assertEquals(0, list.getServices().size());
try {
list.addService(null);
fail();
} catch (IllegalArgumentException expected) {
}
assertEquals(0, list.getServices().size());
// Should have no effect as you're just adding to a clone.
list.getServices().add(new MockService());
assertEquals(0, list.getServices().size());
MockService mockConfirmService = new MockService();
mockConfirmService.setUniqueId("Something");
list.addService(mockConfirmService);
assertFalse(list.addService(mockConfirmService));
assertEquals(1, list.getServices().size());
}
use of com.adaptris.core.stubs.MockService in project interlok by adaptris.
the class SharedComponentListTest method testBindJNDIService.
@Test
public void testBindJNDIService() throws Exception {
Adapter adapter = new Adapter();
adapter.setUniqueId(getName());
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, JndiContextFactory.class.getName());
InitialContext initialContext = new InitialContext(env);
try {
start(adapter);
MockService mockService = new MockService();
adapter.getSharedComponents().addService(mockService);
adapter.getSharedComponents().bindJNDI(mockService.getUniqueId());
Service lookedup = (Service) initialContext.lookup("adapter:comp/env/" + mockService.getUniqueId());
assertNotNull(lookedup);
assertEquals(mockService.getUniqueId(), lookedup.getUniqueId());
adapter.getSharedComponents().bindJNDI("ShouldGetIgnored");
} finally {
stop(adapter);
}
}
Aggregations