activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r941692 - /activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/PooledTopicPublisherTest.java
Date Thu, 06 May 2010 12:23:28 GMT
Author: gtully
Date: Thu May  6 12:23:28 2010
New Revision: 941692

URL: http://svn.apache.org/viewvc?rev=941692&view=rev
Log:
test for pooled connection with inactive timouet on connection, close still works ok

Modified:
    activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/PooledTopicPublisherTest.java

Modified: activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/PooledTopicPublisherTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/PooledTopicPublisherTest.java?rev=941692&r1=941691&r2=941692&view=diff
==============================================================================
--- activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/PooledTopicPublisherTest.java
(original)
+++ activemq/trunk/activemq-pool/src/test/java/org/apache/activemq/pool/PooledTopicPublisherTest.java
Thu May  6 12:23:28 2010
@@ -16,6 +16,9 @@
  */
 package org.apache.activemq.pool;
 
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
 import javax.jms.ExceptionListener;
 import javax.jms.JMSException;
 import javax.jms.Session;
@@ -23,9 +26,13 @@ import javax.jms.TopicConnection;
 import javax.jms.TopicPublisher;
 import javax.jms.TopicSession;
 
+import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.TransportConnector;
 import org.apache.activemq.command.ActiveMQTopic;
 import org.apache.activemq.test.TestSupport;
+import org.apache.activemq.util.SocketProxy;
 
 /**
  * @version $Revision$
@@ -59,6 +66,36 @@ public class PooledTopicPublisherTest ex
         assertEquals(listener, connection.getExceptionListener());
     }
     
+    public void testPooledConnectionAfterInactivity() throws Exception {
+        BrokerService broker = new BrokerService();
+        TransportConnector networkConnector = broker.addConnector("tcp://localhost:0");
+        broker.setPersistent(false);
+        broker.setUseJmx(false);
+        broker.start();
+        
+        SocketProxy proxy = new SocketProxy(networkConnector.getConnectUri());
+        
+        PooledConnectionFactory pcf = new PooledConnectionFactory();
+        String uri = proxy.getUrl().toString() + "?trace=true&wireFormat.maxInactivityDuration=500&wireFormat.maxInactivityDurationInitalDelay=500";
+        pcf.setConnectionFactory(new ActiveMQConnectionFactory(uri));
+        
+        PooledConnection conn =  (PooledConnection) pcf.createConnection();
+        ActiveMQConnection amq = conn.getConnection();
+        final CountDownLatch gotException = new CountDownLatch(1);
+        //amq.set
+        conn.setExceptionListener(new ExceptionListener() {
+            public void onException(JMSException exception) {
+                gotException.countDown();
+            }});
+        conn.setClientID(getName());
+        
+        // let it hang, simulate a server hang so inactivity timeout kicks in
+        proxy.pause();
+        //assertTrue("got an exception", gotException.await(5, TimeUnit.SECONDS));
+        TimeUnit.SECONDS.sleep(2);
+        conn.close();
+    }
+    
     @Override
     protected void tearDown() throws Exception {
         if (connection != null) {



Mime
View raw message