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/17 15:59:30 UTC

svn commit: r766014 - in /qpid/branches/0.5-release/qpid/java: ./ management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ systests/src/main/java/org/apache/qpid/test/client/timeouts/ systests/src/main/java/org/apache/qpid/test/fram...

Author: ritchiem
Date: Fri Apr 17 13:59:14 2009
New Revision: 766014

URL: http://svn.apache.org/viewvc?rev=766014&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.

merged to trunk from r765602


Modified:
    qpid/branches/0.5-release/qpid/java/   (props changed)
    qpid/branches/0.5-release/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java   (props changed)
    qpid/branches/0.5-release/qpid/java/module.xml
    qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java
    qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java
    qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/close/CloseTest.java
    qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
    qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
    qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java

Propchange: qpid/branches/0.5-release/qpid/java/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Apr 17 13:59:14 2009
@@ -1 +1 @@
-/qpid/trunk/qpid/java:764790,764838,765132,765134
+/qpid/trunk/qpid/java:764790,764838,765132,765134,765602

Propchange: qpid/branches/0.5-release/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Apr 17 13:59:14 2009
@@ -1 +1 @@
-/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java:762365,764790,764838,765132,765134
+/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java:762365,764790,764838,765132,765134,765602

Modified: qpid/branches/0.5-release/qpid/java/module.xml
URL: http://svn.apache.org/viewvc/qpid/branches/0.5-release/qpid/java/module.xml?rev=766014&r1=766013&r2=766014&view=diff
==============================================================================
--- qpid/branches/0.5-release/qpid/java/module.xml (original)
+++ qpid/branches/0.5-release/qpid/java/module.xml Fri Apr 17 13:59:14 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/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java?rev=766014&r1=766013&r2=766014&view=diff
==============================================================================
--- qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java (original)
+++ qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java Fri Apr 17 13:59:14 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/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java?rev=766014&r1=766013&r2=766014&view=diff
==============================================================================
--- qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java (original)
+++ qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/framework/FrameworkBaseCase.java Fri Apr 17 13:59:14 2009
@@ -189,6 +189,7 @@
      */
     protected void setUp() throws Exception
     {
+        super.setUp();
         NDC.push(getName());
 
         testProps = TestContextProperties.getInstance(MessagingTestConfigProperties.defaults);

Modified: qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/close/CloseTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/close/CloseTest.java?rev=766014&r1=766013&r2=766014&view=diff
==============================================================================
--- qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/close/CloseTest.java (original)
+++ qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/basic/close/CloseTest.java Fri Apr 17 13:59:14 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/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java?rev=766014&r1=766013&r2=766014&view=diff
==============================================================================
--- qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java (original)
+++ qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java Fri Apr 17 13:59:14 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/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java?rev=766014&r1=766013&r2=766014&view=diff
==============================================================================
--- qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java (original)
+++ qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java Fri Apr 17 13:59:14 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/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java?rev=766014&r1=766013&r2=766014&view=diff
==============================================================================
--- qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java (original)
+++ qpid/branches/0.5-release/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java Fri Apr 17 13:59:14 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