Search in sources :

Example 1 with FtpConnection

use of com.adaptris.core.ftp.FtpConnection in project interlok by adaptris.

the class JndiContextFactoryTest method testJndiLookupFromMultiple.

@Test
public void testJndiLookupFromMultiple() throws Exception {
    // Pump the JNDI context with some connection objects
    NullConnection connection1 = new NullConnection();
    connection1.setUniqueId("connection1");
    JmsConnection connection2 = new JmsConnection();
    connection2.setUniqueId("connection2");
    JmsConnection connection3 = new JmsConnection();
    connection3.setUniqueId("connection3");
    FtpConnection connection4 = new FtpConnection();
    connection4.setUniqueId("connection4");
    HttpConnection connection5 = new HttpConnection();
    connection5.setUniqueId("connection5");
    ArrayList<AdaptrisConnection> connectionList = new ArrayList<AdaptrisConnection>();
    connectionList.add(connection1);
    connectionList.add(connection2);
    connectionList.add(connection3);
    connectionList.add(connection4);
    connectionList.add(connection5);
    AdaptrisConnectionImp connectionObject = null;
    InitialContext ctx = new InitialContext(env);
    try {
        JndiHelper.bind(connectionList);
        connectionObject = (AdaptrisConnectionImp) ctx.lookup("adapter:comp/env/connection1");
        assertTrue(connectionObject instanceof NullConnection);
        assertEquals("connection1", connectionObject.getUniqueId());
        connectionObject = (AdaptrisConnectionImp) ctx.lookup("adapter:comp/env/connection2");
        assertTrue(connectionObject instanceof JmsConnection);
        assertEquals("connection2", connectionObject.getUniqueId());
        connectionObject = (AdaptrisConnectionImp) ctx.lookup("adapter:comp/env/connection3");
        assertTrue(connectionObject instanceof JmsConnection);
        assertEquals("connection3", connectionObject.getUniqueId());
        connectionObject = (AdaptrisConnectionImp) ctx.lookup("adapter:comp/env/connection4");
        assertTrue(connectionObject instanceof FtpConnection);
        assertEquals("connection4", connectionObject.getUniqueId());
        connectionObject = (AdaptrisConnectionImp) ctx.lookup("adapter:comp/env/connection5");
        assertTrue(connectionObject instanceof HttpConnection);
        assertEquals("connection5", connectionObject.getUniqueId());
    } finally {
        JndiHelper.unbindQuietly(ctx, connectionList, false);
    }
}
Also used : HttpConnection(com.adaptris.core.http.jetty.HttpConnection) FtpConnection(com.adaptris.core.ftp.FtpConnection) ArrayList(java.util.ArrayList) JmsConnection(com.adaptris.core.jms.JmsConnection) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Aggregations

FtpConnection (com.adaptris.core.ftp.FtpConnection)1 HttpConnection (com.adaptris.core.http.jetty.HttpConnection)1 JmsConnection (com.adaptris.core.jms.JmsConnection)1 ArrayList (java.util.ArrayList)1 InitialContext (javax.naming.InitialContext)1 Test (org.junit.Test)1