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 2009/04/16 14:26:06 UTC

svn commit: r765602 - in /qpid/trunk/qpid/java: ./ broker/etc/ systests/src/main/java/org/apache/qpid/test/client/timeouts/ systests/src/main/java/org/apache/qpid/test/framework/ systests/src/main/java/org/apache/qpid/test/unit/basic/close/ systests/sr...

Author: ritchiem
Date: Thu Apr 16 12:26:05 2009
New Revision: 765602

URL: http://svn.apache.org/viewvc?rev=765602&view=rev
Log:
QPID-1817 : Update to QpidTestCase to use setUp to start the broker this allows tests to update the _configFile that is being used before the broker is started. By default the etc/config-systests.xml is used. This differs from the stock config.xml only in that it disables the Managment JMX interface by default. If a test requires this functionality it can provided an edited configuration. An example of how that might be done can be seen in SyncWaitDelayTest and will additionally be provided for QPID-1813.

A couple of tests were modified to remove their setUp/tearDown where the code did no additional work. This made the tests cleaner. Additionally FrameworkBaseCase never actually called super.setUp() so that was fixed.

Added:
    qpid/trunk/qpid/java/broker/etc/config-systests.xml
Modified:
    qpid/trunk/qpid/java/module.xml
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/close/CloseTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java

Added: qpid/trunk/qpid/java/broker/etc/config-systests.xml
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/etc/config-systests.xml?rev=765602&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/etc/config-systests.xml (added)
+++ qpid/trunk/qpid/java/broker/etc/config-systests.xml Thu Apr 16 12:26:05 2009
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ -
+ - 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.
+ -
+ -->
+<broker>
+    <prefix>${QPID_HOME}</prefix>
+    <work>${QPID_WORK}</work>
+    <conf>${prefix}/etc</conf>
+    <connector>
+        <!-- Uncomment out this block and edit the keystorePath and keystorePassword
+             to enable SSL support
+        <ssl>
+            <enabled>true</enabled>
+            <sslOnly>true</sslOnly>
+            <keystorePath>/path/to/keystore.ks</keystorePath>
+            <keystorePassword>keystorepass</keystorePassword>
+        </ssl>-->
+        <qpidnio>false</qpidnio>
+        <protectio>
+            <enabled>false</enabled>
+        </protectio>
+        <transport>nio</transport>
+        <port>5672</port>
+        <sslport>8672</sslport>
+        <socketReceiveBuffer>32768</socketReceiveBuffer>
+        <socketSendBuffer>32768</socketSendBuffer>
+    </connector>
+    <management>
+        <enabled>false</enabled>
+        <jmxport>8999</jmxport>
+        <ssl>
+            <enabled>false</enabled>
+            <!-- Update below path to your keystore location, eg ${conf}/qpid.keystore  -->
+            <keyStorePath>${prefix}/../test_resources/ssl/keystore.jks</keyStorePath>
+            <keyStorePassword>password</keyStorePassword>
+        </ssl>
+    </management>
+    <advanced>
+        <filterchain enableExecutorPool="true"/>
+        <enablePooledAllocator>false</enablePooledAllocator>
+        <enableDirectBuffers>false</enableDirectBuffers>
+        <framesize>65535</framesize>
+        <compressBufferOnQueue>false</compressBufferOnQueue>
+        <enableJMSXUserID>false</enableJMSXUserID>
+    </advanced>
+
+    <security>
+        <principal-databases>
+            <!-- Example use of Base64 encoded MD5 hashes for authentication via CRAM-MD5-Hashed -->
+            <principal-database>
+                <name>passwordfile</name>
+                <class>org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase</class>
+                <attributes>
+                    <attribute>
+                        <name>passwordFile</name>
+                        <value>${conf}/passwd</value>
+                    </attribute>
+                </attributes>
+            </principal-database>
+        </principal-databases>
+
+        <access>
+            <class>org.apache.qpid.server.security.access.plugins.AllowAll</class>
+        </access>
+        
+        <msg-auth>false</msg-auth>
+        
+        <jmx>
+            <access>${conf}/jmxremote.access</access>
+            <principal-database>passwordfile</principal-database>
+        </jmx>
+    </security>
+
+    <virtualhosts>
+        <directory>${conf}/virtualhosts</directory>
+
+        <virtualhost>
+            <name>localhost</name>
+            <localhost>
+                <store>
+                    <class>org.apache.qpid.server.store.MemoryMessageStore</class>
+                </store>
+
+                <housekeeping>
+                    <expiredMessageCheckPeriod>20000</expiredMessageCheckPeriod>
+                </housekeeping>
+
+            </localhost>
+        </virtualhost>
+
+        <virtualhost>
+            <name>development</name>
+            <development>
+                <store>
+                    <class>org.apache.qpid.server.store.MemoryMessageStore</class>
+                </store>
+            </development>
+        </virtualhost>
+
+        <virtualhost>
+            <name>test</name>
+            <test>
+                <store>
+                    <class>org.apache.qpid.server.store.MemoryMessageStore</class>
+                </store>
+            </test>
+        </virtualhost>
+
+    </virtualhosts>
+    <heartbeat>
+        <delay>0</delay>
+        <timeoutFactor>2.0</timeoutFactor>
+    </heartbeat>
+    <queue>
+        <auto_register>true</auto_register>
+    </queue>
+
+    <virtualhosts>${conf}/virtualhosts.xml</virtualhosts>
+</broker>
+
+

Modified: qpid/trunk/qpid/java/module.xml
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/module.xml?rev=765602&r1=765601&r2=765602&view=diff
==============================================================================
--- qpid/trunk/qpid/java/module.xml (original)
+++ qpid/trunk/qpid/java/module.xml Thu Apr 16 12:26:05 2009
@@ -251,6 +251,7 @@
       <sysproperty key="example.plugin.target" value="${project.root}/build/lib/plugins"/>
       <sysproperty key="QPID_EXAMPLE_HOME" value="${project.root}/build"/>
       <sysproperty key="QPID_HOME" value="${project.root}/build"/>
+      <sysproperty key="QPID_WORK" value="${project.root}/build/work"/>
 
       <formatter type="plain"/>
       <formatter type="xml"/>

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java?rev=765602&r1=765601&r2=765602&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java Thu Apr 16 12:26:05 2009
@@ -46,9 +46,6 @@
 {
     protected static final Logger _logger = LoggerFactory.getLogger(SyncWaitDelayTest.class);
 
-    final String QpidHome = System.getProperty("QPID_HOME");
-    final File _configFile = new File(QpidHome, "etc/config.xml");
-
     private String VIRTUALHOST = "test";
     protected long POST_COMMIT_DELAY = 1000L;
     protected long SYNC_WRITE_TIMEOUT = POST_COMMIT_DELAY + 1000;
@@ -77,9 +74,9 @@
         tmpFile.deleteOnExit();
         configuration.save(tmpFile);
         
-        ApplicationRegistry reg = new ConfigurationFileApplicationRegistry(tmpFile);
-        
-        startBroker(1, reg);
+        _configFile = tmpFile;
+
+        startBroker(1);
 
         //Set the syncWrite timeout to be just larger than the delay on the commitTran.
         setSystemProperty("amqj.default_syncwrite_timeout", String.valueOf(SYNC_WRITE_TIMEOUT));

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java?rev=765602&r1=765601&r2=765602&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java Thu Apr 16 12:26:05 2009
@@ -189,6 +189,7 @@
      */
     protected void setUp() throws Exception
     {
+        super.setUp();
         NDC.push(getName());
 
         testProps = TestContextProperties.getInstance(MessagingTestConfigProperties.defaults);

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/close/CloseTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/close/CloseTest.java?rev=765602&r1=765601&r2=765602&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/close/CloseTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/close/CloseTest.java Thu Apr 16 12:26:05 2009
@@ -35,18 +35,6 @@
 {
     private static final Logger _logger = LoggerFactory.getLogger(CloseTest.class);
 
-    private static final String BROKER = "vm://:1";
-
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-    }
-
-    protected void tearDown() throws Exception
-    {
-        super.setUp();
-    }
-
     public void testCloseQueueReceiver() throws  Exception
     {
         AMQConnection connection = (AMQConnection) getConnection("guest", "guest");
@@ -62,7 +50,7 @@
 
         _logger.info("About to close consumer");
 
-        consumer.close();
+        consumer.close();                                
 
         _logger.info("Closed Consumer");
         connection.close();

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java?rev=765602&r1=765601&r2=765602&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java Thu Apr 16 12:26:05 2009
@@ -30,9 +30,12 @@
 import org.apache.qpid.client.AMQQueue;
 import org.apache.qpid.client.AMQSession;
 import org.apache.qpid.client.AMQTopic;
+import org.apache.qpid.client.AMQConnectionURL;
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.jms.Session;
+import org.apache.qpid.jms.ConnectionURL;
+import org.apache.qpid.jms.BrokerDetails;
 
 import javax.jms.Connection;
 import javax.jms.QueueSession;
@@ -45,13 +48,13 @@
     String _broker_NotRunning = "vm://:2";
     String _broker_BadDNS = "tcp://hg3sgaaw4lgihjs";
 
-    public String getBroker()
+    public BrokerDetails getBroker()
     {
         try
         {
             if (getConnectionFactory().getConnectionURL().getBrokerCount() > 0)
             {
-                return getConnectionFactory().getConnectionURL().getBrokerDetails(0).toString();
+                return getConnectionFactory().getConnectionURL().getBrokerDetails(0);
             }
             else
             {
@@ -72,7 +75,7 @@
         AMQConnection conn = null;
         try
         {
-            conn = new AMQConnection(getBroker(), "guest", "guest", "fred", "test");
+            conn = new AMQConnection(getBroker().toString(), "guest", "guest", "fred", "test");
         }
         catch (Exception e)
         {
@@ -89,13 +92,18 @@
         AMQConnection conn = null;
         try
         {
-            conn = new AMQConnection("amqp://guest:guest@clientid/test?brokerlist='"
-                                     + getBroker()
-                                     + "?retries='1''&defaultQueueExchange='test.direct'"
+            BrokerDetails broker = getBroker();
+            broker.setProperty("retries","1");
+            ConnectionURL url = new AMQConnectionURL("amqp://guest:guest@clientid/test?brokerlist='"
+                                     + broker
+                                     + "'&defaultQueueExchange='test.direct'"
                                      + "&defaultTopicExchange='test.topic'"
                                      + "&temporaryQueueExchange='tmp.direct'"
                                      + "&temporaryTopicExchange='tmp.topic'");
 
+            System.err.println(url.toString());
+            conn = new AMQConnection(url, null);
+
 
             AMQSession sess = (AMQSession) conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
             
@@ -151,7 +159,9 @@
         AMQConnection conn = null;
         try
         {
-            conn = new AMQConnection("amqp://guest:rubbishpassword@clientid/test?brokerlist='" + getBroker() + "?retries='0''");
+            BrokerDetails broker = getBroker();
+            broker.setProperty("retries", "0");
+            conn = new AMQConnection("amqp://guest:rubbishpassword@clientid/test?brokerlist='" + broker + "'");
             fail("Connection should not be established password is wrong.");
         }
         catch (AMQConnectionFailureException amqe)
@@ -223,7 +233,9 @@
         AMQConnection conn = null;
         try
         {
-            conn = new AMQConnection("amqp://guest:guest@clientid/rubbishhost?brokerlist='" + getBroker() + "?retries='0''");
+            BrokerDetails broker = getBroker();
+            broker.setProperty("retries", "0");            
+            conn = new AMQConnection("amqp://guest:guest@clientid/rubbishhost?brokerlist='" + broker + "'");
             fail("Connection should not be established");
         }
         catch (AMQException amqe)
@@ -244,7 +256,7 @@
 
     public void testClientIdCannotBeChanged() throws Exception
     {
-        Connection connection = new AMQConnection(getBroker(), "guest", "guest",
+        Connection connection = new AMQConnection(getBroker().toString(), "guest", "guest",
                                                   "fred", "test");
         try
         {
@@ -266,7 +278,7 @@
 
     public void testClientIdIsPopulatedAutomatically() throws Exception
     {
-        Connection connection = new AMQConnection(getBroker(), "guest", "guest",
+        Connection connection = new AMQConnection(getBroker().toString(), "guest", "guest",
                                                   null, "test");
         try
         {

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java?rev=765602&r1=765601&r2=765602&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java Thu Apr 16 12:26:05 2009
@@ -51,16 +51,6 @@
 {
     private static final Logger _logger = LoggerFactory.getLogger(DurableSubscriptionTest.class);
 
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-    }
-
-    protected void tearDown() throws Exception
-    {
-        super.tearDown();
-    }
-
     public void testUnsubscribe() throws Exception
     {
         AMQConnection con = (AMQConnection) getConnection("guest", "guest");

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java?rev=765602&r1=765601&r2=765602&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java Thu Apr 16 12:26:05 2009
@@ -21,6 +21,10 @@
 import junit.framework.TestResult;
 
 import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.Session;
+import javax.jms.MessageProducer;
+import javax.jms.Message;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import java.io.*;
@@ -47,6 +51,8 @@
  */
 public class QpidTestCase extends TestCase
 {
+    protected final String QpidHome = System.getProperty("QPID_HOME");
+    protected File _configFile = new File(QpidHome, "etc/config-systests.xml");
 
     private static final Logger _logger = LoggerFactory.getLogger(QpidTestCase.class);
 
@@ -182,7 +188,6 @@
         }
 
         _logger.info("========== start " + _testName + " ==========");
-        startBroker();
         try
         {
             super.runBare();
@@ -209,6 +214,17 @@
         }
     }
 
+    @Override
+    protected void setUp() throws Exception
+    {
+        if (!_configFile.exists())
+        {
+            fail("Unable to test without config file:" + _configFile);
+        }
+        
+        startBroker();
+    }
+
     public void run(TestResult testResult)
     {
         if (_exclusionList != null && (_exclusionList.contains(getClass().getName() + "#*") ||
@@ -294,12 +310,6 @@
         }
     }
 
-    public void startBroker(int port, ApplicationRegistry config) throws Exception
-    {
-        ApplicationRegistry.initialise(config, port);
-        startBroker(port);
-    }
-
     public void startBroker() throws Exception
     {
         startBroker(0);
@@ -336,6 +346,7 @@
         if (_broker.equals(VM))
         {
             // create an in_VM broker
+            ApplicationRegistry.initialise(new ConfigurationFileApplicationRegistry(_configFile), port);
             TransportConnection.createVMBroker(port);
         }
         else if (!_broker.equals(EXTERNAL))
@@ -605,4 +616,22 @@
         revertSystemProperties();
     }
 
+    public List<Message> sendMessage(Session session, Destination destination,
+                                     int count) throws Exception
+    {
+        List<Message> messages = new ArrayList<Message>(count);
+        
+        MessageProducer producer = session.createProducer(destination);
+
+        for (int i = 0; i < count; i++)
+        {
+            Message next = session.createMessage();
+
+            producer.send(next);
+
+            messages.add(next);
+        }
+        return messages;
+    }
+
 }



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org