summaryrefslogtreecommitdiff
path: root/qpid/java/systests/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/java/systests/src/main/java')
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java527
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java2
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java14
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java43
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java6
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java12
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java8
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/queue/ModelTest.java299
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/SimpleACLTest.java134
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java21
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/utils/FailoverBaseCase.java4
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/utils/JMXTestUtils.java208
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java139
13 files changed, 872 insertions, 545 deletions
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 b4ba6e8156..2e107ada34 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
@@ -20,26 +20,19 @@
*/
package org.apache.qpid.management.jmx;
-import org.apache.qpid.commands.objects.AllObjects;
-import org.apache.qpid.management.common.JMXConnnectionFactory;
import org.apache.qpid.management.common.mbeans.ManagedBroker;
import org.apache.qpid.management.common.mbeans.ManagedConnection;
import org.apache.qpid.management.common.mbeans.ManagedExchange;
import org.apache.qpid.server.logging.AbstractTestLogging;
import org.apache.qpid.server.logging.subjects.AbstractTestLogSubject;
+import org.apache.qpid.test.utils.JMXTestUtils;
import javax.jms.Connection;
import javax.jms.ExceptionListener;
import javax.jms.JMSException;
import javax.management.JMException;
-import javax.management.MBeanException;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerInvocationHandler;
-import javax.management.ObjectName;
-import javax.management.remote.JMXConnector;
import java.io.IOException;
import java.util.List;
-import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -50,33 +43,21 @@ import java.util.concurrent.TimeUnit;
*/
public class ManagementActorLoggingTest extends AbstractTestLogging
{
- MBeanServerConnection _mbsc;
- JMXConnector _jmxc;
+ private JMXTestUtils _jmxUtils;
private static final String USER = "admin";
@Override
public void setUp() throws Exception
{
- setConfigurationProperty("management.enabled", "true");
+ _jmxUtils = new JMXTestUtils(this, USER, USER);
+ _jmxUtils.setUp();
super.setUp();
-
- if (isExternalBroker())
- {
- _jmxc = JMXConnnectionFactory.getJMXConnection(
- 5000, "127.0.0.1",
- getManagementPort(getPort()), USER, USER);
-
- _mbsc = _jmxc.getMBeanServerConnection();
- }
}
@Override
public void tearDown() throws Exception
{
- if (isExternalBroker())
- {
- _jmxc.close();
- }
+ _jmxUtils.close();
super.tearDown();
}
@@ -107,34 +88,31 @@ public class ManagementActorLoggingTest extends AbstractTestLogging
*/
public void testJMXManagementConsoleConnection() throws IOException
{
- if (isExternalBroker())
- {
- List<String> results = _monitor.findMatches("MNG-1007");
+ List<String> results = _monitor.findMatches("MNG-1007");
- assertEquals("Unexpected Management Connection count", 1, results.size());
+ assertEquals("Unexpected Management Connection count", 1, results.size());
- String log = getLog(results.get(0));
+ String log = getLog(results.get(0));
- validateMessageID("MNG-1007", log);
+ 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) + "");
+ 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 = _monitor.findMatches("MNG-1008");
+ results = _monitor.findMatches("MNG-1008");
- assertEquals("Unexpected Management Connection close count", 0, results.size());
+ assertEquals("Unexpected Management Connection close count", 0, results.size());
- _jmxc.close();
+ _jmxUtils.close();
- results = _monitor.findMatches("MNG-1008");
+ results = _monitor.findMatches("MNG-1008");
- assertEquals("Unexpected Management Connection count", 1, results.size());
+ 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) + ""));
- }
+ assertEquals("Close does not have same id as open,", connectionID,
+ Integer.parseInt(fromActor(getLog(results.get(0))).charAt(4) + ""));
}
/**
@@ -159,56 +137,40 @@ public class ManagementActorLoggingTest extends AbstractTestLogging
*/
public void testConnectionCloseViaManagement() throws IOException, Exception
{
- if (isExternalBroker())
+ //Create a connection to the broker
+ Connection connection = getConnection();
+
+ // Monitor the connection for an exception being thrown
+ // this should be a DisconnectionException but it is not this tests
+ // job to valiate that. Only use the exception as a synchronisation
+ // to check the log file for the Close message
+ final CountDownLatch exceptionReceived = new CountDownLatch(1);
+ connection.setExceptionListener(new ExceptionListener()
{
-
- //Create a connection to the broker
- Connection connection = getConnection();
-
- // Monitor the connection for an exception being thrown
- // this should be a DisconnectionException but it is not this tests
- // job to valiate that. Only use the exception as a synchronisation
- // to check the log file for the Close message
- final CountDownLatch exceptionReceived = new CountDownLatch(1);
- connection.setExceptionListener(new ExceptionListener()
+ public void onException(JMSException e)
{
- public void onException(JMSException e)
- {
- //Failover being attempted.
- exceptionReceived.countDown();
- }
- });
-
- //Remove the connection close from any 0-10 connections
- _monitor.reset();
+ //Failover being attempted.
+ exceptionReceived.countDown();
+ }
+ });
- // Get all active AMQP connections
- AllObjects allObject = new AllObjects(_mbsc);
- allObject.querystring = "org.apache.qpid:type=VirtualHost.Connection,*";
+ //Remove the connection close from any 0-10 connections
+ _monitor.reset();
- Set<ObjectName> objectNames = allObject.returnObjects();
+ // Get a managedConnection
+ ManagedConnection mangedConnection = _jmxUtils.getManagedObject(ManagedConnection.class, "org.apache.qpid:type=VirtualHost.Connection,*");
- assertEquals("More than one test connection returned", 1, objectNames.size());
+ //Close the connection
+ mangedConnection.closeConnection();
- ObjectName connectionName = objectNames.iterator().next();
+ //Wait for the connection to close
+ assertTrue("Timed out waiting for conneciton to report close",
+ exceptionReceived.await(2, TimeUnit.SECONDS));
- ManagedConnection mangedConnection = MBeanServerInvocationHandler.
- newProxyInstance(_mbsc, connectionName,
- ManagedConnection.class, false);
+ //Validate results
+ List<String> results = _monitor.findMatches("CON-1002");
-
- //Close the connection
- mangedConnection.closeConnection();
-
- //Wait for the connection to close
- assertTrue("Timed out waiting for conneciton to report close",
- exceptionReceived.await(2, TimeUnit.SECONDS));
-
- //Validate results
- List<String> results = _monitor.findMatches("CON-1002");
-
- assertEquals("Unexpected Connection Close count", 1, results.size());
- }
+ assertEquals("Unexpected Connection Close count", 1, results.size());
}
/**
@@ -234,114 +196,100 @@ public class ManagementActorLoggingTest extends AbstractTestLogging
*/
public void testCreateExchangeDirectTransientViaManagementConsole() throws IOException, JMException
{
- if (isExternalBroker())
- {
- //Remove any previous exchange declares
- _monitor.reset();
-
- createExchange("direct");
+ _monitor.reset();
- // Validate
+ _jmxUtils.createExchange("test", "direct", null, false);
- //1 - ID is correct
- List<String> results = _monitor.findMatches("EXH-1001");
+ // Validate
- assertEquals("More than one exchange creation found", 1, results.size());
+ //1 - ID is correct
+ List<String> results = _monitor.findMatches("EXH-1001");
- String log = getLog(results.get(0));
+ assertEquals("More than one exchange creation found", 1, results.size());
- // Validate correct exchange name
- assertTrue("Incorrect exchange name created:" + log, log.endsWith(getName()));
+ String log = getLog(results.get(0));
- // Validate it was a management actor.
- String actor = fromActor(log);
- assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng"));
+ // Validate correct exchange name
+ assertTrue("Incorrect exchange name created:" + log, log.endsWith(getName()));
- }
+ // Validate it was a management actor.
+ String actor = fromActor(log);
+ assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng"));
}
public void testCreateExchangeTopicTransientViaManagementConsole() throws IOException, JMException
{
- if (isExternalBroker())
- {
- //Remove any previous exchange declares
- _monitor.reset();
+ //Remove any previous exchange declares
+ _monitor.reset();
- createExchange("topic");
+ _jmxUtils.createExchange("test", "topic", null, false);
- // Validate
+ // Validate
- //1 - ID is correct
- List<String> results = _monitor.findMatches("EXH-1001");
+ //1 - ID is correct
+ List<String> results = _monitor.findMatches("EXH-1001");
- assertEquals("More than one exchange creation found", 1, results.size());
+ assertEquals("More than one exchange creation found", 1, results.size());
- String log = getLog(results.get(0));
+ String log = getLog(results.get(0));
- // Validate correct exchange name
- assertTrue("Incorrect exchange name created:" + log, log.endsWith(getName()));
+ // Validate correct exchange name
+ assertTrue("Incorrect exchange name created:" + log, log.endsWith(getName()));
- // Validate it was a management actor.
- String actor = fromActor(log);
- assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng"));
+ // Validate it was a management actor.
+ String actor = fromActor(log);
+ assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng"));
- }
}
public void testCreateExchangeFanoutTransientViaManagementConsole() throws IOException, JMException
{
- if (isExternalBroker())
- {
- //Remove any previous exchange declares
- _monitor.reset();
+ //Remove any previous exchange declares
+ _monitor.reset();
- createExchange("fanout");
+ _jmxUtils.createExchange("test", "fanout", null, false);
- // Validate
+ // Validate
- //1 - ID is correct
- List<String> results = _monitor.findMatches("EXH-1001");
+ //1 - ID is correct
+ List<String> results = _monitor.findMatches("EXH-1001");
- assertEquals("More than one exchange creation found", 1, results.size());
+ assertEquals("More than one exchange creation found", 1, results.size());
- String log = getLog(results.get(0));
+ String log = getLog(results.get(0));
- // Validate correct exchange name
- assertTrue("Incorrect exchange name created:" + log, log.endsWith(getName()));
+ // Validate correct exchange name
+ assertTrue("Incorrect exchange name created:" + log, log.endsWith(getName()));
- // Validate it was a management actor.
- String actor = fromActor(log);
- assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng"));
+ // Validate it was a management actor.
+ String actor = fromActor(log);
+ assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng"));
- }
}
public void testCreateExchangeHeadersTransientViaManagementConsole() throws IOException, JMException
{
- if (isExternalBroker())
- {
- //Remove any previous exchange declares
- _monitor.reset();
+ //Remove any previous exchange declares
+ _monitor.reset();
- createExchange("headers");
+ _jmxUtils.createExchange("test", "headers", null, false);
- // Validate
+ // Validate
- //1 - ID is correct
- List<String> results = _monitor.findMatches("EXH-1001");
+ //1 - ID is correct
+ List<String> results = _monitor.findMatches("EXH-1001");
- assertEquals("More than one exchange creation found", 1, results.size());
+ assertEquals("More than one exchange creation found", 1, results.size());
- String log = getLog(results.get(0));
+ String log = getLog(results.get(0));
- // Validate correct exchange name
- assertTrue("Incorrect exchange name created:" + log, log.endsWith(getName()));
+ // Validate correct exchange name
+ assertTrue("Incorrect exchange name created:" + log, log.endsWith(getName()));
- // Validate it was a management actor.
- String actor = fromActor(log);
- assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng"));
+ // Validate it was a management actor.
+ String actor = fromActor(log);
+ assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng"));
- }
}
/**
@@ -365,29 +313,26 @@ public class ManagementActorLoggingTest extends AbstractTestLogging
*/
public void testCreateQueueTransientViaManagementConsole() throws IOException, JMException
{
- if (isExternalBroker())
- {
- //Remove any previous queue declares
- _monitor.reset();
+ //Remove any previous queue declares
+ _monitor.reset();
- createQueue();
+ _jmxUtils.createQueue("test", getName(), null, false);
- // Validate
+ // Validate
- List<String> results = _monitor.findMatches("QUE-1001");
+ List<String> results = _monitor.findMatches("QUE-1001");
- assertEquals("More than one queue creation found", 1, results.size());
+ assertEquals("More than one queue creation found", 1, results.size());
- String log = getLog(results.get(0));
+ String log = getLog(results.get(0));
- // Validate correct queue name
- String subject = fromSubject(log);
- assertEquals("Incorrect queue name created", getName(), AbstractTestLogSubject.getSlice("qu", subject));
+ // Validate correct queue name
+ String subject = fromSubject(log);
+ assertEquals("Incorrect queue name created", getName(), AbstractTestLogSubject.getSlice("qu", subject));
- // Validate it was a management actor.
- String actor = fromActor(log);
- assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng"));
- }
+ // Validate it was a management actor.
+ String actor = fromActor(log);
+ assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng"));
}
/**
@@ -411,34 +356,29 @@ public class ManagementActorLoggingTest extends AbstractTestLogging
*/
public void testQueueDeleteViaManagementConsole() throws IOException, JMException
{
- if (isExternalBroker())
- {
- //Remove any previous queue declares
- _monitor.reset();
+ //Remove any previous queue declares
+ _monitor.reset();
- createQueue();
+ _jmxUtils.createQueue("test", getName(), null, false);
- ManagedBroker managedBroker = MBeanServerInvocationHandler.
- newProxyInstance(_mbsc, getVirtualHostManagerObjectName(),
- ManagedBroker.class, false);
+ ManagedBroker managedBroker = _jmxUtils.getManagedBroker("test");
- managedBroker.deleteQueue(getName());
+ managedBroker.deleteQueue(getName());
- List<String> results = _monitor.findMatches("QUE-1002");
+ List<String> results = _monitor.findMatches("QUE-1002");
- assertEquals("More than one queue deletion found", 1, results.size());
+ assertEquals("More than one queue deletion found", 1, results.size());
- String log = getLog(results.get(0));
+ String log = getLog(results.get(0));
- // Validate correct binding
- String subject = fromSubject(log);
- assertEquals("Incorrect queue named in delete", getName(), AbstractTestLogSubject.getSlice("qu", subject));
+ // Validate correct binding
+ String subject = fromSubject(log);
+ assertEquals("Incorrect queue named in delete", getName(), AbstractTestLogSubject.getSlice("qu", subject));
- // Validate it was a management actor.
- String actor = fromActor(log);
- assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng"));
+ // Validate it was a management actor.
+ String actor = fromActor(log);
+ assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng"));
- }
}
/**
@@ -462,98 +402,83 @@ public class ManagementActorLoggingTest extends AbstractTestLogging
*/
public void testBindingCreateOnDirectViaManagementConsole() throws IOException, JMException
{
- if (isExternalBroker())
- {
- //Remove any previous queue declares
- _monitor.reset();
+ //Remove any previous queue declares
+ _monitor.reset();
- createQueue();
+ _jmxUtils.createQueue("test", getName(), null, false);
- ManagedExchange managedExchange = MBeanServerInvocationHandler.
- newProxyInstance(_mbsc, getExchange("amq.direct"),
- ManagedExchange.class, false);
+ ManagedExchange managedExchange = _jmxUtils.getManagedExchange("amq.direct");
- managedExchange.createNewBinding(getName(), getName());
+ managedExchange.createNewBinding(getName(), getName());
- List<String> results = _monitor.findMatches("BND-1001");
+ List<String> results = _monitor.findMatches("BND-1001");
- assertEquals("More than one bind creation found", 1, results.size());
+ assertEquals("More than one bind creation found", 1, results.size());
- String log = getLog(results.get(0));
+ String log = getLog(results.get(0));
- // Validate correct binding
- String subject = fromSubject(log);
- assertEquals("Incorrect queue named in create", getName(), AbstractTestLogSubject.getSlice("qu", subject));
- assertEquals("Incorrect routing key in create", getName(), AbstractTestLogSubject.getSlice("rk", subject));
+ // Validate correct binding
+ String subject = fromSubject(log);
+ assertEquals("Incorrect queue named in create", getName(), AbstractTestLogSubject.getSlice("qu", subject));
+ assertEquals("Incorrect routing key in create", getName(), AbstractTestLogSubject.getSlice("rk", subject));
- // Validate it was a management actor.
- String actor = fromActor(log);
- assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng"));
- }
+ // Validate it was a management actor.
+ String actor = fromActor(log);
+ assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng"));
}
public void testBindingCreateOnTopicViaManagementConsole() throws IOException, JMException
{
- if (isExternalBroker())
- {
- //Remove any previous queue declares
- _monitor.reset();
+ //Remove any previous queue declares
+ _monitor.reset();
- createQueue();
+ _jmxUtils.createQueue("test", getName(), null, false);
- ManagedExchange managedExchange = MBeanServerInvocationHandler.
- newProxyInstance(_mbsc, getExchange("amq.topic"),
- ManagedExchange.class, false);
+ ManagedExchange managedExchange = _jmxUtils.getManagedExchange("amq.topic");
- managedExchange.createNewBinding(getName(), getName());
+ managedExchange.createNewBinding(getName(), getName());
- List<String> results = _monitor.findMatches("BND-1001");
+ List<String> results = _monitor.findMatches("BND-1001");
- assertEquals("More than one bind creation found", 1, results.size());
+ assertEquals("More than one bind creation found", 1, results.size());
- String log = getLog(results.get(0));
+ String log = getLog(results.get(0));
- // Validate correct binding
- String subject = fromSubject(log);
- assertEquals("Incorrect queue named in create", getName(), AbstractTestLogSubject.getSlice("qu", subject));
- assertEquals("Incorrect routing key in create", getName(), AbstractTestLogSubject.getSlice("rk", subject));
+ // Validate correct binding
+ String subject = fromSubject(log);
+ assertEquals("Incorrect queue named in create", getName(), AbstractTestLogSubject.getSlice("qu", subject));
+ assertEquals("Incorrect routing key in create", getName(), AbstractTestLogSubject.getSlice("rk", subject));
- // Validate it was a management actor.
- String actor = fromActor(log);
- assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng"));
- }
+ // Validate it was a management actor.
+ String actor = fromActor(log);
+ assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng"));
}
public void testBindingCreateOnFanoutViaManagementConsole() throws IOException, JMException
{
- if (isExternalBroker())
- {
- //Remove any previous queue declares
- _monitor.reset();
+ //Remove any previous queue declares
+ _monitor.reset();
- createQueue();
+ _jmxUtils.createQueue("test", getName(), null, false);
- ManagedExchange managedExchange = MBeanServerInvocationHandler.
- newProxyInstance(_mbsc, getExchange("amq.fanout"),
- ManagedExchange.class, false);
+ ManagedExchange managedExchange = _jmxUtils.getManagedExchange("amq.fanout");
- managedExchange.createNewBinding(getName(), getName());
+ managedExchange.createNewBinding(getName(), getName());
- List<String> results = _monitor.findMatches("BND-1001");
+ List<String> results = _monitor.findMatches("BND-1001");
- assertEquals("More than one bind creation found", 1, results.size());
+ assertEquals("More than one bind creation found", 1, results.size());
- String log = getLog(results.get(0));
+ String log = getLog(results.get(0));
- // Validate correct binding
- String subject = fromSubject(log);
- assertEquals("Incorrect queue named in create", getName(), AbstractTestLogSubject.getSlice("qu", subject));
- assertEquals("Incorrect routing key in create", "*", AbstractTestLogSubject.getSlice("rk", subject));
+ // Validate correct binding
+ String subject = fromSubject(log);
+ assertEquals("Incorrect queue named in create", getName(), AbstractTestLogSubject.getSlice("qu", subject));
+ assertEquals("Incorrect routing key in create", "*", AbstractTestLogSubject.getSlice("rk", subject));
- // Validate it was a management actor.
- String actor = fromActor(log);
- assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng"));
- }
+ // Validate it was a management actor.
+ String actor = fromActor(log);
+ assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng"));
}
/**
@@ -578,114 +503,28 @@ public class ManagementActorLoggingTest extends AbstractTestLogging
*/
public void testUnRegisterExchangeViaManagementConsole() throws IOException, JMException
{
- if (isExternalBroker())
- {
+ //Remove any previous queue declares
+ _monitor.reset();
- //Remove any previous queue declares
- _monitor.reset();
+ _jmxUtils.createExchange("test", "direct", null, false);
- createExchange("direct");
+ ManagedBroker managedBroker = _jmxUtils.getManagedBroker("test");
- ManagedBroker managedBroker = MBeanServerInvocationHandler.
- newProxyInstance(_mbsc, getVirtualHostManagerObjectName(),
- ManagedBroker.class, false);
+ managedBroker.unregisterExchange(getName());
- managedBroker.unregisterExchange(getName());
+ List<String> results = _monitor.findMatches("EXH-1002");
- List<String> results = _monitor.findMatches("EXH-1002");
-
- assertEquals("More than one exchange deletion found", 1, results.size());
-
- String log = getLog(results.get(0));
-
- // Validate correct binding
- String subject = fromSubject(log);
- assertEquals("Incorrect exchange named in delete", "direct/" + getName(), AbstractTestLogSubject.getSlice("ex", subject));
-
- // Validate it was a management actor.
- String actor = fromActor(log);
- assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng"));
- }
- }
-
- /**
- * Create a non-durable test exchange with the current test name
- *
- * @throws JMException - is thrown if a exchange with this testName already exists
- * @throws IOException - if there is a problem with the JMX Connection
- * @throws javax.management.MBeanException
- * - if there is another problem creating the exchange
- */
- private void createExchange(String type)
- throws JMException, IOException, MBeanException
- {
- ManagedBroker managedBroker = MBeanServerInvocationHandler.
- newProxyInstance(_mbsc, getVirtualHostManagerObjectName(),
- ManagedBroker.class, false);
-
- managedBroker.createNewExchange(getName(), type, false);
- }
-
- /**
- * Create a non-durable queue (with no owner) that is named after the
- * creating test.
- *
- * @throws JMException - is thrown if a queue with this testName already exists
- * @throws IOException - if there is a problem with the JMX Connection
- */
- private void createQueue()
- throws JMException, IOException
- {
- ManagedBroker managedBroker = MBeanServerInvocationHandler.
- newProxyInstance(_mbsc, getVirtualHostManagerObjectName(),
- ManagedBroker.class, false);
-
- managedBroker.createNewQueue(getName(), null, false);
- }
-
- /**
- * Retrive the ObjectName for the test Virtualhost.
- *
- * This is then use to create aproxy to the ManagedBroker MBean.
- *
- * @return the ObjectName for the 'test' VirtualHost.
- */
- private ObjectName getVirtualHostManagerObjectName()
- {
- // Get the name of the test manager
- AllObjects allObject = new AllObjects(_mbsc);
- allObject.querystring = "org.apache.qpid:type=VirtualHost.VirtualHostManager,VirtualHost=test,*";
-
- Set<ObjectName> objectNames = allObject.returnObjects();
-
- assertEquals("Incorrect number test vhosts returned", 1, objectNames.size());
-
- // We have verified we have only one value in objectNames so return it
- return objectNames.iterator().next();
- }
-
- /**
- * Retrive the ObjectName for the given Exchange on the test Virtualhost.
- *
- * This is then use to create aproxy to the ManagedExchange MBean.
- *
- * @param exchange The exchange to retireve e.g. 'direct'
- *
- * @return the ObjectName for the given exchange on the test VirtualHost.
- */
- private ObjectName getExchange(String exchange)
- {
- // Get the name of the test manager
- AllObjects allObject = new AllObjects(_mbsc);
- allObject.querystring = "org.apache.qpid:type=VirtualHost.Exchange,VirtualHost=test,name=" + exchange + ",*";
+ assertEquals("More than one exchange deletion found", 1, results.size());
- Set<ObjectName> objectNames = allObject.returnObjects();
+ String log = getLog(results.get(0));
- assertEquals("Incorrect number of exchange with name '" + exchange +
- "' returned", 1, objectNames.size());
+ // Validate correct binding
+ String subject = fromSubject(log);
+ assertEquals("Incorrect exchange named in delete", "direct/" + getName(), AbstractTestLogSubject.getSlice("ex", subject));
- // We have verified we have only one value in objectNames so return it
- return objectNames.iterator().next();
+ // Validate it was a management actor.
+ String actor = fromActor(log);
+ assertTrue("Actor is not a manangement actor:" + actor, actor.startsWith("mng"));
}
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java
index c4803e121e..0a88ef391c 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java
@@ -40,6 +40,8 @@ public class ServerConfigurationFileTest extends QpidTestCase
{
fail("Unable to test without config file:" + _configFile);
}
+
+ saveTestConfiguration();
_serverConfig = new ServerConfiguration(_configFile);
}
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 620b2a5161..683abee4da 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
@@ -94,7 +94,7 @@ public class AlertingTest extends AbstractTestLogging
{
_connection = getConnection();
_session = _connection.createSession(true, Session.SESSION_TRANSACTED);
- _destination = _session.createQueue("testQueue");
+ _destination = _session.createQueue(getTestQueueName());
// Consumer is only used to actually create the destination
_session.createConsumer(_destination).close();
@@ -116,14 +116,12 @@ public class AlertingTest extends AbstractTestLogging
// Add the current contents of the log file to test output
message.append(_monitor.readFile());
- // Write the server config file to test output
- message.append("Server configuration file in use:\n");
- message.append(FileUtils.readFileAsString(_configFile));
+ // Write the test config file to test output
+ message.append("Server configuration overrides in use:\n");
+ message.append(FileUtils.readFileAsString(getTestConfigFile()));
- // Write the virtualhost config file to test output
- message.append("\nVirtualhost configuration file in use:\n");
- message.append(FileUtils.readFileAsString(ServerConfiguration.
- flatConfig(_configFile).getString("virtualhosts")));
+ message.append("\nVirtualhost maxMessageCount:\n");
+ message.append((new ServerConfiguration(_configFile)).getConfig().getString("virtualhosts.virtualhost." + VIRTUALHOST + ".queues.maximumMessageCount"));
fail(message.toString());
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java
index 254ec9693d..cc3993249c 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java
@@ -28,6 +28,7 @@ import javax.jms.Connection;
import javax.jms.Queue;
import javax.jms.Session;
import java.util.List;
+import java.io.File;
/**
* The MessageStore test suite validates that the follow log messages as
@@ -56,9 +57,9 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest
//We call super.setUp but this will not start the broker as that is
//part of the test case.
- // Load current configuration file to get the list of defined vhosts
- Configuration configuration = ServerConfiguration.flatConfig(_configFile);
- List<String> vhosts = configuration.getList("virtualhosts.virtualhost.name");
+ // Load the default configuration file to get the list of defined vhosts
+ ServerConfiguration configuration = new ServerConfiguration(new File(_configFile.getParent() + "/config.xml"));
+ List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
// Make them all persistent i.e. Use DerbyMessageStore and
// test that it logs correctly.
@@ -97,8 +98,8 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest
assertTrue("MST messages not logged", results.size() > 0);
// Load VirtualHost list from file.
- Configuration configuration = ServerConfiguration.flatConfig(_configFile);
- List<String> vhosts = configuration.getList("virtualhosts.virtualhost.name");
+ ServerConfiguration configuration = new ServerConfiguration(_configFile);
+ List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
//Validate each vhost logs a creation
results = _monitor.findMatches("MST-1002");
@@ -117,7 +118,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest
// the virtualhost name, found above. AND
// the index that the virtualhost is within the configuration.
// we can retrive that from the vhosts list previously extracted.
- String fullStoreName = configuration.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
+ String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
// Get the Simple class name from the expected class name of o.a.q.s.s.MMS
String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
@@ -160,8 +161,8 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest
assertTrue("MST messages not logged", results.size() > 0);
// Load VirtualHost list from file.
- Configuration configuration = ServerConfiguration.flatConfig(_configFile);
- List<String> vhosts = configuration.getList("virtualhosts.virtualhost.name");
+ ServerConfiguration configuration = new ServerConfiguration(_configFile);
+ List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
//Validate each vhost logs a creation
results = _monitor.findMatches("MST-1004");
@@ -186,7 +187,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest
// the virtualhost name, found above. AND
// the index that the virtualhost is within the configuration.
// we can retrive that from the vhosts list previously extracted.
- String fullStoreName = configuration.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
+ String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
// Get the Simple class name from the expected class name of o.a.q.s.s.MMS
String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
@@ -227,8 +228,8 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest
assertTrue("MST messages not logged", results.size() > 0);
// Load VirtualHost list from file.
- Configuration configuration = ServerConfiguration.flatConfig(_configFile);
- List<String> vhosts = configuration.getList("virtualhosts.virtualhost.name");
+ ServerConfiguration configuration = new ServerConfiguration(_configFile);
+ List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
//Validate each vhost logs a creation
results = _monitor.findMatches("MST-1006");
@@ -253,7 +254,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest
// the virtualhost name, found above. AND
// the index that the virtualhost is within the configuration.
// we can retrive that from the vhosts list previously extracted.
- String fullStoreName = configuration.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
+ String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
// Get the Simple class name from the expected class name of o.a.q.s.s.MMS
String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
@@ -293,8 +294,8 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest
assertTrue("MST messages not logged", results.size() > 0);
// Load VirtualHost list from file.
- Configuration configuration = ServerConfiguration.flatConfig(_configFile);
- List<String> vhosts = configuration.getList("virtualhosts.virtualhost.name");
+ ServerConfiguration configuration = new ServerConfiguration(_configFile);
+ List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
//Validate each vhost logs a creation
results = _monitor.findMatches("MST-1004 : Recovery Start :");
@@ -316,7 +317,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest
// the virtualhost name, found above. AND
// the index that the virtualhost is within the configuration.
// we can retrive that from the vhosts list previously extracted.
- String fullStoreName = configuration.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
+ String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
// Get the Simple class name from the expected class name of o.a.q.s.s.MMS
String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
@@ -358,8 +359,8 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest
assertTrue("MST messages not logged", results.size() > 0);
// Load VirtualHost list from file.
- Configuration configuration = ServerConfiguration.flatConfig(_configFile);
- List<String> vhosts = configuration.getList("virtualhosts.virtualhost.name");
+ ServerConfiguration configuration = new ServerConfiguration(_configFile);
+ List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
//Validate each vhost logs a creation
results = _monitor.findMatches("MST-1006 : Recovery Complete :");
@@ -381,7 +382,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest
// the virtualhost name, found above. AND
// the index that the virtualhost is within the configuration.
// we can retrive that from the vhosts list previously extracted.
- String fullStoreName = configuration.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
+ String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
// Get the Simple class name from the expected class name of o.a.q.s.s.MMS
String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
@@ -500,8 +501,8 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest
assertTrue("MST messages not logged", results.size() > 0);
// Load VirtualHost list from file.
- Configuration configuration = ServerConfiguration.flatConfig(_configFile);
- List<String> vhosts = configuration.getList("virtualhosts.virtualhost.name");
+ ServerConfiguration configuration = new ServerConfiguration(_configFile);
+ List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
//Validate each vhost logs a creation
results = _monitor.findMatches("MST-1004 : Recovery Start : " + queueName);
@@ -542,7 +543,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest
// the virtualhost name, found above. AND
// the index that the virtualhost is within the configuration.
// we can retrive that from the vhosts list previously extracted.
- String fullStoreName = configuration.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
+ String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
// Get the Simple class name from the expected class name of o.a.q.s.s.MMS
String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
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 11c003a2a7..8b7c881a32 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
@@ -24,6 +24,7 @@ import junit.framework.AssertionFailedError;
import org.apache.qpid.util.LogMonitor;
import java.util.List;
+import java.io.File;
/**
* Management Console Test Suite
@@ -308,9 +309,8 @@ public class ManagementLoggingTest extends AbstractTestLogging
// We expect the RMIConnector Server port to be 100 higher than
// the RMI Server Port
- int mPort = getPort() + (DEFAULT_MANAGEMENT_PORT - DEFAULT_PORT) + 100;
- assertTrue("SSL Keystore entry expected(" + mPort + ").:" + getMessageString(log),
- getMessageString(log).endsWith(getConfigurationStringProperty("management.ssl.keyStorePath")));
+ assertTrue("SSL Keystore entry expected.:" + getMessageString(log),
+ getMessageString(log).endsWith(new File(getConfigurationStringProperty("management.ssl.keyStorePath")).getName()));
}
catch (AssertionFailedError afe)
{
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java
index a1cbeca6de..2298ba4da0 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java
@@ -89,8 +89,8 @@ public class MemoryMessageStoreLoggingTest extends AbstractTestLogging
assertEquals("MST-1001 is not the first MST message", "MST-1001", getMessageID(fromMessage(log)));
// Load VirtualHost list from file.
- Configuration configuration = ServerConfiguration.flatConfig(_configFile);
- List<String> vhosts = configuration.getList("virtualhosts.virtualhost.name");
+ ServerConfiguration configuration = new ServerConfiguration(_configFile);
+ List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
//Validate each vhost logs a creation
results = _monitor.findMatches("MST-1001");
@@ -109,7 +109,7 @@ public class MemoryMessageStoreLoggingTest extends AbstractTestLogging
// the virtualhost name, found above. AND
// the index that the virtualhost is within the configuration.
// we can retrive that from the vhosts list previously extracted.
- String fullStoreName = configuration.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
+ String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
// Get the Simple class name from the expected class name of o.a.q.s.s.MMS
String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
@@ -156,8 +156,8 @@ public class MemoryMessageStoreLoggingTest extends AbstractTestLogging
assertTrue("MST messages not logged", results.size() > 0);
// Load VirtualHost list from file.
- Configuration configuration = ServerConfiguration.flatConfig(_configFile);
- List<String> vhosts = configuration.getList("virtualhosts.virtualhost.name");
+ ServerConfiguration configuration = new ServerConfiguration(_configFile);
+ List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
//Validate each vhost logs a creation
results = _monitor.findMatches("MST-1003");
@@ -176,7 +176,7 @@ public class MemoryMessageStoreLoggingTest extends AbstractTestLogging
// the virtualhost name, found above. AND
// the index that the virtualhost is within the configuration.
// we can retrive that from the vhosts list previously extracted.
- String fullStoreName = configuration.getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
+ String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
// Get the Simple class name from the expected class name of o.a.q.s.s.MMS
String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java
index 7bf644508e..f4a0c8b27d 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java
@@ -64,8 +64,8 @@ public class VirtualHostLoggingTest extends AbstractTestLogging
try
{
// Validation
- Configuration configuration = ServerConfiguration.flatConfig(_configFile);
- List<String> vhosts = configuration.getList("virtualhosts.virtualhost.name");
+ ServerConfiguration configuration = new ServerConfiguration(_configFile);
+ List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
//Validate each vhost logs a creation
results = _monitor.findMatches("VHT-1001");
@@ -117,8 +117,8 @@ public class VirtualHostLoggingTest extends AbstractTestLogging
{
// Validation
- Configuration configuration = ServerConfiguration.flatConfig(_configFile);
- List<String> vhosts = configuration.getList("virtualhosts.virtualhost.name");
+ ServerConfiguration configuration = new ServerConfiguration(_configFile);
+ List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
//Validate each vhost logs a creation
results = _monitor.findMatches("VHT-1002");
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/ModelTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/ModelTest.java
new file mode 100644
index 0000000000..078b8f43ce
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/ModelTest.java
@@ -0,0 +1,299 @@
+/*
+ *
+ * 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.server.queue;
+
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.management.common.mbeans.ManagedBroker;
+import org.apache.qpid.management.common.mbeans.ManagedQueue;
+import org.apache.qpid.test.utils.JMXTestUtils;
+import org.apache.qpid.test.utils.QpidTestCase;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.Session;
+import javax.management.JMException;
+import javax.management.MBeanException;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.UndeclaredThrowableException;
+
+/**
+ * This Test validates the Queue Model on the broker.
+ * Currently it has some basic queue creation / deletion tests.
+ * However, it should be expanded to include other tests that relate to the
+ * model. i.e.
+ *
+ * The Create and Delete tests should ensure that the requisite logging is
+ * performed.
+ *
+ * Additions to this suite would be to complete testing of creations, validating
+ * fields such as owner/exclusive, autodelete and priority are correctly set.
+ *
+ * Currently this test uses the JMX interface to validate that the queue has
+ * been declared as expected so these tests cannot run against a CPP broker.
+ *
+ *
+ * Tests should ensure that they clean up after themselves.
+ * e,g. Durable queue creation test should perform a queue delete.
+ */
+public class ModelTest extends QpidTestCase
+{
+
+ private static final String USER = "admin";
+ private JMXTestUtils _jmxUtils;
+ private static final String VIRTUALHOST_NAME = "test";
+
+ @Override
+ public void setUp() throws Exception
+ {
+ // Create a JMX Helper
+ _jmxUtils = new JMXTestUtils(this, USER, USER);
+ _jmxUtils.setUp();
+ super.setUp();
+
+ // Open the JMX Connection
+ _jmxUtils.open();
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ // Close the JMX Connection
+ _jmxUtils.close();
+ super.tearDown();
+ }
+
+ /**
+ * Test that a transient queue can be created via AMQP.
+ *
+ * @throws Exception On unexpected error
+ */
+ public void testQueueCreationTransientViaAMQP() throws Exception
+ {
+ Connection connection = getConnection();
+
+ String queueName = getTestQueueName();
+ boolean durable = false;
+ boolean autoDelete = false;
+ boolean exclusive = false;
+
+ createViaAMQPandValidateViaJMX(connection, queueName, durable,
+ autoDelete, exclusive);
+ }
+
+ /**
+ * Test that a durable queue can be created via AMQP.
+ *
+ * @throws Exception On unexpected error
+ */
+
+ public void testQueueCreationDurableViaAMQP() throws Exception
+ {
+ Connection connection = getConnection();
+
+ String queueName = getTestQueueName();
+ boolean durable = true;
+ boolean autoDelete = false;
+ boolean exclusive = false;
+
+ createViaAMQPandValidateViaJMX(connection, queueName, durable,
+ autoDelete, exclusive);
+
+ // Clean up
+ ManagedBroker managedBroker =
+ _jmxUtils.getManagedBroker(VIRTUALHOST_NAME);
+ managedBroker.deleteQueue(queueName);
+ }
+
+ /**
+ * Test that a transient queue can be created via JMX.
+ *
+ * @throws IOException if there is a problem via the JMX connection
+ * @throws javax.management.JMException if there is a problem with the JMX command
+ */
+ public void testCreationTransientViaJMX() throws IOException, JMException
+ {
+ String name = getName();
+ String owner = null;
+ boolean durable = false;
+
+ createViaJMXandValidateViaJMX(name, owner, durable, durable);
+ }
+
+ /**
+ * Test that a durable queue can be created via JMX.
+ *
+ * @throws IOException if there is a problem via the JMX connection
+ * @throws javax.management.JMException if there is a problem with the JMX command
+ */
+ public void testCreationDurableViaJMX() throws IOException, JMException
+ {
+ String name = getName();
+ String owner = null;
+ boolean durable = true;
+
+ createViaJMXandValidateViaJMX(name, owner, durable, durable);
+
+ // Clean up
+ ManagedBroker managedBroker =
+ _jmxUtils.getManagedBroker(VIRTUALHOST_NAME);
+ managedBroker.deleteQueue(name);
+ }
+
+ /**
+ * Test that a transient queue can be deleted via JMX.
+ *
+ * @throws IOException if there is a problem via the JMX connection
+ * @throws javax.management.JMException if there is a problem with the JMX command
+ */
+ public void testDeletionTransientViaJMX() throws IOException, JMException
+ {
+ String name = getName();
+
+ _jmxUtils.createQueue(VIRTUALHOST_NAME, name, null, false);
+
+ ManagedBroker managedBroker = _jmxUtils.
+ getManagedBroker(VIRTUALHOST_NAME);
+
+ try
+ {
+ managedBroker.deleteQueue(name);
+ }
+ catch (UndeclaredThrowableException e)
+ {
+ fail(((MBeanException) ((InvocationTargetException)
+ e.getUndeclaredThrowable()).getTargetException()).getTargetException().getMessage());
+ }
+ }
+
+ /**
+ * Test that a durable queue can be created via JMX.
+ *
+ * @throws IOException if there is a problem via the JMX connection
+ * @throws javax.management.JMException if there is a problem with the JMX command
+ */
+ public void testDeletionDurableViaJMX() throws IOException, JMException
+ {
+ String name = getName();
+
+ _jmxUtils.createQueue(VIRTUALHOST_NAME, name, null, true);
+
+ ManagedBroker managedBroker = _jmxUtils.
+ getManagedBroker(VIRTUALHOST_NAME);
+
+ try
+ {
+ managedBroker.deleteQueue(name);
+ }
+ catch (UndeclaredThrowableException e)
+ {
+ fail(((MBeanException) ((InvocationTargetException)
+ e.getUndeclaredThrowable()).getTargetException()).getTargetException().getMessage());
+ }
+ }
+
+ /*
+ * Helper Methods
+ */
+
+ /**
+ * Using the provided JMS Connection create a queue using the AMQP extension
+ * with the given properties and then validate it was created correctly via
+ * the JMX Connection
+ *
+ * @param connection Qpid JMS Connection
+ * @param queueName String the desired QueueName
+ * @param durable boolean if the queue should be durable
+ * @param autoDelete boolean if the queue is an autoDelete queue
+ * @param exclusive boolean if the queue is exclusive
+ *
+ * @throws AMQException if there is a problem with the createQueue call
+ * @throws JMException if there is a problem with the JMX validatation
+ * @throws IOException if there is a problem with the JMX connection
+ * @throws JMSException if there is a problem creating the JMS Session
+ */
+ private void createViaAMQPandValidateViaJMX(Connection connection,
+ String queueName,
+ boolean durable,
+ boolean autoDelete,
+ boolean exclusive)
+ throws AMQException, JMException, IOException, JMSException
+ {
+ AMQSession session = (AMQSession) connection.createSession(false,
+ Session.AUTO_ACKNOWLEDGE);
+
+ session.createQueue(new AMQShortString(queueName),
+ autoDelete, durable, exclusive);
+
+ validateQueueViaJMX(queueName, exclusive ? ((AMQConnection) connection).
+ getUsername() : null, durable, autoDelete);
+ }
+
+ /**
+ * Use the JMX Helper to create a queue with the given properties and then
+ * validate it was created correctly via the JMX Connection
+ *
+ * @param queueName String the desired QueueName
+ * @param owner String the owner value that should be set
+ * @param durable boolean if the queue should be durable
+ * @param autoDelete boolean if the queue is an autoDelete queue
+ *
+ * @throws JMException if there is a problem with the JMX validatation
+ * @throws IOException if there is a problem with the JMX connection
+ */
+ private void createViaJMXandValidateViaJMX(String queueName, String owner,
+ boolean durable, boolean autoDelete)
+ throws JMException, IOException
+ {
+ _jmxUtils.createQueue(VIRTUALHOST_NAME, queueName, owner, durable);
+
+ validateQueueViaJMX(queueName, owner, durable, autoDelete);
+ }
+
+ /**
+ * Validate that a queue with the given properties exists on the broker
+ *
+ * @param queueName String the desired QueueName
+ * @param owner String the owner value that should be set
+ * @param durable boolean if the queue should be durable
+ * @param autoDelete boolean if the queue is an autoDelete queue
+ *
+ * @throws JMException if there is a problem with the JMX validatation
+ * @throws IOException if there is a problem with the JMX connection
+ */
+ private void validateQueueViaJMX(String queueName, String owner, boolean durable, boolean autoDelete)
+ throws JMException, IOException
+ {
+ ManagedQueue managedQueue = _jmxUtils.
+ getManagedObject(ManagedQueue.class,
+ _jmxUtils.getQueueObjectName(VIRTUALHOST_NAME,
+ queueName));
+
+ assertEquals(queueName, managedQueue.getName());
+ assertEquals(String.valueOf(owner), managedQueue.getOwner());
+ assertEquals(durable, managedQueue.isDurable());
+ assertEquals(autoDelete, managedQueue.isAutoDelete());
+ }
+
+}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/SimpleACLTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/SimpleACLTest.java
index f402522a19..bb7b5efc75 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/SimpleACLTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/SimpleACLTest.java
@@ -21,6 +21,7 @@
package org.apache.qpid.server.security.acl;
+
import junit.framework.TestCase;
import org.apache.log4j.BasicConfigurator;
@@ -30,6 +31,7 @@ import org.apache.qpid.client.*;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry;
+import org.apache.qpid.AMQConnectionFailureException;
import org.apache.qpid.AMQException;
import org.apache.qpid.test.utils.QpidTestCase;
import org.apache.qpid.jms.ConnectionListener;
@@ -37,6 +39,7 @@ import org.apache.qpid.url.URLSyntaxException;
import javax.jms.*;
import javax.jms.IllegalStateException;
+import javax.naming.NamingException;
import java.io.File;
import java.util.ArrayList;
@@ -51,46 +54,30 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E
public void setUp() throws Exception
{
- //Shutdown the QTC broker
- stopBroker();
-
- // Initialise ACLs.
- final String QpidExampleHome = System.getProperty("QPID_EXAMPLE_HOME");
- final File defaultaclConfigFile = new File(QpidExampleHome, "etc/acl.config.xml");
-
- if (!defaultaclConfigFile.exists())
- {
- System.err.println("Configuration file not found:" + defaultaclConfigFile);
- fail("Configuration file not found:" + defaultaclConfigFile);
- }
+ final String QPID_HOME = System.getProperty("QPID_HOME");
- if (System.getProperty("QPID_HOME") == null)
+ if (QPID_HOME == null)
{
fail("QPID_HOME not set");
}
- ConfigurationFileApplicationRegistry config = new ConfigurationFileApplicationRegistry(defaultaclConfigFile);
- ApplicationRegistry.initialise(config, ApplicationRegistry.DEFAULT_INSTANCE);
- TransportConnection.createVMBroker(ApplicationRegistry.DEFAULT_INSTANCE);
- }
+ // Initialise ACLs.
+ _configFile = new File(QPID_HOME, "etc/config-systests-acl.xml");
- public void tearDown()
- {
- TransportConnection.killVMBroker(ApplicationRegistry.DEFAULT_INSTANCE);
- ApplicationRegistry.remove(ApplicationRegistry.DEFAULT_INSTANCE);
+ super.setUp();
}
- public String createConnectionString(String username, String password, String broker)
+ public String createConnectionString(String username, String password)
{
- return "amqp://" + username + ":" + password + "@clientid/test?brokerlist='" + broker + "?retries='0''";
+ return "amqp://" + username + ":" + password + "@clientid/test?brokerlist='" + getBroker() + "?retries='0''";
}
public void testAccessAuthorized() throws AMQException, URLSyntaxException
{
try
{
- Connection conn = createConnection("client", "guest");
+ Connection conn = getConnection("client", "guest");
Session sesh = conn.createSession(true, Session.SESSION_TRANSACTED);
@@ -103,28 +90,32 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E
}
catch (Exception e)
{
- fail("Connection was not created due to:" + e.getMessage());
+ fail("Connection was not created due to:" + e);
}
}
- public void testAccessNoRights() throws URLSyntaxException, JMSException
+ public void testAccessNoRights() throws Exception
{
try
{
- Connection conn = createConnection("guest", "guest");
+ Connection conn = getConnection("guest", "guest");
//Attempt to do do things to test connection.
Session sesh = conn.createSession(true, Session.SESSION_TRANSACTED);
conn.start();
sesh.rollback();
- conn.close();
fail("Connection was created.");
}
- catch (AMQException amqe)
+ catch (JMSException jmse)
{
- Throwable cause = amqe.getCause();
- assertEquals("Exception was wrong type", AMQAuthenticationException.class, cause.getClass());
+ Throwable linkedException = jmse.getLinkedException();
+ assertNotNull("Cause was null", linkedException);
+
+ assertEquals("Linked Exception was wrong type", AMQConnectionFailureException.class, linkedException.getClass());
+
+ Throwable cause = linkedException.getCause();
+ assertEquals("Cause was wrong type", AMQAuthenticationException.class, cause.getClass());
assertEquals("Incorrect error code thrown", 403, ((AMQAuthenticationException) cause).getErrorCode().getCode());
}
}
@@ -133,7 +124,7 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E
{
try
{
- Connection conn = createConnection("client", "guest");
+ Connection conn = getConnection("client", "guest");
Session sesh = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -149,11 +140,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E
}
}
- public void testClientConsumeFromNamedQueueInvalid() throws AMQException, URLSyntaxException
+ public void testClientConsumeFromNamedQueueInvalid() throws NamingException, Exception
{
try
{
- Connection conn = createConnection("client", "guest");
+ Connection conn = getConnection("client", "guest");
//Prevent Failover
((AMQConnection) conn).setConnectionListener(this);
@@ -180,7 +171,7 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E
{
try
{
- Connection conn = createConnection("client", "guest");
+ Connection conn = getConnection("client", "guest");
Session sesh = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -198,11 +189,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E
}
}
- public void testClientCreateNamedQueue() throws JMSException, URLSyntaxException, AMQException
+ public void testClientCreateNamedQueue() throws NamingException, JMSException, AMQException, Exception
{
try
{
- Connection conn = createConnection("client", "guest");
+ Connection conn = getConnection("client", "guest");
Session sesh = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -216,6 +207,7 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E
}
catch (AMQAuthenticationException amqe)
{
+ amqe.printStackTrace();
assertEquals("Incorrect error code thrown", 403, ((AMQAuthenticationException) amqe).getErrorCode().getCode());
}
}
@@ -224,7 +216,7 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E
{
try
{
- Connection conn = createConnection("client", "guest");
+ Connection conn = getConnection("client", "guest");
((AMQConnection) conn).setConnectionListener(this);
@@ -251,7 +243,7 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E
{
try
{
- Connection conn = createConnection("client", "guest");
+ Connection conn = getConnection("client", "guest");
((AMQConnection) conn).setConnectionListener(this);
@@ -277,11 +269,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E
}
}
- public void testClientPublishInvalidQueueSuccess() throws AMQException, URLSyntaxException, JMSException, InterruptedException
+ public void testClientPublishInvalidQueueSuccess() throws AMQException, URLSyntaxException, JMSException, NamingException, Exception
{
try
{
- Connection conn = createConnection("client", "guest");
+ Connection conn = getConnection("client", "guest");
((AMQConnection) conn).setConnectionListener(this);
@@ -323,7 +315,7 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E
{
try
{
- Connection conn = createConnection("server", "guest");
+ Connection conn = getConnection("server", "guest");
Session sesh = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -339,11 +331,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E
}
}
- public void testServerConsumeFromNamedQueueInvalid() throws AMQException, URLSyntaxException
+ public void testServerConsumeFromNamedQueueInvalid() throws AMQException, URLSyntaxException, NamingException, Exception
{
try
- {
- Connection conn = createConnection("client", "guest");
+ {
+ Connection conn = getConnection("client", "guest");
Session sesh = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -364,11 +356,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E
}
}
- public void testServerConsumeFromTemporaryQueue() throws AMQException, URLSyntaxException
+ public void testServerConsumeFromTemporaryQueue() throws AMQException, URLSyntaxException, NamingException, Exception
{
try
{
- Connection conn = createConnection("server","guest");
+ Connection conn = getConnection("server", "guest");
Session sesh = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -388,30 +380,22 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E
}
}
- private Connection createConnection(String username, String password) throws AMQException
+ @Override
+ public Connection getConnection(String username, String password) throws NamingException, JMSException
{
- AMQConnection connection = null;
- try
- {
- connection = new AMQConnection(createConnectionString(username, password, BROKER));
- }
- catch (URLSyntaxException e)
- {
- // This should never happen as we generate the URLs.
- fail(e.getMessage());
- }
+ AMQConnection connection = (AMQConnection) super.getConnection(username, password);
//Prevent Failover
connection.setConnectionListener(this);
- return (Connection)connection;
+ return (Connection) connection;
}
public void testServerCreateNamedQueueValid() throws JMSException, URLSyntaxException
{
try
{
- Connection conn = createConnection("server", "guest");
+ Connection conn = getConnection("server", "guest");
Session sesh = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -428,11 +412,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E
}
}
- public void testServerCreateNamedQueueInvalid() throws JMSException, URLSyntaxException, AMQException
+ public void testServerCreateNamedQueueInvalid() throws JMSException, URLSyntaxException, AMQException, NamingException, Exception
{
try
{
- Connection conn = createConnection("server", "guest");
+ Connection conn = getConnection("server", "guest");
Session sesh = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -450,18 +434,18 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E
}
}
- public void testServerCreateTemporaryQueueInvalid() throws JMSException, URLSyntaxException, AMQException
+ public void testServerCreateTemporaryQueueInvalid() throws NamingException, Exception
{
try
{
- Connection conn = createConnection("server", "guest");
+ Connection conn = getConnection("server", "guest");
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
conn.start();
session.createTemporaryQueue();
-
+
fail("Test failed as creation succeded.");
//conn will be automatically closed
}
@@ -475,19 +459,19 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E
}
}
- public void testServerCreateAutoDeleteQueueInvalid() throws JMSException, URLSyntaxException, AMQException
+ public void testServerCreateAutoDeleteQueueInvalid() throws NamingException, JMSException, AMQException, Exception
{
Connection connection = null;
try
{
- connection = createConnection("server", "guest");
+ connection = getConnection("server", "guest");
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
connection.start();
((AMQSession) session).createQueue(new AMQShortString("again_ensure_auto_delete_queue_for_temporary"),
- true, false, false);
+ true, false, false);
fail("Test failed as creation succeded.");
//connection will be automatically closed
@@ -495,7 +479,7 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E
catch (AMQAuthenticationException amqe)
{
assertEquals("Incorrect error code thrown", 403, amqe.getErrorCode().getCode());
- }
+ }
}
/**
@@ -506,10 +490,10 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E
* @throws URLSyntaxException
* @throws JMSException
*/
- public void testServerPublishUsingTransactionSuccess() throws AMQException, URLSyntaxException, JMSException
+ public void testServerPublishUsingTransactionSuccess() throws AMQException, URLSyntaxException, JMSException, NamingException, Exception
{
//Set up the Server
- Connection serverConnection = createConnection("server", "guest");
+ Connection serverConnection = getConnection("server", "guest");
((AMQConnection) serverConnection).setConnectionListener(this);
@@ -522,7 +506,7 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E
serverConnection.start();
//Set up the consumer
- Connection clientConnection = createConnection("client", "guest");
+ Connection clientConnection = getConnection("client", "guest");
//Send a test mesage
Session clientSession = clientConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -563,8 +547,6 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E
//Send the message using a transaction as this will allow us to retrieve any errors that occur on the broker.
serverSession.commit();
-
-
//Ensure Response is received.
Message clientResponseMsg = clientResponse.receive(2000);
assertNotNull("Client did not receive response message,", clientResponseMsg);
@@ -588,11 +570,11 @@ public class SimpleACLTest extends QpidTestCase implements ConnectionListener, E
}
}
- public void testServerPublishInvalidQueueSuccess() throws AMQException, URLSyntaxException, JMSException
+ public void testServerPublishInvalidQueueSuccess() throws AMQException, URLSyntaxException, JMSException, NamingException, Exception
{
try
{
- Connection conn = createConnection("server", "guest");
+ Connection conn = getConnection("server", "guest");
((AMQConnection) conn).setConnectionListener(this);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java
index b13170efc9..a123fb290c 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java
@@ -57,26 +57,13 @@ public class SyncWaitDelayTest extends QpidTestCase
public void setUp() throws Exception
{
- super.setUp();
- stopBroker();
- if (!_configFile.exists())
- {
- fail("Unable to test without config file:" + _configFile);
- }
- XMLConfiguration configuration = new XMLConfiguration(_configFile);
- configuration.setProperty("virtualhosts.virtualhost." + VIRTUALHOST+".store.class", "org.apache.qpid.server.store.SlowMessageStore");
- configuration.setProperty("virtualhosts.virtualhost." + VIRTUALHOST+".store.delays.commitTran.post", POST_COMMIT_DELAY);
- configuration.setProperty("management.enabled", "false");
+ setConfigurationProperty("virtualhosts.virtualhost." + VIRTUALHOST+".store.class", "org.apache.qpid.server.store.SlowMessageStore");
+ setConfigurationProperty("virtualhosts.virtualhost." + VIRTUALHOST+".store.delays.commitTran.post", String.valueOf(POST_COMMIT_DELAY));
+ setConfigurationProperty("management.enabled", "false");
- File tmpFile = File.createTempFile("configFile", "test");
- tmpFile.deleteOnExit();
- configuration.save(tmpFile);
-
- _configFile = tmpFile;
-
- startBroker(1);
+ super.setUp();
//Set the syncWrite timeout to be just larger than the delay on the commitTran.
setSystemProperty("amqj.default_syncwrite_timeout", String.valueOf(SYNC_WRITE_TIMEOUT));
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/FailoverBaseCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/FailoverBaseCase.java
index 1bef07fcd5..64bd1503ba 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/FailoverBaseCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/FailoverBaseCase.java
@@ -21,6 +21,8 @@
package org.apache.qpid.test.utils;
import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.naming.NamingException;
import org.apache.qpid.util.FileUtils;
@@ -64,7 +66,7 @@ public class FailoverBaseCase extends QpidTestCase
* @return a connection
* @throws Exception
*/
- public Connection getConnection() throws Exception
+ public Connection getConnection() throws JMSException, NamingException
{
Connection conn =
(Boolean.getBoolean("profile.use_ssl"))?
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/JMXTestUtils.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/JMXTestUtils.java
new file mode 100644
index 0000000000..3f8cdb9c25
--- /dev/null
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/JMXTestUtils.java
@@ -0,0 +1,208 @@
+/*
+ *
+ * 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;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.qpid.commands.objects.AllObjects;
+import org.apache.qpid.management.common.JMXConnnectionFactory;
+import org.apache.qpid.management.common.mbeans.ManagedBroker;
+import org.apache.qpid.management.common.mbeans.ManagedExchange;
+
+import javax.management.JMException;
+import javax.management.MBeanException;
+import javax.management.MBeanServerConnection;
+import javax.management.MBeanServerInvocationHandler;
+import javax.management.ObjectName;
+import javax.management.remote.JMXConnector;
+import java.io.IOException;
+import java.util.Set;
+
+/**
+ *
+ */
+public class JMXTestUtils
+{
+ QpidTestCase _test;
+ MBeanServerConnection _mbsc;
+ JMXConnector _jmxc;
+
+ private String USER;
+ private String PASSWORD;
+
+ public JMXTestUtils(QpidTestCase test, String user, String password)
+ {
+ _test = test;
+ USER = user;
+ PASSWORD = password;
+ }
+
+ public void setUp() throws IOException, ConfigurationException, Exception
+ {
+ _test.setConfigurationProperty("management.enabled", "true");
+ }
+
+ public void open() throws Exception
+ {
+ _jmxc = JMXConnnectionFactory.getJMXConnection(
+ 5000, "127.0.0.1",
+ _test.getManagementPort(_test.getPort()), USER, PASSWORD);
+
+ _mbsc = _jmxc.getMBeanServerConnection();
+ }
+
+ public void close() throws IOException
+ {
+ _jmxc.close();
+ }
+
+ /**
+ * Create a non-durable test exchange with the current test name
+ *
+ * @throws javax.management.JMException - is thrown if a exchange with this testName already exists
+ * @throws java.io.IOException - if there is a problem with the JMX Connection
+ * @throws javax.management.MBeanException
+ * - if there is another problem creating the exchange
+ */
+ public void createExchange(String virtualHostName, String name, String type, boolean durable)
+ throws JMException, IOException, MBeanException
+ {
+ ManagedBroker managedBroker = getManagedBroker(virtualHostName);
+
+ managedBroker.createNewExchange(name, type, durable);
+ }
+
+ /**
+ * Create a non-durable queue (with no owner) that is named after the
+ * creating test.
+ *
+ * @throws JMException - is thrown if a queue with this testName already exists
+ * @throws IOException - if there is a problem with the JMX Connection
+ */
+ public void createQueue(String virtualHostName, String name, String owner, boolean durable)
+ throws JMException, IOException
+ {
+ ManagedBroker managedBroker = getManagedBroker(virtualHostName);
+
+ managedBroker.createNewQueue(name, owner, durable);
+ }
+
+ /**
+ * Retrive the ObjectName for the test Virtualhost.
+ *
+ * This is then use to create aproxy to the ManagedBroker MBean.
+ *
+ * @return the ObjectName for the 'test' VirtualHost.
+ */
+ public ObjectName getVirtualHostManagerObjectName(String vhostName)
+ {
+ // Get the name of the test manager
+ AllObjects allObject = new AllObjects(_mbsc);
+ allObject.querystring = "org.apache.qpid:type=VirtualHost.VirtualHostManager,VirtualHost=" + vhostName + ",*";
+
+ Set<ObjectName> objectNames = allObject.returnObjects();
+
+ _test.assertEquals("Incorrect number test vhosts returned", 1, objectNames.size());
+
+ // We have verified we have only one value in objectNames so return it
+ return objectNames.iterator().next();
+ }
+
+ /**
+ * Retrive the ObjectName for the given Exchange on the test Virtualhost.
+ *
+ * This is then use to create aproxy to the ManagedExchange MBean.
+ *
+ * @param queue The exchange to retireve e.g. 'direct'
+ *
+ * @return the ObjectName for the given exchange on the test VirtualHost.
+ */
+ public ObjectName getQueueObjectName(String virtualHostName, String queue)
+ {
+ // Get the name of the test manager
+ AllObjects allObject = new AllObjects(_mbsc);
+ allObject.querystring = "org.apache.qpid:type=VirtualHost.Queue,VirtualHost=" + virtualHostName + ",name=" + queue + ",*";
+
+ Set<ObjectName> objectNames = allObject.returnObjects();
+
+ _test.assertEquals("Incorrect number of exchange with name '" + queue +
+ "' returned", 1, objectNames.size());
+
+ // We have verified we have only one value in objectNames so return it
+ return objectNames.iterator().next();
+ }
+
+ /**
+ * Retrive the ObjectName for the given Exchange on the test Virtualhost.
+ *
+ * This is then use to create aproxy to the ManagedExchange MBean.
+ *
+ * @param virtualHostName
+ * @param exchange The exchange to retireve e.g. 'direct'
+ *
+ * @return the ObjectName for the given exchange on the test VirtualHost.
+ */
+ public ObjectName getExchangeObjectName(String virtualHostName, String exchange)
+ {
+ // Get the name of the test manager
+ AllObjects allObject = new AllObjects(_mbsc);
+ allObject.querystring = "org.apache.qpid:type=VirtualHost.Exchange,VirtualHost=" + virtualHostName + ",name=" + exchange + ",*";
+
+ Set<ObjectName> objectNames = allObject.returnObjects();
+
+ _test.assertEquals("Incorrect number of exchange with name '" + exchange +
+ "' returned", 1, objectNames.size());
+
+ // We have verified we have only one value in objectNames so return it
+ return objectNames.iterator().next();
+ }
+
+ public <T> T getManagedObject(Class<T> managedClass, String queryString)
+ {
+ AllObjects allObject = new AllObjects(_mbsc);
+ allObject.querystring = queryString;
+
+ Set<ObjectName> objectNames = allObject.returnObjects();
+
+ _test.assertEquals("More than one " + managedClass + " returned", 1, objectNames.size());
+
+ ObjectName objectName = objectNames.iterator().next();
+
+ return getManagedObject(managedClass, objectName);
+ }
+
+ public <T> T getManagedObject(Class<T> managedClass, ObjectName objectName)
+ {
+ return MBeanServerInvocationHandler.
+ newProxyInstance(_mbsc, objectName, managedClass, false);
+ }
+
+ public ManagedBroker getManagedBroker(String virtualHost)
+ {
+ return getManagedObject(ManagedBroker.class, getVirtualHostManagerObjectName(virtualHost).toString());
+ }
+
+ public ManagedExchange getManagedExchange(String exchangeName)
+ {
+ return MBeanServerInvocationHandler.
+ newProxyInstance(_mbsc, getExchangeObjectName("test", exchangeName),
+ ManagedExchange.class, false);
+ }
+}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
index db096710dc..76e4118c96 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
@@ -21,6 +21,7 @@ import junit.framework.TestCase;
import junit.framework.TestResult;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
+import org.apache.qpid.AMQException;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQConnectionFactory;
import org.apache.qpid.client.transport.TransportConnection;
@@ -30,6 +31,7 @@ import org.apache.qpid.server.configuration.ServerConfiguration;
import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry;
import org.apache.qpid.server.store.DerbyMessageStore;
+import org.apache.qpid.url.URLSyntaxException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -73,6 +75,7 @@ public class QpidTestCase extends TestCase
protected long RECEIVE_TIMEOUT = 1000l;
private Map<String, String> _setProperties = new HashMap<String, String>();
+ private XMLConfiguration _testConfiguration = new XMLConfiguration();
/**
* Some tests are excluded when the property test.excludes is set to true.
@@ -183,8 +186,7 @@ public class QpidTestCase extends TestCase
public static final String QUEUE = "queue";
public static final String TOPIC = "topic";
/** Map to hold test defined environment properties */
- private Map<String,String> _env;
-
+ private Map<String, String> _env;
public QpidTestCase(String name)
{
@@ -335,7 +337,7 @@ public class QpidTestCase extends TestCase
latch.countDown();
}
- if (latch != null && line.contains(stopped))
+ if (!seenReady && line.contains(stopped))
{
stopLine = line;
}
@@ -368,7 +370,9 @@ public class QpidTestCase extends TestCase
/**
* Return the management portin use by the broker on this main port
+ *
* @param mainPort the broker's main port.
+ *
* @return the management port that corresponds to the broker on the given port
*/
protected int getManagementPort(int mainPort)
@@ -415,9 +419,14 @@ public class QpidTestCase extends TestCase
{
port = getPort(port);
+ // Save any configuratio changes that have been made
+ saveTestConfiguration();
+
Process process = null;
if (_broker.equals(VM))
{
+ setConfigurationProperty("management.jmxport", String.valueOf(getManagementPort(port)));
+ saveTestConfiguration();
// create an in_VM broker
ApplicationRegistry.initialise(new ConfigurationFileApplicationRegistry(_configFile), port);
TransportConnection.createVMBroker(port);
@@ -438,15 +447,35 @@ public class QpidTestCase extends TestCase
env.put("PATH", env.get("PATH").concat(File.pathSeparator + qpidHome + "/bin"));
//Add the test name to the broker run.
- env.put("QPID_PNAME", "-DPNAME=\"" + _testName + "\"");
+ // DON'T change PNAME, qpid.stop needs this value.
+ env.put("QPID_PNAME", "-DPNAME=QPBRKR -DTNAME=\"" + _testName + "\"");
env.put("QPID_WORK", System.getProperty("QPID_WORK"));
// Add all the environment settings the test requested
if (!_env.isEmpty())
{
- for(Map.Entry<String,String> entry : _env.entrySet())
+ for (Map.Entry<String, String> entry : _env.entrySet())
+ {
+ env.put(entry.getKey(), entry.getValue());
+ }
+ }
+
+ String QPID_OPTS = " ";
+ // Add all the specified system properties to QPID_OPTS
+ if (!_setProperties.isEmpty())
+ {
+ for (String key : _setProperties.keySet())
+ {
+ QPID_OPTS += "-D" + key + "=" + System.getProperty(key) + " ";
+ }
+
+ if (env.containsKey("QPID_OPTS"))
{
- env.put(entry.getKey() ,entry.getValue());
+ env.put("QPID_OPTS", env.get("QPID_OPTS") + QPID_OPTS);
+ }
+ else
+ {
+ env.put("QPID_OPTS", QPID_OPTS);
}
}
@@ -484,6 +513,27 @@ public class QpidTestCase extends TestCase
_brokers.put(port, process);
}
+ public String getTestConfigFile()
+ {
+ String path = _output == null ? System.getProperty("java.io.tmpdir") : _output;
+ return path + "/" + getTestQueueName() + ".xml";
+ }
+
+ protected void saveTestConfiguration() throws ConfigurationException
+ {
+ String testConfig = getTestConfigFile();
+ //Specifiy the test configuration
+ setSystemProperty("test.config", testConfig);
+
+ // This is a work
+ if (_testConfiguration.isEmpty())
+ {
+ _testConfiguration.addProperty("test", getTestQueueName());
+ }
+
+ _testConfiguration.save(getTestConfigFile());
+ }
+
public void cleanBroker()
{
if (_brokerClean != null)
@@ -565,18 +615,12 @@ public class QpidTestCase extends TestCase
storeClass = bdb;
}
- // First we munge the config file and, if we're in a VM, set up an additional logfile
- XMLConfiguration configuration = new XMLConfiguration(_configFile);
- configuration.setProperty("virtualhosts.virtualhost." + virtualhost +
+
+ _testConfiguration.setProperty("virtualhosts.virtualhost." + virtualhost +
".store.class", storeClass.getName());
- configuration.setProperty("virtualhosts.virtualhost." + virtualhost +
+ _testConfiguration.setProperty("virtualhosts.virtualhost." + virtualhost +
".store." + DerbyMessageStore.ENVIRONMENT_PATH_PROPERTY,
- "${work}/" + virtualhost);
-
- File tmpFile = File.createTempFile("configFile", "test");
- tmpFile.deleteOnExit();
- configuration.save(tmpFile);
- _configFile = tmpFile;
+ "${QPID_WORK}/" + virtualhost);
}
/**
@@ -591,6 +635,10 @@ public class QpidTestCase extends TestCase
*/
protected String getConfigurationStringProperty(String property) throws ConfigurationException
{
+ // Call save Configuration to be sure we have saved the test specific
+ // file. As the optional status
+ saveTestConfiguration();
+
ServerConfiguration configuration = new ServerConfiguration(_configFile);
return configuration.getConfig().getString(property);
}
@@ -613,48 +661,9 @@ public class QpidTestCase extends TestCase
protected void setConfigurationProperty(String property, String value)
throws ConfigurationException, IOException
{
- XMLConfiguration configuration = new XMLConfiguration(_configFile);
-
- // If we are modifying a virtualhost value then we need to do so in
- // the virtualhost.xml file as these values overwrite the values in
- // the main config.xml file
- if (property.startsWith("virtualhosts"))
- {
- // So locate the virtualhost.xml file and use the ServerConfiguration
- // flatConfig method to get the interpolated value.
- String vhostConfigFile = ServerConfiguration.
- flatConfig(_configFile).getString("virtualhosts");
-
- // Load the vhostConfigFile
- XMLConfiguration vhostConfiguration = new XMLConfiguration(vhostConfigFile);
-
- // Set the value specified in to the vhostConfig.
- // Remembering that property will be 'virtualhosts.virtulhost....'
- // so we need to take off the 'virtualhosts.' from the start.
- vhostConfiguration.setProperty(property.substring(property.indexOf(".") + 1), value);
-
- // Write out the new virtualhost config file
- File tmpFile = File.createTempFile("virtualhost-configFile", ".xml");
- tmpFile.deleteOnExit();
- vhostConfiguration.save(tmpFile);
-
- // Change the property and value to be the new virtualhosts file
- // so that then update the value in the main config file.
- property = "virtualhosts";
- value = tmpFile.getAbsolutePath();
- }
-
- configuration.setProperty(property, value);
-
- // Write the new server config file
- File tmpFile = File.createTempFile("configFile", ".xml");
- tmpFile.deleteOnExit();
- configuration.save(tmpFile);
-
- _logger.info("Qpid Test Case now using configuration File:"
- + tmpFile.getAbsolutePath());
-
- _configFile = tmpFile;
+ //Write the value in to this configuration file which will override the
+ // defaults.
+ _testConfiguration.setProperty(property, value);
}
/**
@@ -695,14 +704,13 @@ public class QpidTestCase extends TestCase
* Add an environtmen variable for the external broker environment
*
* @param property the property to set
- * @param value the value to set it to
+ * @param value the value to set it to
*/
protected void setBrokerEnvironment(String property, String value)
{
- _env.put(property,value);
+ _env.put(property, value);
}
-
/**
* Check whether the broker is an 0.8
*
@@ -720,7 +728,7 @@ public class QpidTestCase extends TestCase
protected boolean isJavaBroker()
{
- return _brokerLanguage.equals("java");
+ return _brokerLanguage.equals("java") || _broker.equals("vm");
}
protected boolean isCppBroker()
@@ -807,7 +815,7 @@ public class QpidTestCase extends TestCase
return (AMQConnectionFactory) getInitialContext().lookup(factoryName);
}
- public Connection getConnection() throws Exception
+ public Connection getConnection() throws JMSException, NamingException
{
return getConnection("guest", "guest");
}
@@ -831,7 +839,7 @@ public class QpidTestCase extends TestCase
*
* @throws Exception if there is an error getting the connection
*/
- public Connection getConnection(String username, String password) throws Exception
+ public Connection getConnection(String username, String password) throws JMSException, NamingException
{
_logger.info("get Connection");
Connection con = getConnectionFactory().createConnection(username, password);
@@ -840,7 +848,7 @@ public class QpidTestCase extends TestCase
return con;
}
- public Connection getConnection(String username, String password, String id) throws Exception
+ public Connection getConnection(String username, String password, String id) throws JMSException, URLSyntaxException, AMQException, NamingException
{
_logger.info("get Connection");
Connection con;
@@ -860,6 +868,7 @@ public class QpidTestCase extends TestCase
/**
* Return a uniqueName for this test.
* In this case it returns a queue Named by the TestCase and TestName
+ *
* @return String name for a queue
*/
protected String getTestQueueName()