activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1075068 - in /activemq/activemq-apollo/trunk/apollo-stomp: pom.xml src/test/resources/apollo-stomp-bdb.xml src/test/scala/org/apache/activemq/apollo/stomp/StompTest.scala
Date Sun, 27 Feb 2011 14:49:05 GMT
Author: chirino
Date: Sun Feb 27 14:49:05 2011
New Revision: 1075068

URL: http://svn.apache.org/viewvc?rev=1075068&view=rev
Log:
Added a test to validate that multiple durable subs are mirrors of each other.

Added:
    activemq/activemq-apollo/trunk/apollo-stomp/src/test/resources/apollo-stomp-bdb.xml
Modified:
    activemq/activemq-apollo/trunk/apollo-stomp/pom.xml
    activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/StompTest.scala

Modified: activemq/activemq-apollo/trunk/apollo-stomp/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/pom.xml?rev=1075068&r1=1075067&r2=1075068&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-stomp/pom.xml Sun Feb 27 14:49:05 2011
@@ -94,6 +94,23 @@
     </dependency>
 
     <dependency>
+      <groupId>org.eclipse.jetty.aggregate</groupId>
+      <artifactId>jetty-all-server</artifactId>
+      <version>${jetty-version}</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>apollo-web</artifactId>
+      <version>1.0-SNAPSHOT</version>
+      <type>jar</type>
+      <classifier>slim</classifier>
+      <scope>test</scope>
+    </dependency>
+
+
+    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <scope>test</scope>

Added: activemq/activemq-apollo/trunk/apollo-stomp/src/test/resources/apollo-stomp-bdb.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/src/test/resources/apollo-stomp-bdb.xml?rev=1075068&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/src/test/resources/apollo-stomp-bdb.xml (added)
+++ activemq/activemq-apollo/trunk/apollo-stomp/src/test/resources/apollo-stomp-bdb.xml Sun
Feb 27 14:49:05 2011
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+    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 xmlns="http://activemq.apache.org/schema/activemq/apollo">
+  <notes>Has a BDB store enabled.</notes>
+
+  <web_admin host="127.0.0.1" port="61680"/>
+
+  <virtual_host id="default" purge_on_startup="true">
+    <host_name>localhost</host_name>
+
+    <queue name="unified.**" unified="true"/>
+
+    <bdb_store directory="${apollo.base}/data"/>
+  </virtual_host>
+
+  <connector id="tcp" protocol="stomp" bind="tcp://0.0.0.0:0"/>
+
+</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=1075068&r1=1075067&r2=1075068&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 Feb 27 14:49:05 2011
@@ -30,10 +30,15 @@ class StompTestSupport extends FunSuiteS
   val broker_config_uri = "xml:classpath:apollo-stomp.xml"
 
   override protected def beforeAll() = {
-    info("Loading broker configuration from the classpath with URI: " + broker_config_uri)
-    broker = BrokerFactory.createBroker(broker_config_uri)
-    ServiceControl.start(broker, "Starting broker")
-    port = broker.connectors.head.transportServer.getSocketAddress.getPort
+    try {
+      info("Loading broker configuration from the classpath with URI: " + broker_config_uri)
+      broker = BrokerFactory.createBroker(broker_config_uri)
+      ServiceControl.start(broker, "Starting broker")
+      port = broker.connectors.head.transportServer.getSocketAddress.getPort
+    }
+    catch {
+      case e:Throwable => e.printStackTrace
+    }
   }
 
   var client = new StompClient
@@ -633,6 +638,90 @@ class StompDestinationTest extends Stomp
 
 }
 
+class DurableSubscriptionTest extends StompTestSupport {
+
+  override val broker_config_uri: String = "xml:classpath:apollo-stomp-bdb.xml"
+
+  test("Two durable subs contain the same messages") {
+    connect("1.1")
+
+    // establish 2 durable subs..
+    client.write(
+      "SUBSCRIBE\n" +
+      "destination:/topic/sometopic\n" +
+      "id:sub1\n" +
+      "persistent:true\n" +
+      "receipt:0\n" +
+      "\n")
+    wait_for_receipt("0")
+
+    client.write(
+      "SUBSCRIBE\n" +
+      "destination:/topic/sometopic\n" +
+      "id:sub2\n" +
+      "persistent:true\n" +
+      "receipt:0\n" +
+      "\n")
+    wait_for_receipt("0")
+
+    client.close
+    connect("1.1")
+
+
+    client.close
+    connect("1.1")
+
+    // Now send a bunch of messages....
+    println("sending")
+    def put(id:Int) = {
+      client.write(
+        "SEND\n" +
+        "destination:/topic/sometopic\n" +
+        "\n" +
+        "message:"+id+"\n")
+    }
+
+    for( i <- 1 to 1000 ) {
+      put(i)
+    }
+
+    // Now try to get all the previously sent messages.
+
+    def get(id:Int) = {
+      val frame = client.receive()
+      frame should startWith("MESSAGE\n")
+      frame should endWith regex("\n\nmessage:"+id+"\n")
+    }
+
+    // Empty out the first durable sub
+    client.write(
+      "SUBSCRIBE\n" +
+      "destination:/topic/sometopic\n" +
+      "id:sub1\n" +
+      "persistent:true\n" +
+      "\n")
+
+    println("getting from sub 1")
+    for( i <- 1 to 1000 ) {
+      get(i)
+    }
+
+    // Empty out the 2nd durable sub
+    println("getting from sub 2")
+    client.write(
+      "SUBSCRIBE\n" +
+      "destination:/topic/sometopic\n" +
+      "id:sub2\n" +
+      "persistent:true\n" +
+      "\n")
+
+    for( i <- 1 to 1000 ) {
+      get(i)
+    }
+
+  }
+}
+
 class StompUnifiedQueueTest extends StompTestSupport {
 
   test("Topic gets copy of message sent to queue") {



Mime
View raw message