activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1390048 [2/2] - in /activemq/activemq-apollo/trunk: ./ apollo-cli/ apollo-distro/ apollo-distro/src/main/descriptors/ apollo-distro/src/main/release/examples/mqtt/java/ apollo-mqtt/ apollo-mqtt/src/ apollo-mqtt/src/main/ apollo-mqtt/src/ma...
Date Tue, 25 Sep 2012 18:53:04 GMT
Added: activemq/activemq-apollo/trunk/apollo-mqtt/src/test/ide-resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-mqtt/src/test/ide-resources/log4j.properties?rev=1390048&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-mqtt/src/test/ide-resources/log4j.properties (added)
+++ activemq/activemq-apollo/trunk/apollo-mqtt/src/test/ide-resources/log4j.properties Tue
Sep 25 18:53:01 2012
@@ -0,0 +1,34 @@
+# 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.
+#
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=WARN, console, file
+log4j.logger.org.apache.activemq=TRACE
+
+# Console will only display warnnings
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%-5p | %t | %m%n
+log4j.appender.console.threshold=TRACE
+
+# File appender will contain all info messages
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d | %-5p | %m | %c | %t%n
+log4j.appender.file.file=target/test.log
+log4j.appender.file.append=true

Propchange: activemq/activemq-apollo/trunk/apollo-mqtt/src/test/ide-resources/log4j.properties
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/apollo-mqtt-bdb.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/apollo-mqtt-bdb.xml?rev=1390048&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/apollo-mqtt-bdb.xml (added)
+++ activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/apollo-mqtt-bdb.xml Tue
Sep 25 18:53:01 2012
@@ -0,0 +1,32 @@
+<?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>
+
+  <virtual_host id="default">
+    <host_name>localhost</host_name>
+
+    <queue name="unified.**" unified="true"/>
+
+    <bdb_store directory="${testdatadir}"/>
+  </virtual_host>
+
+  <!--<web_admin bind="http://0.0.0.0:61680"/>-->
+  <connector id="tcp" bind="tcp://0.0.0.0:0"/>
+
+</broker>
\ No newline at end of file

Added: activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/apollo-mqtt-leveldb.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/apollo-mqtt-leveldb.xml?rev=1390048&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/apollo-mqtt-leveldb.xml
(added)
+++ activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/apollo-mqtt-leveldb.xml
Tue Sep 25 18:53:01 2012
@@ -0,0 +1,32 @@
+<?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 LevelDB store enabled.</notes>
+
+  <virtual_host id="default">
+    <host_name>localhost</host_name>
+
+    <queue name="unified.**" unified="true"/>
+
+    <leveldb_store directory="${testdatadir}"/>
+  </virtual_host>
+
+  <!--<web_admin bind="http://0.0.0.0:61680"/>-->
+  <connector id="tcp" bind="tcp://0.0.0.0:0"/>
+
+</broker>
\ No newline at end of file

Added: activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/apollo-mqtt.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/apollo-mqtt.xml?rev=1390048&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/apollo-mqtt.xml (added)
+++ activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/apollo-mqtt.xml Tue Sep
25 18:53:01 2012
@@ -0,0 +1,32 @@
+<?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>This broker configuration is what the unit tests in this module load up.</notes>
+
+  <virtual_host id="default" purge_on_startup="true" auto_create_queues="true">
+    <host_name>localhost</host_name>
+    <host_name>127.0.0.1</host_name>
+
+    <queue name="unified.**" unified="true"/>
+
+  </virtual_host>
+
+  <!--<web_admin bind="http://0.0.0.0:61680"/>-->
+  <connector id="tcp" bind="tcp://0.0.0.0:0"/>
+
+</broker>
\ No newline at end of file

Added: activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/apollo.ks
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/apollo.ks?rev=1390048&view=auto
==============================================================================
Files activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/apollo.ks (added) and
activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/apollo.ks Tue Sep 25 18:53:01
2012 differ

Propchange: activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/apollo.ks
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/client.ks
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/client.ks?rev=1390048&view=auto
==============================================================================
Files activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/client.ks (added) and
activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/client.ks Tue Sep 25 18:53:01
2012 differ

Propchange: activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/client.ks
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/log4j.properties?rev=1390048&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/log4j.properties (added)
+++ activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/log4j.properties Tue Sep
25 18:53:01 2012
@@ -0,0 +1,45 @@
+# 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.
+#
+
+#
+# Setup the default logging levels
+#
+log4j.rootLogger=WARN, console, logfile
+log4j.logger.org.apache.activemq.apollo=INFO
+
+#
+# Uncomment one of the following to enable debug logging
+#
+log4j.logger.org.apache.activemq.apollo=TRACE
+# log4j.logger.org.apache.activemq.apollo.broker=DEBUG
+# log4j.logger.org.apache.activemq.apollo.web=DEBUG
+# log4j.logger.org.apache.activemq.apollo.cli=DEBUG
+# log4j.logger.org.apache.activemq.apollo.broker.store.hawtdb=DEBUG
+
+# Console Settings
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%-5p | %m%n
+log4j.appender.console.threshold=TRACE
+
+# File Settings
+log4j.appender.logfile=org.apache.log4j.RollingFileAppender
+log4j.appender.logfile.file=apollo.log
+log4j.appender.logfile.maxFileSize=5MB
+log4j.appender.logfile.maxBackupIndex=5
+log4j.appender.logfile.append=true
+log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
+log4j.appender.logfile.layout.ConversionPattern=%d | %-5p | %m | %c | %t%n

Added: activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/login.config
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/login.config?rev=1390048&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/login.config (added)
+++ activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/login.config Tue Sep 25
18:53:01 2012
@@ -0,0 +1,40 @@
+// ---------------------------------------------------------------------------
+// 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.
+// ---------------------------------------------------------------------------
+
+MqttSecurityTest {
+
+  org.apache.activemq.apollo.broker.security.FileUserLoginModule optional
+    file="users.properties";
+
+  //
+  // For testing purposes, we do a funny thing where we set the user
+  // file to also be used as the groups file.  This only works for the
+  // test since  user==password==group for our tests.
+  //
+  org.apache.activemq.apollo.broker.security.FileGroupLoginModule optional
+    file="users.properties";
+
+};
+
+MqttSslSecurityTest {
+  org.apache.activemq.apollo.broker.security.CertificateLoginModule optional;
+
+  org.apache.activemq.apollo.broker.security.FileGroupLoginModule optional
+    match="javax.security.auth.x500.X500Principal"
+    file="users.properties";
+
+};
\ No newline at end of file

Added: activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/org/apache/activemq/apollo/mqtt/dto/simple.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/org/apache/activemq/apollo/mqtt/dto/simple.xml?rev=1390048&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/org/apache/activemq/apollo/mqtt/dto/simple.xml
(added)
+++ activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/org/apache/activemq/apollo/mqtt/dto/simple.xml
Tue Sep 25 18:53:01 2012
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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">
+  <virtual_host id="vh-local">
+  </virtual_host>
+
+  <connector bind="tcp://0.0.0.0:61616" id="port-61616">
+    <mqtt>
+      <protocol_filter>fooo</protocol_filter>
+    </mqtt>
+  </connector>
+</broker>

Added: activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/users.properties
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/users.properties?rev=1390048&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/users.properties (added)
+++ activemq/activemq-apollo/trunk/apollo-mqtt/src/test/resources/users.properties Tue Sep
25 18:53:01 2012
@@ -0,0 +1,39 @@
+# 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.
+#
+
+connect_group=CN=ssl_user|can_only_connect|can_send_create_queue|can_send_queue|can_receive_queue|can_consume_queue|can_send_create_topic|can_send_topic|can_recieve_topic|can_consume_create_ds|can_consume_ds
+
+guest=guest
+can_not_connect=can_not_connect
+can_only_connect=can_only_connect
+
+#
+# Users with specific roles related to queues
+#
+can_send_create_queue=can_send_create_queue
+can_send_queue=can_send_queue
+can_receive_queue=can_receive_queue
+can_consume_queue=can_consume_queue
+
+#
+# Users with specific roles related to topics
+#
+can_send_create_topic=can_send_create_topic
+can_send_topic=can_send_topic
+can_recieve_topic=can_recieve_topic
+can_consume_create_ds=can_consume_create_ds
+can_consume_ds=can_consume_ds
+

Added: activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/dto/XmlCodecTest.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/dto/XmlCodecTest.java?rev=1390048&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/dto/XmlCodecTest.java
(added)
+++ activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/dto/XmlCodecTest.java
Tue Sep 25 18:53:01 2012
@@ -0,0 +1,52 @@
+/**
+ * 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.
+ */
+package org.apache.activemq.apollo.mqtt.dto;
+
+import org.apache.activemq.apollo.dto.*;
+import org.junit.Test;
+
+import java.io.InputStream;
+import java.util.List;
+
+import static junit.framework.Assert.*;
+import static junit.framework.Assert.assertEquals;
+
+
+/**
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+
+public class XmlCodecTest {
+
+    private InputStream resource(String path) {
+        return getClass().getResourceAsStream(path);
+    }
+
+    @Test
+    public void unmarshalling() throws Exception {
+        BrokerDTO dto = XmlCodec.decode(BrokerDTO.class, resource("simple.xml"));
+        assertNotNull(dto);
+
+        assertEquals(1, dto.connectors.size());
+        AcceptingConnectorDTO connector = (AcceptingConnectorDTO)dto.connectors.get(0);
+        assertEquals(1, connector.protocols.size());
+        ProtocolDTO mqtt = connector.protocols.get(0);
+        assertTrue(mqtt instanceof MqttDTO);
+
+    }
+
+}

Added: activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttCleanSessionTest.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttCleanSessionTest.scala?rev=1390048&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttCleanSessionTest.scala
(added)
+++ activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttCleanSessionTest.scala
Tue Sep 25 18:53:01 2012
@@ -0,0 +1,204 @@
+/**
+ * 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.
+ */
+
+package org.apache.activemq.apollo.mqtt.test
+
+import org.fusesource.hawtdispatch._
+import org.fusesource.mqtt.client._
+import QoS._
+import java.util.concurrent.TimeUnit._
+
+class MqttCleanSessionTest extends MqttTestSupport {
+
+  test("Subscribing to overlapping topics") {
+    connect()
+    subscribe("overlap/#")
+    subscribe("overlap/a/b")
+    subscribe("overlap/a/+")
+
+    // This is checking that we don't get duplicate messages
+    // due to the overlapping nature of the subscriptions.
+    publish("overlap/a/b", "1", EXACTLY_ONCE)
+    should_receive("1", "overlap/a/b")
+    publish("overlap/a", "2", EXACTLY_ONCE)
+    should_receive("2", "overlap/a")
+    publish("overlap/a/b", "3", EXACTLY_ONCE)
+    should_receive("3", "overlap/a/b")
+
+    // Dropping subscriptions should not affect us while there
+    // is still a matching sub left.
+    unsubscribe("overlap/#")
+    publish("overlap/a/b", "4", EXACTLY_ONCE)
+    should_receive("4", "overlap/a/b")
+
+    unsubscribe("overlap/a/b")
+    publish("overlap/a/b", "5", EXACTLY_ONCE)
+    should_receive("5", "overlap/a/b")
+
+    // Drop the last subscription.. but setup root sub we can test
+    // without using timeouts.
+    publish("foo", "6", EXACTLY_ONCE) // never did match
+    unsubscribe("overlap/a/+")
+    publish("overlap/a/b", "7", EXACTLY_ONCE) // should not match anymore.
+
+    // Send a message through to flush everything out and verify none of the other
+    // are getting routed to us.
+    println("subscribing...")
+    subscribe("#")
+    println("publishinng...")
+    publish("foo", "8", EXACTLY_ONCE)
+    println("receiving...")
+    should_receive("8", "foo")
+
+  }
+
+  def will_test(kill_action: (MqttClient) => Unit) = {
+    connect()
+    subscribe("will/foo")
+
+    val will_client = new MqttClient
+    will_client.setWillTopic("will/foo")
+    will_client.setWillQos(AT_LEAST_ONCE)
+    will_client.setWillRetain(false)
+    will_client.setWillMessage("1");
+    kill_action(will_client)
+    should_receive("1", "will/foo")
+  }
+
+  test("Will sent on socket failure") {
+    will_test {
+      client =>
+        connect(client)
+        kill(client)
+    }
+  }
+
+  test("Will sent on keepalive failure") {
+    will_test {
+      client =>
+        val queue = createQueue("")
+        client.setKeepAlive(1)
+        client.setDispatchQueue(queue)
+        client.setReconnectAttemptsMax(0)
+        client.setDispatchQueue(queue);
+        connect(client)
+
+        // Client should time out once we suspend the queue.
+        queue.suspend()
+        Thread.sleep(1000 * 2);
+        queue.resume()
+    }
+  }
+
+  test("Will NOT sent on clean disconnect") {
+    expect(true) {
+      try {
+        will_test {
+          client =>
+            connect(client)
+            disconnect(client)
+        }
+        false
+      } catch {
+        case e: Throwable =>
+          e.printStackTrace()
+          true
+      }
+    }
+  }
+
+  test("Publish") {
+    connect()
+    publish("test", "message", EXACTLY_ONCE)
+    topic_status("test").metrics.enqueue_item_counter should be(1)
+
+    publish("test", "message", AT_LEAST_ONCE)
+    topic_status("test").metrics.enqueue_item_counter should be(2)
+
+    publish("test", "message", AT_MOST_ONCE)
+
+    within(1, SECONDS) {
+      // since AT_MOST_ONCE use non-blocking sends.
+      topic_status("test").metrics.enqueue_item_counter should be(3)
+    }
+  }
+
+  test("Subscribe") {
+    connect()
+    subscribe("foo")
+    publish("foo", "1", EXACTLY_ONCE)
+    should_receive("1", "foo")
+  }
+
+  test("Subscribing wiht multi-level wildcard") {
+    connect()
+    subscribe("mwild/#")
+    publish("mwild", "1", EXACTLY_ONCE)
+    // Should not match
+    publish("mwild.", "2", EXACTLY_ONCE)
+    publish("mwild/hello", "3", EXACTLY_ONCE)
+    publish("mwild/hello/world", "4", EXACTLY_ONCE)
+
+    for (i <- List(("mwild", "1"), ("mwild/hello", "3"), ("mwild/hello/world", "4")))
{
+      should_receive(i._2, i._1)
+    }
+  }
+
+  test("Subscribing with single-level wildcard") {
+    connect()
+    subscribe("swild/+")
+    // Should not a match
+    publish("swild", "1", EXACTLY_ONCE)
+    publish("swild/hello", "2", EXACTLY_ONCE)
+    // Should not match..
+    publish("swild/hello/world", "3", EXACTLY_ONCE)
+    // Should match. so.cool is only one level, but STOMP would treat it like 2,
+    // Lets make sure Apollo's STOMP support does not mess with us.
+    publish("swild/so.cool", "4", EXACTLY_ONCE)
+
+    for (i <- List(("swild/hello", "2"), ("swild/so.cool", "4"))) {
+      should_receive(i._2, i._1)
+    }
+  }
+
+  test("Retained Messages are retained") {
+    connect()
+    publish("retained", "1", AT_LEAST_ONCE, false)
+    publish("retained", "2", AT_LEAST_ONCE, true)
+    publish("retained", "3", AT_LEAST_ONCE, false)
+    subscribe("retained")
+    should_receive("2", "retained")
+  }
+
+  test("Non-retained Messages are not retained") {
+    connect()
+    publish("notretained", "1", AT_LEAST_ONCE, false)
+    subscribe("notretained")
+    publish("notretained", "2", AT_LEAST_ONCE, false)
+    should_receive("2", "notretained")
+  }
+
+  test("You can clear out topic's retained message, by sending a retained empty message.")
{
+    connect()
+    publish("clearretained", "1", AT_LEAST_ONCE, true)
+    publish("clearretained", "", AT_LEAST_ONCE, true)
+    subscribe("clearretained")
+    publish("clearretained", "2", AT_LEAST_ONCE, false)
+    should_receive("2", "clearretained")
+  }
+
+}

Added: activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttConnectionTest.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttConnectionTest.scala?rev=1390048&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttConnectionTest.scala
(added)
+++ activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttConnectionTest.scala
Tue Sep 25 18:53:01 2012
@@ -0,0 +1,49 @@
+/**
+ * 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.
+ */
+
+package org.apache.activemq.apollo.mqtt.test
+
+import org.fusesource.hawtdispatch._
+import java.util.concurrent.TimeUnit._
+
+class MqttConnectionTest extends MqttTestSupport {
+
+  test("MQTT CONNECT") {
+    client.open("localhost", port)
+  }
+
+  test("MQTT Broker times out idle connection") {
+
+    val queue = createQueue("test")
+
+    client.setKeepAlive(1)
+    client.setDispatchQueue(queue)
+    client.setReconnectAttemptsMax(0)
+    client.setDispatchQueue(queue);
+    client.open("localhost", port)
+
+    client.connection.isConnected should be(true)
+    queue.suspend() // this will cause the client to hang
+    Thread.sleep(1000 * 2);
+    queue.resume()
+    within(1, SECONDS) {
+      client.connection.isConnected should be(false)
+    }
+  }
+
+}
+

Added: activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttExistingSessionOnBDBTest.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttExistingSessionOnBDBTest.scala?rev=1390048&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttExistingSessionOnBDBTest.scala
(added)
+++ activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttExistingSessionOnBDBTest.scala
Tue Sep 25 18:53:01 2012
@@ -0,0 +1,25 @@
+/**
+ * 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.
+ */
+
+package org.apache.activemq.apollo.mqtt.test
+
+
+class MqttExistingSessionOnBDBTest extends MqttExistingSessionTest {
+  override val broker_config_uri = "xml:classpath:apollo-mqtt-bdb.xml"
+
+  override def restart = {} //broker_restart
+}

Added: activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttExistingSessionOnLevelDBTest.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttExistingSessionOnLevelDBTest.scala?rev=1390048&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttExistingSessionOnLevelDBTest.scala
(added)
+++ activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttExistingSessionOnLevelDBTest.scala
Tue Sep 25 18:53:01 2012
@@ -0,0 +1,26 @@
+/**
+ * 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.
+ */
+
+package org.apache.activemq.apollo.mqtt.test
+
+
+class MqttExistingSessionOnLevelDBTest extends MqttExistingSessionTest {
+  override val broker_config_uri = "xml:classpath:apollo-mqtt-leveldb.xml"
+
+  override def restart = {} // broker_restart
+}
+

Added: activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttExistingSessionTest.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttExistingSessionTest.scala?rev=1390048&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttExistingSessionTest.scala
(added)
+++ activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttExistingSessionTest.scala
Tue Sep 25 18:53:01 2012
@@ -0,0 +1,42 @@
+/**
+ * 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.
+ */
+
+package org.apache.activemq.apollo.mqtt.test
+
+import org.fusesource.mqtt.client._
+import QoS._
+
+class MqttExistingSessionTest extends MqttTestSupport {
+  client.setCleanSession(false);
+  client.setClientId("default")
+
+  def restart = {}
+
+  test("Subscribe is remembered on existing sessions.") {
+    connect()
+    subscribe("existing/sub")
+
+    // reconnect...
+    disconnect()
+    restart
+    connect()
+
+    // The subscribe should still be remembered.
+    publish("existing/sub", "1", EXACTLY_ONCE)
+    should_receive("1", "existing/sub")
+  }
+}

Added: activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttQosTest.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttQosTest.scala?rev=1390048&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttQosTest.scala
(added)
+++ activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttQosTest.scala
Tue Sep 25 18:53:01 2012
@@ -0,0 +1,43 @@
+/**
+ * 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.
+ */
+
+package org.apache.activemq.apollo.mqtt.test
+
+import org.fusesource.mqtt.client._
+import QoS._
+
+class MqttQosTest extends MqttTestSupport {
+
+  //
+  // Lets make sure we can publish and subscribe with all the QoS combinations.
+  //
+  for (clean <- List(true, false)) {
+    for (send_qos <- List(AT_MOST_ONCE, AT_LEAST_ONCE, EXACTLY_ONCE)) {
+      for (receive_qos <- List(AT_MOST_ONCE, AT_LEAST_ONCE, EXACTLY_ONCE)) {
+        test("Publish " + send_qos + " and subscribe " + receive_qos + " on clean session:
" + clean) {
+          val topic = "qos/" + send_qos + "/" + receive_qos + "/" + clean
+          client.setClientId(topic)
+          client.setCleanSession(clean)
+          connect()
+          subscribe(topic, receive_qos)
+          publish(topic, "1", send_qos)
+          should_receive("1", topic)
+        }
+      }
+    }
+  }
+}

Added: activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttStompInteropTest.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttStompInteropTest.scala?rev=1390048&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttStompInteropTest.scala
(added)
+++ activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttStompInteropTest.scala
Tue Sep 25 18:53:01 2012
@@ -0,0 +1,72 @@
+/**
+ * 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.
+ */
+
+package org.apache.activemq.apollo.mqtt.test
+
+import org.fusesource.mqtt.client._
+import QoS._
+import java.util.concurrent.TimeUnit._
+import org.fusesource.stomp.codec.StompFrame
+import org.fusesource.stomp.client.{Constants, Stomp}
+import org.fusesource.hawtbuf.Buffer
+
+class MqttStompInteropTest extends MqttTestSupport {
+
+  import Constants._
+  import Buffer._
+
+  test("MQTT to STOMP via topic") {
+    val stomp = new Stomp("localhost", port).connectFuture().await()
+
+    // Setup the STOMP subscription.
+    val subscribe = new StompFrame(SUBSCRIBE)
+    subscribe.addHeader(ID, ascii("0"))
+    subscribe.addHeader(DESTINATION, ascii("/topic/mqtt.to.stomp"))
+    stomp.request(subscribe).await()
+
+    // Send from MQTT.
+    connect()
+    publish("mqtt/to/stomp", "Hello World", AT_LEAST_ONCE)
+
+    val frame = stomp.receive().await(5, SECONDS)
+    expect(true, "receive timeout")(frame != null)
+    frame.action().toString should be(MESSAGE.toString)
+    frame.contentAsString() should be("Hello World")
+
+  }
+
+  test("STOMP to MQTT via topic") {
+    connect()
+    subscribe("stomp/to/mqtt")
+
+    val stomp = new Stomp("localhost", port).connectFuture().await()
+    val send = new StompFrame(SEND)
+    send.addHeader(DESTINATION, ascii("/topic/stomp.to.mqtt"))
+    send.addHeader(MESSAGE_ID, ascii("test"))
+    send.content(ascii("Hello World"))
+    stomp.send(send)
+
+    should_receive(
+      "MESSAGE\n" +
+              "content-length:11\n" +
+              "message-id:test\n" +
+              "destination:/topic/stomp.to.mqtt\n" +
+              "\n" +
+              "Hello World",
+      "stomp/to/mqtt")
+  }
+}

Added: activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttTestSupport.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttTestSupport.scala?rev=1390048&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttTestSupport.scala
(added)
+++ activemq/activemq-apollo/trunk/apollo-mqtt/src/test/scala/org/apache/activemq/apollo/mqtt/test/MqttTestSupport.scala
Tue Sep 25 18:53:01 2012
@@ -0,0 +1,105 @@
+/**
+ * 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.
+ */
+
+package org.apache.activemq.apollo.mqtt.test
+
+import org.scalatest.matchers.ShouldMatchers
+import org.scalatest.BeforeAndAfterEach
+import java.lang.String
+import org.fusesource.hawtdispatch._
+import org.fusesource.hawtbuf.Buffer._
+import java.net.InetSocketAddress
+import org.apache.activemq.apollo.broker._
+import org.apache.activemq.apollo.util._
+import org.fusesource.mqtt.client._
+import QoS._
+import org.apache.activemq.apollo.dto.TopicStatusDTO
+import java.util.concurrent.TimeUnit._
+import FileSupport._
+import FutureResult._
+
+class MqttTestSupport extends BrokerFunSuiteSupport with ShouldMatchers with BeforeAndAfterEach
with Logging {
+
+
+  override def broker_config_uri = "xml:classpath:apollo-mqtt.xml"
+
+  var clients = List[MqttClient]()
+  var client = create_client
+
+  def create_client = {
+    val client = new MqttClient
+    clients ::= client
+    client
+  }
+
+  override protected def afterEach() = {
+    super.afterEach
+    clients.foreach(_.disconnect)
+    clients = Nil
+    client = create_client
+  }
+
+  class MqttClient extends MQTT {
+
+    var connection: BlockingConnection = _
+
+    def open(host: String, port: Int) = {
+      setHost(host, port)
+      connection = blockingConnection();
+      connection.connect();
+    }
+
+    def disconnect() = {
+      connection.disconnect()
+    }
+  }
+
+  def connect(c: MqttClient = client) = {
+    c.open("localhost", port)
+  }
+
+  def disconnect(c: MqttClient = client) = {
+    c.disconnect()
+  }
+
+  def kill(c: MqttClient = client) = {
+    c.connection.kill()
+  }
+
+  def publish(topic: String, message: String, qos: QoS = AT_MOST_ONCE, retain: Boolean =
false, c: MqttClient = client) = {
+    c.connection.publish(topic, message.getBytes("UTF-8"), qos, retain)
+  }
+
+  def subscribe(topic: String, qos: QoS = AT_MOST_ONCE, c: MqttClient = client) = {
+    c.connection.subscribe(Array(new org.fusesource.mqtt.client.Topic(topic, qos)))
+  }
+
+  def unsubscribe(topic: String, c: MqttClient = client) = {
+    c.connection.unsubscribe(Array(topic))
+  }
+
+  def should_receive(body: String, topic: String = null, c: MqttClient = client) = {
+    val msg = c.connection.receive(5, SECONDS);
+    expect(true)(msg != null)
+    if (topic != null) {
+      msg.getTopic should equal(topic)
+    }
+    new String(msg.getPayload, "UTF-8") should equal(body)
+    msg.ack()
+  }
+
+}

Modified: activemq/activemq-apollo/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/pom.xml?rev=1390048&r1=1390047&r2=1390048&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/pom.xml (original)
+++ activemq/activemq-apollo/trunk/pom.xml Tue Sep 25 18:53:01 2012
@@ -82,6 +82,7 @@
     <rome-version>0.8</rome-version>
 
     <slf4j-version>1.6.1</slf4j-version>
+    <mqtt-client-version>1.4</mqtt-client-version>
 
     <jaxb-api-version>2.1</jaxb-api-version>
     <jaxb-version>2.1.6</jaxb-version>
@@ -172,6 +173,7 @@
     <module>apollo-bdb</module>
     <module>apollo-dto</module>
     <module>apollo-stomp</module>
+    <module>apollo-mqtt</module>
     <module>apollo-web</module>
     <module>apollo-cli</module>
     <module>apollo-website</module>



Mime
View raw message