List sessions = initiator.getSessions();
List sessions = initiator.getManagedSessions();
    public void testPoll() throws Exception {        ServerThread serverThread = new ServerThread();        try {            serverThread.start();            serverThread.waitForInitialization();            SessionID clientSessionID = new SessionID(FixVersions.BEGINSTRING_FIX42, "TW", "ISLD");            SessionSettings settings = getClientSessionSettings(clientSessionID);            ClientApplication clientApplication = new ClientApplication();            final SocketInitiator initiator = new SocketInitiator(clientApplication,                    new MemoryStoreFactory(), settings, new DefaultMessageFactory());            clientApplication.setUpLogonExpectation();            // BUG #105 - SocketInitiator poll had class cast exception            // The class cast was from timer events occuring every one second.            // We sleep for one second and then check the poll.            try {                initiator.poll();                Session clientSession = Session.lookupSession(clientSessionID);                for (int i = 0; i < 5; i++) {                    Thread.sleep(300);                    if (clientSession.isLoggedOn()) {                        break;                    }                    initiator.poll();                }                assertLoggedOn(clientApplication, clientSession);                // BUG #106 - sessions were not being recorded.                List sessions = initiator.getSessions();                assertTrue("wrong logon status", initiator.isLoggedOn());                assertEquals("wrong # of session", 1, sessions.size());            } finally {                initiator.stop();            }            boolean pollResult = true;            for (int i = 0; i < 5; i++) {                Thread.sleep(300);                pollResult = initiator.poll();                if (!pollResult) {                    break;                }            }            log.info("Poll returned " + pollResult);            assertFalse("wrong logon status", initiator.isLoggedOn());        } finally {            serverThread.interrupt();        }    }