summaryrefslogtreecommitdiff
path: root/qpid/java/systests
diff options
context:
space:
mode:
authorRobert Gemmell <robbie@apache.org>2011-07-07 15:16:33 +0000
committerRobert Gemmell <robbie@apache.org>2011-07-07 15:16:33 +0000
commitf49bc309288098d2ab4858a6555fc30e014e949c (patch)
tree589cb21e49ea88c106b75104f2828827ec35f1dc /qpid/java/systests
parentaa709d3871daac1a0cd36fb52e2e3bc90074113c (diff)
downloadqpid-python-f49bc309288098d2ab4858a6555fc30e014e949c.tar.gz
QPID-3343: refactor test profiles to allow testing within the same JVM for all protocols, remove vm:// transport support and associated forked Mina classes
Applied patch by Keith Wall and myself git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1143874 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/systests')
-rw-r--r--qpid/java/systests/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipeIdleStatusChecker.java125
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java1
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java1
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/client/MultipleJCAProviderRegistrationTest.java82
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsConfigurationTest.java45
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTest.java35
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/MessagingTestConfigProperties.java8
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java73
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java2
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java4
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java17
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java19
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java1
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java18
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/SelectorTest.java28
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/AMQPFeatureDecorator.java96
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/CauseFailureDecorator.java95
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/CauseFailureInVM.java70
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/InVMBrokerDecorator.java136
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java1
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java6
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java1
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseTest.java1
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java22
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java5
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/MessageRequeueTest.java7
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java4
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTestCase.java2
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/utils/FailoverBaseCase.java8
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java160
30 files changed, 143 insertions, 930 deletions
diff --git a/qpid/java/systests/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipeIdleStatusChecker.java b/qpid/java/systests/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipeIdleStatusChecker.java
deleted file mode 100644
index 5323ad28bf..0000000000
--- a/qpid/java/systests/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipeIdleStatusChecker.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.mina.transport.vmpipe.support;
-
-import org.apache.mina.common.IdleStatus;
-
-import java.util.HashMap;
-import java.util.IdentityHashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * This file is a patch to override MINA, because of the IdentityHashMap bug. Workaround to be supplied in MINA 1.0.7.
- * This patched file will be removed once upgraded onto a newer MINA.
- *
- * Dectects idle sessions and fires <tt>sessionIdle</tt> events to them.
- *
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
- */
-public class VmPipeIdleStatusChecker
-{
- private static final VmPipeIdleStatusChecker INSTANCE = new VmPipeIdleStatusChecker();
-
- public static VmPipeIdleStatusChecker getInstance()
- {
- return INSTANCE;
- }
-
- private final Map sessions = new HashMap(); // will use as a set
-
- private final Worker worker = new Worker();
-
- private VmPipeIdleStatusChecker()
- {
- worker.start();
- }
-
- public void addSession(VmPipeSessionImpl session)
- {
- synchronized (sessions)
- {
- sessions.put(session, session);
- }
- }
-
- private class Worker extends Thread
- {
- private Worker()
- {
- super("VmPipeIdleStatusChecker");
- setDaemon(true);
- }
-
- public void run()
- {
- for (;;)
- {
- try
- {
- Thread.sleep(1000);
- }
- catch (InterruptedException e)
- { }
-
- long currentTime = System.currentTimeMillis();
-
- synchronized (sessions)
- {
- Iterator it = sessions.keySet().iterator();
- while (it.hasNext())
- {
- VmPipeSessionImpl session = (VmPipeSessionImpl) it.next();
- if (!session.isConnected())
- {
- it.remove();
- }
- else
- {
- notifyIdleSession(session, currentTime);
- }
- }
- }
- }
- }
- }
-
- private void notifyIdleSession(VmPipeSessionImpl session, long currentTime)
- {
- notifyIdleSession0(session, currentTime, session.getIdleTimeInMillis(IdleStatus.BOTH_IDLE), IdleStatus.BOTH_IDLE,
- Math.max(session.getLastIoTime(), session.getLastIdleTime(IdleStatus.BOTH_IDLE)));
- notifyIdleSession0(session, currentTime, session.getIdleTimeInMillis(IdleStatus.READER_IDLE), IdleStatus.READER_IDLE,
- Math.max(session.getLastReadTime(), session.getLastIdleTime(IdleStatus.READER_IDLE)));
- notifyIdleSession0(session, currentTime, session.getIdleTimeInMillis(IdleStatus.WRITER_IDLE), IdleStatus.WRITER_IDLE,
- Math.max(session.getLastWriteTime(), session.getLastIdleTime(IdleStatus.WRITER_IDLE)));
- }
-
- private void notifyIdleSession0(VmPipeSessionImpl session, long currentTime, long idleTime, IdleStatus status,
- long lastIoTime)
- {
- if ((idleTime > 0) && (lastIoTime != 0) && ((currentTime - lastIoTime) >= idleTime))
- {
- session.increaseIdleCount(status);
- session.getFilterChain().fireSessionIdle(session, status);
- }
- }
-
-}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java
index ca10126aa7..986297bfe1 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/client/AMQQueueDeferredOrderingTest.java
@@ -30,7 +30,6 @@ import javax.jms.TextMessage;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.client.transport.TransportConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java
index a8a23c2c41..29a44ecec3 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/client/DispatcherTest.java
@@ -36,7 +36,6 @@ import javax.jms.Session;
import javax.naming.Context;
import javax.naming.spi.InitialContextFactory;
-import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.jndi.PropertiesFileInitialContextFactory;
import org.apache.qpid.test.utils.QpidBrokerTestCase;
import org.slf4j.Logger;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/MultipleJCAProviderRegistrationTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/MultipleJCAProviderRegistrationTest.java
deleted file mode 100644
index b50643583e..0000000000
--- a/qpid/java/systests/src/main/java/org/apache/qpid/client/MultipleJCAProviderRegistrationTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.client;
-
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.client.transport.TransportConnection;
-
-import java.io.File;
-import java.security.Provider;
-import java.security.Security;
-import java.util.List;
-import java.util.LinkedList;
-
-/**
- * QPID-1394 : Test to ensure that the client can register their custom JCAProviders after the broker to ensure that
- * the Qpid custom authentication SASL plugins are used.
- */
-public class MultipleJCAProviderRegistrationTest extends QpidBrokerTestCase
-{
-
- public void setUp() throws Exception
- {
- _brokerType = VM;
-
- super.setUp();
- }
-
- public void test() throws Exception
- {
- // Get the providers before connection
- Provider[] providers = Security.getProviders();
-
- // Force the client to load the providers
- getConnection();
-
- Provider[] afterConnectionCreation = Security.getProviders();
-
- // Find the additions
- List additions = new LinkedList();
- for (Provider afterCreation : afterConnectionCreation)
- {
- boolean found = false;
- for (Provider provider : providers)
- {
- if (provider == afterCreation)
- {
- found=true;
- break;
- }
- }
-
- // Record added registies
- if (!found)
- {
- additions.add(afterCreation);
- }
- }
-
- assertTrue("Client did not register any providers", additions.size() > 0);
- }
-
-}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsConfigurationTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsConfigurationTest.java
index 7cc5d5995a..383c4c00a8 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsConfigurationTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsConfigurationTest.java
@@ -55,12 +55,9 @@ public class MessageStatisticsConfigurationTest extends MessageStatisticsTestCas
assertEquals("Incorrect vhost data", 0, vhost.getTotalDataReceived());
assertFalse("Vhost statistics should not be enabled", vhost.isStatisticsEnabled());
- if (!_brokerType.equals(VM))
- {
- assertEquals("Incorrect server total messages", 5, _jmxUtils.getServerInformation().getTotalMessagesReceived());
- assertEquals("Incorrect server total data", 1000, _jmxUtils.getServerInformation().getTotalDataReceived());
- assertTrue("Server statistics should be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled());
- }
+ assertEquals("Incorrect server total messages", 5, _jmxUtils.getServerInformation().getTotalMessagesReceived());
+ assertEquals("Incorrect server total data", 1000, _jmxUtils.getServerInformation().getTotalDataReceived());
+ assertTrue("Server statistics should be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled());
}
/**
@@ -83,12 +80,9 @@ public class MessageStatisticsConfigurationTest extends MessageStatisticsTestCas
assertEquals("Incorrect vhost data", 1000, vhost.getTotalDataReceived());
assertTrue("Vhost statistics should be enabled", vhost.isStatisticsEnabled());
- if (!_brokerType.equals(VM))
- {
- assertEquals("Incorrect server total messages", 0, _jmxUtils.getServerInformation().getTotalMessagesReceived());
- assertEquals("Incorrect server total data", 0, _jmxUtils.getServerInformation().getTotalDataReceived());
- assertFalse("Server statistics should not be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled());
- }
+ assertEquals("Incorrect server total messages", 0, _jmxUtils.getServerInformation().getTotalMessagesReceived());
+ assertEquals("Incorrect server total data", 0, _jmxUtils.getServerInformation().getTotalDataReceived());
+ assertFalse("Server statistics should not be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled());
}
/**
@@ -111,12 +105,9 @@ public class MessageStatisticsConfigurationTest extends MessageStatisticsTestCas
assertEquals("Incorrect vhost data", 0, vhost.getTotalDataReceived());
assertFalse("Vhost statistics should not be enabled", vhost.isStatisticsEnabled());
- if (!_brokerType.equals(VM))
- {
- assertEquals("Incorrect server total messages", 0, _jmxUtils.getServerInformation().getTotalMessagesReceived());
- assertEquals("Incorrect server total data", 0, _jmxUtils.getServerInformation().getTotalDataReceived());
- assertFalse("Server statistics should not be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled());
- }
+ assertEquals("Incorrect server total messages", 0, _jmxUtils.getServerInformation().getTotalMessagesReceived());
+ assertEquals("Incorrect server total data", 0, _jmxUtils.getServerInformation().getTotalDataReceived());
+ assertFalse("Server statistics should not be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled());
}
/**
@@ -139,12 +130,9 @@ public class MessageStatisticsConfigurationTest extends MessageStatisticsTestCas
assertEquals("Incorrect vhost data", 1000, vhost.getTotalDataReceived());
assertTrue("Vhost statistics should be enabled", vhost.isStatisticsEnabled());
- if (!_brokerType.equals(VM))
- {
- assertEquals("Incorrect server total messages", 5, _jmxUtils.getServerInformation().getTotalMessagesReceived());
- assertEquals("Incorrect server total data", 1000, _jmxUtils.getServerInformation().getTotalDataReceived());
- assertTrue("Server statistics should be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled());
- }
+ assertEquals("Incorrect server total messages", 5, _jmxUtils.getServerInformation().getTotalMessagesReceived());
+ assertEquals("Incorrect server total data", 1000, _jmxUtils.getServerInformation().getTotalDataReceived());
+ assertTrue("Server statistics should be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled());
}
/**
@@ -167,11 +155,8 @@ public class MessageStatisticsConfigurationTest extends MessageStatisticsTestCas
assertEquals("Incorrect vhost data", 1000, vhost.getTotalDataReceived());
assertTrue("Vhost statistics should be enabled", vhost.isStatisticsEnabled());
- if (!_brokerType.equals(VM))
- {
- assertEquals("Incorrect server total messages", 5, _jmxUtils.getServerInformation().getTotalMessagesReceived());
- assertEquals("Incorrect server total data", 1000, _jmxUtils.getServerInformation().getTotalDataReceived());
- assertTrue("Server statistics should be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled());
- }
+ assertEquals("Incorrect server total messages", 5, _jmxUtils.getServerInformation().getTotalMessagesReceived());
+ assertEquals("Incorrect server total data", 1000, _jmxUtils.getServerInformation().getTotalDataReceived());
+ assertTrue("Server statistics should be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled());
}
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTest.java
index f1953d1eba..824ae41b97 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTest.java
@@ -66,11 +66,8 @@ public class MessageStatisticsTest extends MessageStatisticsTestCase
assertEquals("Incorrect connection total", 45, total);
assertEquals("Incorrect connection data", 4500, data);
}
- if (!_brokerType.equals(VM))
- {
- assertEquals("Incorrect server total", 45, _jmxUtils.getServerInformation().getTotalMessagesReceived());
- assertEquals("Incorrect server data", 4500, _jmxUtils.getServerInformation().getTotalDataReceived());
- }
+ assertEquals("Incorrect server total", 45, _jmxUtils.getServerInformation().getTotalMessagesReceived());
+ assertEquals("Incorrect server data", 4500, _jmxUtils.getServerInformation().getTotalDataReceived());
if (!isBroker010())
{
@@ -147,11 +144,8 @@ public class MessageStatisticsTest extends MessageStatisticsTestCase
assertEquals("Incorrect active connection total", 20, total);
assertEquals("Incorrect active connection data", 2000, data);
}
- if (!_brokerType.equals(VM))
- {
- assertEquals("Incorrect server total", 30, _jmxUtils.getServerInformation().getTotalMessagesReceived());
- assertEquals("Incorrect server data", 3000, _jmxUtils.getServerInformation().getTotalDataReceived());
- }
+ assertEquals("Incorrect server total", 30, _jmxUtils.getServerInformation().getTotalMessagesReceived());
+ assertEquals("Incorrect server data", 3000, _jmxUtils.getServerInformation().getTotalDataReceived());
if (!isBroker010())
{
@@ -187,11 +181,8 @@ public class MessageStatisticsTest extends MessageStatisticsTestCase
assertApprox("Incorrect dev vhost peak messages", 0.2d, 2.0d, dev.getPeakMessageReceiptRate());
assertApprox("Incorrect dev vhost peak data", 0.2d, 20.0d, dev.getPeakDataReceiptRate());
- if (!_brokerType.equals(VM))
- {
- assertApprox("Incorrect server peak messages", 0.2d, 2.0d, _jmxUtils.getServerInformation().getPeakMessageReceiptRate());
- assertApprox("Incorrect server peak data", 0.2d, 20.0d, _jmxUtils.getServerInformation().getPeakDataReceiptRate());
- }
+ assertApprox("Incorrect server peak messages", 0.2d, 2.0d, _jmxUtils.getServerInformation().getPeakMessageReceiptRate());
+ assertApprox("Incorrect server peak data", 0.2d, 20.0d, _jmxUtils.getServerInformation().getPeakDataReceiptRate());
}
/**
@@ -211,11 +202,8 @@ public class MessageStatisticsTest extends MessageStatisticsTestCase
assertEquals("Incorrect dev vhost total messages", 10, dev.getTotalMessagesReceived());
assertEquals("Incorrect dev vhost total data", 100, dev.getTotalDataReceived());
- if (!_brokerType.equals(VM))
- {
- assertEquals("Incorrect server total messages", 20, _jmxUtils.getServerInformation().getTotalMessagesReceived());
- assertEquals("Incorrect server total data", 200, _jmxUtils.getServerInformation().getTotalDataReceived());
- }
+ assertEquals("Incorrect server total messages", 20, _jmxUtils.getServerInformation().getTotalMessagesReceived());
+ assertEquals("Incorrect server total data", 200, _jmxUtils.getServerInformation().getTotalDataReceived());
test.resetStatistics();
@@ -224,10 +212,7 @@ public class MessageStatisticsTest extends MessageStatisticsTestCase
assertEquals("Incorrect dev vhost total messages", 10, dev.getTotalMessagesReceived());
assertEquals("Incorrect dev vhost total data", 100, dev.getTotalDataReceived());
- if (!_brokerType.equals(VM))
- {
- assertEquals("Incorrect server total messages", 20, _jmxUtils.getServerInformation().getTotalMessagesReceived());
- assertEquals("Incorrect server total data", 200, _jmxUtils.getServerInformation().getTotalDataReceived());
- }
+ assertEquals("Incorrect server total messages", 20, _jmxUtils.getServerInformation().getTotalMessagesReceived());
+ assertEquals("Incorrect server total data", 200, _jmxUtils.getServerInformation().getTotalDataReceived());
}
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/MessagingTestConfigProperties.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/MessagingTestConfigProperties.java
index 2d89d319d7..4a92f04b30 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/MessagingTestConfigProperties.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/MessagingTestConfigProperties.java
@@ -83,15 +83,9 @@ public class MessagingTestConfigProperties
/** Holds the name of the default connection factory configuration property. */
public static final String CONNECTION_PROPNAME = "connectionfactory.broker";
- /** Defeins the default connection configuration. */
- public static final String CONNECTION_DEFAULT = "amqp://guest:guest@clientid/?brokerlist='vm://:1'";
-
/** Holds the name of the property to get the test broker url from. */
public static final String BROKER_PROPNAME = "qpid.test.broker";
- /** Holds the default broker url for the test. */
- public static final String BROKER_DEFAULT = "vm://:1";
-
/** Holds the name of the property to get the test broker virtual path. */
public static final String VIRTUAL_HOST_PROPNAME = "virtualHost";
@@ -274,7 +268,6 @@ public class MessagingTestConfigProperties
static
{
defaults.setPropertyIfNull(INITIAL_CONTEXT_FACTORY_PROPNAME, INITIAL_CONTEXT_FACTORY_DEFAULT);
- defaults.setPropertyIfNull(CONNECTION_PROPNAME, CONNECTION_DEFAULT);
defaults.setPropertyIfNull(MESSAGE_SIZE_PROPNAME, MESSAGE_SIZE_DEAFULT);
defaults.setPropertyIfNull(PUBLISHER_PRODUCER_BIND_PROPNAME, PUBLISHER_PRODUCER_BIND_DEFAULT);
defaults.setPropertyIfNull(PUBLISHER_CONSUMER_BIND_PROPNAME, PUBLISHER_CONSUMER_BIND_DEFAULT);
@@ -284,7 +277,6 @@ public class MessagingTestConfigProperties
defaults.setPropertyIfNull(RECEIVE_DESTINATION_NAME_ROOT_PROPNAME, RECEIVE_DESTINATION_NAME_ROOT_DEFAULT);
defaults.setPropertyIfNull(PERSISTENT_MODE_PROPNAME, PERSISTENT_MODE_DEFAULT);
defaults.setPropertyIfNull(TRANSACTED_PROPNAME, TRANSACTED_DEFAULT);
- defaults.setPropertyIfNull(BROKER_PROPNAME, BROKER_DEFAULT);
defaults.setPropertyIfNull(VIRTUAL_HOST_PROPNAME, VIRTUAL_HOST_DEFAULT);
defaults.setPropertyIfNull(RATE_PROPNAME, RATE_DEFAULT);
defaults.setPropertyIfNull(VERBOSE_PROPNAME, VERBOSE_DEFAULT);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java
index 011700d634..35650e314a 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java
@@ -20,55 +20,39 @@
*/
package org.apache.qpid.server.failover;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+
import org.apache.qpid.AMQDisconnectedException;
import org.apache.qpid.AMQException;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQConnectionURL;
-import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
-import org.apache.qpid.server.util.InternalBrokerBaseCase;
-import org.apache.qpid.url.URLSyntaxException;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import java.util.concurrent.CountDownLatch;
-
-public class FailoverMethodTest extends InternalBrokerBaseCase implements ExceptionListener
+public class FailoverMethodTest extends QpidBrokerTestCase implements ExceptionListener
{
private CountDownLatch _failoverComplete = new CountDownLatch(1);
protected static final Logger _logger = LoggerFactory.getLogger(FailoverMethodTest.class);
- @Override
- public void createBroker() throws Exception
- {
- super.createBroker();
- TransportConnection.createVMBroker(TransportConnection.DEFAULT_VM_PORT);
- }
- @Override
- public void stopBroker()
- {
- TransportConnection.killVMBroker(TransportConnection.DEFAULT_VM_PORT);
- super.stopBroker();
- }
/**
* Test that the round robin method has the correct delays.
- * The first connection to vm://:1 will work but the localhost connection should fail but the duration it takes
+ * The first connection will work but the localhost connection should fail but the duration it takes
* to report the failure is what is being tested.
*
- * @throws URLSyntaxException
- * @throws InterruptedException
- * @throws JMSException
*/
- public void testFailoverRoundRobinDelay() throws URLSyntaxException, InterruptedException, JMSException
+ public void testFailoverRoundRobinDelay() throws Exception
{
- //note: The VM broker has no connect delay and the default 1 retry
+ //note: The first broker has no connect delay and the default 1 retry
// while the tcp:localhost broker has 3 retries with a 2s connect delay
String connectionString = "amqp://guest:guest@/test?brokerlist=" +
- "'vm://:" + TransportConnection.DEFAULT_VM_PORT +
+ "'tcp://:" + getPort() +
";tcp://localhost:5670?connectdelay='2000',retries='3''";
AMQConnectionURL url = new AMQConnectionURL(connectionString);
@@ -82,7 +66,9 @@ public class FailoverMethodTest extends InternalBrokerBaseCase implements Except
stopBroker();
- _failoverComplete.await();
+ _failoverComplete.await(30, TimeUnit.SECONDS);
+ assertEquals("failoverLatch was not decremented in given timeframe",
+ 0, _failoverComplete.getCount());
long end = System.currentTimeMillis();
@@ -109,10 +95,9 @@ public class FailoverMethodTest extends InternalBrokerBaseCase implements Except
}
}
- public void testFailoverSingleDelay() throws URLSyntaxException, AMQVMBrokerCreationException,
- InterruptedException, JMSException
+ public void testFailoverSingleDelay() throws Exception
{
- String connectionString = "amqp://guest:guest@/test?brokerlist='vm://:1?connectdelay='2000',retries='3''";
+ String connectionString = "amqp://guest:guest@/test?brokerlist='tcp://localhost:" + getPort() + "?connectdelay='2000',retries='3''";
AMQConnectionURL url = new AMQConnectionURL(connectionString);
@@ -125,7 +110,9 @@ public class FailoverMethodTest extends InternalBrokerBaseCase implements Except
stopBroker();
- _failoverComplete.await();
+ _failoverComplete.await(30, TimeUnit.SECONDS);
+ assertEquals("failoverLatch was not decremented in given timeframe",
+ 0, _failoverComplete.getCount());
long end = System.currentTimeMillis();
@@ -157,6 +144,10 @@ public class FailoverMethodTest extends InternalBrokerBaseCase implements Except
_logger.debug("Received AMQDisconnectedException");
_failoverComplete.countDown();
}
+ else
+ {
+ _logger.error("Unexpected underlying exception", e.getLinkedException());
+ }
}
/**
@@ -165,17 +156,11 @@ public class FailoverMethodTest extends InternalBrokerBaseCase implements Except
*
* Test validates that there is a connection delay as required on initial
* connection.
- *
- * @throws URLSyntaxException
- * @throws AMQVMBrokerCreationException
- * @throws InterruptedException
- * @throws JMSException
*/
- public void testNoFailover() throws URLSyntaxException, AMQVMBrokerCreationException,
- InterruptedException, JMSException
+ public void testNoFailover() throws Exception
{
int CONNECT_DELAY = 2000;
- String connectionString = "amqp://guest:guest@/test?brokerlist='vm://:1?connectdelay='" + CONNECT_DELAY + "'," +
+ String connectionString = "amqp://guest:guest@/test?brokerlist='tcp://localhost:" + getPort() + "?connectdelay='" + CONNECT_DELAY + "'," +
"retries='3'',failover='nofailover'";
AMQConnectionURL url = new AMQConnectionURL(connectionString);
@@ -195,7 +180,7 @@ public class FailoverMethodTest extends InternalBrokerBaseCase implements Except
//Wait before starting broker
// The wait should allow atleast 1 retries to fail before broker is ready
Thread.sleep(750);
- createBroker();
+ startBroker();
}
catch (Exception e)
{
@@ -231,7 +216,9 @@ public class FailoverMethodTest extends InternalBrokerBaseCase implements Except
//Kill connection
stopBroker();
- _failoverComplete.await();
+ _failoverComplete.await(30, TimeUnit.SECONDS);
+ assertEquals("failoverLatch was not decremented in given timeframe",
+ 0, _failoverComplete.getCount());
end = System.currentTimeMillis();
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java
index 05aaf16af1..58b2edfee2 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java
@@ -176,7 +176,7 @@ public class AlertingTest extends AbstractTestLogging
startBroker();
- if (!isExternalBroker())
+ if (isInternalBroker())
{
assertEquals("Alert Max Msg Count is not correct", 5, ApplicationRegistry.getInstance().getVirtualHostRegistry().
getVirtualHost(VIRTUALHOST).getQueueRegistry().getQueue(new AMQShortString(_destination.getQueueName())).
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java
index 02d0d6f334..1b2ec9c092 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java
@@ -77,7 +77,7 @@ public class ChannelLoggingTest extends AbstractTestLogging
validateMessageID("CHN-1001", log);
assertEquals("Incorrect Channel in actor:"+fromActor(log), isBroker010()? 0 : 1, getChannelID(fromActor(log)));
- if (isBroker08())
+ if (!isBroker010())
{
// Wait to ensure that the CHN-1004 message is logged
waitForMessage("CHN-1004");
@@ -89,7 +89,7 @@ public class ChannelLoggingTest extends AbstractTestLogging
log = getLogMessage(results, 0);
// MESSAGE [con:0(guest@anonymous(3273383)/test)/ch:1] CHN-1004 : Prefetch Size (bytes) {0,number} : Count {1,number}
validateMessageID("CHN-1004", log);
- assertEquals("Incorrect Channel in actor:"+fromActor(log), isBroker010()? 0 : 1, getChannelID(fromActor(log)));
+ assertEquals("Incorrect Channel in actor:"+fromActor(log), 1, getChannelID(fromActor(log)));
assertTrue("Prefetch Count not correct",getMessageString(fromMessage(log)).endsWith("Count "+PREFETCH));
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java
index 595c0d5f35..9feca7279e 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java
@@ -76,9 +76,8 @@ public class ManagementLoggingTest extends AbstractTestLogging
*/
public void testManagementStartupEnabled() throws Exception
{
- // This test only works on external java brokers due to the fact that
- // Management is disabled on InVM brokers.
- if (isJavaBroker() && isExternalBroker())
+ // This test only works on java brokers
+ if (isJavaBroker())
{
startBrokerAndCreateMonitor(true, false);
@@ -130,9 +129,7 @@ public class ManagementLoggingTest extends AbstractTestLogging
*/
public void testManagementStartupDisabled() throws Exception
{
- // This test only works on external java brokers due to the fact that
- // Management is disabled on InVM brokers.
- if (isJavaBroker() && isExternalBroker())
+ if (isJavaBroker())
{
startBrokerAndCreateMonitor(false, false);
@@ -191,9 +188,7 @@ public class ManagementLoggingTest extends AbstractTestLogging
*/
public void testManagementStartupRMIEntries() throws Exception
{
- // This test only works on external java brokers due to the fact that
- // Management is disabled on InVM brokers.
- if (isJavaBroker() && isExternalBroker())
+ if (isJavaBroker())
{
startBrokerAndCreateMonitor(true, false);
@@ -250,9 +245,7 @@ public class ManagementLoggingTest extends AbstractTestLogging
*/
public void testManagementStartupSSLKeystore() throws Exception
{
- // This test only works on external java brokers due to the fact that
- // Management is disabled on InVM brokers.
- if (isJavaBroker() && isExternalBroker())
+ if (isJavaBroker())
{
startBrokerAndCreateMonitor(true, true);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java
index ce6cc60ffd..398c83a8d8 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/persistent/NoLocalAfterRecoveryTest.java
@@ -78,21 +78,10 @@ public class NoLocalAfterRecoveryTest extends QpidBrokerTestCase implements Conn
BrokerDetails details = _connectionURL.getBrokerDetails(0);
- // Due to the problem with SingleServer delaying on all connection
- // attempts. So using a high retry value.
- if (_brokerType.equals(VM))
- {
- // Local testing suggests InVM restart takes under a second
- details.setProperty(BrokerDetails.OPTIONS_RETRY, "5");
- details.setProperty(BrokerDetails.OPTIONS_CONNECT_DELAY, "200");
- }
- else
- {
- // This will attempt to failover for 3 seconds.
- // Local testing suggests failover takes 2 seconds
- details.setProperty(BrokerDetails.OPTIONS_RETRY, "10");
- details.setProperty(BrokerDetails.OPTIONS_CONNECT_DELAY, "500");
- }
+ // This will attempt to failover for 3 seconds.
+ // Local testing suggests failover takes 2 seconds
+ details.setProperty(BrokerDetails.OPTIONS_RETRY, "10");
+ details.setProperty(BrokerDetails.OPTIONS_CONNECT_DELAY, "500");
super.setUp();
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java
index 6203e8a194..2ce1251eab 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/PriorityTest.java
@@ -23,7 +23,6 @@ package org.apache.qpid.server.queue;
import junit.framework.TestCase;
import junit.framework.Assert;
import org.apache.log4j.Logger;
-import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.AMQQueue;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java
index be4a865ff6..2d99a44532 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java
@@ -85,12 +85,6 @@ public class FirewallConfigTest extends QpidBrokerTestCase
public void testVhostAllowBrokerDeny() throws Exception
{
- if (_brokerType.equals(VM))
- {
- //No point running this test with an InVM broker as the
- //firewall plugin only functions for TCP connections.
- return;
- }
_configFile = new File(System.getProperty("QPID_HOME"), "etc/config-systests-firewall-2.xml");
@@ -125,13 +119,6 @@ public class FirewallConfigTest extends QpidBrokerTestCase
public void testVhostDenyBrokerAllow() throws Exception
{
- if (_brokerType.equals(VM))
- {
- //No point running this test with an InVM broker as the
- //firewall plugin only functions for TCP connections.
- return;
- }
-
_configFile = new File(System.getProperty("QPID_HOME"), "etc/config-systests-firewall-3.xml");
super.setUp();
@@ -277,11 +264,6 @@ public class FirewallConfigTest extends QpidBrokerTestCase
private void testFirewall(boolean initial, boolean inVhost, Runnable restartOrReload) throws Exception
{
- if (_brokerType.equals(VM))
- {
- // No point running this test in a vm broker
- return;
- }
writeFirewallFile(initial, inVhost);
setConfigurationProperty("management.enabled", String.valueOf(true));
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/SelectorTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/SelectorTest.java
index 212374e8be..b1c8b5682f 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/SelectorTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/message/SelectorTest.java
@@ -52,7 +52,6 @@ public class SelectorTest extends QpidBrokerTestCase implements MessageListener
private AMQConnection _connection;
private AMQDestination _destination;
private int count;
- public String _connectionString = "vm://:1";
private static final String INVALID_SELECTOR = "Cost LIKE 5";
CountDownLatch _responseLatch = new CountDownLatch(1);
@@ -314,31 +313,4 @@ public class SelectorTest extends QpidBrokerTestCase implements MessageListener
assertNull("Consumer2 should not receiver another message",consumer2.receive(1000));
}
- public static void main(String[] argv) throws Exception
- {
- SelectorTest test = new SelectorTest();
- test._connectionString = (argv.length == 0) ? "localhost:3000" : argv[0];
-
- try
- {
- while (true)
- {
- if (test._connectionString.contains("vm://:1"))
- {
- test.setUp();
- }
- test.testUsingOnMessage();
-
- if (test._connectionString.contains("vm://:1"))
- {
- test.tearDown();
- }
- }
- }
- catch (Exception e)
- {
- System.err.println(e.getMessage());
- e.printStackTrace();
- }
- }
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/AMQPFeatureDecorator.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/AMQPFeatureDecorator.java
deleted file mode 100644
index c11f75e742..0000000000
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/AMQPFeatureDecorator.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.test.framework.qpid;
-
-import junit.framework.Test;
-import junit.framework.TestResult;
-
-import org.apache.qpid.test.framework.FrameworkBaseCase;
-import org.apache.qpid.test.framework.LocalAMQPCircuitFactory;
-
-import org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator;
-
-/**
- * AMQPFeatureDecorator applies decorations to {@link FrameworkBaseCase} tests, so that they may use Qpid/AMQP specific
- * features, not available through JMS. For example, the immediate and mandatory flags. This decorator replaces the
- * standard test circuit factory on the base class with one that allows these features to be used.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Substitute the circuit factory with an AMQP/Qpid specific one.
- * </table>
- *
- * @todo This wrapper substitutes in a LocalAMQPCircuitFactory, which is fine for local tests. For distributed tests
- * the Fanout or Interop factories are substituted in by their decorators instead. These actually use
- * distributed circuit static create methods to build the circuits, which should actually be changed to a factory,
- * so that static methods do not need to be used. The distributed circuit creater delegates the circuit
- * construction to remote test nodes. This decorator should not be used with distributed tests, or should be made
- * aware of them, in which case it might ensure that an AMQP feature (implied already by other properties) flag
- * is passed out to the remote test nodes, and provide a mechansim for them to decorate their circuit creation
- * with AMQP features too. Add factory substituion/decoration mechansim for test clients, here or in a seperate
- * class.
- */
-public class AMQPFeatureDecorator extends WrappedSuiteTestDecorator
-{
- /** The test suite to run. */
- private Test test;
-
- /**
- * Creates a wrapped test test decorator from another one.
- *
- * @param test The test test.
- */
- public AMQPFeatureDecorator(WrappedSuiteTestDecorator test)
- {
- super(test);
- this.test = test;
- }
-
- /**
- * Runs the tests with a LocalAMQPCircuitFactory. Only tests that extend FrameworkBaseCase are decorated.
- *
- * @param testResult The the results object to monitor the test results with.
- */
- public void run(TestResult testResult)
- {
- for (Test test : getAllUnderlyingTests())
- {
- if (test instanceof FrameworkBaseCase)
- {
- FrameworkBaseCase frameworkTest = (FrameworkBaseCase) test;
- frameworkTest.setCircuitFactory(new LocalAMQPCircuitFactory());
- }
- }
-
- // Run the test.
- test.run(testResult);
- }
-
- /**
- * Prints the name of the test for debugging purposes.
- *
- * @return The name of the test.
- */
- public String toString()
- {
- return "AMQPFeatureDecorator: [test = \"" + test + "\"]";
- }
-}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/CauseFailureDecorator.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/CauseFailureDecorator.java
deleted file mode 100644
index 2708253d86..0000000000
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/CauseFailureDecorator.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.test.framework.qpid;
-
-import junit.framework.Test;
-import junit.framework.TestResult;
-
-import org.apache.qpid.test.framework.BrokerLifecycleAware;
-import org.apache.qpid.test.framework.CauseFailureUserPrompt;
-
-import org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator;
-
-/**
- * CauseFailureDecorator applies decorations to {@link BrokerLifecycleAware} tests, so that they may use different failure
- * mechanisms. It is capable of detecting when a test case uses in-vm brokers, and setting up an automatic failure
- * for those tests, so that the current live broker can be shut-down by test cases. For external brokers, automatic
- * failure could be implemented, for example by having a kill script. At the moment this sets up the failure to prompt
- * a user interactively to cause a failure, using {@link CauseFailureUserPrompt}.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Setup automatic failures for in-vm brokers. <td> {@link CauseFailureInVM}
- * <tr><td> Setup user generated failures for external brokers. <td> {@link CauseFailureUserPrompt}.
- * <tr><td>
- * </table>
- *
- * @todo Slight problem in that CauseFailureInVM is Qpid specific, whereas CauseFailureUserPrompt is not. Would like the
- * failure decorator to be non-qpid specific so that it can test failure of any JMS implementation too. Either pass
- * in class name of failure mechanism, set it up in the in-vm decorator instead of here but with prompt user as the
- * default for when the in-vm decorator is not used?
- */
-public class CauseFailureDecorator extends WrappedSuiteTestDecorator
-{
- /** The test suite to run. */
- private Test test;
-
- /**
- * Creates a wrapped test test decorator from another one.
- *
- * @param test The test test.
- */
- public CauseFailureDecorator(WrappedSuiteTestDecorator test)
- {
- super(test);
- this.test = test;
- }
-
- /**
- * Runs the tests with a LocalAMQPCircuitFactory. Only tests that extend FrameworkBaseCase are decorated.
- *
- * @param testResult The the results object to monitor the test results with.
- */
- public void run(TestResult testResult)
- {
- for (Test test : getAllUnderlyingTests())
- {
- if (test instanceof BrokerLifecycleAware)
- {
- BrokerLifecycleAware failureTest = (BrokerLifecycleAware) test;
- failureTest.setFailureMechanism(new CauseFailureUserPrompt());
- }
- }
-
- // Run the test.
- test.run(testResult);
- }
-
- /**
- * Prints the name of the test for debugging purposes.
- *
- * @return The name of the test.
- */
- public String toString()
- {
- return "CauseFailureDecorator: [test = \"" + test + "\"]";
- }
-}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/CauseFailureInVM.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/CauseFailureInVM.java
deleted file mode 100644
index fd86fc8e21..0000000000
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/CauseFailureInVM.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.test.framework.qpid;
-
-import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.test.framework.CauseFailure;
-import org.apache.qpid.test.framework.BrokerLifecycleAware;
-
-/**
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Cause messaging broker failure on the active in-vm broker.
- * <td> {@link TransportConnection}, {@link ApplicationRegistry}
- * </table>
- */
-public class CauseFailureInVM implements CauseFailure
-{
- /** Holds the in-vm broker instrumented test case to create failures for. */
- private BrokerLifecycleAware inVMTest;
-
- /**
- * Creates an automated failure mechanism for testing against in-vm brokers. The test to create the mechanism
- * for is specified, and as this failure is for in-vm brokers, the test must be {@link org.apache.qpid.test.framework.BrokerLifecycleAware}. The test
- * must also report that it is currently being run against an in-vm broker, and it is a runtime error if it is not,
- * as the creator of this failure mechanism should already have checked that it is.
- *
- * @param inVMTest The test case to create an automated failure mechanism for.
- */
- public CauseFailureInVM(BrokerLifecycleAware inVMTest)
- {
- // Check that the test is really using in-vm brokers.
- if (!inVMTest.usingInVmBroker())
- {
- throw new RuntimeException(
- "Cannot create in-vm broker failure mechanism for a test that is not using in-vm brokers.");
- }
-
- this.inVMTest = inVMTest;
- }
-
- /**
- * Causes the active message broker to fail.
- */
- public void causeFailure()
- {
- int liveBroker = inVMTest.getLiveBroker();
-
- TransportConnection.killVMBroker(liveBroker);
- ApplicationRegistry.remove();
- }
-}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/InVMBrokerDecorator.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/InVMBrokerDecorator.java
deleted file mode 100644
index c43318165d..0000000000
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/qpid/InVMBrokerDecorator.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.qpid.test.framework.qpid;
-
-import junit.framework.Test;
-import junit.framework.TestResult;
-
-import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.test.framework.BrokerLifecycleAware;
-import org.apache.qpid.test.framework.FrameworkBaseCase;
-
-import org.apache.qpid.junit.extensions.SetupTaskAware;
-import org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator;
-
-/**
- * InVMBrokerDecorator is a test decorator, that is activated when running tests against an in-vm broker only. Its
- * purpose is to automatically create, and close and delete an in-vm broker, during the set-up and tear-down of
- * each test case. This decorator may only be used in conjunction with tests that extend {@link FrameworkBaseCase}.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td> Create/Destroy an in-vm broker on every test run.
- * </table>
- *
- * @todo May need to add a more fine grained injection point for the in-vm broker management, as this acts at the
- * suite level, rather than the individual test level.
- *
- * @todo Management of in-vm brokers for failure testing. Failure test setups may need to set their connection url to
- * use multiple broker (vm://:1;vm://:2), with fail-over between them. There is round-robin fail-over, but also
- * retry? A test case using an in-vm broker needs to record which one it is using, so that it can be
- * killed/restarted.
- */
-public class InVMBrokerDecorator extends WrappedSuiteTestDecorator
-{
- /** The test suite to run. */
- private Test test;
-
- /**
- * Creates a wrapped test suite decorator from another one.
- *
- * @param test The test suite.
- */
- public InVMBrokerDecorator(WrappedSuiteTestDecorator test)
- {
- super(test);
- this.test = test;
- }
-
- /**
- * Runs the tests with in-vm broker creation and clean-up added to the tests task stack.
- *
- * @param testResult The the results object to monitor the test results with.
- */
- public void run(TestResult testResult)
- {
- for (Test test : getAllUnderlyingTests())
- {
- // Check that the test to have an in-vm broker setup/teardown task added to it, is actually a framework
- // test that can handle setup tasks.
- if ((test instanceof SetupTaskAware))
- {
- SetupTaskAware frameworkTest = (SetupTaskAware) test;
-
- frameworkTest.chainSetupTask(new Runnable()
- {
- public void run()
- {
- // Ensure that the in-vm broker is created.
- try
- {
- ApplicationRegistry.getInstance();
- TransportConnection.createVMBroker(1);
- }
- catch (AMQVMBrokerCreationException e)
- {
- throw new RuntimeException("In-VM broker creation failed: " + e.getMessage(), e);
- }
- }
- });
-
- frameworkTest.chainTearDownTask(new Runnable()
- {
- public void run()
- {
- // Ensure that the in-vm broker is cleaned up so that the next test starts afresh.
- TransportConnection.killVMBroker(1);
- ApplicationRegistry.remove();
- }
- });
-
- // Check if the test is aware whether or not it can control the broker life cycle, and if so provide
- // additional instrumentation for it to control the in-vm broker through.
- if (test instanceof BrokerLifecycleAware)
- {
- BrokerLifecycleAware inVMTest = (BrokerLifecycleAware) test;
- inVMTest.setInVmBrokers();
- inVMTest.setLiveBroker(1);
- inVMTest.setFailureMechanism(new CauseFailureInVM(inVMTest));
- }
- }
- }
-
- // Run the test.
- test.run(testResult);
- }
-
- /**
- * Prints the name of the test for debugging purposes.
- *
- * @return The name of the test.
- */
- public String toString()
- {
- return "InVMBrokerDecorator: [test = " + test + "]";
- }
-}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java
index 3a5f676ca6..87eae32cf8 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/MultipleConnectionTest.java
@@ -23,7 +23,6 @@ import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.AMQTopic;
-import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.test.utils.QpidBrokerTestCase;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java
index 292bcd6039..481b144caf 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java
@@ -20,7 +20,6 @@
*/
package org.apache.qpid.test.unit.client;
-import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
@@ -37,11 +36,9 @@ import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.QueueSession;
import javax.jms.Session;
-import javax.jms.TextMessage;
import javax.jms.TopicSession;
import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQConnectionDelegate_0_10;
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.AMQTopic;
@@ -231,7 +228,8 @@ public class AMQConnectionTest extends QpidBrokerTestCase
}
MessageConsumer consumerB = null;
- if (isBroker08())
+ // 0-8, 0-9, 0-9-1 prefetch is per session, not consumer.
+ if (!isBroker010())
{
Session consSessB = _connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
consumerB = consSessB.createConsumer(_queue);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java
index 79e2ff8148..aae8b1feb9 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseOkTest.java
@@ -24,7 +24,6 @@ import junit.textui.TestRunner;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.test.utils.QpidBrokerTestCase;
import org.slf4j.Logger;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseTest.java
index b6232b1734..2e8a2d049d 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/channelclose/ChannelCloseTest.java
@@ -25,7 +25,6 @@ import org.apache.qpid.test.utils.QpidBrokerTestCase;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.failover.FailoverException;
import org.apache.qpid.client.protocol.AMQProtocolHandler;
-import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.framing.*;
import org.apache.qpid.jms.ConnectionListener;
import org.apache.qpid.protocol.AMQConstant;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
index 04fc611cd1..d17ead13aa 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
@@ -20,32 +20,30 @@
*/
package org.apache.qpid.test.unit.client.connection;
+import javax.jms.Connection;
+import javax.jms.QueueSession;
+import javax.jms.TopicSession;
+
import org.apache.qpid.AMQConnectionFailureException;
import org.apache.qpid.AMQException;
import org.apache.qpid.AMQUnresolvedAddressException;
-import org.apache.qpid.server.exchange.Exchange;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.client.AMQAuthenticationException;
import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQConnectionURL;
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.AMQTopic;
-import org.apache.qpid.client.AMQConnectionURL;
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.jms.Session;
-import org.apache.qpid.jms.ConnectionURL;
import org.apache.qpid.jms.BrokerDetails;
-
-import javax.jms.Connection;
-import javax.jms.QueueSession;
-import javax.jms.TopicSession;
-import javax.naming.NamingException;
+import org.apache.qpid.jms.ConnectionURL;
+import org.apache.qpid.jms.Session;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
public class ConnectionTest extends QpidBrokerTestCase
{
- String _broker_NotRunning = "vm://:2";
+ String _broker_NotRunning = "tcp://localhost:" + findFreePort();
+
String _broker_BadDNS = "tcp://hg3sgaaw4lgihjs";
public void testSimpleConnection() throws Exception
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java
index 9c1807199c..5701b5a1fd 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java
@@ -93,11 +93,6 @@ public class AMQProtocolSessionTest extends QpidBrokerTestCase
checkTempQueueName(new InetSocketAddress(InetAddress.getByName("1080:0:0:0:8:800:200C:417A"), 1234), "tmp_1080_0_0_0_8_800_200c_417a_1234_1");
}
- public void testTemporaryQueuePipe() throws UnknownHostException
- {
- checkTempQueueName(new VmPipeAddress(1), "tmp_vm_1_1");
- }
-
private void checkTempQueueName(SocketAddress address, String queueName)
{
_testSession.getNetworkConnection().setLocalAddress(address);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/MessageRequeueTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/MessageRequeueTest.java
index de092fc893..f5e0ed75d2 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/MessageRequeueTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/close/MessageRequeueTest.java
@@ -50,7 +50,6 @@ public class MessageRequeueTest extends QpidBrokerTestCase
protected final String queue = "direct://amq.direct//message-requeue-test-queue";
protected String payload = "Message:";
- //protected final String BROKER = "vm://:1";
protected final String BROKER = "tcp://127.0.0.1:5672";
private boolean testReception = true;
@@ -155,8 +154,8 @@ public class MessageRequeueTest extends QpidBrokerTestCase
_logger.info("consumed: " + messagesReceived);
assertEquals("number of consumed messages does not match initial data", (int) numTestMessages, messagesReceived);
- // wit 0_10 we can have a delivery tag of 0
- if (conn.isBroker08())
+ // with 0_10 we can have a delivery tag of 0
+ if (!conn.isBroker010())
{
for (long b : messageLog)
{
@@ -224,7 +223,7 @@ public class MessageRequeueTest extends QpidBrokerTestCase
StringBuilder list = new StringBuilder();
list.append("Failed to receive:");
int failed = 0;
- if (conn.isBroker08())
+ if (!conn.isBroker010())
{
for (long b : receieved)
{
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java
index 989ac98747..80422cf3e9 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java
@@ -52,7 +52,7 @@ public class DurableSubscriberTest extends QpidBrokerTestCase
*/
public void testDurSubRestoredAfterNonPersistentMessageSent() throws Exception
{
- if (isBrokerStorePersistent() || !isBroker08())
+ if (isBrokerStorePersistent())
{
TopicConnectionFactory factory = getConnectionFactory();
Topic topic = (Topic) getInitialContext().lookup(_topicName);
@@ -116,7 +116,7 @@ public class DurableSubscriberTest extends QpidBrokerTestCase
*/
public void testDurSubRestoresMessageSelector() throws Exception
{
- if (isBrokerStorePersistent() || !isBroker08())
+ if (isBrokerStorePersistent())
{
TopicConnectionFactory factory = getConnectionFactory();
Topic topic = (Topic) getInitialContext().lookup(_topicName);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTestCase.java
index 5fb06dfbb4..786fc2adb0 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTestCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutTestCase.java
@@ -102,7 +102,7 @@ public class TransactionTimeoutTestCase extends QpidBrokerTestCase implements Ex
super.setUp();
// Connect to broker
- String broker = _brokerType.equals(VM) ? ("vm://:" + DEFAULT_VM_PORT) : ("tcp://localhost:" + DEFAULT_PORT);
+ String broker = ("tcp://localhost:" + DEFAULT_PORT);
ConnectionURL url = new AMQConnectionURL("amqp://guest:guest@clientid/test?brokerlist='" + broker + "'&maxprefetch='1'");
_con = (AMQConnection) getConnection(url);
_con.setExceptionListener(this);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/FailoverBaseCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/FailoverBaseCase.java
index 1832a7641e..10217585c1 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/FailoverBaseCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/FailoverBaseCase.java
@@ -68,6 +68,14 @@ public class FailoverBaseCase extends QpidBrokerTestCase
return _connectionFactory;
}
+ @Override
+ public void stopBroker(int port) throws Exception
+ {
+ if (isBrokerPresent(port))
+ {
+ super.stopBroker(port);
+ }
+ }
public void tearDown() throws Exception
{
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
index 66c8a60c36..b39b31df58 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
@@ -55,10 +55,8 @@ import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.qpid.AMQException;
-import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQConnectionFactory;
import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.jms.BrokerDetails;
import org.apache.qpid.jms.ConnectionURL;
@@ -67,8 +65,7 @@ import org.apache.qpid.server.Broker;
import org.apache.qpid.server.BrokerOptions;
import org.apache.qpid.server.ProtocolExclusion;
import org.apache.qpid.server.configuration.ServerConfiguration;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry;
+import org.apache.qpid.server.protocol.AmqpProtocolVersion;
import org.apache.qpid.server.store.DerbyMessageStore;
import org.apache.qpid.url.URLSyntaxException;
import org.apache.qpid.util.FileUtils;
@@ -79,6 +76,13 @@ import org.apache.qpid.util.LogMonitor;
*/
public class QpidBrokerTestCase extends QpidTestCase
{
+
+ public enum BrokerType
+ {
+ EXTERNAL /** Test case relies on a Broker started independently of the test-suite */,
+ INTERNAL /** Test case starts an embedded broker within this JVM */,
+ SPAWNED /** Test case spawns a new broker as a separate process */
+ }
protected final String QpidHome = System.getProperty("QPID_HOME");
protected File _configFile = new File(System.getProperty("broker.config"));
@@ -123,17 +127,12 @@ public class QpidBrokerTestCase extends QpidTestCase
private static final String BROKER_LOG_INTERLEAVE = "broker.log.interleave";
private static final String BROKER_LOG_PREFIX = "broker.log.prefix";
private static final String BROKER_PERSITENT = "broker.persistent";
- private static final String BROKER_PROTOCOL_EXCLUDES = "broker.protocols.excludes";
+ private static final String BROKER_PROTOCOL_EXCLUDES = "broker.protocol.excludes";
// values
protected static final String JAVA = "java";
protected static final String CPP = "cpp";
- protected static final String VM = "vm";
- protected static final String EXTERNAL = "external";
- protected static final String INTERNAL = "internal";
- private static final String VERSION_08 = "0-8";
- private static final String VERSION_010 = "0-10";
protected static final String QPID_HOME = "QPID_HOME";
@@ -144,11 +143,11 @@ public class QpidBrokerTestCase extends QpidTestCase
public static final int DEFAULT_SSL_PORT = Integer.getInteger("test.sslport", ServerConfiguration.DEFAULT_SSL_PORT);
protected String _brokerLanguage = System.getProperty(BROKER_LANGUAGE, JAVA);
- protected String _brokerType = System.getProperty(BROKER_TYPE, INTERNAL);
+ protected BrokerType _brokerType = BrokerType.valueOf(System.getProperty(BROKER_TYPE, "").toUpperCase());
protected String _brokerCommand = System.getProperty(BROKER_COMMAND);
private String _brokerClean = System.getProperty(BROKER_CLEAN, null);
private Boolean _brokerCleanBetweenTests = Boolean.getBoolean(BROKER_CLEAN_BETWEEN_TESTS);
- private String _brokerVersion = System.getProperty(BROKER_VERSION, VERSION_08);
+ private final AmqpProtocolVersion _brokerVersion = AmqpProtocolVersion.valueOf(System.getProperty(BROKER_VERSION, ""));
protected String _output = System.getProperty(TEST_OUTPUT);
protected Boolean _brokerPersistent = Boolean.getBoolean(BROKER_PERSITENT);
private String _brokerProtocolExcludes = System.getProperty(BROKER_PROTOCOL_EXCLUDES);
@@ -407,7 +406,7 @@ public class QpidBrokerTestCase extends QpidTestCase
}
/**
- * Return the management portin use by the broker on this main port
+ * Return the management port in use by the broker on this main port
*
* @param mainPort the broker's main port.
*
@@ -415,7 +414,7 @@ public class QpidBrokerTestCase extends QpidTestCase
*/
protected int getManagementPort(int mainPort)
{
- return mainPort + (DEFAULT_MANAGEMENT_PORT - (_brokerType.equals(VM) ? DEFAULT_VM_PORT : DEFAULT_PORT));
+ return mainPort + (DEFAULT_MANAGEMENT_PORT - DEFAULT_PORT);
}
/**
@@ -430,11 +429,7 @@ public class QpidBrokerTestCase extends QpidTestCase
protected int getPort(int port)
{
- if (_brokerType.equals(VM))
- {
- return port == 0 ? DEFAULT_VM_PORT : port;
- }
- else if (!_brokerType.equals(EXTERNAL))
+ if (!_brokerType.equals(BrokerType.EXTERNAL))
{
return port == 0 ? DEFAULT_PORT : port;
}
@@ -473,34 +468,7 @@ public class QpidBrokerTestCase extends QpidTestCase
throw new IllegalStateException("There is already an existing broker running on port " + port);
}
- if (_brokerType.equals(VM))
- {
- setConfigurationProperty("management.jmxport", String.valueOf(getManagementPort(port)));
- setConfigurationProperty(ServerConfiguration.MGMT_CUSTOM_REGISTRY_SOCKET, String.valueOf(false));
- saveTestConfiguration();
-
- // create an in_VM broker
- final ConfigurationFileApplicationRegistry registry = new ConfigurationFileApplicationRegistry(_configFile);
- try
- {
- ApplicationRegistry.initialise(registry);
- }
- catch (Exception e)
- {
- _logger.error("Broker initialise failed due to:",e);
- try
- {
- registry.close();
- }
- catch (Throwable closeE)
- {
- closeE.printStackTrace();
- }
- throw e;
- }
- TransportConnection.createVMBroker(port);
- }
- else if (_brokerType.equals(INTERNAL) && !existingInternalBroker())
+ if (_brokerType.equals(BrokerType.INTERNAL) && !existingInternalBroker())
{
setConfigurationProperty(ServerConfiguration.MGMT_CUSTOM_REGISTRY_SOCKET, String.valueOf(false));
saveTestConfiguration();
@@ -523,7 +491,7 @@ public class QpidBrokerTestCase extends QpidTestCase
_brokers.put(port, new InternalBrokerHolder(broker));
}
- else if (!_brokerType.equals(EXTERNAL))
+ else if (!_brokerType.equals(BrokerType.EXTERNAL))
{
String cmd = getBrokerCommand(port);
_logger.info("starting external broker: " + cmd);
@@ -633,11 +601,16 @@ public class QpidBrokerTestCase extends QpidTestCase
private void addExcludedPorts(int port, BrokerOptions options)
{
final String protocolExcludesList = _brokerProtocolExcludes.replace("@PORT", "" + port);
+
+ if (protocolExcludesList.equals(""))
+ {
+ return;
+ }
final String[] toks = protocolExcludesList.split("\\s");
if(toks.length % 2 != 0)
{
- throw new IllegalArgumentException("Must be an even number of tokens in " + protocolExcludesList);
+ throw new IllegalArgumentException("Must be an even number of tokens in '" + protocolExcludesList + "'");
}
for (int i = 0; i < toks.length; i=i+2)
{
@@ -662,13 +635,9 @@ public class QpidBrokerTestCase extends QpidTestCase
return false;
}
- private String getQpidWork(String broker, int port)
+ private String getQpidWork(BrokerType broker, int port)
{
- if (broker.equals(VM))
- {
- return System.getProperty("QPID_WORK");
- }
- else if (!broker.equals(EXTERNAL))
+ if (!broker.equals(BrokerType.EXTERNAL))
{
return System.getProperty("QPID_WORK")+ "/" + port;
}
@@ -755,17 +724,16 @@ public class QpidBrokerTestCase extends QpidTestCase
_logger.info("stopping broker: " + getBrokerCommand(port));
BrokerHolder broker = _brokers.remove(port);
- if (broker != null)
- {
- broker.shutdown();
- }
- else if (_brokerType.equals(VM))
- {
- TransportConnection.killVMBroker(port);
- ApplicationRegistry.remove();
- }
+ broker.shutdown();
}
+ public boolean isBrokerPresent(int port) throws Exception
+ {
+ port = getPort(port);
+
+ return _brokers.containsKey(port);
+ }
+
/**
* Attempt to set the Java Broker to use the BDBMessageStore for persistence
* Falling back to the DerbyMessageStore if
@@ -1000,12 +968,12 @@ public class QpidBrokerTestCase extends QpidTestCase
*/
public boolean isBroker08()
{
- return _brokerVersion.equals(VERSION_08);
+ return _brokerVersion.equals(AmqpProtocolVersion.v0_8);
}
public boolean isBroker010()
{
- return _brokerVersion.equals(VERSION_010);
+ return _brokerVersion.equals(AmqpProtocolVersion.v0_10);
}
protected boolean isJavaBroker()
@@ -1020,12 +988,12 @@ public class QpidBrokerTestCase extends QpidTestCase
protected boolean isExternalBroker()
{
- return !_brokerType.equals("vm");
+ return !_brokerType.equals("vm"); //TODO
}
protected boolean isInternalBroker()
{
- return _brokerType.equals(INTERNAL);
+ return _brokerType.equals(BrokerType.INTERNAL);
}
protected boolean isBrokerStorePersistent()
@@ -1099,11 +1067,6 @@ public class QpidBrokerTestCase extends QpidTestCase
*/
public AMQConnectionFactory getConnectionFactory(String factoryName) throws NamingException
{
- if (_brokerType.equals(VM))
- {
- factoryName += ".vm";
- }
-
return (AMQConnectionFactory) getInitialContext().lookup(factoryName);
}
@@ -1144,15 +1107,7 @@ public class QpidBrokerTestCase extends QpidTestCase
public Connection getClientConnection(String username, String password, String id) throws JMSException, URLSyntaxException, AMQException, NamingException
{
_logger.info("get Connection");
- Connection con;
- if (_brokerType.equals(VM))
- {
- con = new AMQConnection("vm://:1", username, password, id, "test");
- }
- else
- {
- con = getConnectionFactory().createConnection(username, password, id);
- }
+ Connection con = getConnectionFactory().createConnection(username, password, id);
//add the connection in the lis of connections
_connections.add(con);
return con;
@@ -1410,41 +1365,26 @@ public class QpidBrokerTestCase extends QpidTestCase
*/
public void reloadBrokerSecurityConfig() throws Exception
{
- if (_brokerType.equals(VM))
+ JMXTestUtils jmxu = new JMXTestUtils(this, "admin" , "admin");
+ jmxu.open();
+
+ try
{
- ApplicationRegistry.getInstance().getConfiguration().reparseConfigFileSecuritySections();
+ ConfigurationManagement configMBean = jmxu.getConfigurationManagement();
+ configMBean.reloadSecurityConfiguration();
}
- else
+ finally
{
- JMXTestUtils jmxu = new JMXTestUtils(this, "admin" , "admin");
- jmxu.open();
-
- try
- {
- ConfigurationManagement configMBean = jmxu.getConfigurationManagement();
- configMBean.reloadSecurityConfiguration();
- }
- finally
- {
- jmxu.close();
- }
-
- LogMonitor _monitor = new LogMonitor(_outputFile);
- assertTrue("The expected server security configuration reload did not occur",
- _monitor.waitForMessage(ServerConfiguration.SECURITY_CONFIG_RELOADED, LOGMONITOR_TIMEOUT));
-
+ jmxu.close();
}
+
+ LogMonitor _monitor = new LogMonitor(_outputFile);
+ assertTrue("The expected server security configuration reload did not occur",
+ _monitor.waitForMessage(ServerConfiguration.SECURITY_CONFIG_RELOADED, LOGMONITOR_TIMEOUT));
}
protected int getFailingPort()
{
- if (_brokerType.equals(VM))
- {
- throw new RuntimeException("VM is not supported for Failover testing");
- }
- else
- {
- return FAILING_PORT;
- }
+ return FAILING_PORT;
}
}