activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-5875 - additional test that shows durable sub registration does not error out with this fix
Date Wed, 17 Feb 2016 14:09:39 GMT
Repository: activemq
Updated Branches:
  refs/heads/master f0378bcd3 -> fd7608881


https://issues.apache.org/jira/browse/AMQ-5875 - additional test that shows durable sub registration
does not error out with this fix


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/fd760888
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/fd760888
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/fd760888

Branch: refs/heads/master
Commit: fd760888147b1db69a330c32a3630ddd87c2a53c
Parents: f0378bc
Author: gtully <gary.tully@gmail.com>
Authored: Wed Feb 17 14:09:05 2016 +0000
Committer: gtully <gary.tully@gmail.com>
Committed: Wed Feb 17 14:09:05 2016 +0000

----------------------------------------------------------------------
 .../vm/VmTransportNetworkBrokerTest.java        | 75 +++++++++++++++++++-
 1 file changed, 74 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/fd760888/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java
index e837e05..dc782a2 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java
@@ -24,14 +24,22 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.jms.Connection;
+import javax.jms.Session;
 import junit.framework.TestCase;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.bugs.embedded.ThreadExplorer;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.command.ActiveMQTopic;
+import org.apache.activemq.network.DurableConduitBridge;
 import org.apache.activemq.network.NetworkConnector;
 
+import org.apache.activemq.util.DefaultTestAppender;
 import org.apache.activemq.util.Wait;
+import org.apache.log4j.Level;
+import org.apache.log4j.spi.LoggingEvent;
+import org.junit.Ignore;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -115,7 +123,72 @@ public class VmTransportNetworkBrokerTest extends TestCase {
             ok);
     }
     
-    
+
+    public void testInvalidClientIdAndDurableSubs() throws Exception {
+
+        BrokerService broker = new BrokerService();
+        broker.setUseJmx(false);
+        broker.setDedicatedTaskRunner(true);
+        broker.setPersistent(false);
+        broker.addConnector("tcp://localhost:0");
+        broker.start();
+
+        // ensure remoteConnection fails with InvalidClientId
+        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString());
+        Connection connection = connectionFactory.createConnection("system", "manager");
+        connection.setClientID("F1_forwarder_outbound");
+        connection.start();
+
+        BrokerService forwarder = new BrokerService();
+        forwarder.setBrokerName("forwarder");
+        forwarder.setPersistent(false);
+        forwarder.setUseJmx(false);
+
+        forwarder.start();
+
+        // setup some durable subs to have some local work to do
+        ActiveMQConnectionFactory vmFactory = new ActiveMQConnectionFactory("vm://forwarder");
+        Connection vmConnection = vmFactory.createConnection("system", "manager");
+        vmConnection.setClientID("vm_local");
+        vmConnection.start();
+        Session session = vmConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        for (int i=0; i<5000; i++) {
+            session.createDurableSubscriber(new ActiveMQTopic("T" + i), "" + i);
+        }
+        vmConnection.close();
+
+        final AtomicInteger logCounts = new AtomicInteger(0);
+        DefaultTestAppender appender = new DefaultTestAppender() {
+            @Override
+            public void doAppend(LoggingEvent event) {
+                if (event.getLevel() == Level.ERROR) {
+                    logCounts.incrementAndGet();
+                }
+            }
+        };
+
+        org.apache.log4j.Logger.getLogger(DurableConduitBridge.class).addAppender(appender);
+        try {
+
+            NetworkConnector networkConnector = forwarder.addNetworkConnector("static:("
+                    + broker.getTransportConnectors().get(0).getPublishableConnectString()
+ ")");
+            networkConnector.setName("F1");
+            forwarder.addNetworkConnector(networkConnector);
+            forwarder.startAllConnectors();
+
+            TimeUnit.SECONDS.sleep(1);
+            connection.close();
+
+            forwarder.stop();
+            broker.stop();
+
+            assertEquals("no errors", 0, logCounts.get());
+
+        } finally {
+            org.apache.log4j.Logger.getLogger(DurableConduitBridge.class).removeAppender(appender);
+        }
+    }
+
     /**
      * Filters any daemon threads from the thread list.
      * 


Mime
View raw message