You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ri...@apache.org on 2008/05/30 16:42:38 UTC
svn commit: r661739 - in /incubator/qpid/branches/M2.x/java:
broker/src/main/java/org/apache/qpid/server/registry/
systests/src/main/java/org/apache/qpid/test/
systests/src/main/java/org/apache/qpid/testutil/
Author: ritchiem
Date: Fri May 30 07:42:38 2008
New Revision: 661739
URL: http://svn.apache.org/viewvc?rev=661739&view=rev
Log:
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.
Added:
incubator/qpid/branches/M2.x/java/systests/src/main/java/org/apache/qpid/testutil/BrokerStartupException.java (with props)
Modified:
incubator/qpid/branches/M2.x/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
incubator/qpid/branches/M2.x/java/systests/src/main/java/org/apache/qpid/test/VMTestCase.java
Modified: incubator/qpid/branches/M2.x/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.x/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java?rev=661739&r1=661738&r2=661739&view=diff
==============================================================================
--- incubator/qpid/branches/M2.x/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java (original)
+++ incubator/qpid/branches/M2.x/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java Fri May 30 07:42:38 2008
@@ -189,7 +189,7 @@
_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;
Modified: incubator/qpid/branches/M2.x/java/systests/src/main/java/org/apache/qpid/test/VMTestCase.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.x/java/systests/src/main/java/org/apache/qpid/test/VMTestCase.java?rev=661739&r1=661738&r2=661739&view=diff
==============================================================================
--- incubator/qpid/branches/M2.x/java/systests/src/main/java/org/apache/qpid/test/VMTestCase.java (original)
+++ incubator/qpid/branches/M2.x/java/systests/src/main/java/org/apache/qpid/test/VMTestCase.java Fri May 30 07:42:38 2008
@@ -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.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 @@
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 @@
//Disabled
// checkQueuesClean();
- TransportConnection.killVMBroker(1);
- ApplicationRegistry.remove(1);
-
+ stopVMBroker(1);
super.tearDown();
}
@@ -161,4 +156,58 @@
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);
+ }
+
}
Added: incubator/qpid/branches/M2.x/java/systests/src/main/java/org/apache/qpid/testutil/BrokerStartupException.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.x/java/systests/src/main/java/org/apache/qpid/testutil/BrokerStartupException.java?rev=661739&view=auto
==============================================================================
--- incubator/qpid/branches/M2.x/java/systests/src/main/java/org/apache/qpid/testutil/BrokerStartupException.java (added)
+++ incubator/qpid/branches/M2.x/java/systests/src/main/java/org/apache/qpid/testutil/BrokerStartupException.java Fri May 30 07:42:38 2008
@@ -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);
+ }
+}
Propchange: incubator/qpid/branches/M2.x/java/systests/src/main/java/org/apache/qpid/testutil/BrokerStartupException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/qpid/branches/M2.x/java/systests/src/main/java/org/apache/qpid/testutil/BrokerStartupException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date