activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [09/52] [abbrv] [partial] activemq-artemis git commit: ARTEMIS-127 Adding activemq unit test module to Artemis
Date Tue, 09 Jun 2015 16:36:40 GMT
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/MessageSelectorTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/MessageSelectorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/MessageSelectorTest.java
new file mode 100644
index 0000000..e9aa3ca
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/MessageSelectorTest.java
@@ -0,0 +1,227 @@
+/* ====================================================================
+   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.bugs.amq1095;
+
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.jms.Topic;
+
+/**
+ * <p>
+ * Test cases for various ActiveMQ functionalities.
+ * </p>
+ *
+ * <ul>
+ * <li>
+ * <p>
+ * Durable subscriptions are used.
+ * </p>
+ * </li>
+ * <li>
+ * <p>
+ * The Kaha persistence manager is used.
+ * </p>
+ * </li>
+ * <li>
+ * <p>
+ * An already existing Kaha directory is used. Everything runs fine if the
+ * ActiveMQ broker creates a new Kaha directory.
+ * </p>
+ * </li>
+ * </ul>
+ *
+ * @author Rainer Klute <a
+ *         href="mailto:rainer.klute@dp-itsolutions.de">&lt;rainer.klute@dp-itsolutions.de&gt;</a>
+ * @since 2007-08-09
+ * @version $Id: MessageSelectorTest.java 12 2007-08-14 12:02:02Z rke $
+ */
+public class MessageSelectorTest extends ActiveMQTestCase {
+
+    private MessageConsumer consumer1;
+    private MessageConsumer consumer2;
+
+    /** <p>Constructor</p> */
+    public MessageSelectorTest()
+    {}
+
+    /** <p>Constructor</p>
+     * @param name the test case's name
+     */
+    public MessageSelectorTest(final String name)
+    {
+        super(name);
+    }
+
+    /**
+     * <p>
+     * Tests whether message selectors work for durable subscribers.
+     * </p>
+     */
+    public void testMessageSelectorForDurableSubscribersRunA()
+    {
+        runMessageSelectorTest(true);
+    }
+
+    /**
+     * <p>
+     * Tests whether message selectors work for durable subscribers.
+     * </p>
+     */
+    public void testMessageSelectorForDurableSubscribersRunB()
+    {
+        runMessageSelectorTest(true);
+    }
+
+    /**
+     * <p>
+     * Tests whether message selectors work for non-durable subscribers.
+     * </p>
+     */
+    public void testMessageSelectorForNonDurableSubscribers()
+    {
+        runMessageSelectorTest(false);
+    }
+
+    /**
+     * <p>
+     * Tests whether message selectors work. This is done by sending two
+     * messages to a topic. Both have an int property with different values. Two
+     * subscribers use message selectors to receive the messages. Each one
+     * should receive exactly one of the messages.
+     * </p>
+     */
+    private void runMessageSelectorTest(final boolean isDurableSubscriber)
+    {
+        try
+        {
+            final String PROPERTY_CONSUMER = "consumer";
+            final String CONSUMER_1 = "Consumer 1";
+            final String CONSUMER_2 = "Consumer 2";
+            final String MESSAGE_1 = "Message to " + CONSUMER_1;
+            final String MESSAGE_2 = "Message to " + CONSUMER_2;
+
+            assertNotNull(connection);
+            assertNotNull(destination);
+
+            final Session producingSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            final MessageProducer producer = producingSession.createProducer(destination);
+
+            final Session consumingSession1 = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            final Session consumingSession2 = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+            if (isDurableSubscriber)
+            {
+                consumer1 = consumingSession1.createDurableSubscriber
+                    ((Topic) destination, CONSUMER_1, PROPERTY_CONSUMER + " = 1", false);
+                consumer2 = consumingSession2.createDurableSubscriber
+                    ((Topic) destination, CONSUMER_2, PROPERTY_CONSUMER + " = 2", false);
+            }
+            else
+            {
+                consumer1 = consumingSession1.createConsumer(destination, PROPERTY_CONSUMER + " = 1");
+                consumer2 = consumingSession2.createConsumer(destination, PROPERTY_CONSUMER + " = 2");
+            }
+            registerToBeEmptiedOnShutdown(consumer1);
+            registerToBeEmptiedOnShutdown(consumer2);
+
+            connection.start();
+
+            TextMessage msg1;
+            TextMessage msg2;
+            int propertyValue;
+            String contents;
+
+            /* Try to receive any messages from the consumers. There shouldn't be any yet. */
+            msg1 = (TextMessage) consumer1.receive(RECEIVE_TIMEOUT);
+            if (msg1 != null)
+            {
+                final StringBuffer msg = new StringBuffer("The consumer read a message that was left over from a former ActiveMQ broker run.");
+                propertyValue = msg1.getIntProperty(PROPERTY_CONSUMER);
+                contents = msg1.getText();
+                if (propertyValue != 1) // Is the property value as expected?
+                {
+                    msg.append(" That message does not match the consumer's message selector.");
+                    fail(msg.toString());
+                }
+                assertEquals(1, propertyValue);
+                assertEquals(MESSAGE_1, contents);
+            }
+            msg2 = (TextMessage) consumer2.receive(RECEIVE_TIMEOUT);
+            if (msg2 != null)
+            {
+                final StringBuffer msg = new StringBuffer("The consumer read a message that was left over from a former ActiveMQ broker run.");
+                propertyValue = msg2.getIntProperty(PROPERTY_CONSUMER);
+                contents = msg2.getText();
+                if (propertyValue != 2) // Is the property value as expected?
+                {
+                    msg.append(" That message does not match the consumer's message selector.");
+                    fail(msg.toString());
+                }
+                assertEquals(2, propertyValue);
+                assertEquals(MESSAGE_2, contents);
+            }
+
+            /* Send two messages. Each is targeted at one of the consumers. */
+            TextMessage msg;
+            msg = producingSession.createTextMessage();
+            msg.setText(MESSAGE_1);
+            msg.setIntProperty(PROPERTY_CONSUMER, 1);
+            producer.send(msg);
+
+            msg = producingSession.createTextMessage();
+            msg.setText(MESSAGE_2);
+            msg.setIntProperty(PROPERTY_CONSUMER, 2);
+            producer.send(msg);
+
+            /* Receive the messages that have just been sent. */
+
+            /* Use consumer 1 to receive one of the messages. The receive()
+             * method is called twice to make sure there is nothing else in
+             * stock for this consumer. */
+            msg1 = (TextMessage) consumer1.receive(RECEIVE_TIMEOUT);
+            assertNotNull(msg1);
+            propertyValue = msg1.getIntProperty(PROPERTY_CONSUMER);
+            contents = msg1.getText();
+            assertEquals(1, propertyValue);
+            assertEquals(MESSAGE_1, contents);
+            msg1 = (TextMessage) consumer1.receive(RECEIVE_TIMEOUT);
+            assertNull(msg1);
+
+            /* Use consumer 2 to receive the other message. The receive()
+             * method is called twice to make sure there is nothing else in
+             * stock for this consumer. */
+            msg2 = (TextMessage) consumer2.receive(RECEIVE_TIMEOUT);
+            assertNotNull(msg2);
+            propertyValue = msg2.getIntProperty(PROPERTY_CONSUMER);
+            contents = msg2.getText();
+            assertEquals(2, propertyValue);
+            assertEquals(MESSAGE_2, contents);
+            msg2 = (TextMessage) consumer2.receive(RECEIVE_TIMEOUT);
+            assertNull(msg2);
+        }
+        catch (JMSException ex)
+        {
+            ex.printStackTrace();
+            fail();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/activemq.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/activemq.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/activemq.xml
new file mode 100644
index 0000000..c89e261
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/activemq.xml
@@ -0,0 +1,39 @@
+<?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.
+-->
+<beans 
+  xmlns="http://www.springframework.org/schema/beans" 
+  xmlns:amq="http://activemq.apache.org/schema/core"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+
+  <broker brokerName="localhost" xmlns="http://activemq.apache.org/schema/core" persistent="true" deleteAllMessagesOnStartup="true">
+
+    <destinations>
+      <queue physicalName="unused"/>
+      <topic physicalName="activemq.TestTopic"/>
+    </destinations>
+  
+    <persistenceAdapter>
+      <kahaDB directory="file:target/amq1095"/>
+    </persistenceAdapter>
+
+
+  </broker>
+
+</beans>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1974/TryJmsClient.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1974/TryJmsClient.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1974/TryJmsClient.java
new file mode 100644
index 0000000..c8b4503
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1974/TryJmsClient.java
@@ -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.bugs.amq1974;
+
+import org.apache.activemq.ActiveMQConnection;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.leveldb.LevelDBStore;
+import org.apache.activemq.network.DiscoveryNetworkConnector;
+import org.apache.activemq.transport.discovery.simple.SimpleDiscoveryAgent;
+
+import javax.jms.*;
+import java.io.File;
+import java.net.URISyntaxException;
+
+public class TryJmsClient
+{
+    private final BrokerService broker = new BrokerService();
+
+    public static void main(String[] args) throws Exception {
+        new TryJmsClient().start();
+    }
+
+    private void start() throws Exception {
+
+        broker.setUseJmx(false);
+        broker.setPersistent(true);
+        broker.setBrokerName("TestBroker");
+        broker.getSystemUsage().setSendFailIfNoSpace(true);
+
+        broker.getSystemUsage().getMemoryUsage().setLimit(10 * 1024 * 1024);
+
+        LevelDBStore persist = new LevelDBStore();
+        persist.setDirectory(new File("/tmp/broker2"));
+        persist.setLogSize(20 * 1024 * 1024);
+        broker.setPersistenceAdapter(persist);
+
+        String brokerUrl = "tcp://localhost:4501";
+        broker.addConnector(brokerUrl);
+
+        broker.start();
+
+        addNetworkBroker();
+
+        startUsageMonitor(broker);
+
+        startMessageSend();
+
+        synchronized(this) {
+            this.wait();
+        }
+    }
+
+    private void startUsageMonitor(final BrokerService brokerService) {
+        new Thread(new Runnable() {
+            public void run() {
+                while (true) {
+                    try {
+                        Thread.sleep(10000);
+                    } catch (InterruptedException e) {
+                        e.printStackTrace();
+                    }
+
+                    System.out.println("ActiveMQ memeory " + brokerService.getSystemUsage().getMemoryUsage().getPercentUsage()
+                            + " " + brokerService.getSystemUsage().getMemoryUsage().getUsage());
+                    System.out.println("ActiveMQ message store " + brokerService.getSystemUsage().getStoreUsage().getPercentUsage());
+                    System.out.println("ActiveMQ temp space " + brokerService.getSystemUsage().getTempUsage().getPercentUsage());
+                }
+            }
+        }).start();
+    }
+
+    private void addNetworkBroker() throws Exception {
+
+        DiscoveryNetworkConnector dnc = new DiscoveryNetworkConnector();
+        dnc.setNetworkTTL(1);
+        dnc.setBrokerName("TestBroker");
+        dnc.setName("Broker1Connector");
+        dnc.setDynamicOnly(true);
+
+        SimpleDiscoveryAgent discoveryAgent = new SimpleDiscoveryAgent();
+        String remoteUrl = "tcp://localhost:4500";
+        discoveryAgent.setServices(remoteUrl);
+
+        dnc.setDiscoveryAgent(discoveryAgent);
+
+        broker.addNetworkConnector(dnc);
+        dnc.start();
+    }
+
+    private void startMessageSend() {
+        new Thread(new MessageSend()).start();
+    }
+
+    private class MessageSend implements Runnable {
+        public void run() {
+            try {
+                String url = "vm://TestBroker";
+                ActiveMQConnection connection = ActiveMQConnection.makeConnection(url);
+                connection.setDispatchAsync(true);
+                Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+                Destination dest = session.createTopic("TestDestination");
+
+                MessageProducer producer = session.createProducer(dest);
+                producer.setDeliveryMode(DeliveryMode.PERSISTENT);
+
+                for(int i = 0; i < 99999999; i++)  {
+                    TextMessage message = session.createTextMessage("test" + i);
+
+                    /*
+                    try {
+                        Thread.sleep(1);
+                    } catch (InterruptedException e) {
+                        e.printStackTrace();
+                    }
+                    */
+
+                    try {
+                        producer.send(message);
+                    } catch (Exception e ) {
+                        e.printStackTrace();
+                        System.out.println("TOTAL number of messages sent " + i);
+                        break;
+                    }
+
+                    if (i % 1000 == 0) {
+                        System.out.println("sent message " + message.getJMSMessageID());
+                    }
+                }
+            } catch (JMSException e) {
+                e.printStackTrace();
+            } catch (URISyntaxException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1974/TryJmsManager.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1974/TryJmsManager.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1974/TryJmsManager.java
new file mode 100644
index 0000000..3f58987
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1974/TryJmsManager.java
@@ -0,0 +1,124 @@
+/**
+ * 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.bugs.amq1974;
+
+import org.apache.activemq.ActiveMQConnection;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.leveldb.LevelDBStore;
+import org.apache.activemq.network.DiscoveryNetworkConnector;
+import org.apache.activemq.transport.discovery.simple.SimpleDiscoveryAgent;
+
+import javax.jms.*;
+import java.io.File;
+import java.net.URISyntaxException;
+
+public class TryJmsManager {
+
+    private final BrokerService broker = new BrokerService();
+
+    public static void main(String[] args) throws Exception {
+        new TryJmsManager().start();
+    }
+
+    private void start() throws Exception {
+
+        broker.setUseJmx(false);
+        broker.setPersistent(true);
+        broker.setBrokerName("TestBroker");
+        broker.getSystemUsage().setSendFailIfNoSpace(true);
+
+        broker.getSystemUsage().getMemoryUsage().setLimit(10 * 1024 * 1024);
+
+        LevelDBStore persist = new LevelDBStore();
+        persist.setDirectory(new File("/tmp/broker1"));
+        persist.setLogSize(20 * 1024 * 1024);
+        broker.setPersistenceAdapter(persist);
+
+        String brokerUrl = "tcp://localhost:4500";
+        broker.addConnector(brokerUrl);
+
+        broker.start();
+
+        addNetworkBroker();
+
+        startUsageMonitor(broker);
+
+        startMessageConsumer();
+
+        synchronized(this) {
+            this.wait();
+        }
+    }
+
+    private void startUsageMonitor(final BrokerService brokerService) {
+        new Thread(new Runnable() {
+            public void run() {
+                while (true) {
+                    try {
+                        Thread.sleep(10000);
+                    } catch (InterruptedException e) {
+                        e.printStackTrace();
+                    }
+
+                    System.out.println("ActiveMQ memeory " + brokerService.getSystemUsage().getMemoryUsage().getPercentUsage()
+                            + " " + brokerService.getSystemUsage().getMemoryUsage().getUsage());
+                    System.out.println("ActiveMQ message store " + brokerService.getSystemUsage().getStoreUsage().getPercentUsage());
+                    System.out.println("ActiveMQ temp space " + brokerService.getSystemUsage().getTempUsage().getPercentUsage());
+                }
+            }
+        }).start();
+    }
+
+    private void addNetworkBroker() throws Exception {
+        DiscoveryNetworkConnector dnc = new DiscoveryNetworkConnector();
+        dnc.setNetworkTTL(1);
+        dnc.setBrokerName("TestBroker");
+        dnc.setName("Broker1Connector");
+        dnc.setDynamicOnly(true);
+
+        SimpleDiscoveryAgent discoveryAgent = new SimpleDiscoveryAgent();
+        String remoteUrl = "tcp://localhost:4501";
+        discoveryAgent.setServices(remoteUrl);
+
+        dnc.setDiscoveryAgent(discoveryAgent);
+
+        broker.addNetworkConnector(dnc);
+        dnc.start();
+    }
+
+    private void startMessageConsumer() throws JMSException, URISyntaxException {
+        String url = "vm://TestBroker";
+        ActiveMQConnection connection = ActiveMQConnection.makeConnection(url);
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        Destination dest = session.createTopic("TestDestination");
+
+        MessageConsumer consumer = session.createConsumer(dest);
+        consumer.setMessageListener(new MessageListener() {
+
+            public void onMessage(Message message) {
+                try {
+                    System.out.println("got message " + message.getJMSMessageID());
+                } catch (JMSException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        );
+
+        connection.start();
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/JaasStompSSLBroker1.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/JaasStompSSLBroker1.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/JaasStompSSLBroker1.xml
new file mode 100644
index 0000000..9b82ae1
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/JaasStompSSLBroker1.xml
@@ -0,0 +1,65 @@
+<?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.
+-->
+
+
+<beans 
+  xmlns="http://www.springframework.org/schema/beans"
+  xmlns:amq="http://activemq.apache.org/schema/core"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+
+  <broker xmlns="http://activemq.apache.org/schema/core" brokerName="broker1" id="broker1" useJmx="false" persistent="false">
+
+    <plugins>
+      <jaasCertificateAuthenticationPlugin configuration="CertLogin"/>
+
+      <authorizationPlugin>
+        <map>
+          <authorizationMap>
+            <authorizationEntries>
+              <authorizationEntry queue=">" read="admins" write="admins" admin="admins" />
+              <amq:authorizationEntry queue="USERS.>" read="users" write="users" admin="users" />
+              <amq:authorizationEntry queue="GUEST.>" read="guests" write="guests,users" admin="guests,users" />
+              <authorizationEntry topic=">" read="admins" write="admins" admin="admins" />
+              <authorizationEntry topic="USERS.>" read="users" write="users" admin="users" />
+              <authorizationEntry topic="GUEST.>" read="guests" write="guests,users" admin="guests,users" />
+
+              <authorizationEntry topic="ActiveMQ.Advisory.>" read="guests,users" write="guests,users" admin="guests,users"/>
+            </authorizationEntries>
+            <tempDestinationAuthorizationEntry>  
+              <tempDestinationAuthorizationEntry read="tempDestinationAdmins" write="tempDestinationAdmins" admin="tempDestinationAdmins"/> 
+            </tempDestinationAuthorizationEntry>  
+          </authorizationMap>
+        </map>
+      </authorizationPlugin>
+    </plugins>
+
+    <sslContext>
+      <sslContext
+        keyStore="file:./src/test/resources/org/apache/activemq/bugs/amq3625/keys/broker2.ks"   keyStorePassword="password"
+        trustStore="file:./src/test/resources/org/apache/activemq/bugs/amq3625/keys/client2.ks" trustStorePassword="password"/>
+    </sslContext>
+
+    <transportConnectors>
+      <transportConnector name="openwire" uri="ssl://0.0.0.0:0?needClientAuth=true" />
+    </transportConnectors>
+
+  </broker>
+
+</beans>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/JaasStompSSLBroker2.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/JaasStompSSLBroker2.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/JaasStompSSLBroker2.xml
new file mode 100644
index 0000000..0b68aed
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/JaasStompSSLBroker2.xml
@@ -0,0 +1,39 @@
+<?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.
+-->
+
+<beans 
+  xmlns="http://www.springframework.org/schema/beans"
+  xmlns:amq="http://activemq.apache.org/schema/core"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+
+  <broker xmlns="http://activemq.apache.org/schema/core" brokerName="broker2" id="broker2" useJmx="false" persistent="false">
+
+    <sslContext>
+      <sslContext
+        keyStore="./src/test/resources/org/apache/activemq/bugs/amq3625/keys/client2.ks"   keyStorePassword="password"
+        trustStore="./src/test/resources/org/apache/activemq/bugs/amq3625/keys/client2.ts" trustStorePassword="password"/>
+    </sslContext>
+
+    <transportConnectors>
+      <transportConnector name="openwire" uri="ssl://localhost:0?needClientAuth=true" />
+    </transportConnectors>
+
+  </broker>
+</beans>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/groups2.properties
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/groups2.properties b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/groups2.properties
new file mode 100644
index 0000000..ad1398f
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/groups2.properties
@@ -0,0 +1,20 @@
+/**
+ * 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.
+ */
+admins=system,dave
+tempDestinationAdmins=system,user,dave
+users=system,tester,user,dave,admin
+guests=guest

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/login.config
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/login.config b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/login.config
new file mode 100644
index 0000000..898a174
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/login.config
@@ -0,0 +1,22 @@
+/**
+ * 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.
+ */
+CertLogin {
+    org.apache.activemq.jaas.TextFileCertificateLoginModule required
+       debug=true
+       org.apache.activemq.jaas.textfiledn.user="users2.properties
+       org.apache.activemq.jaas.textfiledn.group="groups2.properties";
+};

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/users2.properties
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/users2.properties b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/users2.properties
new file mode 100644
index 0000000..6c19d19
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/users2.properties
@@ -0,0 +1,23 @@
+/**
+ * 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.
+ */
+guests=myguests
+system=manager
+admin=apassword
+user=password
+guest=password
+tester=mypassword
+dave=CN=Hello Dave Stanley, OU=FuseSource, O=Progress, L=Unknown, ST=MA, C=US

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/keys/broker2.ks
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/keys/broker2.ks b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/keys/broker2.ks
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/keys/client2.ks
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/keys/client2.ks b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/keys/client2.ks
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/keys/client2.ts
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/keys/client2.ts b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/keys/client2.ts
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/InconsistentConnectorPropertiesBehaviour.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/InconsistentConnectorPropertiesBehaviour.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/InconsistentConnectorPropertiesBehaviour.xml
new file mode 100644
index 0000000..325e354
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/InconsistentConnectorPropertiesBehaviour.xml
@@ -0,0 +1,46 @@
+<?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.
+-->
+
+<beans 
+  xmlns="http://www.springframework.org/schema/beans"
+  xmlns:amq="http://activemq.apache.org/schema/core"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+
+  <broker xmlns="http://activemq.apache.org/schema/core" brokerName="broker" id="broker" useJmx="false" persistent="false">
+
+    <plugins>
+        <jaasDualAuthenticationPlugin configuration="activemq-domain" sslConfiguration="activemq-ssl-domain"/>
+    </plugins>
+    
+    <sslContext>
+      <sslContext
+        keyStore="./src/test/resources/org/apache/activemq/security/broker1.ks"   keyStorePassword="password"
+        trustStore="./src/test/resources/org/apache/activemq/security/client.ks" trustStorePassword="password"/>
+    </sslContext>
+
+    <transportConnectors>
+      <transportConnector name="stomp+ssl+special" uri="stomp+ssl://0.0.0.0:0?needClientAuth=true" />
+      <transportConnector name="stomp+ssl" uri="stomp+ssl://0.0.0.0:0?transport.needClientAuth=true" />
+      <transportConnector name="stomp+nio+ssl+special" uri="stomp+nio+ssl://0.0.0.0:0?needClientAuth=true" />
+      <transportConnector name="stomp+nio+ssl" uri="stomp+nio+ssl://0.0.0.0:0?transport.needClientAuth=true" />
+    </transportConnectors>
+
+  </broker>
+</beans>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/JaasStompSSLBroker.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/JaasStompSSLBroker.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/JaasStompSSLBroker.xml
new file mode 100644
index 0000000..a245028
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/JaasStompSSLBroker.xml
@@ -0,0 +1,46 @@
+<?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.
+-->
+
+<beans
+  xmlns="http://www.springframework.org/schema/beans"
+  xmlns:amq="http://activemq.apache.org/schema/core"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+
+  <broker xmlns="http://activemq.apache.org/schema/core" brokerName="broker" id="broker" useJmx="true" persistent="false">
+
+    <plugins>
+        <jaasDualAuthenticationPlugin configuration="activemq-domain" sslConfiguration="activemq-ssl-domain"/>
+    </plugins>
+
+    <sslContext>
+      <sslContext
+        keyStore="./src/test/resources/org/apache/activemq/security/broker1.ks"   keyStorePassword="password"
+        trustStore="./src/test/resources/org/apache/activemq/security/client.ks" trustStorePassword="password"/>
+    </sslContext>
+
+    <transportConnectors>
+      <transportConnector name="stomp+ssl" uri="stomp+ssl://0.0.0.0:0?transport.needClientAuth=true" />
+      <transportConnector name="stomp+nio+ssl" uri="stomp+nio+ssl://0.0.0.0:0?transport.needClientAuth=true" />
+      <transportConnector name="openwire+ssl" uri="ssl://0.0.0.0:0?transport.needClientAuth=true" />
+      <transportConnector name="openwire+nio+ssl" uri="nio+ssl://0.0.0.0:0?transport.needClientAuth=true&amp;transport.enabledCipherSuites=SSL_RSA_WITH_RC4_128_SHA,SSL_DH_anon_WITH_3DES_EDE_CBC_SHA" />
+    </transportConnectors>
+
+  </broker>
+</beans>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/dns.properties
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/dns.properties b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/dns.properties
new file mode 100644
index 0000000..fcfe558
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/dns.properties
@@ -0,0 +1,17 @@
+/**
+ * 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.
+ */
+client=CN=client, OU=activemq, O=apache

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/groups.properties
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/groups.properties b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/groups.properties
new file mode 100644
index 0000000..4171c5f
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/groups.properties
@@ -0,0 +1,18 @@
+/**
+ * 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.
+ */
+admins=system,client
+guests=guest

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/login.config
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/login.config b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/login.config
new file mode 100644
index 0000000..c3d87c1
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/login.config
@@ -0,0 +1,30 @@
+/**
+ * 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.
+ */
+activemq-domain {
+
+    org.apache.activemq.jaas.PropertiesLoginModule requisite
+        debug=true
+        org.apache.activemq.jaas.properties.user="users.properties"
+        org.apache.activemq.jaas.properties.group="groups.properties";
+};
+
+activemq-ssl-domain {   
+    org.apache.activemq.jaas.TextFileCertificateLoginModule required
+        debug=true
+        org.apache.activemq.jaas.textfiledn.user="dns.properties"
+        org.apache.activemq.jaas.textfiledn.group="groups.properties";
+};

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/users.properties
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/users.properties b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/users.properties
new file mode 100644
index 0000000..2915bdb
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/users.properties
@@ -0,0 +1,18 @@
+/**
+ * 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.
+ */
+system=manager
+guest=password
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq5035/activemq.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq5035/activemq.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq5035/activemq.xml
new file mode 100644
index 0000000..660fff5
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq5035/activemq.xml
@@ -0,0 +1,109 @@
+<!--
+    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.
+-->
+<!-- START SNIPPET: example -->
+<beans
+  xmlns="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+
+    <!--
+        The <broker> element is used to configure the ActiveMQ broker.
+    -->
+    <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="target/activemq-data" schedulerSupport="true">
+
+        <destinationPolicy>
+            <policyMap>
+              <policyEntries>
+                <policyEntry topic=">" >
+                    <!-- The constantPendingMessageLimitStrategy is used to prevent
+                         slow topic consumers to block producers and affect other consumers
+                         by limiting the number of messages that are retained
+                         For more information, see:
+
+                         http://activemq.apache.org/slow-consumer-handling.html
+                    -->
+                  <pendingMessageLimitStrategy>
+                    <constantPendingMessageLimitStrategy limit="1000"/>
+                  </pendingMessageLimitStrategy>
+                </policyEntry>
+              </policyEntries>
+            </policyMap>
+        </destinationPolicy>
+
+        <!--
+            The managementContext is used to configure how ActiveMQ is exposed in
+            JMX. By default, ActiveMQ uses the MBean server that is started by
+            the JVM. For more information, see:
+
+            http://activemq.apache.org/jmx.html
+        -->
+        <managementContext>
+            <managementContext createConnector="false"/>
+        </managementContext>
+
+        <!--
+            Configure message persistence for the broker. The default persistence
+            mechanism is the KahaDB store (identified by the kahaDB tag).
+            For more information, see:
+
+            http://activemq.apache.org/persistence.html
+        -->
+        <persistenceAdapter>
+            <kahaDB directory="target/activemq-data/KahaDB"/>
+        </persistenceAdapter>
+
+
+          <!--
+            The systemUsage controls the maximum amount of space the broker will
+            use before disabling caching and/or slowing down producers. For more information, see:
+            http://activemq.apache.org/producer-flow-control.html
+          -->
+          <systemUsage>
+            <systemUsage>
+                <memoryUsage>
+                    <memoryUsage percentOfJvmHeap="70" />
+                </memoryUsage>
+                <storeUsage>
+                    <storeUsage limit="100 gb"/>
+                </storeUsage>
+                <tempUsage>
+                    <tempUsage limit="50 gb"/>
+                </tempUsage>
+            </systemUsage>
+        </systemUsage>
+
+        <!--
+            The transport connectors expose ActiveMQ over a given protocol to
+            clients and other brokers. For more information, see:
+
+            http://activemq.apache.org/configuring-transports.html
+        -->
+        <transportConnectors>
+            <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
+            <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
+        </transportConnectors>
+
+        <!-- destroy the spring context on shutdown to stop jetty -->
+        <shutdownHooks>
+            <bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" />
+        </shutdownHooks>
+
+    </broker>
+
+</beans>
+<!-- END SNIPPET: example -->

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/embedded/EmbeddedActiveMQ.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/embedded/EmbeddedActiveMQ.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/embedded/EmbeddedActiveMQ.java
new file mode 100644
index 0000000..3b4f2fd
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/embedded/EmbeddedActiveMQ.java
@@ -0,0 +1,114 @@
+/**
+ * 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.bugs.embedded;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.Message;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.log4j.Logger;
+
+public class EmbeddedActiveMQ
+{
+ 
+        private static Logger logger = Logger.getLogger(EmbeddedActiveMQ.class);
+ 
+        public static void main(String[] args)
+        {
+ 
+                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
+                BrokerService brokerService = null;
+                Connection connection = null;
+ 
+                logger.info("Start...");
+                try
+                {
+                        brokerService = new BrokerService();
+                        brokerService.setBrokerName("TestMQ");
+                        brokerService.setUseJmx(true);
+                        logger.info("Broker '" + brokerService.getBrokerName() + "' is starting........");
+                        brokerService.start();
+                        ConnectionFactory fac = new ActiveMQConnectionFactory("vm://TestMQ");
+                        connection = fac.createConnection();
+                        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+                        Destination queue = session.createQueue("TEST.QUEUE");
+                        MessageProducer producer = session.createProducer(queue);
+                        for (int i = 0; i < 1000;i++) {
+                            Message msg = session.createTextMessage("test"+i);
+                            producer.send(msg);
+                        }
+                        logger.info(ThreadExplorer.show("Active threads after start:"));
+                        System.out.println("Press return to stop........");
+                        String key = br.readLine();
+                }
+ 
+                catch (Exception e)
+                {
+                        e.printStackTrace();
+                }
+                finally
+                {
+                        try
+                        {
+                                br.close();
+                                logger.info("Broker '" + brokerService.getBrokerName() + "' is stopping........");
+                                connection.close();
+                                brokerService.stop(); 
+                                sleep(8);
+                                logger.info(ThreadExplorer.show("Active threads after stop:"));
+ 
+                        }
+                        catch (Exception e)
+                        {
+                                e.printStackTrace();
+                        }
+                }
+ 
+                logger.info("Waiting for list theads is greater then 1 ...");
+                int numTh = ThreadExplorer.active();
+ 
+                while (numTh > 2)
+                {
+                        sleep(3);
+                        numTh = ThreadExplorer.active();
+                        logger.info(ThreadExplorer.show("Still active threads:"));
+                }
+ 
+                System.out.println("Stop...");
+        }
+ 
+        private static void sleep(int second)
+        {
+                try
+                {
+                        logger.info("Waiting for " + second + "s...");
+                        Thread.sleep(second * 1000L);
+                }
+                catch (InterruptedException e)
+                {
+                        // TODO Auto-generated catch block
+                        e.printStackTrace();
+                }
+        }
+ 
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/embedded/ThreadExplorer.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/embedded/ThreadExplorer.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/embedded/ThreadExplorer.java
new file mode 100644
index 0000000..eab5fd1
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/embedded/ThreadExplorer.java
@@ -0,0 +1,168 @@
+/**
+ * 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.bugs.embedded;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.log4j.Logger;
+
+public class ThreadExplorer
+{
+    static Logger logger = Logger.getLogger(ThreadExplorer.class);
+
+    public static Thread[] listThreads()
+    {
+
+        int nThreads = Thread.activeCount();
+        Thread ret[] = new Thread[nThreads];
+
+        Thread.enumerate(ret);
+
+        return ret;
+
+    }
+
+    /**
+     * Helper function to access a thread per name (ignoring case)
+     * 
+     * @param name
+     * @return
+     */
+    public static Thread fetchThread(String name)
+    {
+        Thread[] threadArray = listThreads();
+        // for (Thread t : threadArray)
+        for (int i = 0; i < threadArray.length; i++)
+        {
+            Thread t = threadArray[i];
+            if (t.getName().equalsIgnoreCase(name))
+                return t;
+        }
+        return null;
+    }
+
+    /**
+     * Allow for killing threads
+     * 
+     * @param threadName
+     * @param isStarredExp
+     *            (regular expressions with *)
+     */
+    @SuppressWarnings("deprecation")
+    public static int kill(String threadName, boolean isStarredExp, String motivation)
+    {
+        String me = "ThreadExplorer.kill: ";
+        if (logger.isDebugEnabled())
+        {
+            logger.debug("Entering " + me + " with " + threadName + " isStarred: " + isStarredExp);
+        }
+        int ret = 0;
+        Pattern mypattern = null;
+        if (isStarredExp)
+        {
+            String realreg = threadName.toLowerCase().replaceAll("\\*", "\\.\\*");
+            mypattern = Pattern.compile(realreg);
+
+        }
+        Thread[] threads = listThreads();
+        for (int i = 0; i < threads.length; i++)
+        {
+            Thread thread = threads[i];
+            if (thread == null)
+                continue;
+            // kill the thread unless it is not current thread
+            boolean matches = false;
+
+            if (isStarredExp)
+            {
+                Matcher matcher = mypattern.matcher(thread.getName().toLowerCase());
+                matches = matcher.matches();
+            }
+            else
+            {
+                matches = (thread.getName().equalsIgnoreCase(threadName));
+            }
+            if (matches && (Thread.currentThread() != thread) && !thread.getName().equals("main"))
+            {
+                if (logger.isInfoEnabled())
+                    logger.info("Killing thread named [" + thread.getName() + "]"); // , removing its uncaught
+                // exception handler to
+                // avoid ThreadDeath
+                // exception tracing
+                // "+motivation );
+
+                ret++;
+
+                // PK leaving uncaught exception handler otherwise master push
+                // cannot recover from this error
+                // thread.setUncaughtExceptionHandler(null);
+                try
+                {
+                    thread.stop();
+                }
+                catch (ThreadDeath e)
+                {
+                    logger.warn("Thread already death.", e);
+                }
+
+            }
+        }
+        return ret;
+    }
+
+    public static String show(String title)
+    {
+        StringBuffer out = new StringBuffer();
+        Thread[] threadArray = ThreadExplorer.listThreads();
+
+        out.append(title + "\n");
+        for (int i = 0; i < threadArray.length; i++)
+        {
+            Thread thread = threadArray[i];
+
+            if (thread != null)
+            {
+                out.append("* [" + thread.getName() + "] " + (thread.isDaemon() ? "(Daemon)" : "")
+                        + " Group: " + thread.getThreadGroup().getName() + "\n");
+            }
+            else
+            {
+                out.append("* ThreadDeath: " + thread + "\n");
+            }
+
+        }
+        return out.toString();
+    }
+
+    public static int active()
+    {
+        int count = 0;
+        Thread[] threadArray = ThreadExplorer.listThreads();
+
+        for (int i = 0; i < threadArray.length; i++)
+        {
+            Thread thread = threadArray[i];
+            if (thread != null)
+            {
+                count++;
+            }
+        }
+
+        return count;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQBytesMessageTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQBytesMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQBytesMessageTest.java
new file mode 100644
index 0000000..0219815
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQBytesMessageTest.java
@@ -0,0 +1,488 @@
+/**
+ * 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.command;
+
+import javax.jms.JMSException;
+import javax.jms.MessageFormatException;
+import javax.jms.MessageNotReadableException;
+import javax.jms.MessageNotWriteableException;
+
+import junit.framework.TestCase;
+
+/**
+ * 
+ */
+public class ActiveMQBytesMessageTest extends TestCase {
+
+    public ActiveMQBytesMessageTest(String name) {
+        super(name);
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(ActiveMQBytesMessageTest.class);
+    }
+
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testGetDataStructureType() {
+        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
+        assertEquals(msg.getDataStructureType(), CommandTypes.ACTIVEMQ_BYTES_MESSAGE);
+    }
+
+    public void testGetBodyLength() {
+        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
+        int len = 10;
+        try {
+            for (int i = 0; i < len; i++) {
+                msg.writeLong(5L);
+            }
+        } catch (JMSException ex) {
+            ex.printStackTrace();
+        }
+        try {
+            msg.reset();
+            assertTrue(msg.getBodyLength() == (len * 8));
+        } catch (Throwable e) {
+            e.printStackTrace();
+            assertTrue(false);
+        }
+    }
+
+    public void testReadBoolean() {
+        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
+        try {
+            msg.writeBoolean(true);
+            msg.reset();
+            assertTrue(msg.readBoolean());
+        } catch (JMSException jmsEx) {
+            jmsEx.printStackTrace();
+            assertTrue(false);
+        }
+    }
+
+    public void testReadByte() {
+        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
+        try {
+            msg.writeByte((byte) 2);
+            msg.reset();
+            assertTrue(msg.readByte() == 2);
+        } catch (JMSException jmsEx) {
+            jmsEx.printStackTrace();
+            assertTrue(false);
+        }
+    }
+
+    public void testReadUnsignedByte() {
+        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
+        try {
+            msg.writeByte((byte) 2);
+            msg.reset();
+            assertTrue(msg.readUnsignedByte() == 2);
+        } catch (JMSException jmsEx) {
+            jmsEx.printStackTrace();
+            assertTrue(false);
+        }
+    }
+
+    public void testReadShort() {
+        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
+        try {
+            msg.writeShort((short) 3000);
+            msg.reset();
+            assertTrue(msg.readShort() == 3000);
+        } catch (JMSException jmsEx) {
+            jmsEx.printStackTrace();
+            assertTrue(false);
+        }
+    }
+
+    public void testReadUnsignedShort() {
+        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
+        try {
+            msg.writeShort((short) 3000);
+            msg.reset();
+            assertTrue(msg.readUnsignedShort() == 3000);
+        } catch (JMSException jmsEx) {
+            jmsEx.printStackTrace();
+            assertTrue(false);
+        }
+    }
+
+    public void testReadChar() {
+        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
+        try {
+            msg.writeChar('a');
+            msg.reset();
+            assertTrue(msg.readChar() == 'a');
+        } catch (JMSException jmsEx) {
+            jmsEx.printStackTrace();
+            assertTrue(false);
+        }
+    }
+
+    public void testReadInt() {
+        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
+        try {
+            msg.writeInt(3000);
+            msg.reset();
+            assertTrue(msg.readInt() == 3000);
+        } catch (JMSException jmsEx) {
+            jmsEx.printStackTrace();
+            assertTrue(false);
+        }
+    }
+
+    public void testReadLong() {
+        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
+        try {
+            msg.writeLong(3000);
+            msg.reset();
+            assertTrue(msg.readLong() == 3000);
+        } catch (JMSException jmsEx) {
+            jmsEx.printStackTrace();
+            assertTrue(false);
+        }
+    }
+
+    public void testReadFloat() {
+        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
+        try {
+            msg.writeFloat(3.3f);
+            msg.reset();
+            assertTrue(msg.readFloat() == 3.3f);
+        } catch (JMSException jmsEx) {
+            jmsEx.printStackTrace();
+            assertTrue(false);
+        }
+    }
+
+    public void testReadDouble() {
+        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
+        try {
+            msg.writeDouble(3.3d);
+            msg.reset();
+            assertTrue(msg.readDouble() == 3.3d);
+        } catch (JMSException jmsEx) {
+            jmsEx.printStackTrace();
+            assertTrue(false);
+        }
+    }
+
+    public void testReadUTF() {
+        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
+        try {
+            String str = "this is a test";
+            msg.writeUTF(str);
+            msg.reset();
+            assertTrue(msg.readUTF().equals(str));
+        } catch (JMSException jmsEx) {
+            jmsEx.printStackTrace();
+            assertTrue(false);
+        }
+    }
+
+    /*
+     * Class to test for int readBytes(byte[])
+     */
+    public void testReadBytesbyteArray() {
+        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
+        try {
+            byte[] data = new byte[50];
+            for (int i = 0; i < data.length; i++) {
+                data[i] = (byte) i;
+            }
+            msg.writeBytes(data);
+            msg.reset();
+            byte[] test = new byte[data.length];
+            msg.readBytes(test);
+            for (int i = 0; i < test.length; i++) {
+                assertTrue(test[i] == i);
+            }
+        } catch (JMSException jmsEx) {
+            jmsEx.printStackTrace();
+            assertTrue(false);
+        }
+    }
+
+    public void testWriteObject() throws JMSException {
+        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
+        try {
+            msg.writeObject("fred");
+            msg.writeObject(Boolean.TRUE);
+            msg.writeObject(Character.valueOf('q'));
+            msg.writeObject(Byte.valueOf((byte) 1));
+            msg.writeObject(Short.valueOf((short) 3));
+            msg.writeObject(Integer.valueOf(3));
+            msg.writeObject(Long.valueOf(300L));
+            msg.writeObject(new Float(3.3f));
+            msg.writeObject(new Double(3.3));
+            msg.writeObject(new byte[3]);
+        } catch (MessageFormatException mfe) {
+            fail("objectified primitives should be allowed");
+        }
+        try {
+            msg.writeObject(new Object());
+            fail("only objectified primitives are allowed");
+        } catch (MessageFormatException mfe) {
+        }
+    }
+
+
+    /* new */
+    public void testClearBody() throws JMSException {
+        ActiveMQBytesMessage bytesMessage = new ActiveMQBytesMessage();
+        try {
+            bytesMessage.writeInt(1);
+            bytesMessage.clearBody();
+            assertFalse(bytesMessage.isReadOnlyBody());
+            bytesMessage.writeInt(1);
+            bytesMessage.readInt();
+        } catch (MessageNotReadableException mnwe) {
+        } catch (MessageNotWriteableException mnwe) {
+            assertTrue(false);
+        }
+    }
+
+    public void testReset() throws JMSException {
+        ActiveMQBytesMessage message = new ActiveMQBytesMessage();
+        try {
+            message.writeDouble(24.5);
+            message.writeLong(311);
+        } catch (MessageNotWriteableException mnwe) {
+            fail("should be writeable");
+        }
+        message.reset();
+        try {
+            assertTrue(message.isReadOnlyBody());
+            assertEquals(message.readDouble(), 24.5, 0);
+            assertEquals(message.readLong(), 311);
+        } catch (MessageNotReadableException mnre) {
+            fail("should be readable");
+        }
+        try {
+            message.writeInt(33);
+            fail("should throw exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+    }
+
+    public void testReadOnlyBody() throws JMSException {
+        ActiveMQBytesMessage message = new ActiveMQBytesMessage();
+        try {
+            message.writeBoolean(true);
+            message.writeByte((byte) 1);
+            message.writeByte((byte) 1);
+            message.writeBytes(new byte[1]);
+            message.writeBytes(new byte[3], 0, 2);
+            message.writeChar('a');
+            message.writeDouble(1.5);
+            message.writeFloat((float) 1.5);
+            message.writeInt(1);
+            message.writeLong(1);
+            message.writeObject("stringobj");
+            message.writeShort((short) 1);
+            message.writeShort((short) 1);
+            message.writeUTF("utfstring");
+        } catch (MessageNotWriteableException mnwe) {
+            fail("Should be writeable");
+        }
+        message.reset();
+        try {
+            message.readBoolean();
+            message.readByte();
+            message.readUnsignedByte();
+            message.readBytes(new byte[1]);
+            message.readBytes(new byte[2], 2);
+            message.readChar();
+            message.readDouble();
+            message.readFloat();
+            message.readInt();
+            message.readLong();
+            message.readUTF();
+            message.readShort();
+            message.readUnsignedShort();
+            message.readUTF();
+        } catch (MessageNotReadableException mnwe) {
+            fail("Should be readable");
+        }
+        try {
+            message.writeBoolean(true);
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+        try {
+            message.writeByte((byte) 1);
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+        try {
+            message.writeBytes(new byte[1]);
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+        try {
+            message.writeBytes(new byte[3], 0, 2);
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+        try {
+            message.writeChar('a');
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+        try {
+            message.writeDouble(1.5);
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+        try {
+            message.writeFloat((float) 1.5);
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+        try {
+            message.writeInt(1);
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+        try {
+            message.writeLong(1);
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+        try {
+            message.writeObject("stringobj");
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+        try {
+            message.writeShort((short) 1);
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+        try {
+            message.writeUTF("utfstring");
+            fail("Should have thrown exception");
+        } catch (MessageNotWriteableException mnwe) {
+        }
+    }
+
+    public void testWriteOnlyBody() throws JMSException {
+        ActiveMQBytesMessage message = new ActiveMQBytesMessage();
+        message.clearBody();
+        try {
+            message.writeBoolean(true);
+            message.writeByte((byte) 1);
+            message.writeByte((byte) 1);
+            message.writeBytes(new byte[1]);
+            message.writeBytes(new byte[3], 0, 2);
+            message.writeChar('a');
+            message.writeDouble(1.5);
+            message.writeFloat((float) 1.5);
+            message.writeInt(1);
+            message.writeLong(1);
+            message.writeObject("stringobj");
+            message.writeShort((short) 1);
+            message.writeShort((short) 1);
+            message.writeUTF("utfstring");
+        } catch (MessageNotWriteableException mnwe) {
+            fail("Should be writeable");
+        }
+        try {
+            message.readBoolean();
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException mnwe) {
+        }
+        try {
+            message.readByte();
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+        try {
+            message.readUnsignedByte();
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+        try {
+            message.readBytes(new byte[1]);
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+        try {
+            message.readBytes(new byte[2], 2);
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+        try {
+            message.readChar();
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+        try {
+            message.readDouble();
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+        try {
+            message.readFloat();
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+        try {
+            message.readInt();
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+        try {
+            message.readLong();
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+        try {
+            message.readUTF();
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+        try {
+            message.readShort();
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+        try {
+            message.readUnsignedShort();
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+        try {
+            message.readUTF();
+            fail("Should have thrown exception");
+        } catch (MessageNotReadableException e) {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQDestinationTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQDestinationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQDestinationTest.java
new file mode 100644
index 0000000..844be34
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQDestinationTest.java
@@ -0,0 +1,145 @@
+/**
+ * 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.command;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.TemporaryQueue;
+import javax.jms.TemporaryTopic;
+import javax.jms.Topic;
+
+import junit.framework.Test;
+
+public class ActiveMQDestinationTest extends DataStructureTestSupport {
+
+    public ActiveMQDestination destination;
+
+    public void initCombosForTestDestinationMarshaling() {
+        addCombinationValues("destination", new Object[] {new ActiveMQQueue("TEST"),
+                                                          new ActiveMQTopic("TEST"),
+                                                          new ActiveMQTempQueue("TEST:1"),
+                                                          new ActiveMQTempTopic("TEST:1"),
+                                                          new ActiveMQTempQueue("TEST"),
+                                                          new ActiveMQTempTopic("TEST"),
+                                                          new ActiveMQQueue("TEST?option=value"),
+                                                          new ActiveMQTopic("TEST?option=value"),
+                                                          new ActiveMQTempQueue("TEST:1?option=value"),
+                                                          new ActiveMQTempTopic("TEST:1?option=value")});
+    }
+
+    public void testDestinationMarshaling() throws IOException {
+        assertBeanMarshalls(destination);
+    }
+
+    public void initCombosForTestDestinationOptions() {
+        addCombinationValues("destination", new Object[] {new ActiveMQQueue("TEST?k1=v1&k2=v2"),
+                                                          new ActiveMQTopic("TEST?k1=v1&k2=v2"),
+                                                          new ActiveMQTempQueue("TEST:1?k1=v1&k2=v2"),
+                                                          new ActiveMQTempTopic("TEST:1?k1=v1&k2=v2")});
+    }
+
+    public void testDestinationOptions() throws IOException {
+        Map options = destination.getOptions();
+        assertNotNull(options);
+        assertEquals("v1", options.get("k1"));
+        assertEquals("v2", options.get("k2"));
+    }
+
+    public void testSorting() throws Exception {
+        SortedSet<ActiveMQDestination> set = new TreeSet<ActiveMQDestination>();
+        ActiveMQDestination[] destinations = {new ActiveMQQueue("A"), new ActiveMQQueue("B"),
+                                              new ActiveMQTopic("A"), new ActiveMQTopic("B")};
+        List<ActiveMQDestination> expected = Arrays.asList(destinations);
+        set.addAll(expected);
+        List<ActiveMQDestination> actual = new ArrayList<ActiveMQDestination>(set);
+        assertEquals("Sorted order", expected, actual);
+    }
+
+    // https://issues.apache.org/activemq/browse/AMQ-2630
+    class CombyDest implements Queue, Topic, TemporaryQueue, TemporaryTopic {
+
+        private final String qName;
+        private final String topicName;
+
+        public CombyDest(String qName, String topicName) {
+            this.qName = qName;
+            this.topicName = topicName;
+        }
+        
+        public void delete() throws JMSException {
+        }
+
+        public String getTopicName() throws JMSException {
+            return topicName;
+        }
+
+        public String getQueueName() throws JMSException {
+            return qName;
+        }    
+    }
+    
+    public void testTransformPollymorphic() throws Exception {
+        ActiveMQQueue queue = new ActiveMQQueue("TEST");
+        assertEquals(ActiveMQDestination.transform(queue), queue);
+        assertTrue("is a q", ActiveMQDestination.transform(new CombyDest(null, "Topic")) instanceof ActiveMQTopic);
+        assertTrue("is a q", ActiveMQDestination.transform(new CombyDest("Q", null)) instanceof ActiveMQQueue);
+        try {
+            ActiveMQDestination.transform(new CombyDest(null, null));
+            fail("expect ex as cannot disambiguate");
+        } catch (JMSException expected) { 
+        } 
+        try {
+            ActiveMQDestination.transform(new CombyDest("Q", "T"));
+            fail("expect ex as cannot disambiguate");
+        } catch (JMSException expected) { 
+        }
+    }
+    
+    public static Test suite() {
+        return suite(ActiveMQDestinationTest.class);
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(suite());
+    }
+
+    public void testEmptyQueueName() {
+        try {
+            new ActiveMQQueue("");
+            fail("Should have thrown IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+
+        }
+    }
+
+    public void testEmptyTopicName() {
+        try {
+            new ActiveMQTopic("");
+            fail("Should have thrown IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+
+        }
+    }
+}


Mime
View raw message