activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1408161 [2/4] - in /activemq/trunk: activemq-core/src/test/java/org/apache/activemq/transport/stomp/ activemq-core/src/test/resources/org/apache/activemq/transport/stomp/ activemq-stomp/ activemq-stomp/src/test/ activemq-stomp/src/test/jav...
Date Mon, 12 Nov 2012 00:15:56 GMT
Added: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/Stomp12Test.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/Stomp12Test.java?rev=1408161&view=auto
==============================================================================
--- activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/Stomp12Test.java (added)
+++ activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/Stomp12Test.java Mon Nov 12 00:15:50 2012
@@ -0,0 +1,359 @@
+/**
+ * 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.transport.stomp;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.Socket;
+
+import javax.jms.Connection;
+
+import org.apache.activemq.broker.TransportConnector;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Stomp12Test extends StompTestSupport {
+
+    private static final Logger LOG = LoggerFactory.getLogger(Stomp12Test.class);
+
+    private Connection connection;
+
+    @Override
+    public void setUp() throws Exception {
+
+        super.setUp();
+
+        stompConnect();
+
+        connection = cf.createConnection("system", "manager");
+        connection.start();
+    }
+
+    @Override
+	protected void addStompConnector() throws Exception {
+        TransportConnector connector = brokerService.addConnector("stomp://0.0.0.0:"+port);
+        port = connector.getConnectUri().getPort();
+    }
+
+    @Override
+    protected Socket createSocket() throws IOException {
+        return new Socket("127.0.0.1", this.port);
+    }
+
+    @Override
+    protected String getQueueName() {
+        return getClass().getName() + "." + getName();
+    }
+
+    @Test
+    public void testTelnetStyleSends() throws Exception {
+
+        stompConnection.setVersion(Stomp.V1_2);
+
+        String connect = "CONNECT\r\n" +
+                         "accept-version:1.2\r\n" +
+                         "login:system\r\n" +
+                         "passcode:manager\r\n" +
+                         "\r\n" +
+                         "\u0000\r\n";
+
+        stompConnection.sendFrame(connect);
+
+        String f = stompConnection.receiveFrame();
+        LOG.info("Broker sent: " + f);
+
+        assertTrue(f.startsWith("CONNECTED"));
+        assertTrue(f.indexOf("version:1.2") >= 0);
+        assertTrue(f.indexOf("session:") >= 0);
+
+        String send = "SUBSCRIBE\r\n" +
+                      "id:1\r\n" +
+                      "destination:/queue/" + getQueueName() + "\r\n" +
+                      "receipt:1\r\n" +
+                      "\r\n"+
+                      "\u0000\r\n";
+
+        stompConnection.sendFrame(send);
+
+        StompFrame receipt = stompConnection.receive();
+        LOG.info("Broker sent: " + receipt);
+        assertTrue(receipt.getAction().startsWith("RECEIPT"));
+        String receiptId = receipt.getHeaders().get("receipt-id");
+        assertEquals("1", receiptId);
+
+        String disconnect = "DISCONNECT\n" + "\n\n" + Stomp.NULL;
+        stompConnection.sendFrame(disconnect);
+    }
+
+    @Test
+    public void testClientAckWithoutAckId() throws Exception {
+
+        stompConnection.setVersion(Stomp.V1_2);
+
+        String connect = "STOMP\r\n" +
+                         "accept-version:1.2\r\n" +
+                         "login:system\r\n" +
+                         "passcode:manager\r\n" +
+                         "\r\n" +
+                         "\u0000\r\n";
+
+        stompConnection.sendFrame(connect);
+
+        String f = stompConnection.receiveFrame();
+        LOG.info("Broker sent: " + f);
+
+        assertTrue(f.startsWith("CONNECTED"));
+        assertTrue(f.indexOf("version:1.2") >= 0);
+        assertTrue(f.indexOf("session:") >= 0);
+
+        String subscribe = "SUBSCRIBE\n" +
+                           "id:1\n" +
+                           "ack:client\n" +
+                           "destination:/queue/" + getQueueName() + "\n" +
+                           "receipt:1\n" +
+                           "\n" + Stomp.NULL;
+
+        stompConnection.sendFrame(subscribe);
+
+        StompFrame receipt = stompConnection.receive();
+        LOG.info("Broker sent: " + receipt);
+        assertTrue(receipt.getAction().startsWith("RECEIPT"));
+        String receiptId = receipt.getHeaders().get("receipt-id");
+        assertEquals("1", receiptId);
+
+        String message = "SEND\n" + "destination:/queue/" + getQueueName() + "\n\n" + "1" + Stomp.NULL;
+        stompConnection.sendFrame(message);
+
+        StompFrame received = stompConnection.receive();
+        assertTrue(received.getAction().equals("MESSAGE"));
+        assertTrue(received.getHeaders().containsKey(Stomp.Headers.Message.ACK_ID));
+        assertEquals("1", received.getBody());
+
+        String frame = "ACK\n" + "message-id:" +
+                received.getHeaders().get(Stomp.Headers.Message.ACK_ID) + "\n\n" + Stomp.NULL;
+        stompConnection.sendFrame(frame);
+
+        received = stompConnection.receive();
+        assertTrue(received.getAction().equals("ERROR"));
+        LOG.info("Broker sent: " + received);
+
+        String disconnect = "DISCONNECT\n" + "\n\n" + Stomp.NULL;
+        stompConnection.sendFrame(disconnect);
+    }
+
+    @Test
+    public void testClientAck() throws Exception {
+
+        stompConnection.setVersion(Stomp.V1_2);
+
+        String connect = "STOMP\r\n" +
+                         "accept-version:1.2\r\n" +
+                         "login:system\r\n" +
+                         "passcode:manager\r\n" +
+                         "\r\n" +
+                         "\u0000\r\n";
+
+        stompConnection.sendFrame(connect);
+
+        String f = stompConnection.receiveFrame();
+        LOG.info("Broker sent: " + f);
+
+        assertTrue(f.startsWith("CONNECTED"));
+        assertTrue(f.indexOf("version:1.2") >= 0);
+        assertTrue(f.indexOf("session:") >= 0);
+
+        String subscribe = "SUBSCRIBE\n" +
+                           "id:1\n" +
+                           "ack:client\n" +
+                           "destination:/queue/" + getQueueName() + "\n" +
+                           "receipt:1\n" +
+                           "\n" + Stomp.NULL;
+
+        stompConnection.sendFrame(subscribe);
+
+        StompFrame receipt = stompConnection.receive();
+        LOG.info("Broker sent: " + receipt);
+        assertTrue(receipt.getAction().startsWith("RECEIPT"));
+        String receiptId = receipt.getHeaders().get("receipt-id");
+        assertEquals("1", receiptId);
+
+        String message = "SEND\n" + "destination:/queue/" + getQueueName() + "\n\n" + "1" + Stomp.NULL;
+        stompConnection.sendFrame(message);
+        message = "SEND\n" + "destination:/queue/" + getQueueName() + "\n\n" + "2" + Stomp.NULL;
+        stompConnection.sendFrame(message);
+
+        StompFrame received = stompConnection.receive();
+        LOG.info("Stomp Message: {}", received);
+        assertTrue(received.getAction().equals("MESSAGE"));
+        assertTrue(received.getHeaders().containsKey(Stomp.Headers.Message.ACK_ID));
+        assertEquals("1", received.getBody());
+
+        received = stompConnection.receive();
+        LOG.info("Stomp Message: {}", received);
+        assertTrue(received.getAction().equals("MESSAGE"));
+        assertTrue(received.getHeaders().containsKey(Stomp.Headers.Message.ACK_ID));
+        assertEquals("2", received.getBody());
+
+        String frame = "ACK\n" + "id:" +
+                received.getHeaders().get(Stomp.Headers.Message.ACK_ID) + "\n\n" + Stomp.NULL;
+        stompConnection.sendFrame(frame);
+
+        frame = "DISCONNECT\n\n" + Stomp.NULL;
+        stompConnection.sendFrame(frame);
+        try {
+            Thread.sleep(400);
+        } catch (InterruptedException e){}
+
+        // reconnect and send some messages to the offline subscribers and then try to get
+        // them after subscribing again.
+        stompConnect();
+        stompConnection.sendFrame(connect);
+        frame = stompConnection.receiveFrame();
+        LOG.debug("Broker sent: " + frame);
+        assertTrue(frame.startsWith("CONNECTED"));
+
+        stompConnection.sendFrame(subscribe);
+
+        receipt = stompConnection.receive();
+        LOG.info("Broker sent: " + receipt);
+        assertTrue(receipt.getAction().startsWith("RECEIPT"));
+        receiptId = receipt.getHeaders().get("receipt-id");
+        assertEquals("1", receiptId);
+
+        message = "SEND\n" + "destination:/queue/" + getQueueName() + "\n\n" + "3" + Stomp.NULL;
+        stompConnection.sendFrame(message);
+
+        received = stompConnection.receive();
+        LOG.info("Stomp Message: {}", received);
+        assertTrue(received.getAction().equals("MESSAGE"));
+        assertTrue(received.getHeaders().containsKey(Stomp.Headers.Message.ACK_ID));
+        assertEquals("3", received.getBody());
+
+        frame = "ACK\n" + "id:" +
+                received.getHeaders().get(Stomp.Headers.Message.ACK_ID) + "\n\n" + Stomp.NULL;
+        stompConnection.sendFrame(frame);
+
+        String disconnect = "DISCONNECT\n" + "\n\n" + Stomp.NULL;
+        stompConnection.sendFrame(disconnect);
+    }
+
+    @Test
+    public void testClientIndividualAck() throws Exception {
+
+        stompConnection.setVersion(Stomp.V1_2);
+
+        String connect = "STOMP\r\n" +
+                         "accept-version:1.2\r\n" +
+                         "login:system\r\n" +
+                         "passcode:manager\r\n" +
+                         "\r\n" +
+                         "\u0000\r\n";
+
+        stompConnection.sendFrame(connect);
+
+        String f = stompConnection.receiveFrame();
+        LOG.info("Broker sent: " + f);
+
+        assertTrue(f.startsWith("CONNECTED"));
+        assertTrue(f.indexOf("version:1.2") >= 0);
+        assertTrue(f.indexOf("session:") >= 0);
+
+        String subscribe = "SUBSCRIBE\n" +
+                           "id:1\n" +
+                           "ack:client-individual\n" +
+                           "destination:/queue/" + getQueueName() + "\n" +
+                           "receipt:1\n" +
+                           "\n" + Stomp.NULL;
+
+        stompConnection.sendFrame(subscribe);
+
+        StompFrame receipt = stompConnection.receive();
+        LOG.info("Broker sent: " + receipt);
+        assertTrue(receipt.getAction().startsWith("RECEIPT"));
+        String receiptId = receipt.getHeaders().get("receipt-id");
+        assertEquals("1", receiptId);
+
+        String message = "SEND\n" + "destination:/queue/" + getQueueName() + "\n\n" + "1" + Stomp.NULL;
+        stompConnection.sendFrame(message);
+        message = "SEND\n" + "destination:/queue/" + getQueueName() + "\n\n" + "2" + Stomp.NULL;
+        stompConnection.sendFrame(message);
+
+        StompFrame received = stompConnection.receive();
+        assertTrue(received.getAction().equals("MESSAGE"));
+        assertTrue(received.getHeaders().containsKey(Stomp.Headers.Message.ACK_ID));
+        assertEquals("1", received.getBody());
+
+        received = stompConnection.receive();
+        assertTrue(received.getAction().equals("MESSAGE"));
+        assertTrue(received.getHeaders().containsKey(Stomp.Headers.Message.ACK_ID));
+        assertEquals("2", received.getBody());
+
+        String frame = "ACK\n" + "id:" +
+                received.getHeaders().get(Stomp.Headers.Message.ACK_ID) + "\n\n" + Stomp.NULL;
+        stompConnection.sendFrame(frame);
+
+        frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL;
+        stompConnection.sendFrame(frame);
+        try {
+            Thread.sleep(400);
+        } catch (InterruptedException e){}
+
+        // reconnect and send some messages to the offline subscribers and then try to get
+        // them after subscribing again.
+        stompConnect();
+        stompConnection.sendFrame(connect);
+        frame = stompConnection.receiveFrame();
+        LOG.debug("Broker sent: " + frame);
+        assertTrue(frame.startsWith("CONNECTED"));
+
+        stompConnection.sendFrame(subscribe);
+
+        receipt = stompConnection.receive();
+        LOG.info("Broker sent: " + receipt);
+        assertTrue(receipt.getAction().startsWith("RECEIPT"));
+        receiptId = receipt.getHeaders().get("receipt-id");
+        assertEquals("1", receiptId);
+
+        message = "SEND\n" + "destination:/queue/" + getQueueName() + "\n\n" + "3" + Stomp.NULL;
+        stompConnection.sendFrame(message);
+
+        received = stompConnection.receive();
+        assertTrue(received.getAction().equals("MESSAGE"));
+        assertTrue(received.getHeaders().containsKey(Stomp.Headers.Message.ACK_ID));
+        assertEquals("1", received.getBody());
+
+        frame = "ACK\n" + "id:" +
+                received.getHeaders().get(Stomp.Headers.Message.ACK_ID) + "\n\n" + Stomp.NULL;
+        stompConnection.sendFrame(frame);
+
+        received = stompConnection.receive();
+        assertTrue(received.getAction().equals("MESSAGE"));
+        assertTrue(received.getHeaders().containsKey(Stomp.Headers.Message.ACK_ID));
+        assertEquals("3", received.getBody());
+
+        frame = "ACK\n" + "id:" +
+                received.getHeaders().get(Stomp.Headers.Message.ACK_ID) + "\n\n" + Stomp.NULL;
+        stompConnection.sendFrame(frame);
+
+        String disconnect = "DISCONNECT\n" + "\n\n" + Stomp.NULL;
+        stompConnection.sendFrame(disconnect);
+    }
+
+}

Propchange: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/Stomp12Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompAdvisoryTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompAdvisoryTest.java?rev=1408161&view=auto
==============================================================================
--- activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompAdvisoryTest.java (added)
+++ activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompAdvisoryTest.java Mon Nov 12 00:15:50 2012
@@ -0,0 +1,272 @@
+/**
+ * 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.transport.stomp;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+
+import org.apache.activemq.ActiveMQConnection;
+import org.apache.activemq.broker.region.policy.ConstantPendingMessageLimitStrategy;
+import org.apache.activemq.broker.region.policy.PolicyEntry;
+import org.apache.activemq.broker.region.policy.PolicyMap;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class StompAdvisoryTest extends StompTestSupport {
+    private static final Logger LOG = LoggerFactory.getLogger(StompAdvisoryTest.class);
+
+    protected ActiveMQConnection connection;
+
+    @Override
+    protected void applyBrokerPolicies() throws Exception {
+
+        PolicyEntry policy = new PolicyEntry();
+        policy.setAdvisoryForFastProducers(true);
+        policy.setAdvisoryForConsumed(true);
+        policy.setAdvisoryForDelivery(true);
+        policy.setAdvisoryForDiscardingMessages(true);
+        policy.setAdvisoryForSlowConsumers(true);
+        policy.setAdvisoryWhenFull(true);
+        policy.setProducerFlowControl(false);
+
+        ConstantPendingMessageLimitStrategy strategy = new ConstantPendingMessageLimitStrategy();
+        strategy.setLimit(10);
+        policy.setPendingMessageLimitStrategy(strategy);
+        PolicyMap pMap = new PolicyMap();
+        pMap.setDefaultEntry(policy);
+
+        brokerService.setDestinationPolicy(pMap);
+        brokerService.setAdvisorySupport(true);
+    }
+
+    @Test
+    public void testConnectionAdvisory() throws Exception {
+
+        stompConnection.connect("system", "manager");
+        stompConnection.subscribe("/topic/ActiveMQ.Advisory.Connection", Stomp.Headers.Subscribe.AckModeValues.AUTO);
+
+        // Now connect via openwire and check we get the advisory
+        Connection c = cf.createConnection("system", "manager");
+        c.start();
+
+        StompFrame f = stompConnection.receive();
+        LOG.debug(f.toString());
+        assertEquals(f.getAction(),"MESSAGE");
+        assertTrue("Should have a body", f.getBody().length() > 0);
+        assertTrue(f.getBody().startsWith("{\"ConnectionInfo\":"));
+
+        c.stop();
+        c.close();
+
+        f = stompConnection.receive();
+        LOG.debug(f.toString());
+        assertEquals(f.getAction(),"MESSAGE");
+        assertNotNull("Body is not null", f.getBody());
+        assertTrue("Body should have content", f.getBody().length() > 0);
+        assertTrue(f.getBody().startsWith("{\"ConnectionInfo\":"));
+    }
+
+    @Test
+    public void testConnectionAdvisoryJSON() throws Exception {
+
+        HashMap<String, String> subheaders = new HashMap<String, String>(1);
+        subheaders.put("transformation", Stomp.Transformations.JMS_JSON.toString());
+
+        stompConnection.connect("system", "manager");
+        stompConnection.subscribe("/topic/ActiveMQ.Advisory.Connection",
+                Stomp.Headers.Subscribe.AckModeValues.AUTO, subheaders);
+
+        // Now connect via openwire and check we get the advisory
+        Connection c = cf.createConnection("system", "manager");
+        c.start();
+
+        StompFrame f = stompConnection.receive();
+        LOG.debug(f.toString());
+        assertEquals(f.getAction(),"MESSAGE");
+        assertTrue("Should have a body", f.getBody().length() > 0);
+        assertTrue(f.getBody().startsWith("{\"ConnectionInfo\":"));
+
+        c.stop();
+        c.close();
+
+        f = stompConnection.receive();
+        LOG.debug(f.toString());
+        assertEquals(f.getAction(),"MESSAGE");
+        assertNotNull("Body is not null", f.getBody());
+        assertTrue("Body should have content", f.getBody().length() > 0);
+        assertTrue(f.getBody().startsWith("{\"ConnectionInfo\":"));
+    }
+
+    @Test
+    public void testConnectionAdvisoryXML() throws Exception {
+
+        HashMap<String, String> subheaders = new HashMap<String, String>(1);
+        subheaders.put("transformation", Stomp.Transformations.JMS_XML.toString());
+
+        stompConnection.connect("system", "manager");
+        stompConnection.subscribe("/topic/ActiveMQ.Advisory.Connection",
+                Stomp.Headers.Subscribe.AckModeValues.AUTO, subheaders);
+
+        // Now connect via openwire and check we get the advisory
+        Connection c = cf.createConnection("system", "manager");
+        c.start();
+
+        StompFrame f = stompConnection.receive();
+        LOG.debug(f.toString());
+        assertEquals(f.getAction(),"MESSAGE");
+        assertTrue("Should have a body", f.getBody().length() > 0);
+        assertTrue(f.getBody().startsWith("<ConnectionInfo>"));
+
+        c.stop();
+        c.close();
+
+        f = stompConnection.receive();
+        LOG.debug(f.toString());
+        assertEquals(f.getAction(),"MESSAGE");
+        assertNotNull("Body is not null", f.getBody());
+        assertTrue("Body should have content", f.getBody().length() > 0);
+        assertTrue(f.getBody().startsWith("<ConnectionInfo>"));
+    }
+
+    @Test
+    public void testConsumerAdvisory() throws Exception {
+
+        Destination dest = new ActiveMQQueue("testConsumerAdvisory");
+
+        stompConnection.connect("system", "manager");
+        stompConnection.subscribe("/topic/ActiveMQ.Advisory.Consumer.>", Stomp.Headers.Subscribe.AckModeValues.AUTO);
+
+        // Now connect via openwire and check we get the advisory
+        Connection c = cf.createConnection("system", "manager");
+        c.start();
+
+        Session session = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        MessageConsumer consumer = session.createConsumer(dest);
+        assertNotNull(consumer);
+
+        StompFrame f = stompConnection.receive();
+        LOG.debug(f.toString());
+        assertEquals(f.getAction(),"MESSAGE");
+        assertTrue("Should have a body", f.getBody().length() > 0);
+        assertTrue(f.getBody().startsWith("{\"ConsumerInfo\":"));
+
+        c.stop();
+        c.close();
+    }
+
+    @Test
+    public void testProducerAdvisory() throws Exception {
+
+        Destination dest = new ActiveMQQueue("testProducerAdvisory");
+
+        stompConnection.connect("system", "manager");
+        stompConnection.subscribe("/topic/ActiveMQ.Advisory.Producer.>", Stomp.Headers.Subscribe.AckModeValues.AUTO);
+
+        // Now connect via openwire and check we get the advisory
+        Connection c = cf.createConnection("system", "manager");
+        c.start();
+
+        Session session = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        MessageProducer producer = session.createProducer(dest);
+        Message mess = session.createTextMessage("test");
+        producer.send(mess);
+
+        StompFrame f = stompConnection.receive();
+        LOG.debug(f.toString());
+        assertEquals(f.getAction(),"MESSAGE");
+        assertTrue("Should have a body", f.getBody().length() > 0);
+        assertTrue(f.getBody().startsWith("{\"ProducerInfo\":"));
+
+        c.stop();
+        c.close();
+    }
+
+    @Test
+    public void testProducerAdvisoryXML() throws Exception {
+
+        Destination dest = new ActiveMQQueue("testProducerAdvisoryXML");
+
+        HashMap<String, String> subheaders = new HashMap<String, String>(1);
+        subheaders.put("transformation", Stomp.Transformations.JMS_ADVISORY_XML.toString());
+
+        stompConnection.connect("system", "manager");
+        stompConnection.subscribe("/topic/ActiveMQ.Advisory.Producer.>",
+                Stomp.Headers.Subscribe.AckModeValues.AUTO, subheaders);
+
+        // Now connect via openwire and check we get the advisory
+        Connection c = cf.createConnection("system", "manager");
+        c.start();
+
+        Session session = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        MessageProducer producer = session.createProducer(dest);
+        Message mess = session.createTextMessage("test");
+        producer.send(mess);
+
+        StompFrame f = stompConnection.receive();
+        LOG.debug(f.toString());
+        assertEquals(f.getAction(),"MESSAGE");
+        assertTrue("Should have a body", f.getBody().length() > 0);
+        assertTrue(f.getBody().startsWith("<ProducerInfo>"));
+
+        c.stop();
+        c.close();
+    }
+
+    @Test
+    public void testProducerAdvisoryJSON() throws Exception {
+
+        Destination dest = new ActiveMQQueue("testProducerAdvisoryJSON");
+
+        HashMap<String, String> subheaders = new HashMap<String, String>(1);
+        subheaders.put("transformation", Stomp.Transformations.JMS_ADVISORY_JSON.toString());
+
+        stompConnection.connect("system", "manager");
+        stompConnection.subscribe("/topic/ActiveMQ.Advisory.Producer.>",
+                Stomp.Headers.Subscribe.AckModeValues.AUTO, subheaders);
+
+        // Now connect via openwire and check we get the advisory
+        Connection c = cf.createConnection("system", "manager");
+        c.start();
+
+        Session session = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        MessageProducer producer = session.createProducer(dest);
+        Message mess = session.createTextMessage("test");
+        producer.send(mess);
+
+        StompFrame f = stompConnection.receive();
+        LOG.debug(f.toString());
+        assertEquals(f.getAction(),"MESSAGE");
+        assertTrue("Should have a body", f.getBody().length() > 0);
+        assertTrue(f.getBody().startsWith("{\"ProducerInfo\":"));
+
+        c.stop();
+        c.close();
+    }
+}

Propchange: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompAdvisoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompFrameTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompFrameTest.java?rev=1408161&view=auto
==============================================================================
--- activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompFrameTest.java (added)
+++ activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompFrameTest.java Mon Nov 12 00:15:50 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.
+ */
+package org.apache.activemq.transport.stomp;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+
+public class StompFrameTest {
+    StompFrame underTest = new StompFrame();
+
+    @Test
+    public void testNoPasscodeInToString() throws Exception {
+        HashMap<String, String> headers = new HashMap<String, String>();
+        headers.put("userName", "bob");
+        headers.put("passcode", "please");
+        underTest.setHeaders(headers);
+
+        assertEquals("no password present", -1, underTest.toString().indexOf("please"));
+        assertTrue("*** present", underTest.toString().indexOf("***") > 0);
+    }
+}

Propchange: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompFrameTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompLoadTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompLoadTest.java?rev=1408161&view=auto
==============================================================================
--- activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompLoadTest.java (added)
+++ activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompLoadTest.java Mon Nov 12 00:15:50 2012
@@ -0,0 +1,199 @@
+/**
+ * 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.transport.stomp;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.jms.Connection;
+import javax.jms.Session;
+
+import org.apache.activemq.broker.TransportConnector;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.util.Wait;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class StompLoadTest extends StompTestSupport {
+
+    private static final Logger LOG = LoggerFactory.getLogger(StompLoadTest.class);
+
+    private static final int TASK_COUNT = 100;
+    private static final int MSG_COUNT = 250;  // AMQ-3819: Above 250 or so and the CPU goes bonkers with NOI+SSL.
+
+    protected Connection connection;
+    protected Session session;
+    protected ActiveMQQueue queue;
+
+    private ExecutorService executor;
+    private CountDownLatch started;
+    private CountDownLatch ready;
+    private AtomicInteger receiveCount;
+
+    @Override
+	protected void addStompConnector() throws Exception {
+        TransportConnector connector = brokerService.addConnector("stomp://0.0.0.0:"+port);
+        port = connector.getConnectUri().getPort();
+    }
+
+    @Override
+    public void setUp() throws Exception {
+
+        super.setUp();
+
+        stompConnect();
+        stompConnection.connect("system", "manager");
+
+        connection = cf.createConnection("system", "manager");
+        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        queue = new ActiveMQQueue(getTopicName());
+        connection.start();
+
+        executor = Executors.newFixedThreadPool(TASK_COUNT, new ThreadFactory() {
+
+            private long i = 0;
+
+            @Override
+            public Thread newThread(Runnable runnable) {
+                this.i++;
+                final Thread t = new Thread(runnable, "Test Worker " + this.i);
+                return t;
+            }
+        });
+
+        started = new CountDownLatch(TASK_COUNT);
+        ready = new CountDownLatch(1);
+        receiveCount = new AtomicInteger(0);
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        try {
+            executor.shutdownNow();
+            connection.close();
+        } catch (Exception e) {
+        } finally {
+            super.tearDown();
+        }
+    }
+
+    @Test(timeout=20*60*1000*1000)
+    public void testStompUnloadLoad() throws Exception {
+
+        for (int i = 0; i < TASK_COUNT; ++i) {
+            executor.execute(new Runnable() {
+
+                @Override
+                public void run() {
+
+                    LOG.debug("Receive Thread Connecting to Broker.");
+
+                    int numReceived = 0;
+
+                    StompConnection connection = new StompConnection();
+                    try {
+                        stompConnect(connection);
+                        connection.connect("system", "manager");
+                    } catch (Exception e) {
+                        LOG.error("Caught Exception while connecting: " + e.getMessage());
+                    }
+
+                    try {
+
+                        for (int i = 0; i < 10; i++) {
+                            connection.subscribe("/queue/test-" + i, "auto");
+                            connection.subscribe("/topic/test-" + i, "auto");
+                        }
+
+                        HashMap<String, String> headers = new HashMap<String, String>();
+                        headers.put("activemq.prefetchSize", "1");
+                        connection.subscribe("/topic/" + getTopicName(), "auto", headers);
+                        ready.await();
+
+                        // Now that the main test thread is ready we wait a bit to let the tasks
+                        // all subscribe and the CPU to settle a bit.
+                        TimeUnit.SECONDS.sleep(3);
+                        started.countDown();
+
+                        while (true) {
+                            // Read Timeout ends this task, we override the default here since there
+                            // are so many threads running and we don't know how slow the test box is.
+                            StompFrame frame = connection.receive(TimeUnit.SECONDS.toMillis(60));
+                            assertNotNull(frame);
+                            numReceived++;
+                            if (LOG.isDebugEnabled() && (numReceived % 50) == 0 || numReceived == MSG_COUNT) {
+                                LOG.debug("Receiver thread got message: " + frame.getHeaders().get("message-id"));
+                            }
+                            receiveCount.incrementAndGet();
+                        }
+
+                    } catch (Exception e) {
+                        if (numReceived != MSG_COUNT) {
+                            LOG.warn("Receive task caught exception after receipt of ["+numReceived+
+                                     "] messages: " + e.getMessage());
+                        }
+                    }
+                }
+            });
+        }
+
+        ready.countDown();
+        assertTrue("Timed out waiting for receivers to start.", started.await(5, TimeUnit.MINUTES));
+        String frame;
+
+        // Lets still wait a bit to make sure all subscribers get a fair shake at
+        // getting online before we send.  Account for slow Hudson machines
+        TimeUnit.SECONDS.sleep(5);
+
+        for( int ix = 0; ix < MSG_COUNT; ix++) {
+            frame = "SEND\n" +
+                    "destination:/topic/" + getTopicName() +
+                    "\nid:" + ix +
+                    "\ncontent-length:5" + " \n\n" +
+                    "\u0001\u0002\u0000\u0004\u0005" + Stomp.NULL;
+            stompConnection.sendFrame(frame);
+        }
+
+        LOG.info("All " + MSG_COUNT + " message have been sent, awaiting receipt.");
+
+        assertTrue("Should get [" + TASK_COUNT * MSG_COUNT + "] message but was: " + receiveCount.get(), Wait.waitFor(new Wait.Condition() {
+
+            @Override
+            public boolean isSatisified() throws Exception {
+                return receiveCount.get() == TASK_COUNT * MSG_COUNT;
+            }
+        }, TimeUnit.MINUTES.toMillis(10)));
+
+        LOG.info("Test Completed and all messages received, shutting down.");
+
+        executor.shutdown();
+        executor.awaitTermination(2, TimeUnit.MINUTES);
+        frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL;
+        stompConnection.sendFrame(frame);
+        LOG.info("Test Finished.");
+    }
+}

Propchange: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompLoadTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompMissingMessageTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompMissingMessageTest.java?rev=1408161&view=auto
==============================================================================
--- activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompMissingMessageTest.java (added)
+++ activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompMissingMessageTest.java Mon Nov 12 00:15:50 2012
@@ -0,0 +1,205 @@
+/**
+ * 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.transport.stomp;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.HashMap;
+import java.util.UUID;
+
+import org.apache.activemq.broker.TransportConnector;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class StompMissingMessageTest extends StompTestSupport {
+
+    private static final Logger LOG = LoggerFactory.getLogger(StompMissingMessageTest.class);
+
+    protected String destination;
+
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        destination = "/topic/" + getTopicName();
+    }
+
+    @Override
+	protected void addStompConnector() throws Exception {
+        TransportConnector connector = brokerService.addConnector("stomp://0.0.0.0:"+port);
+        port = connector.getConnectUri().getPort();
+    }
+
+    @Test
+    public void testProducerConsumerLoop() throws Exception {
+        final int ITERATIONS = 500;
+        int received = 0;
+
+        for (int i = 1; i <= ITERATIONS*2; i+=2) {
+            if (doTestProducerConsumer(i) != null) {
+                received++;
+            }
+        }
+
+        assertEquals(ITERATIONS, received);
+    }
+
+    public String doTestProducerConsumer(int index) throws Exception {
+        String message = null;
+
+        assertEquals("Should not be any consumers", 0, brokerService.getAdminView().getTopicSubscribers().length);
+
+        StompConnection producer = stompConnect();
+        StompConnection consumer = stompConnect();
+
+        subscribe(consumer, Integer.toString(index));
+
+        sendMessage(producer, index);
+
+        try {
+            StompFrame frame = consumer.receive();
+            LOG.debug("Consumer got frame: " + message);
+            assertEquals(index, (int) Integer.valueOf(frame.getBody()));
+            message = frame.getBody();
+        } catch(Exception e) {
+            fail("Consumer["+index+"] got error while consuming: " + e.getMessage());
+        }
+
+        unsubscribe(consumer, Integer.toString(index));
+
+        stompDisconnect(consumer);
+        stompDisconnect(producer);
+
+        return message;
+    }
+
+    @Test
+    public void testProducerDurableConsumerLoop() throws Exception {
+        final int ITERATIONS = 500;
+        int received = 0;
+
+        for (int i = 1; i <= ITERATIONS*2; i+=2) {
+            if (doTestProducerDurableConsumer(i) != null) {
+                received++;
+            }
+        }
+
+        assertEquals(ITERATIONS, received);
+    }
+
+    public String doTestProducerDurableConsumer(int index) throws Exception {
+        String message = null;
+
+        assertEquals("Should not be any consumers", 0, brokerService.getAdminView().getTopicSubscribers().length);
+
+        StompConnection producer = stompConnect();
+        StompConnection consumer = stompConnect("test");
+
+        subscribe(consumer, Integer.toString(index), true);
+
+        sendMessage(producer, index);
+
+        try {
+            StompFrame frame = consumer.receive();
+            LOG.debug("Consumer got frame: " + message);
+            assertEquals(index, (int) Integer.valueOf(frame.getBody()));
+            message = frame.getBody();
+        } catch(Exception e) {
+            fail("Consumer["+index+"] got error while consuming: " + e.getMessage());
+        }
+
+        unsubscribe(consumer, Integer.toString(index));
+
+        stompDisconnect(consumer);
+        stompDisconnect(producer);
+
+        return message;
+    }
+
+    protected void subscribe(StompConnection stompConnection, String subscriptionId) throws Exception {
+        subscribe(stompConnection, subscriptionId, false);
+    }
+
+    protected void subscribe(StompConnection stompConnection, String subscriptionId, boolean durable) throws Exception {
+        HashMap<String, String> headers = new HashMap<String, String>();
+        headers.put("id", subscriptionId);
+        if (durable) {
+            headers.put("activemq.subscriptionName", subscriptionId);
+        }
+        headers.put(Stomp.Headers.RECEIPT_REQUESTED, UUID.randomUUID().toString());
+
+        stompConnection.subscribe(destination, "auto", headers);
+
+        StompFrame received = stompConnection.receive();
+        assertEquals("RECEIPT", received.getAction());
+        String receipt = received.getHeaders().get(Stomp.Headers.Response.RECEIPT_ID);
+        assertEquals(headers.get(Stomp.Headers.RECEIPT_REQUESTED), receipt);
+    }
+
+    protected void unsubscribe(StompConnection stompConnection, String subscriptionId) throws Exception {
+        HashMap<String, String> headers = new HashMap<String, String>();
+        headers.put("id", subscriptionId);
+        headers.put(Stomp.Headers.RECEIPT_REQUESTED, UUID.randomUUID().toString());
+
+        stompConnection.unsubscribe(destination, headers);
+
+        StompFrame received = stompConnection.receive();
+        assertEquals("RECEIPT", received.getAction());
+        String receipt = received.getHeaders().get(Stomp.Headers.Response.RECEIPT_ID);
+        assertEquals(headers.get(Stomp.Headers.RECEIPT_REQUESTED), receipt);
+    }
+
+    protected void sendMessage(StompConnection producer, int index) throws Exception {
+        HashMap<String, String> headers = new HashMap<String, String>();
+        headers.put(Stomp.Headers.RECEIPT_REQUESTED, UUID.randomUUID().toString());
+
+        producer.send(destination, Integer.toString(index), null, headers);
+
+        StompFrame received = producer.receive();
+        assertEquals("RECEIPT", received.getAction());
+        String receipt = received.getHeaders().get(Stomp.Headers.Response.RECEIPT_ID);
+        assertEquals(headers.get(Stomp.Headers.RECEIPT_REQUESTED), receipt);
+    }
+
+    @Override
+    protected StompConnection stompConnect() throws Exception {
+        StompConnection stompConnection = new StompConnection();
+        stompConnect(stompConnection);
+        stompConnection.connect("system", "manager", null);
+        return stompConnection;
+    }
+
+    protected StompConnection stompConnect(String clientId) throws Exception {
+        StompConnection stompConnection = new StompConnection();
+        stompConnect(stompConnection);
+        stompConnection.connect("system", "manager", clientId);
+        return stompConnection;
+    }
+
+    protected void stompDisconnect(StompConnection connection) throws Exception {
+        if (connection != null) {
+            String receiptId = UUID.randomUUID().toString();
+            connection.disconnect(receiptId);
+            if (!connection.receive().getAction().equals(Stomp.Responses.RECEIPT)) {
+                throw new Exception("Failed to receive receipt for disconnect.");
+            }
+            connection.close();
+            connection = null;
+        }
+    }
+}

Propchange: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompMissingMessageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompNIOLoadTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompNIOLoadTest.java?rev=1408161&view=auto
==============================================================================
--- activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompNIOLoadTest.java (added)
+++ activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompNIOLoadTest.java Mon Nov 12 00:15:50 2012
@@ -0,0 +1,37 @@
+/**
+ * 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.transport.stomp;
+
+import java.io.IOException;
+import java.net.Socket;
+
+import org.apache.activemq.broker.TransportConnector;
+
+public class StompNIOLoadTest extends StompLoadTest {
+
+    @Override
+	protected void addStompConnector() throws Exception {
+        TransportConnector connector = brokerService.addConnector("stomp+nio://0.0.0.0:"+nioPort);
+        nioPort = connector.getConnectUri().getPort();
+    }
+
+    @Override
+    protected Socket createSocket() throws IOException {
+        return new Socket("127.0.0.1", this.nioPort);
+    }
+}

Propchange: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompNIOLoadTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompNIOSSLLoadTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompNIOSSLLoadTest.java?rev=1408161&view=auto
==============================================================================
--- activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompNIOSSLLoadTest.java (added)
+++ activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompNIOSSLLoadTest.java Mon Nov 12 00:15:50 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.transport.stomp;
+
+import java.io.IOException;
+import java.net.Socket;
+
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLSocketFactory;
+
+import org.apache.activemq.broker.TransportConnector;
+
+public class StompNIOSSLLoadTest extends StompLoadTest {
+
+    @Override
+    public void setUp() throws Exception {
+        System.setProperty("javax.net.ssl.trustStore", "src/test/resources/client.keystore");
+        System.setProperty("javax.net.ssl.trustStorePassword", "password");
+        System.setProperty("javax.net.ssl.trustStoreType", "jks");
+        System.setProperty("javax.net.ssl.keyStore", "src/test/resources/server.keystore");
+        System.setProperty("javax.net.ssl.keyStorePassword", "password");
+        System.setProperty("javax.net.ssl.keyStoreType", "jks");
+        super.setUp();
+    }
+
+    @Override
+	protected void addStompConnector() throws Exception {
+        TransportConnector connector = brokerService.addConnector("stomp+nio+ssl://0.0.0.0:"+nioSslPort);
+        nioSslPort = connector.getConnectUri().getPort();
+    }
+
+    @Override
+    protected Socket createSocket() throws IOException {
+        SocketFactory factory = SSLSocketFactory.getDefault();
+        return factory.createSocket("127.0.0.1", this.nioSslPort);
+    }
+}

Propchange: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompNIOSSLLoadTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompNIOSSLTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompNIOSSLTest.java?rev=1408161&view=auto
==============================================================================
--- activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompNIOSSLTest.java (added)
+++ activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompNIOSSLTest.java Mon Nov 12 00:15:50 2012
@@ -0,0 +1,51 @@
+/**
+ * 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.transport.stomp;
+
+import java.io.IOException;
+import java.net.Socket;
+
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLSocketFactory;
+
+import org.apache.activemq.broker.TransportConnector;
+
+public class StompNIOSSLTest extends StompTest {
+
+    @Override
+    public void setUp() throws Exception {
+        System.setProperty("javax.net.ssl.trustStore", "src/test/resources/client.keystore");
+        System.setProperty("javax.net.ssl.trustStorePassword", "password");
+        System.setProperty("javax.net.ssl.trustStoreType", "jks");
+        System.setProperty("javax.net.ssl.keyStore", "src/test/resources/server.keystore");
+        System.setProperty("javax.net.ssl.keyStorePassword", "password");
+        System.setProperty("javax.net.ssl.keyStoreType", "jks");
+        super.setUp();
+    }
+
+    @Override
+	protected void addStompConnector() throws Exception {
+        TransportConnector connector = brokerService.addConnector("stomp+nio+ssl://0.0.0.0:"+nioSslPort);
+        nioSslPort = connector.getConnectUri().getPort();
+    }
+
+    @Override
+    protected Socket createSocket() throws IOException {
+        SocketFactory factory = SSLSocketFactory.getDefault();
+        return factory.createSocket("127.0.0.1", this.nioSslPort);
+    }
+}

Propchange: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompNIOSSLTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompNIOTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompNIOTest.java?rev=1408161&view=auto
==============================================================================
--- activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompNIOTest.java (added)
+++ activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompNIOTest.java Mon Nov 12 00:15:50 2012
@@ -0,0 +1,36 @@
+/**
+ * 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.transport.stomp;
+
+import java.io.IOException;
+import java.net.Socket;
+
+import org.apache.activemq.broker.TransportConnector;
+
+public class StompNIOTest extends StompTest {
+
+    @Override
+	protected void addStompConnector() throws Exception {
+        TransportConnector connector = brokerService.addConnector("stomp+nio://0.0.0.0:"+nioPort);
+        nioPort = connector.getConnectUri().getPort();
+    }
+
+    @Override
+    protected Socket createSocket() throws IOException {
+        return new Socket("127.0.0.1", this.nioPort);
+    }
+}

Propchange: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompNIOTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompSSLLoadTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompSSLLoadTest.java?rev=1408161&view=auto
==============================================================================
--- activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompSSLLoadTest.java (added)
+++ activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompSSLLoadTest.java Mon Nov 12 00:15:50 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.transport.stomp;
+
+import java.io.IOException;
+import java.net.Socket;
+
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLSocketFactory;
+
+import org.apache.activemq.broker.TransportConnector;
+
+public class StompSSLLoadTest extends StompLoadTest {
+
+    @Override
+    public void setUp() throws Exception {
+        System.setProperty("javax.net.ssl.trustStore", "src/test/resources/client.keystore");
+        System.setProperty("javax.net.ssl.trustStorePassword", "password");
+        System.setProperty("javax.net.ssl.trustStoreType", "jks");
+        System.setProperty("javax.net.ssl.keyStore", "src/test/resources/server.keystore");
+        System.setProperty("javax.net.ssl.keyStorePassword", "password");
+        System.setProperty("javax.net.ssl.keyStoreType", "jks");
+        super.setUp();
+    }
+
+    @Override
+    protected void addStompConnector() throws Exception {
+        TransportConnector connector = brokerService.addConnector("stomp+ssl://0.0.0.0:"+sslPort);
+        sslPort = connector.getConnectUri().getPort();
+    }
+
+    @Override
+    protected Socket createSocket() throws IOException {
+        SocketFactory factory = SSLSocketFactory.getDefault();
+        return factory.createSocket("127.0.0.1", this.sslPort);
+    }
+}

Propchange: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompSSLLoadTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompSslAuthTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompSslAuthTest.java?rev=1408161&view=auto
==============================================================================
--- activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompSslAuthTest.java (added)
+++ activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompSslAuthTest.java Mon Nov 12 00:15:50 2012
@@ -0,0 +1,103 @@
+/**
+ * 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.transport.stomp;
+
+import java.io.IOException;
+import java.net.Socket;
+
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLSocketFactory;
+
+import org.apache.activemq.broker.BrokerPlugin;
+import org.apache.activemq.broker.TransportConnector;
+import org.apache.activemq.security.JaasCertificateAuthenticationPlugin;
+
+public class StompSslAuthTest extends StompTest {
+
+    @Override
+    public void setUp() throws Exception {
+
+        System.setProperty("javax.net.ssl.trustStore", "src/test/resources/client.keystore");
+        System.setProperty("javax.net.ssl.trustStorePassword", "password");
+        System.setProperty("javax.net.ssl.trustStoreType", "jks");
+        System.setProperty("javax.net.ssl.keyStore", "src/test/resources/server.keystore");
+        System.setProperty("javax.net.ssl.keyStorePassword", "password");
+        System.setProperty("javax.net.ssl.keyStoreType", "jks");
+        //System.setProperty("javax.net.debug","ssl,handshake");
+        super.setUp();
+    }
+
+    @Override
+    protected BrokerPlugin configureAuthentication() throws Exception {
+        JaasCertificateAuthenticationPlugin plugin = new JaasCertificateAuthenticationPlugin();
+        plugin.setConfiguration("cert-login");
+        return plugin;
+    }
+
+    @Override
+    protected Socket createSocket() throws IOException {
+        SocketFactory factory = SSLSocketFactory.getDefault();
+        return factory.createSocket("127.0.0.1", this.sslPort);
+    }
+
+    @Override
+    protected void addOpenWireConnector() throws Exception {
+        TransportConnector connector = brokerService.addConnector(
+                "ssl://0.0.0.0:0?needClientAuth=true");
+        jmsUri = connector.getPublishableConnectString();
+    }
+
+    @Override
+    protected void addStompConnector() throws Exception {
+        TransportConnector connector = brokerService.addConnector(
+                "stomp+ssl://0.0.0.0:"+port+"?needClientAuth=true");
+        sslPort = connector.getConnectUri().getPort();
+    }
+
+    // NOOP - These operations handled by jaas cert login module
+    @Override
+    public void testSubscribeWithReceiptNotAuthorized() throws Exception {
+    }
+
+    @Override
+    public void testConnectNotAuthenticatedWrongUser() throws Exception {
+    }
+
+    @Override
+    public void testConnectNotAuthenticatedWrongPassword() throws Exception {
+    }
+
+    @Override
+    public void testSendNotAuthorized() throws Exception {
+    }
+
+    @Override
+    public void testSubscribeNotAuthorized() throws Exception {
+    }
+
+    @Override
+    public void testJMSXUserIDIsSetInMessage() throws Exception {
+    }
+
+    @Override
+    public void testJMSXUserIDIsSetInStompMessage() throws Exception {
+    }
+
+    @Override
+    public void testClientSetMessageIdIsIgnored() throws Exception {
+    }
+}

Propchange: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompSslAuthTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompSslTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompSslTest.java?rev=1408161&view=auto
==============================================================================
--- activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompSslTest.java (added)
+++ activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompSslTest.java Mon Nov 12 00:15:50 2012
@@ -0,0 +1,51 @@
+/**
+ * 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.transport.stomp;
+
+import java.io.IOException;
+import java.net.Socket;
+
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLSocketFactory;
+
+import org.apache.activemq.broker.TransportConnector;
+
+public class StompSslTest extends StompTest {
+
+    @Override
+    public void setUp() throws Exception {
+        System.setProperty("javax.net.ssl.trustStore", "src/test/resources/client.keystore");
+        System.setProperty("javax.net.ssl.trustStorePassword", "password");
+        System.setProperty("javax.net.ssl.trustStoreType", "jks");
+        System.setProperty("javax.net.ssl.keyStore", "src/test/resources/server.keystore");
+        System.setProperty("javax.net.ssl.keyStorePassword", "password");
+        System.setProperty("javax.net.ssl.keyStoreType", "jks");
+        super.setUp();
+    }
+
+    @Override
+	protected void addStompConnector() throws Exception {
+        TransportConnector connector = brokerService.addConnector("stomp+ssl://0.0.0.0:"+sslPort);
+        sslPort = connector.getConnectUri().getPort();
+    }
+
+    @Override
+    protected Socket createSocket() throws IOException {
+        SocketFactory factory = SSLSocketFactory.getDefault();
+        return factory.createSocket("127.0.0.1", this.sslPort);
+    }
+}

Propchange: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompSslTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompSubscriptionRemoveTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompSubscriptionRemoveTest.java?rev=1408161&view=auto
==============================================================================
--- activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompSubscriptionRemoveTest.java (added)
+++ activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompSubscriptionRemoveTest.java Mon Nov 12 00:15:50 2012
@@ -0,0 +1,150 @@
+/**
+ * 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.transport.stomp;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInput;
+import java.io.DataInputStream;
+import java.io.IOException;
+
+import javax.jms.Connection;
+import javax.jms.Message;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+
+import org.apache.activemq.command.ActiveMQQueue;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class StompSubscriptionRemoveTest extends StompTestSupport {
+
+    private static final Logger LOG = LoggerFactory.getLogger(StompSubscriptionRemoveTest.class);
+    private static final String COMMAND_MESSAGE = "MESSAGE";
+    private static final String HEADER_MESSAGE_ID = "message-id";
+
+    @Test
+    public void testRemoveSubscriber() throws Exception {
+
+        Connection connection = cf.createConnection("system", "manager");
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        MessageProducer producer = session.createProducer(new ActiveMQQueue(getQueueName()));
+        Message message = session.createTextMessage("Testas");
+        for (int idx = 0; idx < 2000; ++idx) {
+            producer.send(message);
+            LOG.debug("Sending: " + idx);
+        }
+        producer.close();
+        session.close();
+        connection.close();
+
+        String connectFrame = "CONNECT\n" + "login:system\n" + "passcode:manager\n\n" + Stomp.NULL;
+        stompConnection.sendFrame(connectFrame);
+
+        stompConnection.receiveFrame();
+        String frame = "SUBSCRIBE\n" + "destination:/queue/" + getQueueName() + "\n" + "ack:client\n\n" + Stomp.NULL;
+        stompConnection.sendFrame(frame);
+
+        int messagesCount = 0;
+        int count = 0;
+        while (count < 2) {
+            String receiveFrame = stompConnection.receiveFrame();
+            LOG.debug("Received: " + receiveFrame);
+            assertEquals("Unexpected frame received", COMMAND_MESSAGE, getCommand(receiveFrame));
+            String messageId = getHeaderValue(receiveFrame, HEADER_MESSAGE_ID);
+            String ackmessage = "ACK\n" + HEADER_MESSAGE_ID + ":" + messageId + "\n\n"+ Stomp.NULL;
+            stompConnection.sendFrame(ackmessage);
+            // Thread.sleep(1000);
+            ++messagesCount;
+            ++count;
+        }
+
+        stompConnection.sendFrame("DISCONNECT\n\n");
+        Thread.sleep(1000);
+        stompConnection.close();
+
+        stompDisconnect();
+        stompConnect();
+
+        connectFrame = "CONNECT\n" + "login:system\n" + "passcode:manager\n\n" + Stomp.NULL;
+        stompConnection.sendFrame(connectFrame);
+
+        stompConnection.receiveFrame();
+
+        frame = "SUBSCRIBE\n" + "destination:/queue/" + getQueueName() + "\n" + "ack:client\n\n" + Stomp.NULL;
+        stompConnection.sendFrame(frame);
+        try {
+            while (count != 2000) {
+                String receiveFrame = stompConnection.receiveFrame();
+                LOG.debug("Received: " + receiveFrame);
+                assertEquals("Unexpected frame received", COMMAND_MESSAGE, getCommand(receiveFrame));
+                String messageId = getHeaderValue(receiveFrame, HEADER_MESSAGE_ID);
+                String ackmessage = "ACK\n" + HEADER_MESSAGE_ID + ":" + messageId.trim() + "\n\n" + Stomp.NULL;
+                stompConnection.sendFrame(ackmessage);
+                // Thread.sleep(1000);
+                ++messagesCount;
+                ++count;
+            }
+        } catch (IOException ex) {
+            ex.printStackTrace();
+        }
+
+        stompConnection.sendFrame("DISCONNECT\n\n");
+        stompConnection.close();
+
+        LOG.info("Total messages received: " + messagesCount);
+        assertTrue("Messages received after connection loss: " + messagesCount, messagesCount >= 2000);
+
+        // The first ack messages has no chance complete, so we receiving more
+        // messages
+
+        // Don't know how to list subscriptions for the broker. Currently you
+        // can check using JMX console. You'll see
+        // Subscription without any connections
+    }
+
+    // These two methods could move to a utility class
+    protected String getCommand(String frame) {
+        return frame.substring(0, frame.indexOf('\n') + 1).trim();
+    }
+
+    protected String getHeaderValue(String frame, String header) throws IOException {
+        DataInput input = new DataInputStream(new ByteArrayInputStream(frame.getBytes()));
+        String line;
+        for (int idx = 0; /* forever, sort of */; ++idx) {
+            line = input.readLine();
+            if (line == null) {
+                // end of message, no headers
+                return null;
+            }
+            line = line.trim();
+            if (line.length() == 0) {
+                // start body, no headers from here on
+                return null;
+            }
+            if (idx > 0) { // Ignore command line
+                int pos = line.indexOf(':');
+                if (header.equals(line.substring(0, pos))) {
+                    return line.substring(pos + 1).trim();
+                }
+            }
+        }
+    }
+}

Propchange: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompSubscriptionRemoveTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompTelnetTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompTelnetTest.java?rev=1408161&view=auto
==============================================================================
--- activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompTelnetTest.java (added)
+++ activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompTelnetTest.java Mon Nov 12 00:15:50 2012
@@ -0,0 +1,98 @@
+/**
+ * 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.transport.stomp;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.Socket;
+
+import org.apache.activemq.broker.BrokerPlugin;
+import org.apache.activemq.broker.TransportConnector;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class StompTelnetTest extends StompTestSupport {
+
+    private static final Logger LOG = LoggerFactory.getLogger(StompTelnetTest.class);
+
+    @Test
+    public void testCRLF() throws Exception {
+
+        for (TransportConnector connector : brokerService.getTransportConnectors()) {
+            LOG.info("try: " + connector.getConnectUri());
+            int port = connector.getConnectUri().getPort();
+
+            StompConnection stompConnection = new StompConnection();
+            stompConnection.open(createSocket(port));
+            String frame = "CONNECT\r\n\r\n" + Stomp.NULL;
+            stompConnection.sendFrame(frame);
+
+            frame = stompConnection.receiveFrame();
+            LOG.info("response from: " + connector.getConnectUri() + ", " + frame);
+            assertTrue(frame.startsWith("CONNECTED"));
+            stompConnection.close();
+        }
+    }
+
+    @Test
+    public void testCRLF11() throws Exception {
+
+        for (TransportConnector connector : brokerService.getTransportConnectors()) {
+            LOG.info("try: " + connector.getConnectUri());
+            int port = connector.getConnectUri().getPort();
+
+            StompConnection stompConnection = new StompConnection();
+            stompConnection.open(createSocket(port));
+            String frame = "CONNECT\r\naccept-version:1.1\r\n\r\n" + Stomp.NULL;
+            stompConnection.sendFrame(frame);
+
+            frame = stompConnection.receiveFrame();
+            LOG.info("response from: " + connector.getConnectUri() + ", " + frame);
+            assertTrue(frame.startsWith("CONNECTED"));
+            stompConnection.close();
+        }
+    }
+
+    @Override
+    protected BrokerPlugin configureAuthentication() throws Exception {
+        return null;
+    }
+
+    @Override
+    protected BrokerPlugin configureAuthorization() throws Exception {
+        return null;
+    }
+
+    @Override
+    protected void addStompConnector() throws Exception {
+        TransportConnector connector = brokerService.addConnector("stomp://0.0.0.0:"+port);
+        port = connector.getConnectUri().getPort();
+        connector = brokerService.addConnector("stomp+nio://0.0.0.0:"+nioPort);
+        nioPort = connector.getConnectUri().getPort();
+    }
+
+    protected Socket createSocket(int port) throws IOException {
+        return new Socket("127.0.0.1", port);
+    }
+
+    @Override
+	protected String getQueueName() {
+        return getClass().getName() + "." + getName();
+    }
+}

Propchange: activemq/trunk/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompTelnetTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message