[hornetq-commits] JBoss hornetq SVN: r11171 - in branches/Branch_2_2_EAP: tests/joram-tests/src/org/hornetq/jms and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Aug 9 15:29:51 EDT 2011


Author: clebert.suconic at jboss.com
Date: 2011-08-09 15:29:50 -0400 (Tue, 09 Aug 2011)
New Revision: 11171

Added:
   branches/Branch_2_2_EAP/tests/joram-tests/src/org/hornetq/jms/JoramAggregationTest.java
Modified:
   branches/Branch_2_2_EAP/build-hornetq.xml
   branches/Branch_2_2_EAP/tests/joram-tests/src/org/objectweb/jtests/jms/conform/message/MessageBodyTest.java
   branches/Branch_2_2_EAP/tests/joram-tests/src/org/objectweb/jtests/jms/framework/JMSTestCase.java
Log:
Speeding up JORAM tests

Modified: branches/Branch_2_2_EAP/build-hornetq.xml
===================================================================
--- branches/Branch_2_2_EAP/build-hornetq.xml	2011-08-09 17:43:09 UTC (rev 11170)
+++ branches/Branch_2_2_EAP/build-hornetq.xml	2011-08-09 19:29:50 UTC (rev 11171)
@@ -1873,7 +1873,7 @@
                     haltonerror="${junit.batchtest.haltonerror}">
             <formatter type="plain" usefile="${junit.formatter.usefile}"/>
             <fileset dir="${test.joram.classes.dir}">
-               <include name="**/${test-mask}.class"/>
+               <include name="**/JoramAggregationTest.class"/>
             </fileset>
          </batchtest>
       </junit>

Added: branches/Branch_2_2_EAP/tests/joram-tests/src/org/hornetq/jms/JoramAggregationTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/joram-tests/src/org/hornetq/jms/JoramAggregationTest.java	                        (rev 0)
+++ branches/Branch_2_2_EAP/tests/joram-tests/src/org/hornetq/jms/JoramAggregationTest.java	2011-08-09 19:29:50 UTC (rev 11171)
@@ -0,0 +1,231 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat 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.hornetq.jms;
+
+import java.io.IOException;
+import java.util.Hashtable;
+import java.util.Properties;
+
+import junit.extensions.TestSetup;
+import junit.framework.AssertionFailedError;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestListener;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+import org.objectweb.jtests.jms.admin.Admin;
+import org.objectweb.jtests.jms.admin.AdminFactory;
+import org.objectweb.jtests.jms.conform.connection.ConnectionTest;
+import org.objectweb.jtests.jms.conform.connection.TopicConnectionTest;
+import org.objectweb.jtests.jms.conform.message.MessageBodyTest;
+import org.objectweb.jtests.jms.conform.message.MessageDefaultTest;
+import org.objectweb.jtests.jms.conform.message.MessageTypeTest;
+import org.objectweb.jtests.jms.conform.message.headers.MessageHeaderTest;
+import org.objectweb.jtests.jms.conform.message.properties.JMSXPropertyTest;
+import org.objectweb.jtests.jms.conform.message.properties.MessagePropertyConversionTest;
+import org.objectweb.jtests.jms.conform.message.properties.MessagePropertyTest;
+import org.objectweb.jtests.jms.conform.queue.QueueBrowserTest;
+import org.objectweb.jtests.jms.conform.queue.TemporaryQueueTest;
+import org.objectweb.jtests.jms.conform.selector.SelectorSyntaxTest;
+import org.objectweb.jtests.jms.conform.selector.SelectorTest;
+import org.objectweb.jtests.jms.conform.session.QueueSessionTest;
+import org.objectweb.jtests.jms.conform.session.SessionTest;
+import org.objectweb.jtests.jms.conform.session.TopicSessionTest;
+import org.objectweb.jtests.jms.conform.session.UnifiedSessionTest;
+import org.objectweb.jtests.jms.conform.topic.TemporaryTopicTest;
+import org.objectweb.jtests.jms.framework.JMSTestCase;
+
+/**
+ * JoramAggregationTest.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class JoramAggregationTest extends TestCase
+{
+   public JoramAggregationTest(String name)
+   {
+      super(name);
+   }
+
+   
+   
+   /** Used to similuate tests while renaming its names. */
+   private static class DummyTestCase extends TestCase
+   {
+       DummyTestCase(String name)
+       {
+           super (name);
+       }
+   }
+ 
+   /**
+    * One of the goals of this class also is to keep original classNames into testNames. So, you will realize several proxies existent here to
+    * keep these class names while executing method names.
+    */
+   static class TestProxy extends TestCase
+   {
+       Hashtable hashTests = new Hashtable();
+
+
+       public TestProxy(Test testcase, String name)
+       {
+           super(name);
+           this.testcase = testcase;
+       }
+
+       public int countTestCases()
+       {
+           return testcase.countTestCases();
+       }
+
+       /**
+        * Create a dummy test renaming its content
+        * @param test
+        * @return
+        */
+       private Test createDummyTest(Test test)
+       {
+           Test dummyTest = (Test)hashTests.get(test);
+           if (dummyTest==null)
+           {
+               if (test instanceof TestCase)
+               {
+                   dummyTest = new DummyTestCase(this.getName() + ":"+ ((TestCase)test).getName());
+               } else
+               if (test instanceof TestSuite)
+               {
+                   dummyTest = new DummyTestCase(this.getName() + ":"+ ((TestCase)test).getName());
+               }
+               else
+               {
+                   dummyTest = new DummyTestCase(test.getClass().getName());
+               }
+
+               hashTests.put(test,dummyTest);
+           }
+
+           return dummyTest;
+       }
+
+       public void run(final TestResult result)
+       {
+           TestResult subResult = new TestResult();
+           subResult.addListener(new TestListener()
+           {
+               public void addError(Test subtest, Throwable throwable)
+               {
+                   Test dummyTest = createDummyTest(subtest);
+                   result.addError(dummyTest, throwable);
+               }
+
+               public void addFailure(Test subtest, AssertionFailedError assertionFailedError)
+               {
+                   Test dummyTest = createDummyTest(subtest);
+                   result.addFailure(dummyTest, assertionFailedError);
+               }
+
+               public void endTest(Test subtest)
+               {
+                   Test dummyTest = createDummyTest(subtest);
+                   result.endTest(dummyTest);
+               }
+
+               public void startTest(Test subtest)
+               {
+                   Test dummyTest = createDummyTest(subtest);
+                   result.startTest(dummyTest);
+               }
+           });
+           testcase.run(subResult);
+       }
+
+       Test testcase;
+   }
+
+   
+
+   
+
+   public static junit.framework.Test suite() throws Exception
+   {
+      TestSuite suite = new TestSuite();
+
+      suite.addTest(new TestProxy(TopicConnectionTest.suite(),TopicConnectionTest.class.getName()));
+      suite.addTest(new TestProxy(ConnectionTest.suite(), ConnectionTest.class.getName()));
+      suite.addTest(new TestProxy(MessageBodyTest.suite(), MessageBodyTest.class.getName()));
+      suite.addTest(new TestProxy(MessageDefaultTest.suite(), MessageDefaultTest.class.getName()));
+      suite.addTest(new TestProxy(MessageTypeTest.suite(), MessageTypeTest.class.getName()));
+      suite.addTest(new TestProxy(MessageHeaderTest.suite(), MessageHeaderTest.class.getName()));
+      suite.addTest(new TestProxy(JMSXPropertyTest.suite(), JMSXPropertyTest.class.getName()));
+      suite.addTest(new TestProxy(MessagePropertyConversionTest.suite(), MessagePropertyConversionTest.class.getName()));
+      suite.addTest(new TestProxy(MessagePropertyTest.suite(), MessagePropertyTest.class.getName()));
+      suite.addTest(new TestProxy(QueueBrowserTest.suite(), QueueBrowserTest.class.getName()));
+      suite.addTest(new TestProxy(TemporaryQueueTest.suite(), TemporaryQueueTest.class.getName()));
+      suite.addTest(new TestProxy(SelectorSyntaxTest.suite(), SelectorSyntaxTest.class.getName()));
+      suite.addTest(new TestProxy(SelectorTest.suite(), SelectorTest.class.getName()));
+      suite.addTest(new TestProxy(QueueSessionTest.suite(), QueueSessionTest.class.getName()));
+      suite.addTest(new TestProxy(SessionTest.suite(), SessionTest.class.getName()));
+      suite.addTest(new TestProxy(TopicSessionTest.suite(), TopicSessionTest.class.getName()));
+      suite.addTest(new TestProxy(UnifiedSessionTest.suite(), UnifiedSessionTest.class.getName()));
+      suite.addTest(new TestProxy(TemporaryTopicTest.suite(), TemporaryTopicTest.class.getName()));
+      
+      return new TestAggregation(suite);
+   }
+   /**
+    * Should be overriden 
+    * @return
+    */
+   protected static Properties getProviderProperties() throws IOException
+   {
+      Properties props = new Properties();
+      props.load(ClassLoader.getSystemResourceAsStream(JMSTestCase.PROP_FILE_NAME));
+      return props;
+   }
+
+   
+   static class TestAggregation extends TestSetup
+   {
+      
+      Admin admin;
+
+      /**
+       * @param test
+       */
+      public TestAggregation(Test test)
+      {
+         super(test);
+      }
+      
+      public void setUp() throws Exception
+      {
+         JMSTestCase.startServer = false;
+         // Admin step
+         // gets the provider administration wrapper...
+         Properties props = getProviderProperties();
+         admin = AdminFactory.getAdmin(props);
+         admin.startServer();
+
+      }
+      
+      public void tearDown() throws Exception
+      {
+         System.out.println("TearDown");
+         admin.stopServer();
+         JMSTestCase.startServer = true;
+      }
+      
+   }
+}

Modified: branches/Branch_2_2_EAP/tests/joram-tests/src/org/objectweb/jtests/jms/conform/message/MessageBodyTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/joram-tests/src/org/objectweb/jtests/jms/conform/message/MessageBodyTest.java	2011-08-09 17:43:09 UTC (rev 11170)
+++ branches/Branch_2_2_EAP/tests/joram-tests/src/org/objectweb/jtests/jms/conform/message/MessageBodyTest.java	2011-08-09 19:29:50 UTC (rev 11171)
@@ -19,6 +19,8 @@
 import javax.jms.TextMessage;
 
 import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestSuite;
 
 import org.objectweb.jtests.jms.framework.PTPTestCase;
 import org.objectweb.jtests.jms.framework.TestConfig;
@@ -31,7 +33,16 @@
  */
 public class MessageBodyTest extends PTPTestCase
 {
+   
+   /** 
+    * Method to use this class in a Test suite
+    */
+   public static Test suite()
+   {
+      return new TestSuite(MessageBodyTest.class);
+   }
 
+
    /**
     * Test that the <code>TextMessage.clearBody()</code> method does nto clear the 
     * message properties.

Modified: branches/Branch_2_2_EAP/tests/joram-tests/src/org/objectweb/jtests/jms/framework/JMSTestCase.java
===================================================================
--- branches/Branch_2_2_EAP/tests/joram-tests/src/org/objectweb/jtests/jms/framework/JMSTestCase.java	2011-08-09 17:43:09 UTC (rev 11170)
+++ branches/Branch_2_2_EAP/tests/joram-tests/src/org/objectweb/jtests/jms/framework/JMSTestCase.java	2011-08-09 19:29:50 UTC (rev 11171)
@@ -35,7 +35,9 @@
  */
 public abstract class JMSTestCase extends TestCase
 {
-   private static final String PROP_FILE_NAME = "provider.properties";
+   public static final String PROP_FILE_NAME = "provider.properties";
+   
+   public static boolean startServer = true;
 
    protected Admin admin;
 
@@ -91,8 +93,10 @@
       Properties props = getProviderProperties();
       admin = AdminFactory.getAdmin(props);
 
-      admin.startServer();
-
+      if (startServer)
+      {
+         admin.startServer();
+      }
       admin.start();
    }
 
@@ -101,8 +105,10 @@
    {
       admin.stop();
 
-      admin.stopServer();
-
+      if (startServer)
+      {
+          admin.stopServer();
+      }
       super.tearDown();
    }
 



More information about the hornetq-commits mailing list