mirror of https://github.com/apache/activemq.git
https://issues.apache.org/jira/browse/AMQ-5875 - additional test that shows durable sub registration does not error out with this fix
This commit is contained in:
parent
f0378bcd3f
commit
fd76088814
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue