summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2008-06-02 15:53:33 +0000
committerMartin Ritchie <ritchiem@apache.org>2008-06-02 15:53:33 +0000
commit2cefafe62ddcdcd2958c58857e568e80665168a9 (patch)
tree654c32b003d72493bedf5b272a5d1656c4a67924
parent43a1c5a1d9d17fc1da09c7057329034f0072d54b (diff)
downloadqpid-python-2cefafe62ddcdcd2958c58857e568e80665168a9.tar.gz
Merged revisions 661739-661746 via svnmerge from
https://svn.apache.org/repos/asf/incubator/qpid/branches/M2.x ........ r661739 | ritchiem | 2008-05-30 15:42:38 +0100 (Fri, 30 May 2008) | 1 line QPID-1103 :Changed VMTestCase to allow the creation of InVM brokers based on a configuration file. Updated ApplicationRegistry as it was not correctly utilising the set configuration and always using AR 1. ........ r661746 | ritchiem | 2008-05-30 15:54:35 +0100 (Fri, 30 May 2008) | 1 line QPID-1101 : Update to DestNameExchange to perform deep copy. ........ git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2.1.x@662467 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/exchange/DestNameExchange.java2
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java2
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/VMTestCase.java73
-rw-r--r--java/systests/src/main/java/org/apache/qpid/testutil/BrokerStartupException.java29
4 files changed, 92 insertions, 14 deletions
diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/DestNameExchange.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/DestNameExchange.java
index 12347c0278..72c3483e96 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/exchange/DestNameExchange.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/exchange/DestNameExchange.java
@@ -212,7 +212,7 @@ public class DestNameExchange extends AbstractExchange
_logger.debug("Publishing message to queue " + queues);
}
- payload.enqueue(queues);
+ payload.enqueue(new ArrayList<AMQQueue>(queues));
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java b/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
index 455983c6d8..b14884b717 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
@@ -189,7 +189,7 @@ public abstract class ApplicationRegistry implements IApplicationRegistry
_logger.error("Unable to instantiate configuration class " + instanceType + " - ensure it has a public default constructor");
throw new IllegalArgumentException("Unable to instantiate configuration class " + instanceType + " - ensure it has a public default constructor", e);
}
- Configurator.configure(instance);
+ Configurator.configure(instance, _configuration);
_configuredObjects.put(instanceType, instance);
}
return instance;
diff --git a/java/systests/src/main/java/org/apache/qpid/test/VMTestCase.java b/java/systests/src/main/java/org/apache/qpid/test/VMTestCase.java
index cf5e72eebc..16dc81e82d 100644
--- a/java/systests/src/main/java/org/apache/qpid/test/VMTestCase.java
+++ b/java/systests/src/main/java/org/apache/qpid/test/VMTestCase.java
@@ -21,13 +21,16 @@
package org.apache.qpid.test;
import junit.framework.TestCase;
+import org.apache.qpid.AMQException;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.jndi.PropertiesFileInitialContextFactory;
import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.AMQException;
+import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry;
+import org.apache.qpid.testutil.BrokerStartupException;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
@@ -37,6 +40,7 @@ import javax.jms.Session;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.spi.InitialContextFactory;
+import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
@@ -60,14 +64,7 @@ public class VMTestCase extends TestCase
protected void setUp() throws Exception
{
super.setUp();
- try
- {
- TransportConnection.createVMBroker(1);
- }
- catch (Exception e)
- {
- fail("Unable to create broker: " + e);
- }
+ startVMBroker(1);
InitialContextFactory factory = new PropertiesFileInitialContextFactory();
@@ -118,9 +115,7 @@ public class VMTestCase extends TestCase
//Disabled
// checkQueuesClean();
- TransportConnection.killVMBroker(1);
- ApplicationRegistry.remove(1);
-
+ stopVMBroker(1);
super.tearDown();
}
@@ -161,4 +156,58 @@ public class VMTestCase extends TestCase
return ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHost(_virtualhost.substring(1))
.getQueueRegistry().getQueue(new AMQShortString(queueName)).getMessageCount();
}
+
+ public void startVMBroker(int vmID) throws Exception
+ {
+ startVMBroker(vmID, null);
+ }
+
+ /** FIXME: for now vmID must be unique client is responsible for this. */
+ public void startVMBroker(int vmID, File configFile)
+ {
+ //If we have configuration file then load that
+ if (configFile != null)
+ {
+ if (!configFile.exists())
+ {
+ System.err.println("Configuration file not found:" + configFile);
+ fail("Configuration file not found:" + configFile);
+ }
+
+ if (System.getProperty("QPID_HOME") == null)
+ {
+ fail("QPID_HOME not set");
+ }
+
+ try
+ {
+ ConfigurationFileApplicationRegistry config = new ConfigurationFileApplicationRegistry(configFile);
+
+ //For now disable management on all configured inVM broker.
+ config.getConfiguration().setProperty("management.enabled", "false");
+
+ ApplicationRegistry.initialise(config, vmID);
+ }
+ catch (Exception e)
+ {
+ throw new BrokerStartupException("Unable to configure broker:" + vmID + " With file:" + configFile, e);
+ }
+ }
+
+ try
+ {
+ TransportConnection.createVMBroker(vmID);
+ }
+ catch (AMQVMBrokerCreationException e)
+ {
+ throw new BrokerStartupException("Unable to start broker:" + vmID, e);
+ }
+ }
+
+ public void stopVMBroker(int inVMid)
+ {
+ TransportConnection.killVMBroker(inVMid);
+ ApplicationRegistry.remove(inVMid);
+ }
+
}
diff --git a/java/systests/src/main/java/org/apache/qpid/testutil/BrokerStartupException.java b/java/systests/src/main/java/org/apache/qpid/testutil/BrokerStartupException.java
new file mode 100644
index 0000000000..6ad251954d
--- /dev/null
+++ b/java/systests/src/main/java/org/apache/qpid/testutil/BrokerStartupException.java
@@ -0,0 +1,29 @@
+/*
+ *
+ * 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.testutil;
+
+public class BrokerStartupException extends RuntimeException
+{
+ public BrokerStartupException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+}