### Question:
JmsPoolSession implements Session, TopicSession, QueueSession, XASession, AutoCloseable { public void addSessionEventListener(JmsPoolSessionEventListener listener) throws JMSException { checkClosed(); if (!sessionEventListeners.contains(listener)) { this.sessionEventListeners.add(listener); } } JmsPoolSession(PooledSessionKey key, PooledSessionHolder sessionHolder, KeyedObjectPool<PooledSessionKey, PooledSessionHolder> sessionPool, boolean transactional); @Override void close(); @Override TemporaryQueue createTemporaryQueue(); @Override TemporaryTopic createTemporaryTopic(); @Override Queue createQueue(String s); @Override Topic createTopic(String s); @Override BytesMessage createBytesMessage(); @Override MapMessage createMapMessage(); @Override Message createMessage(); @Override ObjectMessage createObjectMessage(); @Override ObjectMessage createObjectMessage(Serializable serializable); @Override StreamMessage createStreamMessage(); @Override TextMessage createTextMessage(); @Override TextMessage createTextMessage(String s); @Override void unsubscribe(String s); @Override int getAcknowledgeMode(); @Override boolean getTransacted(); @Override void recover(); @Override void commit(); @Override void rollback(); @Override XAResource getXAResource(); @Override Session getSession(); @Override MessageListener getMessageListener(); @Override void setMessageListener(MessageListener messageListener); @Override void run(); @Override QueueBrowser createBrowser(Queue queue); @Override QueueBrowser createBrowser(Queue queue, String selector); @Override MessageConsumer createConsumer(Destination destination); @Override MessageConsumer createConsumer(Destination destination, String selector); @Override MessageConsumer createConsumer(Destination destination, String selector, boolean noLocal); @Override TopicSubscriber createDurableSubscriber(Topic topic, String selector); @Override TopicSubscriber createDurableSubscriber(Topic topic, String name, String selector, boolean noLocal); @Override TopicSubscriber createSubscriber(Topic topic); @Override TopicSubscriber createSubscriber(Topic topic, String selector, boolean local); @Override QueueReceiver createReceiver(Queue queue); @Override QueueReceiver createReceiver(Queue queue, String selector); @Override MessageConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName); @Override MessageConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName, String messageSelector); @Override MessageConsumer createDurableConsumer(Topic topic, String name); @Override MessageConsumer createDurableConsumer(Topic topic, String name, String messageSelector, boolean noLocal); @Override MessageConsumer createSharedDurableConsumer(Topic topic, String name); @Override MessageConsumer createSharedDurableConsumer(Topic topic, String name, String messageSelector); @Override MessageProducer createProducer(Destination destination); @Override QueueSender createSender(Queue queue); @Override TopicPublisher createPublisher(Topic topic); void addSessionEventListener(JmsPoolSessionEventListener listener); Session getInternalSession(); void setIsXa(boolean isXa); boolean isIgnoreClose(); void setIgnoreClose(boolean ignoreClose); @Override String toString();  }### Answer:
@Test(timeout = 60000) public void testAddSessionEventListener() throws Exception { JmsPoolConnection connection = (JmsPoolConnection) cf.createConnection(); JmsPoolSession session = (JmsPoolSession) connection.createSession(); final CountDownLatch tempTopicCreated = new CountDownLatch(2); final CountDownLatch tempQueueCreated = new CountDownLatch(2); final CountDownLatch sessionClosed = new CountDownLatch(2); JmsPoolSessionEventListener listener = new JmsPoolSessionEventListener() { @Override public void onTemporaryTopicCreate(TemporaryTopic tempTopic) { tempTopicCreated.countDown(); } @Override public void onTemporaryQueueCreate(TemporaryQueue tempQueue) { tempQueueCreated.countDown(); } @Override public void onSessionClosed(JmsPoolSession session) { sessionClosed.countDown(); } }; session.addSessionEventListener(listener); session.addSessionEventListener(listener); assertNotNull(session.createTemporaryQueue()); assertNotNull(session.createTemporaryTopic()); session.close(); assertEquals(1, tempQueueCreated.getCount()); assertEquals(1, tempTopicCreated.getCount()); assertEquals(1, sessionClosed.getCount()); try { session.addSessionEventListener(listener); fail("Should throw on closed session."); } catch (IllegalStateException ise) {} }