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);
}
}
Aggregations