@Test
public void testConnection() throws Exception {

	InitialContext ic = new InitialContext();
	TransactionManager tm = (TransactionManager) ic
			.lookup("TransactionManager");
	DataSource ds = (DataSource) ic.lookup("TestDS");
	assertNotNull(ds);
	Connection conn = null;
	tm.begin();
	try {
		conn = (Connection) ds.getConnection();
		assertNotNull(conn);
		Connection conn1 = ds.getConnection();
		ds = (DataSource) ic.lookup("TestDS");
		Connection conn2 = ds.getConnection();
		assertEquals(conn, conn1);
		assertEquals(conn, conn2);
		Transaction tx = tm.suspend();
		tm.begin();
		conn2 = ds.getConnection();
		assertFalse(conn.equals(conn2));
		tm.commit();
		tm.resume(tx);
		ds = (DataSource) ic.lookup("TestDS");
		conn1 = ds.getConnection();
		ds = (DataSource) ic.lookup("OtherTestDS");
		conn2 = ds.getConnection();
		assertEquals(conn, conn1);
		assertFalse(conn.equals(conn2));
	} finally {
		if (conn != null) {
			conn.close();
		}
	}
	tm.commit();
}