summaryrefslogtreecommitdiff
path: root/qpid/java/systests/src
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/java/systests/src')
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/client/ssl/SSLTest.java159
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/jms/xa/XAResourceTest.java116
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java55
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsDeliveryTest.java2
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/failover/FailoverMethodTest.java49
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/failover/MessageDisappearWithIOExceptionTest.java6
-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/BrokerLoggingTest.java2
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ExchangeLoggingTest.java51
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java5
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java2
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLTest.java42
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/client/QueueBrowserAutoAckTest.java4
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java127
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/client/failover/FailoverTest.java2
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/TTLTest.java154
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/QuickAcking.java2
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java2
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java15
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQConnectionTest.java219
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQSSLConnectionTest.java57
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/CloseAfterConnectionFailureTest.java2
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionCloseTest.java26
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionFactoryTest.java41
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java79
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ExceptionListenerTest.java6
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java1
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java13
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/StreamMessageTest.java45
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/UTF8Test.java51
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutConfigurationTest.java2
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutDisabledTest.java2
-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/QpidBrokerTestCase.java119
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/utils/protocol/TestIoSession.java104
35 files changed, 776 insertions, 790 deletions
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/client/ssl/SSLTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/client/ssl/SSLTest.java
index 8cdf12eaa4..471ebb16fc 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/client/ssl/SSLTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/client/ssl/SSLTest.java
@@ -31,62 +31,72 @@ import org.apache.qpid.test.utils.QpidBrokerTestCase;
import org.apache.qpid.transport.Connection;
public class SSLTest extends QpidBrokerTestCase
-{
-
+{
+ private static final String KEYSTORE = TEST_RESOURCES_DIR + "/ssl/java_client_keystore.jks";
+ private static final String KEYSTORE_PASSWORD = "password";
+ private static final String TRUSTSTORE = TEST_RESOURCES_DIR + "/ssl/java_client_truststore.jks";
+ private static final String TRUSTSTORE_PASSWORD = "password";
+ private static final String CERT_ALIAS_APP1 = "app1";
+ private static final String CERT_ALIAS_APP2 = "app2";
+
@Override
protected void setUp() throws Exception
{
- System.setProperty("javax.net.debug", "ssl");
+ if(isJavaBroker())
+ {
+ setTestClientSystemProperty("profile.use_ssl", "true");
+ setConfigurationProperty("connector.ssl.enabled", "true");
+ setConfigurationProperty("connector.ssl.sslOnly", "true");
+ }
+
+ // set the ssl system properties
+ setSystemProperty("javax.net.ssl.keyStore", KEYSTORE);
+ setSystemProperty("javax.net.ssl.keyStorePassword", KEYSTORE_PASSWORD);
+ setSystemProperty("javax.net.ssl.trustStore", TRUSTSTORE);
+ setSystemProperty("javax.net.ssl.trustStorePassword", TRUSTSTORE_PASSWORD);
+ setSystemProperty("javax.net.debug", "ssl");
super.setUp();
}
- @Override
- protected void tearDown() throws Exception
- {
- System.setProperty("javax.net.debug", "");
- super.tearDown();
- }
-
- public void testCreateSSLContextFromConnectionURLParams()
+ public void testCreateSSLConnectionUsingConnectionURLParams() throws Exception
{
if (Boolean.getBoolean("profile.use_ssl"))
- {
+ {
+ // Clear the ssl system properties
+ setSystemProperty("javax.net.ssl.keyStore", null);
+ setSystemProperty("javax.net.ssl.keyStorePassword", null);
+ setSystemProperty("javax.net.ssl.trustStore", null);
+ setSystemProperty("javax.net.ssl.trustStorePassword", null);
+
String url = "amqp://guest:guest@test/?brokerlist='tcp://localhost:%s" +
"?ssl='true'&ssl_verify_hostname='true'" +
"&key_store='%s'&key_store_password='%s'" +
"&trust_store='%s'&trust_store_password='%s'" +
"'";
- String keyStore = System.getProperty("javax.net.ssl.keyStore");
- String keyStorePass = System.getProperty("javax.net.ssl.keyStorePassword");
- String trustStore = System.getProperty("javax.net.ssl.trustStore");
- String trustStorePass = System.getProperty("javax.net.ssl.trustStorePassword");
+ url = String.format(url,QpidBrokerTestCase.DEFAULT_SSL_PORT,
+ KEYSTORE,KEYSTORE_PASSWORD,TRUSTSTORE,TRUSTSTORE_PASSWORD);
- url = String.format(url,System.getProperty("test.port.ssl"),
- keyStore,keyStorePass,trustStore,trustStorePass);
+ AMQConnection con = new AMQConnection(url);
+ assertNotNull("connection should be successful", con);
+ Session ssn = con.createSession(false,Session.AUTO_ACKNOWLEDGE);
+ assertNotNull("create session should be successful", ssn);
+ }
+ }
+
+ public void testCreateSSLConnectionUsingSystemProperties() throws Exception
+ {
+ if (Boolean.getBoolean("profile.use_ssl"))
+ {
+
+ String url = "amqp://guest:guest@test/?brokerlist='tcp://localhost:%s?ssl='true''";
+
+ url = String.format(url,QpidBrokerTestCase.DEFAULT_SSL_PORT);
- // temporarily set the trust/key store jvm args to something else
- // to ensure we only read from the connection URL param.
- System.setProperty("javax.net.ssl.trustStore","fessgsdgd");
- System.setProperty("javax.net.ssl.trustStorePassword","fessgsdgd");
- System.setProperty("javax.net.ssl.keyStore","fessgsdgd");
- System.setProperty("javax.net.ssl.keyStorePassword","fessgsdgd");
- try
- {
- AMQConnection con = new AMQConnection(url);
- Session ssn = con.createSession(false,Session.AUTO_ACKNOWLEDGE);
- }
- catch (Exception e)
- {
- fail("SSL Connection should be successful");
- }
- finally
- {
- System.setProperty("javax.net.ssl.trustStore",trustStore);
- System.setProperty("javax.net.ssl.trustStorePassword",trustStorePass);
- System.setProperty("javax.net.ssl.keyStore",keyStore);
- System.setProperty("javax.net.ssl.keyStorePassword",keyStorePass);
- }
+ AMQConnection con = new AMQConnection(url);
+ assertNotNull("connection should be successful", con);
+ Session ssn = con.createSession(false,Session.AUTO_ACKNOWLEDGE);
+ assertNotNull("create session should be successful", ssn);
}
}
@@ -95,8 +105,8 @@ public class SSLTest extends QpidBrokerTestCase
if (Boolean.getBoolean("profile.use_ssl"))
{
String url = "amqp://guest:guest@test/?brokerlist='tcp://localhost:" +
- System.getProperty("test.port.ssl") +
- "?ssl='true'&ssl_cert_alias='app1''";
+ QpidBrokerTestCase.DEFAULT_SSL_PORT +
+ "?ssl='true'&ssl_cert_alias='" + CERT_ALIAS_APP1 + "''";
AMQTestConnection_0_10 con = new AMQTestConnection_0_10(url);
Connection transportCon = con.getConnection();
@@ -105,8 +115,8 @@ public class SSLTest extends QpidBrokerTestCase
con.close();
url = "amqp://guest:guest@test/?brokerlist='tcp://localhost:" +
- System.getProperty("test.port.ssl") +
- "?ssl='true'&ssl_cert_alias='app2''";
+ QpidBrokerTestCase.DEFAULT_SSL_PORT +
+ "?ssl='true'&ssl_cert_alias='" + CERT_ALIAS_APP2 + "''";
con = new AMQTestConnection_0_10(url);
transportCon = con.getConnection();
@@ -116,12 +126,12 @@ public class SSLTest extends QpidBrokerTestCase
}
}
- public void testVerifyHostName()
+ public void testVerifyHostNameWithIncorrectHostname()
{
if (Boolean.getBoolean("profile.use_ssl"))
{
String url = "amqp://guest:guest@test/?brokerlist='tcp://127.0.0.1:" +
- System.getProperty("test.port.ssl") +
+ QpidBrokerTestCase.DEFAULT_SSL_PORT +
"?ssl='true'&ssl_verify_hostname='true''";
try
@@ -140,42 +150,53 @@ public class SSLTest extends QpidBrokerTestCase
}
}
- public void testVerifyLocalHost()
+ public void testVerifyLocalHost() throws Exception
{
if (Boolean.getBoolean("profile.use_ssl"))
{
String url = "amqp://guest:guest@test/?brokerlist='tcp://localhost:" +
- System.getProperty("test.port.ssl") +
+ QpidBrokerTestCase.DEFAULT_SSL_PORT +
"?ssl='true'&ssl_verify_hostname='true''";
-
- try
- {
- AMQConnection con = new AMQConnection(url);
- }
- catch (Exception e)
- {
- fail("Hostname verification should succeed");
- }
- }
+
+ AMQConnection con = new AMQConnection(url);
+ assertNotNull("connection should have been created", con);
+ }
}
- public void testVerifyLocalHostLocalDomain()
+ public void testVerifyLocalHostLocalDomain() throws Exception
{
if (Boolean.getBoolean("profile.use_ssl"))
{
String url = "amqp://guest:guest@test/?brokerlist='tcp://localhost.localdomain:" +
- System.getProperty("test.port.ssl") +
+ QpidBrokerTestCase.DEFAULT_SSL_PORT +
"?ssl='true'&ssl_verify_hostname='true''";
+
+ AMQConnection con = new AMQConnection(url);
+ assertNotNull("connection should have been created", con);
+ }
+ }
+
+ public void testCreateSSLConnectionUsingConnectionURLParamsTrustStoreOnly() throws Exception
+ {
+ if (Boolean.getBoolean("profile.use_ssl"))
+ {
+ // Clear the ssl system properties
+ setSystemProperty("javax.net.ssl.keyStore", null);
+ setSystemProperty("javax.net.ssl.keyStorePassword", null);
+ setSystemProperty("javax.net.ssl.trustStore", null);
+ setSystemProperty("javax.net.ssl.trustStorePassword", null);
- try
- {
- AMQConnection con = new AMQConnection(url);
- }
- catch (Exception e)
- {
- fail("Hostname verification should succeed");
- }
-
+ String url = "amqp://guest:guest@test/?brokerlist='tcp://localhost:%s" +
+ "?ssl='true'&ssl_verify_hostname='true'" +
+ "&trust_store='%s'&trust_store_password='%s'" +
+ "'";
+
+ url = String.format(url,QpidBrokerTestCase.DEFAULT_SSL_PORT, TRUSTSTORE,TRUSTSTORE_PASSWORD);
+
+ AMQConnection con = new AMQConnection(url);
+ assertNotNull("connection should be successful", con);
+ Session ssn = con.createSession(false,Session.AUTO_ACKNOWLEDGE);
+ assertNotNull("create session should be successful", ssn);
}
}
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/jms/xa/XAResourceTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/jms/xa/XAResourceTest.java
new file mode 100644
index 0000000000..d7ee203fdf
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/jms/xa/XAResourceTest.java
@@ -0,0 +1,116 @@
+/*
+ *
+ * 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.jms.xa;
+
+import javax.jms.XAConnection;
+import javax.jms.XAConnectionFactory;
+import javax.jms.XASession;
+import javax.transaction.xa.XAResource;
+
+import org.apache.qpid.client.AMQConnectionFactory;
+import org.apache.qpid.jms.ConnectionURL;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import org.apache.qpid.util.FileUtils;
+
+public class XAResourceTest extends QpidBrokerTestCase
+{
+
+ private static final String FACTORY_NAME = "default";
+ private static final String ALT_FACTORY_NAME = "connection2";
+
+ /*
+ * Test with multiple XAResources originating from the same connection factory. XAResource(s) will be equal,
+ * as they originate from the same session.
+ */
+ public void testIsSameRMSingleCF() throws Exception
+ {
+ XAConnectionFactory factory = getConnectionFactory(FACTORY_NAME);
+ XAConnection conn = factory.createXAConnection();
+ XASession session = conn.createXASession();
+ XAResource xaResource1 = session.getXAResource();
+ XAResource xaResource2 = session.getXAResource();
+
+ assertEquals("XAResource objects not equal", xaResource1, xaResource2);
+ assertTrue("isSameRM not true for identical objects", xaResource1.isSameRM(xaResource2));
+
+ session.close();
+ conn.close();
+ }
+
+ /*
+ * Test with multiple XAResources originating from different connection factory's and different sessions. XAResources will not be
+ * equal as they do not originate from the same session. As the UUID from the broker will be the same, isSameRM will be true.
+ *
+ */
+ public void testIsSameRMMultiCF() throws Exception
+ {
+ startBroker(FAILING_PORT);
+ ConnectionURL url = getConnectionFactory(FACTORY_NAME).getConnectionURL();
+ XAConnectionFactory factory = new AMQConnectionFactory(url);
+ XAConnectionFactory factory2 = new AMQConnectionFactory(url);
+ XAConnectionFactory factory3 = getConnectionFactory(ALT_FACTORY_NAME);
+
+ XAConnection conn = factory.createXAConnection();
+ XAConnection conn2 = factory2.createXAConnection();
+ XAConnection conn3 = factory3.createXAConnection();
+
+ XASession session = conn.createXASession();
+ XASession session2 = conn2.createXASession();
+ XASession session3 = conn3.createXASession();
+
+ XAResource xaResource1 = session.getXAResource();
+ XAResource xaResource2 = session2.getXAResource();
+ XAResource xaResource3 = session3.getXAResource();
+
+ assertFalse("XAResource objects should not be equal", xaResource1.equals(xaResource2));
+ assertTrue("isSameRM not true for identical objects", xaResource1.isSameRM(xaResource2));
+ assertFalse("isSameRM true for XA Resources created by two different brokers", xaResource1.isSameRM(xaResource3));
+
+ conn.close();
+ conn2.close();
+ conn3.close();
+ }
+
+ @Override
+ public void stopBroker(int port) throws Exception
+ {
+ if (isBrokerPresent(port))
+ {
+ super.stopBroker(port);
+ }
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ try
+ {
+ super.tearDown();
+ }
+ finally
+ {
+ // Ensure we shutdown any secondary brokers
+ stopBroker(FAILING_PORT);
+ FileUtils.deleteDirectory(System.getProperty("QPID_WORK") + "/" + getFailingPort());
+ }
+ }
+
+}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java
index 19657ef396..2864d8e994 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java
@@ -68,61 +68,6 @@ public class ManagementActorLoggingTest extends AbstractTestLogging
/**
* Description:
- * When a JMX Management connection is made then this will be logged out.
- *
- * Input:
- *
- * 1. Running Broker
- * 2. Connect Management client via JMX
- * Output:
- *
- * <date> MNG-1007 : Open <user>
- *
- * Validation Steps:
- * 1. The MNG ID is correct
- * 2. The user is correct
- *
- * On connection close a MNG-1008 is expected
- *
- * * <date> MNG-1008 : Close
- *
- * Validation Steps:
- * 1. The MNG ID is correct
- *
- * @throws java.io.IOException - if there is a problem reseting the log monitor
- */
- public void testJMXManagementConsoleConnection() throws IOException
- {
- List<String> results = waitAndFindMatches("MNG-1007");
-
- assertEquals("Unexpected Management Connection count", 1, results.size());
-
- String log = getLogMessage(results, 0);
-
- validateMessageID("MNG-1007", log);
-
- assertTrue("User not in log message:" + log, log.endsWith(USER));
- // Extract the id from the log string
- // MESSAGE [mng:1(rmi://169.24.29.116)] MNG-1007 : Open : User admin
- int connectionID = Integer.parseInt(fromActor(getLog(results.get(0))).charAt(4) + "");
-
- results = findMatches("MNG-1008");
-
- assertEquals("Unexpected Management Connection close count", 0, results.size());
-
- _jmxUtils.close();
- _closed = true;
-
- results = waitAndFindMatches("MNG-1008");
-
- assertEquals("Unexpected Management Connection count", 1, results.size());
-
- assertEquals("Close does not have same id as open,", connectionID,
- Integer.parseInt(fromActor(getLog(results.get(0))).charAt(4) + ""));
- }
-
- /**
- * Description:
* When a connected client has its connection closed via the Management Console this will be logged as a CON-1002 message.
* Input:
*
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsDeliveryTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsDeliveryTest.java
index e657856d0e..c374d23473 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsDeliveryTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsDeliveryTest.java
@@ -103,7 +103,7 @@ public class MessageStatisticsDeliveryTest extends MessageStatisticsTestCase
MessageConsumer consumer = session.createConsumer(_queue);
for (int i = 0; i < number; i++)
{
- Message msg = consumer.receive(100);
+ Message msg = consumer.receive(1000);
assertNotNull("Message " + i + " was not received", msg);
}
}
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 35650e314a..470fcefae3 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
@@ -26,6 +26,7 @@ import java.util.concurrent.TimeUnit;
import javax.jms.ExceptionListener;
import javax.jms.JMSException;
+import org.apache.qpid.AMQConnectionClosedException;
import org.apache.qpid.AMQDisconnectedException;
import org.apache.qpid.AMQException;
import org.apache.qpid.client.AMQConnection;
@@ -60,7 +61,7 @@ public class FailoverMethodTest extends QpidBrokerTestCase implements ExceptionL
try
{
long start = System.currentTimeMillis();
- AMQConnection connection = new AMQConnection(url, null);
+ AMQConnection connection = new AMQConnection(url);
connection.setExceptionListener(this);
@@ -104,7 +105,7 @@ public class FailoverMethodTest extends QpidBrokerTestCase implements ExceptionL
try
{
long start = System.currentTimeMillis();
- AMQConnection connection = new AMQConnection(url, null);
+ AMQConnection connection = new AMQConnection(url);
connection.setExceptionListener(this);
@@ -128,8 +129,8 @@ public class FailoverMethodTest extends QpidBrokerTestCase implements ExceptionL
assertTrue("Failover took less than 6 seconds", duration > 6000);
// Ensure we don't have delays before initial connection and reconnection.
- // We allow 1 second for initial connection and failover logic on top of 6s of sleep.
- assertTrue("Failover took more than 7 seconds:(" + duration + ")", duration < 7000);
+ // We allow 3 second for initial connection and failover logic on top of 6s of sleep.
+ assertTrue("Failover took more than 9 seconds:(" + duration + ")", duration < 9000);
}
catch (AMQException e)
{
@@ -139,7 +140,7 @@ public class FailoverMethodTest extends QpidBrokerTestCase implements ExceptionL
public void onException(JMSException e)
{
- if (e.getLinkedException() instanceof AMQDisconnectedException)
+ if (e.getLinkedException() instanceof AMQDisconnectedException || e.getLinkedException() instanceof AMQConnectionClosedException)
{
_logger.debug("Received AMQDisconnectedException");
_failoverComplete.countDown();
@@ -159,19 +160,34 @@ public class FailoverMethodTest extends QpidBrokerTestCase implements ExceptionL
*/
public void testNoFailover() throws Exception
{
+ if (!isInternalBroker())
+ {
+ // QPID-3359
+ // These tests always used to be inVM tests, then QPID-2815, with removal of ivVM,
+ // converted the test to use QpidBrokerTestCase. However, since then we notice this
+ // test fails on slower CI boxes. It turns out the test design is *extremely*
+ // sensitive the length of time the broker takes to start up.
+ //
+ // Making the test a same-VM test to temporarily avoid the issue. In long term, test
+ // needs redesigned to avoid the issue.
+ return;
+ }
+
int CONNECT_DELAY = 2000;
String connectionString = "amqp://guest:guest@/test?brokerlist='tcp://localhost:" + getPort() + "?connectdelay='" + CONNECT_DELAY + "'," +
"retries='3'',failover='nofailover'";
+
AMQConnectionURL url = new AMQConnectionURL(connectionString);
+ Thread brokerStart = null;
try
{
//Kill initial broker
stopBroker();
//Create a thread to start the broker asynchronously
- Thread brokerStart = new Thread(new Runnable()
+ brokerStart = new Thread(new Runnable()
{
public void run()
{
@@ -194,9 +210,8 @@ public class FailoverMethodTest extends QpidBrokerTestCase implements ExceptionL
brokerStart.start();
long start = System.currentTimeMillis();
-
//Start the connection so it will use the retries
- AMQConnection connection = new AMQConnection(url, null);
+ AMQConnection connection = new AMQConnection(url);
long end = System.currentTimeMillis();
@@ -210,6 +225,7 @@ public class FailoverMethodTest extends QpidBrokerTestCase implements ExceptionL
//Ensure we collect the brokerStart thread
brokerStart.join();
+ brokerStart = null;
start = System.currentTimeMillis();
@@ -233,6 +249,23 @@ public class FailoverMethodTest extends QpidBrokerTestCase implements ExceptionL
{
fail(e.getMessage());
}
+ finally
+ {
+ // Guard against the case where the broker took too long to start
+ // and the initial connection failed to be formed.
+ if (brokerStart != null)
+ {
+ brokerStart.join();
+ }
+ }
+ }
+
+ public void stopBroker(int port) throws Exception
+ {
+ if (isBrokerPresent(port))
+ {
+ super.stopBroker(port);
+ }
}
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/MessageDisappearWithIOExceptionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/MessageDisappearWithIOExceptionTest.java
index 4c2758241e..fd33266414 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/MessageDisappearWithIOExceptionTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/failover/MessageDisappearWithIOExceptionTest.java
@@ -20,13 +20,10 @@
*/
package org.apache.qpid.server.failover;
-import org.apache.mina.common.WriteTimeoutException;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.protocol.AMQProtocolSession;
import org.apache.qpid.jms.ConnectionListener;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
import org.apache.qpid.test.utils.FailoverBaseCase;
-import org.apache.qpid.AMQConnectionClosedException;
import javax.jms.Destination;
import javax.jms.Message;
@@ -34,6 +31,7 @@ import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
@@ -195,7 +193,7 @@ public class MessageDisappearWithIOExceptionTest extends FailoverBaseCase implem
// Send IO Exception - causing failover
_connection.getProtocolHandler().
- exception(new WriteTimeoutException("WriteTimeoutException to cause failover."));
+ exception(new IOException("IOException to cause failover."));
// Verify Failover occured through ConnectionListener
assertTrue("Failover did not occur",
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 58b2edfee2..a2487b49bf 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
@@ -46,7 +46,7 @@ public class AlertingTest extends AbstractTestLogging
{
// Update the configuration to make our virtualhost Persistent.
makeVirtualHostPersistent(VIRTUALHOST);
- setConfigurationProperty("virtualhosts.virtualhost." + VIRTUALHOST + ".housekeeping.expiredMessageCheckPeriod", "5000");
+ setConfigurationProperty("virtualhosts.virtualhost." + VIRTUALHOST + ".housekeeping.checkPeriod", "5000");
_numMessages = 50;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java
index 9155b84365..e901903eb4 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java
@@ -519,7 +519,7 @@ public class BrokerLoggingTest extends AbstractTestLogging
setConfigurationProperty("connector.ssl.keyStorePath", getConfigurationStringProperty("management.ssl.keyStorePath"));
setConfigurationProperty("connector.ssl.keyStorePassword", getConfigurationStringProperty("management.ssl.keyStorePassword"));
- Integer sslPort = Integer.parseInt(getConfigurationStringProperty("connector.sslport"));
+ Integer sslPort = Integer.parseInt(getConfigurationStringProperty("connector.ssl.port"));
startBroker();
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ExchangeLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ExchangeLoggingTest.java
index 1e48f34f99..b3c080b2e3 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ExchangeLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ExchangeLoggingTest.java
@@ -20,6 +20,16 @@
*/
package org.apache.qpid.server.logging;
+import java.io.IOException;
+import java.util.List;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQSession_0_10;
import org.apache.qpid.framing.AMQFrame;
@@ -28,13 +38,6 @@ import org.apache.qpid.framing.ExchangeDeleteBody;
import org.apache.qpid.framing.ExchangeDeleteOkBody;
import org.apache.qpid.framing.amqp_8_0.MethodRegistry_8_0;
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.Queue;
-import javax.jms.Session;
-import java.io.IOException;
-import java.util.List;
-
/**
* Exchange
*
@@ -214,4 +217,38 @@ public class ExchangeLoggingTest extends AbstractTestLogging
}
+ public void testDiscardedMessage() throws Exception
+ {
+ //Ignore broker startup messages
+ _monitor.reset();
+
+ if (!isBroker010())
+ {
+ // Default 0-8..-0-9-1 behaviour is for messages to be rejected (returned to client).
+ setTestClientSystemProperty("qpid.default_mandatory", "false");
+ }
+
+ _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Do not create consumer so queue is not created and message will be discarded.
+ final MessageProducer producer = _session.createProducer(_queue);
+
+ // Sending message
+ final TextMessage msg = _session.createTextMessage("msg");
+ producer.send(msg);
+
+ final String expectedMessageBody = "Discarded Message : Name: " + _name + " Routing Key: " + _queue.getQueueName();
+
+ // Ensure we have received the EXH log msg.
+ waitForMessage("EXH-1003");
+
+ List<String> results = findMatches(EXH_PREFIX);
+ assertEquals("Result set larger than expected.", 2, results.size());
+
+ final String log = getLogMessage(results, 1);
+ validateMessageID("EXH-1003", log);
+
+ final String message = getMessageString(fromMessage(log));
+ assertEquals("Log Message not as expected", expectedMessageBody, message);
+ }
}
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 9feca7279e..24e6aa4207 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
@@ -22,6 +22,7 @@ package org.apache.qpid.server.logging;
import junit.framework.AssertionFailedError;
+import org.apache.qpid.server.configuration.ServerConfiguration;
import org.apache.qpid.util.LogMonitor;
import java.util.List;
@@ -206,7 +207,7 @@ public class ManagementLoggingTest extends AbstractTestLogging
validateMessageID("MNG-1002", log);
//Check the RMI Registry port is as expected
- int mPort = getPort() + (DEFAULT_MANAGEMENT_PORT - DEFAULT_PORT);
+ int mPort = getManagementPort(getPort());
assertTrue("RMI Registry port not as expected(" + mPort + ").:" + getMessageString(log),
getMessageString(log).endsWith(String.valueOf(mPort)));
@@ -217,7 +218,7 @@ public class ManagementLoggingTest extends AbstractTestLogging
// We expect the RMI Registry port (the defined 'management port') to be
// 100 lower than the JMX RMIConnector Server Port (the actual JMX server)
- int jmxPort = mPort + 100;
+ int jmxPort = mPort + ServerConfiguration.JMXPORT_CONNECTORSERVER_OFFSET;
assertTrue("JMX RMIConnectorServer port not as expected(" + jmxPort + ").:" + getMessageString(log),
getMessageString(log).endsWith(String.valueOf(jmxPort)));
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java
index 7f8f71d965..8aa5b6d9de 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java
@@ -196,7 +196,7 @@ public abstract class AbstractACLTestCase extends QpidBrokerTestCase implements
}
PrintWriter out = new PrintWriter(new FileWriter(aclFile));
- out.println(String.format("# %s", _testName));
+ out.println(String.format("# %s", getTestName()));
for (String line : rules)
{
out.println(line);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLTest.java
index d1ba725721..782ca22965 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/ExternalACLTest.java
@@ -67,14 +67,14 @@ public class ExternalACLTest extends AbstractACLTestCase
fail("Connection was not created due to:" + e);
}
}
-
+
public void testAccessVhostAuthorisedGuestSuccess() throws IOException, Exception
{
//The 'guest' user has no access to the 'test' vhost, as tested below in testAccessNoRights(), and so
- //is unable to perform actions such as connecting (and by extension, creating a queue, and consuming
- //from a queue etc). In order to test the vhost-wide 'access' ACL right, the 'guest' user has been given
+ //is unable to perform actions such as connecting (and by extension, creating a queue, and consuming
+ //from a queue etc). In order to test the vhost-wide 'access' ACL right, the 'guest' user has been given
//this right in the 'test2' vhost.
-
+
try
{
//get a connection to the 'test2' vhost using the guest user and perform various actions.
@@ -106,7 +106,7 @@ public class ExternalACLTest extends AbstractACLTestCase
fail("Test failed due to:" + e.getMessage());
}
}
-
+
public void testAccessNoRightsFailure() throws Exception
{
try
@@ -115,7 +115,7 @@ public class ExternalACLTest extends AbstractACLTestCase
Session sess = conn.createSession(true, Session.SESSION_TRANSACTED);
conn.start();
sess.rollback();
-
+
fail("Connection was created.");
}
catch (JMSException e)
@@ -126,11 +126,11 @@ public class ExternalACLTest extends AbstractACLTestCase
Throwable cause = linkedException.getCause();
assertNotNull("Cause was null", cause);
assertTrue("Wrong linked exception type", cause instanceof AMQException);
- AMQConstant errorCode = isBroker010() ? AMQConstant.CONTEXT_IN_USE : AMQConstant.ACCESS_REFUSED;
+ AMQConstant errorCode = isBroker010() ? AMQConstant.CONNECTION_FORCED : AMQConstant.ACCESS_REFUSED;
assertEquals("Incorrect error code received", errorCode, ((AMQException) cause).getErrorCode());
}
}
-
+
public void testClientDeleteQueueSuccess() throws Exception
{
try
@@ -155,7 +155,7 @@ public class ExternalACLTest extends AbstractACLTestCase
fail("Test failed due to:" + e.getMessage());
}
}
-
+
public void testServerDeleteQueueFailure() throws Exception
{
try
@@ -207,13 +207,13 @@ public class ExternalACLTest extends AbstractACLTestCase
try
{
Connection conn = getConnection("test", "client", "guest");
-
+
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
conn.start();
sess.createConsumer(sess.createQueue("IllegalQueue"));
-
+
fail("Test failed as consumer was created.");
}
catch (JMSException e)
@@ -253,10 +253,10 @@ public class ExternalACLTest extends AbstractACLTestCase
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
conn.start();
-
+
//Create a Named Queue
((AMQSession<?, ?>) sess).createQueue(new AMQShortString("IllegalQueue"), false, false, false);
-
+
fail("Test failed as Queue creation succeded.");
//conn will be automatically closed
}
@@ -385,7 +385,7 @@ public class ExternalACLTest extends AbstractACLTestCase
try
{
Connection conn = getConnection("test", "client", "guest");
-
+
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
conn.start();
@@ -405,13 +405,13 @@ public class ExternalACLTest extends AbstractACLTestCase
try
{
Connection conn = getConnection("test", "server", "guest");
-
+
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
conn.start();
sess.createConsumer(sess.createTemporaryQueue());
-
+
fail("Test failed as consumer was created.");
}
catch (JMSException e)
@@ -446,7 +446,7 @@ public class ExternalACLTest extends AbstractACLTestCase
try
{
Connection conn = getConnection("test", "server", "guest");
-
+
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
conn.start();
@@ -480,13 +480,13 @@ public class ExternalACLTest extends AbstractACLTestCase
check403Exception(e.getLinkedException());
}
}
-
+
public void testServerCreateAutoDeleteQueueInvalid() throws NamingException, JMSException, AMQException, Exception
{
try
{
Connection connection = getConnection("test", "server", "guest");
-
+
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
connection.start();
@@ -630,8 +630,8 @@ public class ExternalACLTest extends AbstractACLTestCase
check403Exception(e.getLinkedException());
}
}
-
-
+
+
@Override
public String getConfig()
{
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/QueueBrowserAutoAckTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/QueueBrowserAutoAckTest.java
index 97d825177c..d6caf05d33 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/QueueBrowserAutoAckTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/QueueBrowserAutoAckTest.java
@@ -59,7 +59,7 @@ public class QueueBrowserAutoAckTest extends FailoverBaseCase
_queue = _clientSession.createQueue(getTestQueueName());
_clientSession.createConsumer(_queue).close();
-
+
//Ensure there are no messages on the queue to start with.
checkQueueDepth(0);
}
@@ -490,7 +490,7 @@ public class QueueBrowserAutoAckTest extends FailoverBaseCase
}
}
- assertTrue("We should get atleast " + messages + " msgs.", msgCount >= messages);
+ assertTrue("We should get atleast " + messages + " msgs (found " + msgCount +").", msgCount >= messages);
if (_logger.isDebugEnabled())
{
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java
index 5dac9fb7c3..b5bb74327e 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java
@@ -49,11 +49,13 @@ import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.AMQSession_0_10;
+import org.apache.qpid.client.message.QpidMessageProperties;
import org.apache.qpid.client.messaging.address.Node.ExchangeNode;
import org.apache.qpid.client.messaging.address.Node.QueueNode;
import org.apache.qpid.jndi.PropertiesFileInitialContextFactory;
import org.apache.qpid.messaging.Address;
import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import org.apache.qpid.transport.ExecutionErrorCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -210,7 +212,7 @@ public class AddressBasedDestinationTest extends QpidBrokerTestCase
"durable: true ," +
"x-declare: " +
"{" +
- "auto-delete: true," +
+ "exclusive: true," +
"arguments: {" +
"'qpid.max_size': 1000," +
"'qpid.max_count': 100" +
@@ -226,6 +228,9 @@ public class AddressBasedDestinationTest extends QpidBrokerTestCase
"}";
AMQDestination dest = new AMQAnyDestination(addr);
MessageConsumer cons = jmsSession.createConsumer(dest);
+ cons.close();
+
+ // Even if the consumer is closed the queue and the bindings should be intact.
assertTrue("Queue not created as expected",(
(AMQSession_0_10)jmsSession).isQueueExist(dest,(QueueNode)dest.getSourceNode(), true));
@@ -254,12 +259,44 @@ public class AddressBasedDestinationTest extends QpidBrokerTestCase
(AMQSession_0_10)jmsSession).isQueueBound("amq.match",
dest.getAddressName(),null, args));
+ MessageProducer prod = jmsSession.createProducer(dest);
+ prod.send(jmsSession.createTextMessage("test"));
+
+ MessageConsumer cons2 = jmsSession.createConsumer(jmsSession.createQueue("ADDR:my-queue"));
+ Message m = cons2.receive(1000);
+ assertNotNull("Should receive message sent to my-queue",m);
+ assertEquals("The subject set in the message is incorrect","hello",m.getStringProperty(QpidMessageProperties.QPID_SUBJECT));
}
public void testCreateExchange() throws Exception
{
+ createExchangeImpl(false, false);
+ }
+
+ /**
+ * Verify creating an exchange via an Address, with supported
+ * exchange-declare arguments.
+ */
+ public void testCreateExchangeWithArgs() throws Exception
+ {
+ createExchangeImpl(true, false);
+ }
+
+ /**
+ * Verify that when creating an exchange via an Address, if a
+ * nonsense argument is specified the broker throws an execution
+ * exception back on the session with NOT_IMPLEMENTED status.
+ */
+ public void testCreateExchangeWithNonsenseArgs() throws Exception
+ {
+ createExchangeImpl(true, true);
+ }
+
+ private void createExchangeImpl(final boolean withExchangeArgs,
+ final boolean useNonsenseArguments) throws Exception
+ {
Session jmsSession = _connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
-
+
String addr = "ADDR:my-exchange/hello; " +
"{ " +
"create: always, " +
@@ -269,17 +306,36 @@ public class AddressBasedDestinationTest extends QpidBrokerTestCase
"x-declare: " +
"{ " +
"type:direct, " +
- "auto-delete: true, " +
- "arguments: {" +
- "'qpid.msg_sequence': 1, " +
- "'qpid.ive': 1" +
- "}" +
+ "auto-delete: true" +
+ createExchangeArgsString(withExchangeArgs, useNonsenseArguments) +
"}" +
"}" +
"}";
AMQDestination dest = new AMQAnyDestination(addr);
- MessageConsumer cons = jmsSession.createConsumer(dest);
+
+ MessageConsumer cons;
+ try
+ {
+ cons = jmsSession.createConsumer(dest);
+ if(useNonsenseArguments)
+ {
+ fail("Expected execution exception during exchange declare did not occur");
+ }
+ }
+ catch(JMSException e)
+ {
+ if(useNonsenseArguments && e.getCause().getMessage().contains(ExecutionErrorCode.NOT_IMPLEMENTED.toString()))
+ {
+ //expected because we used an argument which the broker doesn't have functionality
+ //for. We can't do the rest of the test as a result of the exception, just stop.
+ return;
+ }
+ else
+ {
+ fail("Unexpected exception whilst creating consumer: " + e);
+ }
+ }
assertTrue("Exchange not created as expected",(
(AMQSession_0_10)jmsSession).isExchangeExist(dest, (ExchangeNode)dest.getTargetNode() , true));
@@ -294,6 +350,32 @@ public class AddressBasedDestinationTest extends QpidBrokerTestCase
cons = jmsSession.createConsumer(dest);
}
+ private String createExchangeArgsString(final boolean withExchangeArgs,
+ final boolean useNonsenseArguments)
+ {
+ String argsString;
+
+ if(withExchangeArgs && useNonsenseArguments)
+ {
+ argsString = ", arguments: {" +
+ "'abcd.1234.wxyz': 1, " +
+ "}";
+ }
+ else if(withExchangeArgs)
+ {
+ argsString = ", arguments: {" +
+ "'qpid.msg_sequence': 1, " +
+ "'qpid.ive': 1" +
+ "}";
+ }
+ else
+ {
+ argsString = "";
+ }
+
+ return argsString;
+ }
+
public void checkQueueForBindings(Session jmsSession, AMQDestination dest,String headersBinding) throws Exception
{
assertTrue("Queue not created as expected",(
@@ -547,11 +629,25 @@ public class AddressBasedDestinationTest extends QpidBrokerTestCase
}
/**
- * Test goal: Verifies that session.creatTopic method
- * works as expected both with the new and old addressing scheme.
+ * Test goal: Verifies that session.creatTopic method works as expected
+ * both with the new and old addressing scheme.
*/
public void testSessionCreateTopic() throws Exception
{
+ sessionCreateTopicImpl(false);
+ }
+
+ /**
+ * Test goal: Verifies that session.creatTopic method works as expected
+ * both with the new and old addressing scheme when adding exchange arguments.
+ */
+ public void testSessionCreateTopicWithExchangeArgs() throws Exception
+ {
+ sessionCreateTopicImpl(true);
+ }
+
+ private void sessionCreateTopicImpl(boolean withExchangeArgs) throws Exception
+ {
Session ssn = _connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
// Using the BURL method
@@ -571,7 +667,7 @@ public class AddressBasedDestinationTest extends QpidBrokerTestCase
prod.send(ssn.createTextMessage("test"));
assertNotNull("consumer should receive a message",cons.receive(1000));
cons.close();
-
+
String addr = "ADDR:vehicles/bus; " +
"{ " +
"create: always, " +
@@ -581,11 +677,8 @@ public class AddressBasedDestinationTest extends QpidBrokerTestCase
"x-declare: " +
"{ " +
"type:direct, " +
- "auto-delete: true, " +
- "arguments: {" +
- "'qpid.msg_sequence': 1, " +
- "'qpid.ive': 1" +
- "}" +
+ "auto-delete: true" +
+ createExchangeArgsString(withExchangeArgs, false) +
"}" +
"}, " +
"link: {name : my-topic, " +
@@ -697,7 +790,7 @@ public class AddressBasedDestinationTest extends QpidBrokerTestCase
public void testSubscriptionForSameDestination() throws Exception
{
Session ssn = _connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
- Destination dest = ssn.createTopic("ADDR:amq.topic/foo");
+ Destination dest = ssn.createTopic("ADDR:amq.topic/foo; {link:{durable:true}}");
MessageConsumer consumer1 = ssn.createConsumer(dest);
MessageConsumer consumer2 = ssn.createConsumer(dest);
MessageProducer prod = ssn.createProducer(dest);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/failover/FailoverTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/failover/FailoverTest.java
index fcbab273e5..3068deecf8 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/failover/FailoverTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/failover/FailoverTest.java
@@ -299,7 +299,7 @@ public class FailoverTest extends FailoverBaseCase implements ConnectionListener
details.setProperty(BrokerDetails.OPTIONS_RETRY, String.valueOf(RETRIES));
details.setProperty(BrokerDetails.OPTIONS_CONNECT_DELAY, String.valueOf(DELAY));
- connection = new AMQConnection(connectionURL, null);
+ connection = new AMQConnection(connectionURL);
((AMQConnection) connection).setConnectionListener(this);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/TTLTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/TTLTest.java
deleted file mode 100644
index d4bab657d7..0000000000
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/testcases/TTLTest.java
+++ /dev/null
@@ -1,154 +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.testcases;
-
-import org.apache.qpid.test.framework.Circuit;
-import org.apache.qpid.test.framework.FrameworkBaseCase;
-import static org.apache.qpid.test.framework.MessagingTestConfigProperties.ACK_MODE_PROPNAME;
-import static org.apache.qpid.test.framework.MessagingTestConfigProperties.PUBSUB_PROPNAME;
-import org.apache.qpid.test.framework.TestUtils;
-import org.apache.qpid.test.framework.localcircuit.LocalCircuitImpl;
-import org.apache.qpid.test.framework.sequencers.CircuitFactory;
-
-import javax.jms.*;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Random;
-
-/**
- * TTLTest checks that time-to-live is applied to messages. The test sends messages with a variety of TTL stamps on them
- * then after a pause attempts to receive those messages. Only messages with a large enough TTL to have survived the pause
- * should be receiveable. This test case also applies an additional assertion against the broker, that the message store
- * is empty at the end of the test.
- *
- * <p/>This test is designed to run over local circuits only, as it must control a timed pause between sending and receiving
- * messages to that TTL can be applied to purge some of the messages.
- *
- * <p/><table id="crc"><caption>CRC Card</caption>
- * <tr><th> Responsibilities <th> Collaborations
- * <tr><td>
- * </table>
- *
- * @todo Use an interface or other method to mark this test as local only.
- *
- * @todo Implement the message store assertion for in-vm broker. Could also be done for external broker, for example
- * by using diagnostic exchange.
- *
- * @todo Implement and add a queue depth assertion too. This might already be in another test to copy from.
- *
- * @todo Create variations on test theme, for different ack mode and tx and message sizes etc.
- *
- * @todo Add an allowable margin of error to the test, as ttl may not be precise.
- */
-public class TTLTest extends FrameworkBaseCase
-{
- /**
- * Creates a new test case with the specified name.
- *
- * @param name The test case name.
- */
- public TTLTest(String name)
- {
- super(name);
- }
-
- /**
- * Checks that all messages sent with a TTL shorter than a pause between sending them and attempting to receive them
- * will fail to arrive. Once all messages have been purged by TTL or received, check that they no longer exist on
- * the broker.
- *
- * @throws javax.jms.JMSException Allowed to fall through and fail test.
- */
- public void testTTLP2P() throws Exception
- {
- String errorMessages = "";
- Random r = new Random();
-
- // Used to accumulate correctly received messages in.
- List<Message> receivedMessages = new LinkedList<Message>();
-
- // Set up the test properties to match the test case requirements.
- getTestProps().setProperty(ACK_MODE_PROPNAME, Session.AUTO_ACKNOWLEDGE);
- getTestProps().setProperty(PUBSUB_PROPNAME, false);
-
- // Create the test circuit from the test configuration parameters.
- CircuitFactory circuitFactory = getCircuitFactory();
- Circuit testCircuit = circuitFactory.createCircuit(getConnection(), getTestProps());
-
- // This test case assumes it is using a local circuit.
- LocalCircuitImpl localCircuit = (LocalCircuitImpl) testCircuit;
-
- Session producerSession = localCircuit.getLocalPublisherCircuitEnd().getSession();
- MessageProducer producer = localCircuit.getLocalPublisherCircuitEnd().getProducer();
- MessageConsumer consumer = localCircuit.getLocalReceiverCircuitEnd().getConsumer();
-
- // Send some tests messages, with random TTLs, some shorter and some longer than the pause time.
- for (int i = 0; i < 100; i++)
- {
- Message testMessage = TestUtils.createTestMessageOfSize(producerSession, 10);
-
- // Set the TTL on the message and record its value in the message headers.
- long ttl = 500 + r.nextInt(1500);
- producer.setTimeToLive(ttl);
- testMessage.setLongProperty("testTTL", ttl);
-
- producer.send(testMessage);
- // producerSession.commit();
- }
-
- // Inject a pause to allow some messages to be purged by TTL.
- TestUtils.pause(1000);
-
- // Attempt to receive back all of the messages, confirming by the message time stamps and TTLs that only
- // those received should have avoided being purged by the TTL.
- boolean timedOut = false;
-
-
- Message testMessage = null;
-
- do
- {
- testMessage = consumer.receive(1000);
-
- long ttl = testMessage.getLongProperty("testTTL");
- long timeStamp = testMessage.getJMSTimestamp();
- long now = System.currentTimeMillis();
-
- if ((timeStamp + ttl) < now)
- {
- errorMessages +=
- "Received message [sent: " + timeStamp + ", ttl: " + ttl + ", received: " + now
- + "] which should have been purged by its TTL.\n";
- }
- /*else
- {
- receivedMessages.add(testMessage);
- }*/
- } while (!timedOut && testMessage != null);
-
- // Check that the queue and message store on the broker are empty.
- // assertTrue("Message store is not empty.", messageStoreEmpty.apply());
- // assertTrue("Queue is not empty.", queueEmpty.apply());
-
- assertTrue(errorMessages, "".equals(errorMessages));
- }
-}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/QuickAcking.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/QuickAcking.java
index 6c83136511..13c78c1e14 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/QuickAcking.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ack/QuickAcking.java
@@ -20,7 +20,7 @@
*/
package org.apache.qpid.test.unit.ack;
-import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch;
+import java.util.concurrent.CountDownLatch;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.jms.ConnectionListener;
import org.apache.qpid.test.utils.QpidBrokerTestCase;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
index 59ce64eb4f..0731d56204 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
@@ -21,7 +21,6 @@ package org.apache.qpid.test.unit.basic;
import junit.framework.Assert;
-import org.apache.mina.common.ByteBuffer;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQDestination;
@@ -45,6 +44,7 @@ import javax.jms.MessageNotWriteableException;
import javax.jms.MessageProducer;
import javax.jms.Session;
+import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
index abf8da799c..3af215d1d5 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
@@ -20,8 +20,6 @@
*/
package org.apache.qpid.test.unit.basic;
-import org.apache.mina.common.ByteBuffer;
-
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQQueue;
@@ -41,6 +39,8 @@ import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.MessageProducer;
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.concurrent.CountDownLatch;
@@ -105,7 +105,7 @@ public class FieldTableMessageTest extends QpidBrokerTestCase implements Message
{
int count = _count;
_waitForCompletion = new CountDownLatch(_count);
- send(count);
+ send(count);
_waitForCompletion.await(20, TimeUnit.SECONDS);
check();
_logger.info("Completed without failure");
@@ -125,12 +125,15 @@ public class FieldTableMessageTest extends QpidBrokerTestCase implements Message
}
- void check() throws JMSException, AMQFrameDecodingException
+ void check() throws JMSException, AMQFrameDecodingException, IOException
{
for (Object m : received)
{
- ByteBuffer buffer = ((JMSBytesMessage) m).getData();
- FieldTable actual = FieldTableFactory.newFieldTable(buffer, buffer.remaining());
+ final BytesMessage bytesMessage = (BytesMessage) m;
+ final long bodyLength = bytesMessage.getBodyLength();
+ byte[] data = new byte[(int) bodyLength];
+ bytesMessage.readBytes(data);
+ FieldTable actual = FieldTableFactory.newFieldTable(new DataInputStream(new ByteArrayInputStream(data)), bodyLength);
for (String key : _expected.keys())
{
assertEquals("Values for " + key + " did not match", _expected.getObject(key), actual.getObject(key));
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 481b144caf..e79fe69199 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
@@ -50,9 +50,9 @@ import org.slf4j.LoggerFactory;
public class AMQConnectionTest extends QpidBrokerTestCase
{
- private static AMQConnection _connection;
- private static AMQTopic _topic;
- private static AMQQueue _queue;
+ protected static AMQConnection _connection;
+ protected static AMQTopic _topic;
+ protected static AMQQueue _queue;
private static QueueSession _queueSession;
private static TopicSession _topicSession;
protected static final Logger _logger = LoggerFactory.getLogger(AMQConnectionTest.class);
@@ -60,15 +60,14 @@ public class AMQConnectionTest extends QpidBrokerTestCase
protected void setUp() throws Exception
{
super.setUp();
- _connection = (AMQConnection) getConnection("guest", "guest");
+ createConnection();
_topic = new AMQTopic(_connection.getDefaultTopicExchangeName(), new AMQShortString("mytopic"));
_queue = new AMQQueue(_connection.getDefaultQueueExchangeName(), new AMQShortString("myqueue"));
}
-
- protected void tearDown() throws Exception
+
+ protected void createConnection() throws Exception
{
- _connection.close();
- super.tearDown();
+ _connection = (AMQConnection) getConnection("guest", "guest");
}
/**
@@ -207,61 +206,50 @@ public class AMQConnectionTest extends QpidBrokerTestCase
public void testPrefetchSystemProperty() throws Exception
{
- String oldPrefetch = System.getProperty(ClientProperties.MAX_PREFETCH_PROP_NAME);
- try
- {
- _connection.close();
- System.setProperty(ClientProperties.MAX_PREFETCH_PROP_NAME, new Integer(2).toString());
- _connection = (AMQConnection) getConnection();
- _connection.start();
- // Create two consumers on different sessions
- Session consSessA = _connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer consumerA = consSessA.createConsumer(_queue);
-
- Session producerSession = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer producer = producerSession.createProducer(_queue);
+ _connection.close();
+ setTestClientSystemProperty(ClientProperties.MAX_PREFETCH_PROP_NAME, new Integer(2).toString());
+
+ createConnection();
+ _connection.start();
+ // Create two consumers on different sessions
+ Session consSessA = _connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer consumerA = consSessA.createConsumer(_queue);
- // Send 3 messages
- for (int i = 0; i < 3; i++)
- {
- producer.send(producerSession.createTextMessage("test"));
- }
-
- MessageConsumer consumerB = null;
- // 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);
- }
- else
- {
- consumerB = consSessA.createConsumer(_queue);
- }
+ Session producerSession = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer producer = producerSession.createProducer(_queue);
- Message msg;
- // Check that consumer A has 2 messages
- for (int i = 0; i < 2; i++)
- {
- msg = consumerA.receive(1500);
- assertNotNull("Consumer A should receive 2 messages",msg);
- }
-
- msg = consumerA.receive(1500);
- assertNull("Consumer A should not have received a 3rd message",msg);
-
- // Check that consumer B has the last message
- msg = consumerB.receive(1500);
- assertNotNull("Consumer B should have received the message",msg);
+ // Send 3 messages
+ for (int i = 0; i < 3; i++)
+ {
+ producer.send(producerSession.createTextMessage("test"));
}
- finally
+
+ MessageConsumer consumerB = null;
+ // 0-8, 0-9, 0-9-1 prefetch is per session, not consumer.
+ if (!isBroker010())
{
- if (oldPrefetch == null)
- {
- oldPrefetch = ClientProperties.MAX_PREFETCH_DEFAULT;
- }
- System.setProperty(ClientProperties.MAX_PREFETCH_PROP_NAME, oldPrefetch);
+ Session consSessB = _connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
+ consumerB = consSessB.createConsumer(_queue);
+ }
+ else
+ {
+ consumerB = consSessA.createConsumer(_queue);
+ }
+
+ Message msg;
+ // Check that consumer A has 2 messages
+ for (int i = 0; i < 2; i++)
+ {
+ msg = consumerA.receive(1500);
+ assertNotNull("Consumer A should receive 2 messages",msg);
}
+
+ msg = consumerA.receive(1500);
+ assertNull("Consumer A should not have received a 3rd message",msg);
+
+ // Check that consumer B has the last message
+ msg = consumerB.receive(1500);
+ assertNotNull("Consumer B should have received the message",msg);
}
public void testGetChannelID() throws Exception
@@ -284,120 +272,5 @@ public class AMQConnectionTest extends QpidBrokerTestCase
}
}
}
-
- /**
- * Test Strategy : Kill -STOP the broker and see
- * if the client terminates the connection with a
- * read timeout.
- * The broker process is cleaned up in the test itself
- * and avoids using process.waitFor() as it hangs.
- */
- public void testHeartBeat() throws Exception
- {
- boolean windows =
- ((String) System.getProperties().get("os.name")).matches("(?i).*windows.*");
-
- if (!isCppBroker() || windows)
- {
- return;
- }
-
- Process process = null;
- int port = getPort(0);
- String pid = null;
- try
- {
- // close the connection and shutdown the broker started by QpidTest
- _connection.close();
- stopBroker(port);
-
- System.setProperty("qpid.heartbeat", "1");
-
- // in case this broker gets stuck, atleast the rest of the tests will not fail.
- port = port + 200;
- String startCmd = getBrokerCommand(port);
-
- // start a broker using a script
- ProcessBuilder pb = new ProcessBuilder(System.getProperty("broker.start"));
- pb.redirectErrorStream(true);
-
- Map<String, String> env = pb.environment();
- env.put("BROKER_CMD",startCmd);
- env.put("BROKER_READY",System.getProperty(BROKER_READY));
-
- Process startScript = pb.start();
- startScript.waitFor();
- startScript.destroy();
-
- Connection con =
- new AMQConnection("amqp://guest:guest@clientid/testpath?brokerlist='tcp://localhost:" + port + "'");
- final AtomicBoolean lock = new AtomicBoolean(false);
-
- String cmd = "/usr/bin/pgrep -f " + port;
- process = Runtime.getRuntime().exec("/bin/bash");
- LineNumberReader reader = new LineNumberReader(new InputStreamReader(process.getInputStream()));
- PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(process.getOutputStream())), true);
- out.println(cmd);
- pid = reader.readLine();
- try
- {
- Integer.parseInt(pid);
- }
- catch (NumberFormatException e)
- {
- // Error! try to read further to gather the error msg.
- String line;
- _logger.debug(pid);
- while ((line = reader.readLine()) != null )
- {
- _logger.debug(line);
- }
- throw new Exception( "Unable to get the brokers pid " + pid);
- }
- _logger.debug("pid : " + pid);
-
- con.setExceptionListener(new ExceptionListener(){
-
- public void onException(JMSException e)
- {
- synchronized(lock) {
- lock.set(true);
- lock.notifyAll();
- }
- }
- });
- out.println("kill -STOP " + pid);
-
- synchronized(lock){
- lock.wait(2500);
- }
- out.close();
- reader.close();
- assertTrue("Client did not terminate the connection, check log for details",lock.get());
- }
- catch(Exception e)
- {
- throw e;
- }
- finally
- {
- System.setProperty("qpid.heartbeat", "");
-
- if (process != null)
- {
- process.destroy();
- }
-
- Process killScript = Runtime.getRuntime().exec(System.getProperty("broker.kill") + " " + pid);
- killScript.waitFor();
- killScript.destroy();
- cleanBroker();
- }
- }
-
- public static junit.framework.Test suite()
- {
- return new junit.framework.TestSuite(AMQConnectionTest.class);
- }
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQSSLConnectionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQSSLConnectionTest.java
new file mode 100644
index 0000000000..53a433c543
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/AMQSSLConnectionTest.java
@@ -0,0 +1,57 @@
+/*
+ *
+ * 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.unit.client;
+
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQConnectionURL;
+
+public class AMQSSLConnectionTest extends AMQConnectionTest
+{
+ private static final String KEYSTORE = TEST_RESOURCES_DIR + "/ssl/java_client_keystore.jks";
+ private static final String KEYSTORE_PASSWORD = "password";
+ private static final String TRUSTSTORE = TEST_RESOURCES_DIR + "/ssl/java_client_truststore.jks";
+ private static final String TRUSTSTORE_PASSWORD = "password";
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ setTestClientSystemProperty("profile.use_ssl", "true");
+ setConfigurationProperty("connector.ssl.enabled", "true");
+ setConfigurationProperty("connector.ssl.sslOnly", "true");
+ super.setUp();
+ }
+
+ protected void createConnection() throws Exception
+ {
+
+ final String sslPrototypeUrl = "amqp://guest:guest@test/?brokerlist='tcp://localhost:%s" +
+ "?ssl='true'&ssl_verify_hostname='false'" +
+ "&key_store='%s'&key_store_password='%s'" +
+ "&trust_store='%s'&trust_store_password='%s'" +
+ "'";
+
+ final String url = String.format(sslPrototypeUrl,System.getProperty("test.port.ssl"),
+ KEYSTORE,KEYSTORE_PASSWORD,TRUSTSTORE,TRUSTSTORE_PASSWORD);
+
+ _connection = (AMQConnection) getConnection(new AMQConnectionURL(url));
+ }
+}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/CloseAfterConnectionFailureTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/CloseAfterConnectionFailureTest.java
index dc2f59c384..91e681131f 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/CloseAfterConnectionFailureTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/CloseAfterConnectionFailureTest.java
@@ -55,7 +55,7 @@ public class CloseAfterConnectionFailureTest extends QpidBrokerTestCase implemen
try
{
//Start the connection so it will use the retries
- connection = new AMQConnection(url, null);
+ connection = new AMQConnection(url);
connection.setExceptionListener(this);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionCloseTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionCloseTest.java
index 6d1b6de238..7f166d07fe 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionCloseTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionCloseTest.java
@@ -27,6 +27,7 @@ import java.util.HashMap;
import java.util.Map;
import javax.jms.Connection;
+import javax.jms.JMSException;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
@@ -98,6 +99,31 @@ public class ConnectionCloseTest extends QpidBrokerTestCase
delta.size() < deltaThreshold);
}
+ /**
+ * This test is added due to QPID-3453 to test connection closing when AMQ
+ * session is not closed but underlying transport session is in detached
+ * state and transport connection is closed
+ */
+ public void testConnectionCloseOnOnForcibleBrokerStop() throws Exception
+ {
+ Connection connection = getConnection();
+ connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ stopBroker();
+
+ // we need to close connection explicitly in order to verify that
+ // closing of connection having transport session in DETACHED state and
+ // transport connection in CLOSED state does not throw an exception
+ try
+ {
+ connection.close();
+ }
+ catch (JMSException e)
+ {
+ // session closing should not fail
+ fail("Cannot close connection:" + e.getMessage());
+ }
+ }
+
private void dumpStacks(Map<Thread,StackTraceElement[]> map)
{
for (Map.Entry<Thread,StackTraceElement[]> entry : map.entrySet())
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionFactoryTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionFactoryTest.java
new file mode 100644
index 0000000000..545081fb43
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionFactoryTest.java
@@ -0,0 +1,41 @@
+package org.apache.qpid.test.unit.client.connection;
+
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQConnectionFactory;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
+public class ConnectionFactoryTest extends QpidBrokerTestCase
+{
+
+ /**
+ * The username & password specified should not override the default
+ * specified in the URL.
+ */
+ public void testCreateConnectionWithUsernamePassword() throws Exception
+ {
+
+ String brokerUrl = getBroker().toString();
+ String URL = "amqp://guest:guest@clientID/test?brokerlist='" + brokerUrl + "'";
+ AMQConnectionFactory factory = new AMQConnectionFactory(URL);
+
+ AMQConnection con = (AMQConnection)factory.createConnection();
+ assertEquals("Usernames used is different from the one in URL","guest",con.getConnectionURL().getUsername());
+ assertEquals("Password used is different from the one in URL","guest",con.getConnectionURL().getPassword());
+
+ try
+ {
+ AMQConnection con2 = (AMQConnection)factory.createConnection("user","pass");
+ assertEquals("Usernames used is different from the one in URL","user",con2.getConnectionURL().getUsername());
+ assertEquals("Password used is different from the one in URL","pass",con2.getConnectionURL().getPassword());
+ }
+ catch(Exception e)
+ {
+ // ignore
+ }
+
+ AMQConnection con3 = (AMQConnection)factory.createConnection();
+ assertEquals("Usernames used is different from the one in URL","guest",con3.getConnectionURL().getUsername());
+ assertEquals("Password used is different from the one in URL","guest",con3.getConnectionURL().getPassword());
+ }
+
+}
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 d17ead13aa..f18f365f20 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
@@ -32,6 +32,7 @@ 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.configuration.ClientProperties;
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.jms.BrokerDetails;
@@ -81,21 +82,21 @@ public class ConnectionTest extends QpidBrokerTestCase
+ "&temporaryTopicExchange='tmp.topic'");
System.err.println(url.toString());
- conn = new AMQConnection(url, null);
+ conn = new AMQConnection(url);
AMQSession sess = (AMQSession) conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- sess.declareExchange(new AMQShortString("test.direct"),
+
+ sess.declareExchange(new AMQShortString("test.direct"),
ExchangeDefaults.DIRECT_EXCHANGE_CLASS, false);
- sess.declareExchange(new AMQShortString("tmp.direct"),
+ sess.declareExchange(new AMQShortString("tmp.direct"),
ExchangeDefaults.DIRECT_EXCHANGE_CLASS, false);
- sess.declareExchange(new AMQShortString("tmp.topic"),
+ sess.declareExchange(new AMQShortString("tmp.topic"),
ExchangeDefaults.TOPIC_EXCHANGE_CLASS, false);
- sess.declareExchange(new AMQShortString("test.topic"),
+ sess.declareExchange(new AMQShortString("test.topic"),
ExchangeDefaults.TOPIC_EXCHANGE_CLASS, false);
QueueSession queueSession = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -111,7 +112,7 @@ public class ConnectionTest extends QpidBrokerTestCase
queueSession.close();
TopicSession topicSession = conn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
-
+
AMQTopic topic = (AMQTopic) topicSession.createTopic("silly.topic");
assertEquals(topic.getExchangeName().toString(), "test.topic");
@@ -269,7 +270,7 @@ public class ConnectionTest extends QpidBrokerTestCase
}
connection.close();
}
-
+
public void testUnsupportedSASLMechanism() throws Exception
{
BrokerDetails broker = getBroker();
@@ -285,10 +286,64 @@ public class ConnectionTest extends QpidBrokerTestCase
}
catch (Exception e)
{
- assertTrue("Incorrect exception thrown",
- e.getMessage().contains("The following SASL mechanisms " +
- "[MY_MECH]" +
- " specified by the client are not supported by the broker"));
+ assertTrue("Unexpected exception message : " + e.getMessage(),
+ e.getMessage().contains("Client and broker have no SASL mechanisms in common."));
+ assertTrue("Unexpected exception message : " + e.getMessage(),
+ e.getMessage().contains("Client restricted itself to : MY_MECH"));
+
+ }
+ }
+
+ /**
+ * Tests that when the same user connects twice with same clientid, the second connection
+ * fails if the clientid verification feature is enabled (which uses a dummy 0-10 Session
+ * with the clientid as its name to detect the previous usage of the clientid by the user)
+ */
+ public void testClientIDVerificationForSameUser() throws Exception
+ {
+ setTestSystemProperty(ClientProperties.QPID_VERIFY_CLIENT_ID, "true");
+
+ BrokerDetails broker = getBroker();
+ try
+ {
+ Connection con = new AMQConnection(broker.toString(), "guest", "guest",
+ "client_id", "test");
+
+ Connection con2 = new AMQConnection(broker.toString(), "guest", "guest",
+ "client_id", "test");
+
+ fail("The client should throw a ConnectionException stating the" +
+ " client ID is not unique");
+ }
+ catch (Exception e)
+ {
+ assertTrue("Incorrect exception thrown: " + e.getMessage(),
+ e.getMessage().contains("ClientID must be unique"));
+ }
+ }
+
+ /**
+ * Tests that when different users connects with same clientid, the second connection
+ * succeeds even though the clientid verification feature is enabled (which uses a dummy
+ * 0-10 Session with the clientid as its name; these are only verified unique on a
+ * per-principal basis)
+ */
+ public void testClientIDVerificationForDifferentUsers() throws Exception
+ {
+ setTestSystemProperty(ClientProperties.QPID_VERIFY_CLIENT_ID, "true");
+
+ BrokerDetails broker = getBroker();
+ try
+ {
+ Connection con = new AMQConnection(broker.toString(), "guest", "guest",
+ "client_id", "test");
+
+ Connection con2 = new AMQConnection(broker.toString(), "admin", "admin",
+ "client_id", "test");
+ }
+ catch (Exception e)
+ {
+ fail("Unexpected exception thrown, client id was not unique but usernames were different! " + e.getMessage());
}
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ExceptionListenerTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ExceptionListenerTest.java
index cec9d292cf..0057422c8f 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ExceptionListenerTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ExceptionListenerTest.java
@@ -47,13 +47,15 @@ public class ExceptionListenerTest extends QpidBrokerTestCase
{
public void onException(JMSException e)
{
+ _logger.debug("&&&&&&&&&&&&&&&&&&&&&&&&&&&& Caught exception &&&&&&&&&&&&&&&&&&&&&&&&&&&& ", e);
fired.countDown();
}
});
-
+ _logger.debug("%%%%%%%%%%%%%%%% Stopping Broker %%%%%%%%%%%%%%%%%%%%%");
stopBroker();
+ _logger.debug("%%%%%%%%%%%%%%%% Stopped Broker %%%%%%%%%%%%%%%%%%%%%");
- if (!fired.await(3, TimeUnit.SECONDS))
+ if (!fired.await(5, TimeUnit.SECONDS))
{
fail("exception listener was not fired");
}
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 5701b5a1fd..836684c965 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
@@ -25,7 +25,6 @@ import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.net.UnknownHostException;
-import org.apache.mina.transport.vmpipe.VmPipeAddress;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.protocol.AMQProtocolHandler;
import org.apache.qpid.client.protocol.AMQProtocolSession;
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java
index 5721bcf4e3..97452ad1c8 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java
@@ -25,6 +25,7 @@ import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.message.NonQpidObjectMessage;
+import org.apache.qpid.client.message.QpidMessageProperties;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.test.utils.QpidBrokerTestCase;
@@ -172,7 +173,7 @@ public class JMSPropertiesTest extends QpidBrokerTestCase
* Test Goal : Test if custom message properties can be set and retrieved properly with out an error.
* Also test if unsupported properties are filtered out. See QPID-2930.
*/
- public void testApplicationProperties() throws Exception
+ public void testQpidExtensionProperties() throws Exception
{
Connection con = getConnection("guest", "guest");
Session ssn = (AMQSession) con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
@@ -182,8 +183,8 @@ public class JMSPropertiesTest extends QpidBrokerTestCase
MessageConsumer consumer = ssn.createConsumer(topic);
MessageProducer prod = ssn.createProducer(topic);
Message m = ssn.createMessage();
- m.setObjectProperty("x-amqp-0-10.routing-key", "routing-key".getBytes());
- m.setObjectProperty("x-amqp-0-10.app-id", "my-app-id");
+ m.setObjectProperty("foo-bar", "foobar".getBytes());
+ m.setObjectProperty(QpidMessageProperties.AMQP_0_10_APP_ID, "my-app-id");
prod.send(m);
Message msg = consumer.receive(1000);
@@ -198,7 +199,9 @@ public class JMSPropertiesTest extends QpidBrokerTestCase
map.put(name, value);
}
- assertFalse("Property 'x-amqp-0-10.routing-key' should have been filtered out",map.containsKey("x-amqp-0-10.routing-key"));
- assertEquals("Property x-amqp-0-10.app-id should be present","my-app-id",msg.getStringProperty("x-amqp-0-10.app-id"));
+ assertFalse("Property 'foo-bar' should have been filtered out",map.containsKey("foo-bar"));
+ assertEquals("Property "+ QpidMessageProperties.AMQP_0_10_APP_ID + " should be present","my-app-id",msg.getStringProperty(QpidMessageProperties.AMQP_0_10_APP_ID));
+ assertEquals("Property "+ QpidMessageProperties.AMQP_0_10_ROUTING_KEY + " should be present","test",msg.getStringProperty(QpidMessageProperties.AMQP_0_10_ROUTING_KEY));
+
}
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/StreamMessageTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/StreamMessageTest.java
index 0f799073b4..39691a5c7c 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/StreamMessageTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/StreamMessageTest.java
@@ -20,6 +20,10 @@
*/
package org.apache.qpid.test.unit.message;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQHeadersExchange;
import org.apache.qpid.client.AMQQueue;
@@ -50,21 +54,8 @@ import javax.jms.StreamMessage;
*/
public class StreamMessageTest extends QpidBrokerTestCase
{
-
private static final Logger _logger = LoggerFactory.getLogger(StreamMessageTest.class);
- public String _connectionString = "vm://:1";
-
- protected void setUp() throws Exception
- {
- super.setUp();
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
public void testStreamMessageEOF() throws Exception
{
Connection con = (AMQConnection) getConnection("guest", "guest");
@@ -114,6 +105,7 @@ public class StreamMessageTest extends QpidBrokerTestCase
try
{
msg2.readByte();
+ fail("Expected exception not thrown");
}
catch (Exception e)
{
@@ -125,6 +117,9 @@ public class StreamMessageTest extends QpidBrokerTestCase
public void testModifyReceivedMessageExpandsBuffer() throws Exception
{
+ final CountDownLatch awaitMessages = new CountDownLatch(1);
+ final AtomicReference<Throwable> listenerCaughtException = new AtomicReference<Throwable>();
+
AMQConnection con = (AMQConnection) getConnection("guest", "guest");
AMQSession consumerSession = (AMQSession) con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
AMQQueue queue = new AMQQueue(con.getDefaultQueueExchangeName(), new AMQShortString("testQ"));
@@ -134,28 +129,38 @@ public class StreamMessageTest extends QpidBrokerTestCase
public void onMessage(Message message)
{
- StreamMessage sm = (StreamMessage) message;
+ final StreamMessage sm = (StreamMessage) message;
try
{
sm.clearBody();
+ // it is legal to extend a stream message's content
sm.writeString("dfgjshfslfjshflsjfdlsjfhdsljkfhdsljkfhsd");
}
- catch (JMSException e)
+ catch (Throwable t)
+ {
+ listenerCaughtException.set(t);
+ }
+ finally
{
- _logger.error("Error when writing large string to received msg: " + e, e);
- fail("Error when writing large string to received msg" + e);
+ awaitMessages.countDown();
}
}
});
Connection con2 = (AMQConnection) getConnection("guest", "guest");
AMQSession producerSession = (AMQSession) con2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- MessageProducer mandatoryProducer = producerSession.createProducer(queue);
+ MessageProducer producer = producerSession.createProducer(queue);
con.start();
StreamMessage sm = producerSession.createStreamMessage();
sm.writeInt(42);
- mandatoryProducer.send(sm);
- Thread.sleep(2000);
+ producer.send(sm);
+
+ // Allow up to five seconds for the message to arrive with the consumer
+ final boolean completed = awaitMessages.await(5, TimeUnit.SECONDS);
+ assertTrue("Message did not arrive with consumer within a reasonable time", completed);
+ final Throwable listenerException = listenerCaughtException.get();
+ assertNull("No exception should be caught by listener : " + listenerException, listenerException);
+
con.close();
con2.close();
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/UTF8Test.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/UTF8Test.java
index fe929b4965..978ebfa93f 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/UTF8Test.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/message/UTF8Test.java
@@ -20,17 +20,20 @@
*/
package org.apache.qpid.test.unit.message;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.transport.Connection;
-import org.apache.qpid.transport.Session;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.util.Properties;
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
import javax.naming.InitialContext;
-import javax.jms.*;
-import java.util.Properties;
-import java.io.*;
+
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
/**
@@ -41,8 +44,6 @@ import java.io.*;
*/
public class UTF8Test extends QpidBrokerTestCase
{
- private static final Logger _logger = LoggerFactory.getLogger(UTF8Test.class);
-
public void testPlainEn() throws Exception
{
invoke("UTF8En");
@@ -65,38 +66,24 @@ public class UTF8Test extends QpidBrokerTestCase
private void runTest(String exchangeName, String queueName, String routingKey, String data) throws Exception
{
- _logger.info("Running test for exchange: " + exchangeName
- + " queue Name: " + queueName
- + " routing key: " + routingKey);
- declareQueue(exchangeName, routingKey, queueName);
+ Connection con = getConnection();
+ Session sess = con.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
+ final Destination dest = getDestination(exchangeName, routingKey, queueName);
+
+ final MessageConsumer msgCons = sess.createConsumer(dest);
+ con.start();
- javax.jms.Connection con = getConnection();
- javax.jms.Session sess = con.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
- Destination dest = getDestination(exchangeName, routingKey, queueName);
// Send data
MessageProducer msgProd = sess.createProducer(dest);
TextMessage message = sess.createTextMessage(data);
msgProd.send(message);
+
// consume data
- MessageConsumer msgCons = sess.createConsumer(dest);
- con.start();
TextMessage m = (TextMessage) msgCons.receive(RECEIVE_TIMEOUT);
assertNotNull(m);
assertEquals(m.getText(), data);
}
- private void declareQueue(String exch, String routkey, String qname) throws Exception
- {
- Connection conn = new Connection();
- conn.connect("localhost", QpidBrokerTestCase.DEFAULT_PORT, "test", "guest", "guest",false);
- Session sess = conn.createSession(0);
- sess.exchangeDeclare(exch, "direct", null, null);
- sess.queueDeclare(qname, null, null);
- sess.exchangeBind(qname, exch, routkey, null);
- sess.sync();
- conn.close();
- }
-
private Destination getDestination(String exch, String routkey, String qname) throws Exception
{
Properties props = new Properties();
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutConfigurationTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutConfigurationTest.java
index 36bac3b715..46e5d214f5 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutConfigurationTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutConfigurationTest.java
@@ -31,7 +31,7 @@ public class TransactionTimeoutConfigurationTest extends TransactionTimeoutTestC
protected void configure() throws Exception
{
// Setup housekeeping every second
- setConfigurationProperty("virtualhosts.virtualhost." + VIRTUALHOST + ".housekeeping.expiredMessageCheckPeriod", "100");
+ setConfigurationProperty("virtualhosts.virtualhost." + VIRTUALHOST + ".housekeeping.checkPeriod", "100");
// Set transaction timout properties.
setConfigurationProperty("virtualhosts.virtualhost." + VIRTUALHOST + ".transactionTimeout.openWarn", "200");
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutDisabledTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutDisabledTest.java
index 71b89bf911..db508143f9 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutDisabledTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/TransactionTimeoutDisabledTest.java
@@ -29,7 +29,7 @@ public class TransactionTimeoutDisabledTest extends TransactionTimeoutTestCase
protected void configure() throws Exception
{
// Setup housekeeping every second
- setConfigurationProperty("virtualhosts.virtualhost." + VIRTUALHOST + ".housekeeping.expiredMessageCheckPeriod", "100");
+ setConfigurationProperty("virtualhosts.virtualhost." + VIRTUALHOST + ".housekeeping.checkPeriod", "100");
}
public void testProducerIdleCommit() throws Exception
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 786fc2adb0..ef2de5c592 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
@@ -72,7 +72,7 @@ public class TransactionTimeoutTestCase extends QpidBrokerTestCase implements Ex
protected void configure() throws Exception
{
// Setup housekeeping every second
- setConfigurationProperty("virtualhosts.virtualhost." + VIRTUALHOST + ".housekeeping.expiredMessageCheckPeriod", "100");
+ setConfigurationProperty("virtualhosts.virtualhost." + VIRTUALHOST + ".housekeeping.checkPeriod", "100");
/*
* Set transaction timout properties. The XML in the virtualhosts configuration is as follows:
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 b39b31df58..40df024c67 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
@@ -83,7 +83,7 @@ public class QpidBrokerTestCase extends QpidTestCase
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 final static String QpidHome = System.getProperty("QPID_HOME");
protected File _configFile = new File(System.getProperty("broker.config"));
protected static final Logger _logger = Logger.getLogger(QpidBrokerTestCase.class);
@@ -91,9 +91,7 @@ public class QpidBrokerTestCase extends QpidTestCase
protected long RECEIVE_TIMEOUT = 1000l;
- private Map<String, String> _propertiesSetForTestOnly = new HashMap<String, String>();
private Map<String, String> _propertiesSetForBroker = new HashMap<String, String>();
- private Map<Logger, Level> _loggerLevelSetForTest = new HashMap<Logger, Level>();
private XMLConfiguration _testConfiguration = new XMLConfiguration();
private XMLConfiguration _testVirtualhosts = new XMLConfiguration();
@@ -139,8 +137,8 @@ public class QpidBrokerTestCase extends QpidTestCase
public static final int DEFAULT_VM_PORT = 1;
public static final int DEFAULT_PORT = Integer.getInteger("test.port", ServerConfiguration.DEFAULT_PORT);
public static final int FAILING_PORT = Integer.parseInt(System.getProperty("test.port.alt"));
- public static final int DEFAULT_MANAGEMENT_PORT = Integer.getInteger("test.mport", ServerConfiguration.DEFAULT_JMXPORT);
- public static final int DEFAULT_SSL_PORT = Integer.getInteger("test.sslport", ServerConfiguration.DEFAULT_SSL_PORT);
+ public static final int DEFAULT_MANAGEMENT_PORT = Integer.getInteger("test.mport", ServerConfiguration.DEFAULT_JMXPORT_REGISTRYSERVER);
+ public static final int DEFAULT_SSL_PORT = Integer.getInteger("test.port.ssl", ServerConfiguration.DEFAULT_SSL_PORT);
protected String _brokerLanguage = System.getProperty(BROKER_LANGUAGE, JAVA);
protected BrokerType _brokerType = BrokerType.valueOf(System.getProperty(BROKER_TYPE, "").toUpperCase());
@@ -164,8 +162,6 @@ public class QpidBrokerTestCase extends QpidTestCase
protected InitialContext _initialContext;
protected AMQConnectionFactory _connectionFactory;
- protected String _testName;
-
// the connections created for a given test
protected List<Connection> _connections = new ArrayList<Connection>();
public static final String QUEUE = "queue";
@@ -207,7 +203,6 @@ public class QpidBrokerTestCase extends QpidTestCase
public void runBare() throws Throwable
{
- _testName = getClass().getSimpleName() + "." + getName();
String qname = getClass().getName() + "." + getName();
// Initialize this for each test run
@@ -238,7 +233,6 @@ public class QpidBrokerTestCase extends QpidTestCase
}
}
- _logger.info("========== start " + _testName + " ==========");
try
{
super.runBare();
@@ -259,6 +253,10 @@ public class QpidBrokerTestCase extends QpidTestCase
_logger.error("exception stopping broker", e);
}
+ // reset properties used in the test
+ revertSystemProperties();
+ revertLoggingLevels();
+
if(_brokerCleanBetweenTests)
{
try
@@ -271,7 +269,7 @@ public class QpidBrokerTestCase extends QpidTestCase
}
}
- _logger.info("========== stop " + _testName + " ==========");
+ _logger.info("========== stop " + getTestName() + " ==========");
if (redirected)
{
@@ -290,6 +288,8 @@ public class QpidBrokerTestCase extends QpidTestCase
@Override
protected void setUp() throws Exception
{
+ super.setUp();
+
if (!_configFile.exists())
{
fail("Unable to test without config file:" + _configFile);
@@ -441,10 +441,11 @@ public class QpidBrokerTestCase extends QpidTestCase
protected String getBrokerCommand(int port) throws MalformedURLException
{
- final String protocolExcludesList = _brokerProtocolExcludes.replace("@PORT", "" + port);
+ final int sslPort = port-1;
+ final String protocolExcludesList = getProtocolExcludesList(port, sslPort);
return _brokerCommand
.replace("@PORT", "" + port)
- .replace("@SSL_PORT", "" + (port - 1))
+ .replace("@SSL_PORT", "" + sslPort)
.replace("@MPORT", "" + getManagementPort(port))
.replace("@CONFIG_FILE", _configFile.toString())
.replace("@EXCLUDES", protocolExcludesList);
@@ -477,9 +478,9 @@ public class QpidBrokerTestCase extends QpidTestCase
options.setConfigFile(_configFile.getAbsolutePath());
options.addPort(port);
- addExcludedPorts(port, options);
+ addExcludedPorts(port, DEFAULT_SSL_PORT, options);
- options.setJmxPort(getManagementPort(port));
+ options.setJmxPortRegistryServer(getManagementPort(port));
//Set the log config file, relying on the log4j.configuration system property
//set on the JVM by the JUnit runner task in module.xml.
@@ -508,7 +509,7 @@ public class QpidBrokerTestCase extends QpidTestCase
//Add the test name to the broker run.
// DON'T change PNAME, qpid.stop needs this value.
- env.put("QPID_PNAME", "-DPNAME=QPBRKR -DTNAME=\"" + _testName + "\"");
+ env.put("QPID_PNAME", "-DPNAME=QPBRKR -DTNAME=\"" + getTestName() + "\"");
// Add the port to QPID_WORK to ensure unique working dirs for multi broker tests
env.put("QPID_WORK", getQpidWork(_brokerType, port));
@@ -598,9 +599,9 @@ public class QpidBrokerTestCase extends QpidTestCase
}
}
- private void addExcludedPorts(int port, BrokerOptions options)
+ private void addExcludedPorts(int port, int sslPort, BrokerOptions options)
{
- final String protocolExcludesList = _brokerProtocolExcludes.replace("@PORT", "" + port);
+ final String protocolExcludesList = getProtocolExcludesList(port, sslPort);
if (protocolExcludesList.equals(""))
{
@@ -622,6 +623,13 @@ public class QpidBrokerTestCase extends QpidTestCase
}
}
+ protected String getProtocolExcludesList(int port, int sslPort)
+ {
+ final String protocolExcludesList =
+ _brokerProtocolExcludes.replace("@PORT", "" + port).replace("@SSL_PORT", "" + sslPort);
+ return protocolExcludesList;
+ }
+
private boolean existingInternalBroker()
{
for(BrokerHolder holder : _brokers.values())
@@ -875,20 +883,14 @@ public class QpidBrokerTestCase extends QpidTestCase
}
/**
- * Set a System (-D) property for the external Broker of this test.
+ * Set a System property for the client (and broker if using the same vm) of this test.
*
* @param property The property to set
* @param value the value to set it to.
*/
protected void setTestClientSystemProperty(String property, String value)
{
- if (!_propertiesSetForTestOnly.containsKey(property))
- {
- // Record the current value so we can revert it later.
- _propertiesSetForTestOnly.put(property, System.getProperty(property));
- }
-
- System.setProperty(property, value);
+ setTestSystemProperty(property, value);
}
/**
@@ -896,20 +898,7 @@ public class QpidBrokerTestCase extends QpidTestCase
*/
protected void revertSystemProperties()
{
- for (String key : _propertiesSetForTestOnly.keySet())
- {
- String value = _propertiesSetForTestOnly.get(key);
- if (value != null)
- {
- System.setProperty(key, value);
- }
- else
- {
- System.clearProperty(key);
- }
- }
-
- _propertiesSetForTestOnly.clear();
+ revertTestSystemProperties();
// We don't change the current VMs settings for Broker only properties
// so we can just clear this map
@@ -928,40 +917,6 @@ public class QpidBrokerTestCase extends QpidTestCase
}
/**
- * Adjust the VMs Log4j Settings just for this test run
- *
- * @param logger the logger to change
- * @param level the level to set
- */
- protected void setLoggerLevel(Logger logger, Level level)
- {
- assertNotNull("Cannot set level of null logger", logger);
- assertNotNull("Cannot set Logger("+logger.getName()+") to null level.",level);
-
- if (!_loggerLevelSetForTest.containsKey(logger))
- {
- // Record the current value so we can revert it later.
- _loggerLevelSetForTest.put(logger, logger.getLevel());
- }
-
- logger.setLevel(level);
- }
-
- /**
- * Restore the logging levels defined by this test.
- */
- protected void revertLoggingLevels()
- {
- for (Logger logger : _loggerLevelSetForTest.keySet())
- {
- logger.setLevel(_loggerLevelSetForTest.get(logger));
- }
-
- _loggerLevelSetForTest.clear();
-
- }
-
- /**
* Check whether the broker is an 0.8
*
* @return true if the broker is an 0_8 version, false otherwise.
@@ -1069,7 +1024,7 @@ public class QpidBrokerTestCase extends QpidTestCase
{
return (AMQConnectionFactory) getInitialContext().lookup(factoryName);
}
-
+
public Connection getConnection() throws JMSException, NamingException
{
return getConnection("guest", "guest");
@@ -1137,18 +1092,12 @@ public class QpidBrokerTestCase extends QpidTestCase
protected void tearDown() throws java.lang.Exception
{
- try
+ super.tearDown();
+
+ // close all the connections used by this test.
+ for (Connection c : _connections)
{
- // close all the connections used by this test.
- for (Connection c : _connections)
- {
- c.close();
- }
- }
- finally{
- // Ensure any problems with close does not interfer with property resets
- revertSystemProperties();
- revertLoggingLevels();
+ c.close();
}
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/protocol/TestIoSession.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/protocol/TestIoSession.java
deleted file mode 100644
index f1eb8159b6..0000000000
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/protocol/TestIoSession.java
+++ /dev/null
@@ -1,104 +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.utils.protocol;
-
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-
-import org.apache.mina.common.IoFilterChain;
-import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoService;
-import org.apache.mina.common.IoServiceConfig;
-import org.apache.mina.common.IoSessionConfig;
-import org.apache.mina.common.TransportType;
-import org.apache.mina.common.support.BaseIoSession;
-
-public class TestIoSession extends BaseIoSession {
-
- private String _stringLocalAddress;
- private int _localPort;
-
- public SocketAddress getLocalAddress()
- {
- //create a new address for testing purposes using member variables
- return new InetSocketAddress(_stringLocalAddress,_localPort);
- }
-
- protected void updateTrafficMask() {
- //dummy
- }
-
- public IoService getService() {
- return null;
- }
-
- public IoServiceConfig getServiceConfig() {
- return null;
- }
-
- public IoHandler getHandler() {
- return null;
- }
-
- public IoSessionConfig getConfig() {
- return null;
- }
-
- public IoFilterChain getFilterChain() {
- return null;
- }
-
- public TransportType getTransportType() {
- return null;
- }
-
- public SocketAddress getRemoteAddress() {
- return null;
- }
-
- public SocketAddress getServiceAddress() {
- return null;
- }
-
- public int getScheduledWriteRequests() {
- return 0;
- }
-
- public int getScheduledWriteBytes() {
- return 0;
- }
-
- public String getStringLocalAddress() {
- return _stringLocalAddress;
- }
-
- public void setStringLocalAddress(String _stringLocalAddress) {
- this._stringLocalAddress = _stringLocalAddress;
- }
-
- public int getLocalPort() {
- return _localPort;
- }
-
- public void setLocalPort(int _localPort) {
- this._localPort = _localPort;
- }
-}