activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1032406 - in /activemq/activemq-apollo/trunk: apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ apollo-broker/src/test/scala/org/apache/activemq/apollo/broker/jaxb/ apollo-stomp/src/test/resources/ apollo-stomp/src/test/scala...
Date Sun, 07 Nov 2010 21:48:14 GMT
Author: chirino
Date: Sun Nov  7 21:48:14 2010
New Revision: 1032406

URL: http://svn.apache.org/viewvc?rev=1032406&view=rev
Log:
use dynamic ports for the stomp unit test to avoid port conflicts.

Modified:
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala
    activemq/activemq-apollo/trunk/apollo-broker/src/test/scala/org/apache/activemq/apollo/broker/jaxb/XMLBrokerFactoryTest.scala
    activemq/activemq-apollo/trunk/apollo-stomp/src/test/resources/activemq-stomp.xml
    activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/StompTest.scala

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala?rev=1032406&r1=1032405&r2=1032406&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala
Sun Nov  7 21:48:14 2010
@@ -53,17 +53,14 @@ object BrokerFactory {
   var providers = discover
 
 
-  def createBroker(uri:String, start:Boolean=false):Broker = {
+  def createBroker(uri:String):Broker = {
     if( uri == null ) {
       return null
     }
     providers.foreach { provider=>
       val broker = provider.createBroker(uri)
       if( broker!=null ) {
-        if (start) {
-          broker.start();
-        }
-        return broker
+        return broker;
       }
     }
     throw new IllegalArgumentException("Uknonwn broker uri: "+uri)

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/test/scala/org/apache/activemq/apollo/broker/jaxb/XMLBrokerFactoryTest.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/test/scala/org/apache/activemq/apollo/broker/jaxb/XMLBrokerFactoryTest.scala?rev=1032406&r1=1032405&r2=1032406&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/test/scala/org/apache/activemq/apollo/broker/jaxb/XMLBrokerFactoryTest.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/test/scala/org/apache/activemq/apollo/broker/jaxb/XMLBrokerFactoryTest.scala
Sun Nov  7 21:48:14 2010
@@ -29,7 +29,7 @@ class XMLBrokerFactoryTest extends FunSu
   test("Simple Config") {
     val uri = "xml:classpath:org/apache/activemq/apollo/broker/jaxb/testSimpleConfig.xml"
     info("Loading broker configuration from the classpath with URI: " + uri)
-    val broker = BrokerFactory.createBroker(uri, false)
+    val broker = BrokerFactory.createBroker(uri)
 
     //		assertEquals(4, p.getSize())
     //		assertEquals("test dispatcher", p.getName())
@@ -71,24 +71,24 @@ class XMLBrokerFactoryTest extends FunSu
 
     expectException("Creating broker from non-existing url does not throw an exception!")
{
       val uri = "xml:classpath:org/apache/activemq/apollo/broker/jaxb/testUris-fail.xml"
-      BrokerFactory.createBroker(uri, false)
+      BrokerFactory.createBroker(uri)
     }
 
     //non-existent file
     expectException("Creating broker from non-existing url does not throw an exception!")
{
       val uri = "xml:file:/org/apache/activemq/apollo/broker/jaxb/testUris-fail.xml"
-      BrokerFactory.createBroker(uri, false)
+      BrokerFactory.createBroker(uri)
     }
 
     //non-existent url
     expectException("Creating broker from non-existing url does not throw an exception!")
{
       val uri = "xml:http://localhost/testUris.xml"
-      BrokerFactory.createBroker(uri, false)
+      BrokerFactory.createBroker(uri)
     }
 
     // regular file
     val uri = "xml:" + Thread.currentThread().getContextClassLoader().getResource("org/apache/activemq/apollo/broker/jaxb/testUris.xml")
-    BrokerFactory.createBroker(uri, false)
+    BrokerFactory.createBroker(uri)
   }
 
 }

Modified: activemq/activemq-apollo/trunk/apollo-stomp/src/test/resources/activemq-stomp.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/src/test/resources/activemq-stomp.xml?rev=1032406&r1=1032405&r2=1032406&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/src/test/resources/activemq-stomp.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-stomp/src/test/resources/activemq-stomp.xml Sun
Nov  7 21:48:14 2010
@@ -16,9 +16,9 @@
     limitations under the License.
 -->
 <broker basedir="./activemq-data/default" rev="1" enabled="true" id="default" xmlns="http://activemq.apache.org/schema/activemq/apollo">
-    <notes>A default configuration</notes>
+    <notes>This broker configuration is what the unit tests in this module load up.</notes>
     <virtual-host purge-on-startup="false" auto-create-queues="true" enabled="true" id="default">
         <host-name>localhost</host-name>
     </virtual-host>
-    <connectors advertise="tcp://localhost:61613" protocol="stomp" bind="tcp://0.0.0.0:61613"
enabled="true" id="default"/>
+    <connectors advertise="tcp://localhost:61613" protocol="stomp" bind="tcp://0.0.0.0:0"
enabled="true" id="default"/>
 </broker>
\ No newline at end of file

Modified: activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/StompTest.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/StompTest.scala?rev=1032406&r1=1032405&r2=1032406&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/StompTest.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/StompTest.scala
Sun Nov  7 21:48:14 2010
@@ -19,16 +19,18 @@ package org.apache.activemq.apollo.stomp
 import org.scalatest.matchers.ShouldMatchers
 import org.apache.activemq.apollo.broker.{Broker, BrokerFactory}
 import org.scalatest.BeforeAndAfterEach
-import org.apache.activemq.apollo.util.{Logging, FunSuiteSupport}
+import org.apache.activemq.apollo.util.{Logging, FunSuiteSupport, ServiceControl}
 
 class StompTestSupport extends FunSuiteSupport with ShouldMatchers with BeforeAndAfterEach
with Logging {
   var broker: Broker = null
-
+  var port = 0
+  
   override protected def beforeAll() = {
     val uri = "xml:classpath:activemq-stomp.xml"
     info("Loading broker configuration from the classpath with URI: " + uri)
-    broker = BrokerFactory.createBroker(uri, true)
-    Thread.sleep(1000); //TODO implement waitUntilStarted
+    broker = BrokerFactory.createBroker(uri)
+    ServiceControl.start(broker, "Starting broker")
+    port = broker.connectors.head.transportServer.getSocketAddress.getPort
   }
 
   var client = new StompClient
@@ -43,7 +45,7 @@ class StompTestSupport extends FunSuiteS
   }
 
   def connect(version:String, c: StompClient = client) = {
-    c.open("localhost", 61613)
+    c.open("localhost", port)
     version match {
       case "1.0"=>
         c.write(
@@ -88,7 +90,7 @@ class Stomp11ConnectTest extends StompTe
 
   test("Stomp 1.1 CONNECT /w STOMP Action") {
 
-    client.open("localhost", 61613)
+    client.open("localhost", port)
 
     client.write(
       "STOMP\n" +
@@ -103,7 +105,7 @@ class Stomp11ConnectTest extends StompTe
 
   test("Stomp 1.1 CONNECT /w valid version fallback") {
 
-    client.open("localhost", 61613)
+    client.open("localhost", port)
 
     client.write(
       "CONNECT\n" +
@@ -118,7 +120,7 @@ class Stomp11ConnectTest extends StompTe
 
   test("Stomp 1.1 CONNECT /w invalid version fallback") {
 
-    client.open("localhost", 61613)
+    client.open("localhost", port)
 
     client.write(
       "CONNECT\n" +
@@ -133,7 +135,7 @@ class Stomp11ConnectTest extends StompTe
 
   test("Stomp CONNECT /w invalid virtual host") {
 
-    client.open("localhost", 61613)
+    client.open("localhost", port)
 
     client.write(
       "CONNECT\n" +
@@ -151,7 +153,7 @@ class Stomp11HeartBeatTest extends Stomp
 
   test("Stomp 1.1 Broker sends heart-beat") {
 
-    client.open("localhost", 61613)
+    client.open("localhost", port)
 
     client.write(
       "CONNECT\n" +
@@ -180,7 +182,7 @@ class Stomp11HeartBeatTest extends Stomp
     StompProtocolHandler.inbound_heartbeat = 1000L
     try {
   
-      client.open("localhost", 61613)
+      client.open("localhost", port)
 
       client.write(
         "CONNECT\n" +



Mime
View raw message