Search in sources :

Example 6 with MockService

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());
}
Also used : MockService(com.adaptris.core.stubs.MockService) Test(org.junit.Test)

Example 7 with MockService

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);
    }
}
Also used : MockService(com.adaptris.core.stubs.MockService) MockService(com.adaptris.core.stubs.MockService) LogMessageService(com.adaptris.core.services.LogMessageService) Properties(java.util.Properties) PooledConnectionProperties(com.adaptris.core.jdbc.PooledConnectionProperties) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Aggregations

MockService (com.adaptris.core.stubs.MockService)7 Test (org.junit.Test)7 LogMessageService (com.adaptris.core.services.LogMessageService)3 PooledConnectionProperties (com.adaptris.core.jdbc.PooledConnectionProperties)2 Properties (java.util.Properties)2 InitialContext (javax.naming.InitialContext)2 CoreException (com.adaptris.core.CoreException)1 TimeInterval (com.adaptris.util.TimeInterval)1 NamingException (javax.naming.NamingException)1 GenericObjectPool (org.apache.commons.pool2.impl.GenericObjectPool)1