Search in sources :

Example 1 with DummyTransactionManager

use of com.adaptris.core.transaction.DummyTransactionManager in project interlok by adaptris.

the class JndiHelperTest method testUnbindUnboundTransactionManager.

@Test
public void testUnbindUnboundTransactionManager() throws Exception {
    TransactionManager transactionManager = new DummyTransactionManager(getName());
    try {
        JndiHelper.unbind(transactionManager, false);
        fail();
    } catch (CoreException expected) {
    // not previously bound, so should error.
    }
}
Also used : DummyTransactionManager(com.adaptris.core.transaction.DummyTransactionManager) CoreException(com.adaptris.core.CoreException) DummyTransactionManager(com.adaptris.core.transaction.DummyTransactionManager) TransactionManager(com.adaptris.core.transaction.TransactionManager) Test(org.junit.Test)

Example 2 with DummyTransactionManager

use of com.adaptris.core.transaction.DummyTransactionManager in project interlok by adaptris.

the class JndiHelperTest method testBindTransactionManager_AlreadyBound.

@Test
public void testBindTransactionManager_AlreadyBound() throws Exception {
    TransactionManager transactionManager = new DummyTransactionManager(getName());
    InitialContext initialContext = new InitialContext(env);
    JndiHelper.bind(initialContext, transactionManager, false);
    try {
        JndiHelper.bind(initialContext, transactionManager, true);
        fail();
    } catch (CoreException expected) {
        ;
    }
    try {
        JndiHelper.bind(initialContext, transactionManager, false);
        fail();
    } catch (CoreException expected) {
        ;
    }
    JndiHelper.unbindQuietly(initialContext, transactionManager, false);
}
Also used : DummyTransactionManager(com.adaptris.core.transaction.DummyTransactionManager) CoreException(com.adaptris.core.CoreException) DummyTransactionManager(com.adaptris.core.transaction.DummyTransactionManager) TransactionManager(com.adaptris.core.transaction.TransactionManager) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Example 3 with DummyTransactionManager

use of com.adaptris.core.transaction.DummyTransactionManager in project interlok by adaptris.

the class JndiHelperTest method testUnbindUnboundTransactionManager_Debug.

@Test
public void testUnbindUnboundTransactionManager_Debug() throws Exception {
    TransactionManager transactionManager = new DummyTransactionManager(getName());
    try {
        JndiHelper.unbind(transactionManager, true);
        fail();
    } catch (CoreException expected) {
    // not previously bound, so should error.
    }
}
Also used : DummyTransactionManager(com.adaptris.core.transaction.DummyTransactionManager) CoreException(com.adaptris.core.CoreException) DummyTransactionManager(com.adaptris.core.transaction.DummyTransactionManager) TransactionManager(com.adaptris.core.transaction.TransactionManager) Test(org.junit.Test)

Example 4 with DummyTransactionManager

use of com.adaptris.core.transaction.DummyTransactionManager in project interlok by adaptris.

the class SharedComponentListTest method testSharedTransactionManager_CompEnvLookupName.

@Test
public void testSharedTransactionManager_CompEnvLookupName() throws Exception {
    Adapter adapter = new Adapter();
    adapter.setUniqueId(getName());
    adapter.getSharedComponents().setTransactionManager(new DummyTransactionManager(getName()));
    try {
        start(adapter);
        SharedTransactionManager conn = new SharedTransactionManager("comp/env/" + getName());
        conn.init();
        assertNotNull(conn.proxiedTransactionManager());
    } finally {
        stop(adapter);
    }
}
Also used : DummyTransactionManager(com.adaptris.core.transaction.DummyTransactionManager) SharedTransactionManager(com.adaptris.core.transaction.SharedTransactionManager) Test(org.junit.Test)

Example 5 with DummyTransactionManager

use of com.adaptris.core.transaction.DummyTransactionManager in project interlok by adaptris.

the class SharedComponentListTest method testBindJNDITransactionManager.

@Test
public void testBindJNDITransactionManager() 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);
        adapter.getSharedComponents().setTransactionManager(new DummyTransactionManager(getName()));
        adapter.getSharedComponents().bindJNDI(getName());
        TransactionManager lookedup = (TransactionManager) initialContext.lookup("adapter:comp/env/" + getName());
        assertNotNull(lookedup);
        assertEquals(getName(), lookedup.getUniqueId());
        adapter.getSharedComponents().bindJNDI("ShouldGetIgnored");
    } finally {
        stop(adapter);
    }
}
Also used : DummyTransactionManager(com.adaptris.core.transaction.DummyTransactionManager) SharedTransactionManager(com.adaptris.core.transaction.SharedTransactionManager) TransactionManager(com.adaptris.core.transaction.TransactionManager) DummyTransactionManager(com.adaptris.core.transaction.DummyTransactionManager) Properties(java.util.Properties) PooledConnectionProperties(com.adaptris.core.jdbc.PooledConnectionProperties) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Aggregations

DummyTransactionManager (com.adaptris.core.transaction.DummyTransactionManager)7 Test (org.junit.Test)6 TransactionManager (com.adaptris.core.transaction.TransactionManager)5 SharedTransactionManager (com.adaptris.core.transaction.SharedTransactionManager)4 CoreException (com.adaptris.core.CoreException)3 InitialContext (javax.naming.InitialContext)2 EmbeddedConnection (com.adaptris.core.http.jetty.EmbeddedConnection)1 PooledConnectionProperties (com.adaptris.core.jdbc.PooledConnectionProperties)1 PasswordException (com.adaptris.security.exc.PasswordException)1 Properties (java.util.Properties)1 NamingException (javax.naming.NamingException)1