activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1366704 - in /activemq/activemq-apollo/trunk: apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/ apollo-util/src/test/scala/org/apache/activemq/apollo/util/
Date Sat, 28 Jul 2012 16:26:47 GMT
Author: chirino
Date: Sat Jul 28 16:26:46 2012
New Revision: 1366704

URL: http://svn.apache.org/viewvc?rev=1366704&view=rev
Log:
Run the DestinationWildCard tests in parallel and avoid using receive timeouts.

Modified:
    activemq/activemq-apollo/trunk/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/DestinationWildcardTest.scala
    activemq/activemq-apollo/trunk/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/OpenwireTestSupport.scala
    activemq/activemq-apollo/trunk/apollo-util/src/test/scala/org/apache/activemq/apollo/util/FunSuiteSupport.scala

Modified: activemq/activemq-apollo/trunk/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/DestinationWildcardTest.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/DestinationWildcardTest.scala?rev=1366704&r1=1366703&r2=1366704&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/DestinationWildcardTest.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/DestinationWildcardTest.scala
Sat Jul 28 16:26:46 2012
@@ -17,47 +17,50 @@
 package org.apache.activemq.apollo.openwire.test
 
 import javax.jms.{MessageConsumer, MessageProducer, TextMessage, Session}
+import org.apache.activemq.apollo.broker.BrokerParallelTestExecution
 
-class DestinationWildcardTest extends OpenwireTestSupport {
+class DestinationWildcardTest extends OpenwireTestSupport with BrokerParallelTestExecution
{
 
   def path_separator = "."
 
   test("Wildcard subscription") {
     connect()
 
-    val prefix = "foo" + path_separator
+    val common_prefix = next_id()
+    val prefix = common_prefix + path_separator
 
     val session = default_connection.createSession(false, Session.AUTO_ACKNOWLEDGE)
     val producer1 = session.createProducer(queue(prefix + "A"))
     val producer2 = session.createProducer(queue(prefix + "B"))
-    val producer3 = session.createProducer(queue("bar.A"))
+    val producer3 = session.createProducer(queue(common_prefix+ "bar.A"))
     def put(producer: MessageProducer, id: Int) {
       producer.send(session.createTextMessage("message:" + id))
     }
 
-    List(1, 2, 3).foreach(put(producer1, _))
-    producer3.send(session.createTextMessage("This one shouldn't get consumed."))
-    List(1, 2, 3).foreach(put(producer2, _))
-
     val consumer = session.createConsumer(queue(prefix + "*"))
-
     def get(id: Int) {
-      val m = consumer.receive().asInstanceOf[TextMessage]
-      m.getText should equal("message:" + id)
+      receive_text(consumer) should equal("message:" + id)
     }
 
+    List(1, 2, 3).foreach(put(producer1, _))
     List(1, 2, 3).foreach(get _)
+
+    producer3.send(session.createTextMessage("This one shouldn't get consumed."))
+
+    List(1, 2, 3).foreach(put(producer2, _))
     List(1, 2, 3).foreach(get _)
 
-    consumer.receive(1000) should be(null)
+    put(producer1, -1)
+    get(-1)
   }
 
   test("Wildcard subscription with multiple path sections") {
     connect()
 
-    val prefix1 = "foo" + path_separator + "bar" + path_separator
-    val prefix2 = "foo" + path_separator + "bar" + path_separator + "cheeze" + path_separator
-    val prefix3 = "foo" + path_separator + "bar" + path_separator + "cracker" + path_separator
+    val common_prefix = next_id()
+    val prefix1 = common_prefix+"foo" + path_separator + "bar" + path_separator
+    val prefix2 = common_prefix+"foo" + path_separator + "bar" + path_separator + "cheeze"
+ path_separator
+    val prefix3 = common_prefix+"foo" + path_separator + "bar" + path_separator + "cracker"
+ path_separator
 
     val session = default_connection.createSession(false, Session.AUTO_ACKNOWLEDGE)
     val producer1 = session.createProducer(topic(prefix1 + "A"))
@@ -67,37 +70,35 @@ class DestinationWildcardTest extends Op
     def put(producer: MessageProducer, id: Int) {
       producer.send(session.createTextMessage("message:" + id))
     }
+    def get(consumer: MessageConsumer, id: Int) {
+      receive_text(consumer) should equal("message:" + id)
+    }
 
     val consumer1 = session.createConsumer(topic(prefix1 + "*"))
     val consumer2 = session.createConsumer(topic(prefix2 + "*"))
     val consumer3 = session.createConsumer(topic(prefix3 + "*"))
 
-    def get(consumer: MessageConsumer, id: Int) {
-      val m = consumer.receive(2000).asInstanceOf[TextMessage]
-      m should not be (null)
-      m.getText should equal("message:" + id)
-    }
 
-    // They only consumer one should see these.
-    List(1, 2, 3).foreach(put(producer1, _))
+    put(producer1, 1)
+    List(producer1, producer2, producer3).foreach(put(_, -1))
 
-    List(1, 2, 3).foreach(get(consumer1, _))
-    consumer2.receive(2000) should be(null)
-    consumer3.receive(2000) should be(null)
+    get(consumer1, 1)
+    List(consumer1, consumer2, consumer3).foreach(get(_, -1))
 
-    // They only consumer two should see these.
-    List(1, 2, 3).foreach(put(producer2, _))
 
-    List(1, 2, 3).foreach(get(consumer2, _))
-    consumer1.receive(2000) should be(null)
-    consumer3.receive(2000) should be(null)
-
-    // They only consumer two should see these.
-    List(1, 2, 3).foreach(put(producer3, _))
-
-    List(1, 2, 3).foreach(get(consumer3, _))
-    consumer1.receive(2000) should be(null)
-    consumer2.receive(2000) should be(null)
+    put(producer2, 2)
+    List(producer1, producer2, producer3).foreach(put(_, -1))
+
+    get(consumer2, 2)
+    List(consumer1, consumer2, consumer3).foreach(get(_, -1))
+
+
+    put(producer3, 3)
+    List(producer1, producer2, producer3).foreach(put(_, -1))
+
+    get(consumer3, 3)
+    List(consumer1, consumer2, consumer3).foreach(get(_, -1))
+
   }
 
 }
\ No newline at end of file

Modified: activemq/activemq-apollo/trunk/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/OpenwireTestSupport.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/OpenwireTestSupport.scala?rev=1366704&r1=1366703&r2=1366704&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/OpenwireTestSupport.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/OpenwireTestSupport.scala
Sat Jul 28 16:26:46 2012
@@ -20,7 +20,7 @@ package org.apache.activemq.apollo.openw
 import org.scalatest.matchers.ShouldMatchers
 import org.scalatest.BeforeAndAfterEach
 import java.lang.String
-import javax.jms.Connection
+import javax.jms.{MessageConsumer, TextMessage, Connection}
 import org.apache.activemq.ActiveMQConnectionFactory
 import org.apache.activemq.command.{ActiveMQTopic, ActiveMQQueue}
 import org.apache.activemq.apollo.broker.BrokerFunSuiteSupport
@@ -65,4 +65,7 @@ class OpenwireTestSupport extends Broker
     connection
   }
 
+  def receive_text(consumer:MessageConsumer) = consumer.receive().asInstanceOf[TextMessage].getText
+
+
 }
\ No newline at end of file

Modified: activemq/activemq-apollo/trunk/apollo-util/src/test/scala/org/apache/activemq/apollo/util/FunSuiteSupport.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/test/scala/org/apache/activemq/apollo/util/FunSuiteSupport.scala?rev=1366704&r1=1366703&r2=1366704&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-util/src/test/scala/org/apache/activemq/apollo/util/FunSuiteSupport.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-util/src/test/scala/org/apache/activemq/apollo/util/FunSuiteSupport.scala
Sat Jul 28 16:26:46 2012
@@ -27,10 +27,12 @@ import FileSupport._
 import scala.Some
 import org.apache.activemq.apollo.util.FunSuiteSupport._
 import java.util.concurrent.locks.{ReentrantReadWriteLock, Lock, ReadWriteLock}
+import java.util.concurrent.atomic.AtomicLong
 
 object FunSuiteSupport {
   class SkipTestException extends RuntimeException
   val parallel_test_class_lock = new ReentrantReadWriteLock()
+  val id_counter = new AtomicLong()
 }
 
 /**
@@ -39,6 +41,8 @@ object FunSuiteSupport {
 @RunWith(classOf[org.scalatest.junit.ParallelJUnitRunner])
 abstract class FunSuiteSupport extends FunSuite with Logging with ParallelBeforeAndAfterAll
{
 
+  def next_id(prefix:String="", suffix:String="") = prefix+id_counter.incrementAndGet()+suffix
+
   protected var _basedir = try {
     var file = new File(getClass.getProtectionDomain.getCodeSource.getLocation.getFile)
     file = (file / ".." / "..").getCanonicalFile



Mime
View raw message