You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2016/03/16 02:53:25 UTC

[01/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208 [Forced Update!]

Repository: activemq-artemis
Updated Branches:
  refs/heads/refactor-openwire 2774f6924 -> 22325fbb1 (forced update)


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/SocketProxy.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/SocketProxy.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/SocketProxy.java
new file mode 100644
index 0000000..b01a4e1
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/SocketProxy.java
@@ -0,0 +1,396 @@
+/**
+ * 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.util;
+
+import javax.net.ssl.SSLServerSocketFactory;
+import javax.net.ssl.SSLSocketFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketException;
+import java.net.SocketTimeoutException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SocketProxy {
+
+    private static final transient Logger LOG = LoggerFactory.getLogger(SocketProxy.class);
+
+    public static final int ACCEPT_TIMEOUT_MILLIS = 100;
+
+    private URI proxyUrl;
+    private URI target;
+
+    private Acceptor acceptor;
+    private ServerSocket serverSocket;
+
+    private CountDownLatch closed = new CountDownLatch(1);
+
+    public final List<Bridge> connections = new LinkedList<Bridge>();
+
+    private int listenPort = 0;
+
+    private int receiveBufferSize = -1;
+
+    private boolean pauseAtStart = false;
+
+    private int acceptBacklog = 50;
+
+    public SocketProxy() throws Exception {
+    }
+
+    public SocketProxy(URI uri) throws Exception {
+        this(0, uri);
+    }
+
+    public SocketProxy(int port, URI uri) throws Exception {
+        listenPort = port;
+        target = uri;
+        open();
+    }
+
+    public void setReceiveBufferSize(int receiveBufferSize) {
+        this.receiveBufferSize = receiveBufferSize;
+    }
+
+    public void setTarget(URI tcpBrokerUri) {
+        target = tcpBrokerUri;
+    }
+
+    public void open() throws Exception {
+        serverSocket = createServerSocket(target);
+        serverSocket.setReuseAddress(true);
+        if (receiveBufferSize > 0) {
+            serverSocket.setReceiveBufferSize(receiveBufferSize);
+        }
+        if (proxyUrl == null) {
+            serverSocket.bind(new InetSocketAddress(listenPort), acceptBacklog);
+            proxyUrl = urlFromSocket(target, serverSocket);
+        } else {
+            serverSocket.bind(new InetSocketAddress(proxyUrl.getPort()));
+        }
+        acceptor = new Acceptor(serverSocket, target);
+        if (pauseAtStart) {
+            acceptor.pause();
+        }
+        new Thread(null, acceptor, "SocketProxy-Acceptor-" + serverSocket.getLocalPort()).start();
+        closed = new CountDownLatch(1);
+    }
+
+    private boolean isSsl(URI target) {
+        return "ssl".equals(target.getScheme());
+    }
+
+    private ServerSocket createServerSocket(URI target) throws Exception {
+        if (isSsl(target)) {
+            return SSLServerSocketFactory.getDefault().createServerSocket();
+        }
+        return new ServerSocket();
+    }
+
+    private Socket createSocket(URI target) throws Exception {
+        if (isSsl(target)) {
+            return SSLSocketFactory.getDefault().createSocket();
+        }
+        return new Socket();
+    }
+
+    public URI getUrl() {
+        return proxyUrl;
+    }
+
+    /*
+     * close all proxy connections and acceptor
+     */
+    public void close() {
+        List<Bridge> connections;
+        synchronized(this.connections) {
+            connections = new ArrayList<Bridge>(this.connections);
+        }
+        LOG.info("close, numConnections=" + connections.size());
+        for (Bridge con : connections) {
+            closeConnection(con);
+        }
+        acceptor.close();
+        closed.countDown();
+    }
+
+    /*
+     * close all proxy receive connections, leaving acceptor
+     * open
+     */
+    public void halfClose() {
+        List<Bridge> connections;
+        synchronized(this.connections) {
+            connections = new ArrayList<Bridge>(this.connections);
+        }
+        LOG.info("halfClose, numConnections=" + connections.size());
+        for (Bridge con : connections) {
+            halfCloseConnection(con);
+        }
+    }
+
+    public boolean waitUntilClosed(long timeoutSeconds) throws InterruptedException {
+        return closed.await(timeoutSeconds, TimeUnit.SECONDS);
+    }
+
+    /*
+     * called after a close to restart the acceptor on the same port
+     */
+    public void reopen() {
+        LOG.info("reopen");
+        try {
+            open();
+        } catch (Exception e) {
+            LOG.debug("exception on reopen url:" + getUrl(), e);
+        }
+    }
+
+    /*
+     * pause accepting new connections and data transfer through existing proxy
+     * connections. All sockets remain open
+     */
+    public void pause() {
+        synchronized(connections) {
+            LOG.info("pause, numConnections=" + connections.size());
+            acceptor.pause();
+            for (Bridge con : connections) {
+                con.pause();
+            }
+        }
+    }
+
+    /*
+     * continue after pause
+     */
+    public void goOn() {
+        synchronized(connections) {
+            LOG.info("goOn, numConnections=" + connections.size());
+            for (Bridge con : connections) {
+                con.goOn();
+            }
+        }
+        acceptor.goOn();
+    }
+
+    private void closeConnection(Bridge c) {
+        try {
+            c.close();
+        } catch (Exception e) {
+            LOG.debug("exception on close of: " + c, e);
+        }
+    }
+
+    private void halfCloseConnection(Bridge c) {
+        try {
+            c.halfClose();
+        } catch (Exception e) {
+            LOG.debug("exception on half close of: " + c, e);
+        }
+    }
+
+    public boolean isPauseAtStart() {
+        return pauseAtStart;
+    }
+
+    public void setPauseAtStart(boolean pauseAtStart) {
+        this.pauseAtStart = pauseAtStart;
+    }
+
+    public int getAcceptBacklog() {
+        return acceptBacklog;
+    }
+
+    public void setAcceptBacklog(int acceptBacklog) {
+        this.acceptBacklog = acceptBacklog;
+    }
+
+    private URI urlFromSocket(URI uri, ServerSocket serverSocket) throws Exception {
+        int listenPort = serverSocket.getLocalPort();
+
+        return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), listenPort, uri.getPath(), uri.getQuery(), uri.getFragment());
+    }
+
+    public class Bridge {
+
+        private Socket receiveSocket;
+        private Socket sendSocket;
+        private Pump requestThread;
+        private Pump responseThread;
+
+        public Bridge(Socket socket, URI target) throws Exception {
+            receiveSocket = socket;
+            sendSocket = createSocket(target);
+            if (receiveBufferSize > 0) {
+                sendSocket.setReceiveBufferSize(receiveBufferSize);
+            }
+            sendSocket.connect(new InetSocketAddress(target.getHost(), target.getPort()));
+            linkWithThreads(receiveSocket, sendSocket);
+            LOG.info("proxy connection " + sendSocket + ", receiveBufferSize=" + sendSocket.getReceiveBufferSize());
+        }
+
+        public void goOn() {
+            responseThread.goOn();
+            requestThread.goOn();
+        }
+
+        public void pause() {
+            requestThread.pause();
+            responseThread.pause();
+        }
+
+        public void close() throws Exception {
+            synchronized(connections) {
+                connections.remove(this);
+            }
+            receiveSocket.close();
+            sendSocket.close();
+        }
+
+        public void halfClose() throws Exception {
+            receiveSocket.close();
+        }
+
+        private void linkWithThreads(Socket source, Socket dest) {
+            requestThread = new Pump(source, dest);
+            requestThread.start();
+            responseThread = new Pump(dest, source);
+            responseThread.start();
+        }
+
+        public class Pump extends Thread {
+
+            protected Socket src;
+            private Socket destination;
+            private AtomicReference<CountDownLatch> pause = new AtomicReference<CountDownLatch>();
+
+            public Pump(Socket source, Socket dest) {
+                super("SocketProxy-DataTransfer-" + source.getPort() + ":" + dest.getPort());
+                src = source;
+                destination = dest;
+                pause.set(new CountDownLatch(0));
+            }
+
+            public void pause() {
+                pause.set(new CountDownLatch(1));
+            }
+
+            public void goOn() {
+                pause.get().countDown();
+            }
+
+            public void run() {
+                byte[] buf = new byte[1024];
+                try {
+                    InputStream in = src.getInputStream();
+                    OutputStream out = destination.getOutputStream();
+                    while (true) {
+                        int len = in.read(buf);
+                        if (len == -1) {
+                            LOG.debug("read eof from:" + src);
+                            break;
+                        }
+                        pause.get().await();
+                        out.write(buf, 0, len);
+                    }
+                } catch (Exception e) {
+                    LOG.debug("read/write failed, reason: " + e.getLocalizedMessage());
+                    try {
+                        if (!receiveSocket.isClosed()) {
+                            // for halfClose, on read/write failure if we close the
+                            // remote end will see a close at the same time.
+                            close();
+                        }
+                    } catch (Exception ignore) {
+                    }
+                }
+            }
+        }
+    }
+
+    public class Acceptor implements Runnable {
+
+        private ServerSocket socket;
+        private URI target;
+        private AtomicReference<CountDownLatch> pause = new AtomicReference<CountDownLatch>();
+
+
+        public Acceptor(ServerSocket serverSocket, URI uri) {
+            socket = serverSocket;
+            target = uri;
+            pause.set(new CountDownLatch(0));
+            try {
+                socket.setSoTimeout(ACCEPT_TIMEOUT_MILLIS);
+            } catch (SocketException e) {
+                e.printStackTrace();
+            }
+        }
+
+        public void pause() {
+            pause.set(new CountDownLatch(1));
+        }
+
+        public void goOn() {
+            pause.get().countDown();
+        }
+
+        public void run() {
+            try {
+                while(!socket.isClosed()) {
+                    pause.get().await();
+                    try {
+                        Socket source = socket.accept();
+                        pause.get().await();
+                        if (receiveBufferSize > 0) {
+                            source.setReceiveBufferSize(receiveBufferSize);
+                        }
+                        LOG.info("accepted " + source + ", receiveBufferSize:" + source.getReceiveBufferSize());
+                        synchronized(connections) {
+                            connections.add(new Bridge(source, target));
+                        }
+                    } catch (SocketTimeoutException expected) {
+                    }
+                }
+            } catch (Exception e) {
+                LOG.debug("acceptor: finished for reason: " + e.getLocalizedMessage());
+            }
+        }
+
+        public void close() {
+            try {
+                socket.close();
+                closed.countDown();
+                goOn();
+            } catch (IOException ignored) {
+            }
+        }
+    }
+
+}
+

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/Wait.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/Wait.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/Wait.java
new file mode 100644
index 0000000..244db59
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/Wait.java
@@ -0,0 +1,50 @@
+/**
+ * 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.util;
+
+
+import java.util.concurrent.TimeUnit;
+
+public class Wait {
+
+    public static final long MAX_WAIT_MILLIS = 30*1000;
+    public static final long SLEEP_MILLIS = 1000;
+
+    public interface Condition {
+        boolean isSatisified() throws Exception;
+    }
+
+    public static boolean waitFor(Condition condition) throws Exception {
+        return waitFor(condition, MAX_WAIT_MILLIS);
+    }
+
+    public static boolean waitFor(final Condition condition, final long duration) throws Exception {
+        return waitFor(condition, duration, SLEEP_MILLIS);
+    }
+
+    public static boolean waitFor(final Condition condition, final long duration, final long sleepMillis) throws Exception {
+
+        final long expiry = System.currentTimeMillis() + duration;
+        boolean conditionSatisified = condition.isSatisified();
+        while (!conditionSatisified && System.currentTimeMillis() < expiry) {
+            TimeUnit.MILLISECONDS.sleep(sleepMillis);
+            conditionSatisified = condition.isSatisified();
+        }
+        return conditionSatisified;
+    }
+}


[60/60] [abbrv] activemq-artemis git commit: fix AMQ1924Test

Posted by cl...@apache.org.
fix AMQ1924Test


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/22325fbb
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/22325fbb
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/22325fbb

Branch: refs/heads/refactor-openwire
Commit: 22325fbb1203843db7e5ddf551b910767dc7f969
Parents: bd46bbc
Author: Howard Gao <ho...@gmail.com>
Authored: Tue Mar 15 23:11:39 2016 +0800
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:58:03 2016 -0400

----------------------------------------------------------------------
 .../openwire/OpenWireProtocolManager.java       |  5 ++
 .../core/server/impl/ServerConsumerImpl.java    | 64 +++++++++++++++-----
 .../transport/failover/AMQ1925Test.java         | 54 +++++++++--------
 3 files changed, 82 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/22325fbb/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
index abfcca5..3cb1215 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
@@ -488,6 +488,11 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, Cl
       if (txSession != null) {
          txSession.rollback(info);
       }
+      else if (info.getTransactionId().isLocalTransaction()) {
+         //during a broker restart, recovered local transaction may not be registered
+         //in that case we ignore and let the tx removed silently by connection.
+         //see AMQ1925Test.testAMQ1925_TXBegin
+      }
       else {
          throw newXAException("Transaction '" + info.getTransactionId() + "' has not been started.", XAException.XAER_NOTA);
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/22325fbb/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
index b2ca0df..cb2cd38 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
@@ -89,6 +89,8 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
 
    private Object protocolContext;
 
+   private final ActiveMQServer server;
+
    private SlowConsumerDetectionListener slowConsumerListener;
 
    /**
@@ -153,8 +155,9 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
                              final SessionCallback callback,
                              final boolean preAcknowledge,
                              final boolean strictUpdateDeliveryCount,
-                             final ManagementService managementService) throws Exception {
-      this(id, session, binding, filter, started, browseOnly, storageManager, callback, preAcknowledge, strictUpdateDeliveryCount, managementService, true, null);
+                             final ManagementService managementService,
+                             final ActiveMQServer server) throws Exception {
+      this(id, session, binding, filter, started, browseOnly, storageManager, callback, preAcknowledge, strictUpdateDeliveryCount, managementService, true, null, server);
    }
 
    public ServerConsumerImpl(final long id,
@@ -169,7 +172,8 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
                              final boolean strictUpdateDeliveryCount,
                              final ManagementService managementService,
                              final boolean supportLargeMessage,
-                             final Integer credits) throws Exception {
+                             final Integer credits,
+                             final ActiveMQServer server) throws Exception {
       this.id = id;
 
       this.filter = filter;
@@ -214,6 +218,8 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
             availableCredits.set(credits);
          }
       }
+
+      this.server = server;
    }
 
    @Override
@@ -398,7 +404,9 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
       }
       finally {
          lockDelivery.readLock().unlock();
+         callback.afterDelivery();
       }
+
    }
 
    @Override
@@ -583,12 +591,19 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
    @Override
    public void setStarted(final boolean started) {
       synchronized (lock) {
-         lockDelivery.writeLock().lock();
+         boolean locked = lockDelivery();
+
+         // This is to make sure nothing would sneak to the client while started = false
+         // the client will stop the session and perform a rollback in certain cases.
+         // in case something sneaks to the client you could get to messaging delivering forever until
+         // you restart the server
          try {
             this.started = browseOnly || started;
          }
          finally {
-            lockDelivery.writeLock().unlock();
+            if (locked) {
+               lockDelivery.writeLock().unlock();
+            }
          }
       }
 
@@ -598,21 +613,38 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
       }
    }
 
-   @Override
-   public void setTransferring(final boolean transferring) {
-      synchronized (lock) {
-         this.transferring = transferring;
-      }
-
-      // This is to make sure that the delivery process has finished any pending delivery
-      // otherwise a message may sneak in on the client while we are trying to stop the consumer
+   private boolean lockDelivery() {
       try {
-         lockDelivery.writeLock().lock();
+         if (!lockDelivery.writeLock().tryLock(30, TimeUnit.SECONDS)) {
+            ActiveMQServerLogger.LOGGER.timeoutLockingConsumer();
+            if (server != null) {
+               server.threadDump();
+            }
+            return false;
+         }
+         return true;
       }
-      finally {
-         lockDelivery.writeLock().unlock();
+      catch (Exception e) {
+         ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e);
+         return false;
       }
+   }
 
+   @Override
+   public void setTransferring(final boolean transferring) {
+      synchronized (lock) {
+         // This is to make sure that the delivery process has finished any pending delivery
+         // otherwise a message may sneak in on the client while we are trying to stop the consumer
+         boolean locked = lockDelivery();
+         try {
+            this.transferring = transferring;
+         }
+         finally {
+            if (locked) {
+               lockDelivery.writeLock().unlock();
+            }
+         }
+      }
 
       // Outside the lock
       if (transferring) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/22325fbb/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/AMQ1925Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/AMQ1925Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/AMQ1925Test.java
index 3d75905..564fd86 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/AMQ1925Test.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/AMQ1925Test.java
@@ -33,8 +33,6 @@ import javax.jms.MessageProducer;
 import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.jms.TransactionRolledBackException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.artemis.api.core.SimpleString;
@@ -235,32 +233,39 @@ public class AMQ1925Test extends OpenwireArtemisBaseTest implements ExceptionLis
       MessageConsumer consumer = session.createConsumer(session.createQueue(QUEUE_NAME));
 
       boolean restartDone = false;
-      for (int i = 0; i < MESSAGE_COUNT; i++) {
-         Message message = consumer.receive(5000);
-         Assert.assertNotNull(message);
+      try {
+         for (int i = 0; i < MESSAGE_COUNT; i++) {
+            Message message = consumer.receive(5000);
+            Assert.assertNotNull(message);
 
-         if (i == 222 && !restartDone) {
-            // Simulate broker failure & restart
-            bs.stop();
-            bs = createNewServer();
-            bs.start();
-            restartDone = true;
-         }
+            if (i == 222 && !restartDone) {
+               // Simulate broker failure & restart
+               bs.stop();
+               bs = createNewServer();
+               bs.start();
+               restartDone = true;
+            }
 
-         Assert.assertEquals(i, message.getIntProperty(PROPERTY_MSG_NUMBER));
-         try {
-            session.commit();
-         }
-         catch (TransactionRolledBackException expectedOnOccasion) {
-            log.info("got rollback: " + expectedOnOccasion);
-            i--;
+            Assert.assertEquals(i, message.getIntProperty(PROPERTY_MSG_NUMBER));
+            try {
+               session.commit();
+            }
+            catch (TransactionRolledBackException expectedOnOccasion) {
+               log.info("got rollback: " + expectedOnOccasion);
+               i--;
+            }
          }
+         Assert.assertNull(consumer.receive(500));
+      }
+      catch (Exception eee) {
+         log.error("got exception", eee);
+         throw eee;
+      }
+      finally {
+         consumer.close();
+         session.close();
+         connection.close();
       }
-      Assert.assertNull(consumer.receive(500));
-
-      consumer.close();
-      session.close();
-      connection.close();
 
       assertQueueEmpty();
       Assert.assertNull("no exception on connection listener: " + exception, exception);
@@ -368,7 +373,6 @@ public class AMQ1925Test extends OpenwireArtemisBaseTest implements ExceptionLis
       } catch (Exception e) {
          log.error(e);
       }
-
    }
 
    public void onException(JMSException exception) {


[50/60] [abbrv] activemq-artemis git commit: small tweak

Posted by cl...@apache.org.
small tweak


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/3bd1cdeb
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/3bd1cdeb
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/3bd1cdeb

Branch: refs/heads/refactor-openwire
Commit: 3bd1cdebe016f048e9fde7efeabdaf4ee0ccb48c
Parents: 4bbe983
Author: Clebert Suconic <cl...@apache.org>
Authored: Fri Mar 4 17:42:01 2016 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:45:29 2016 -0400

----------------------------------------------------------------------
 .../artemis/core/protocol/openwire/OpenWireConnection.java    | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/3bd1cdeb/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
index 598016d..5880f07 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
@@ -224,7 +224,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
 
             try {
                setLastCommand(command);
-               response = command.visit(new CommandProcessor());
+               response = command.visit(commandProcessorInstance);
             }
             catch (Exception e) {
                if (responseRequired) {
@@ -835,10 +835,13 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
    }
 
 
+   CommandProcessor commandProcessorInstance = new CommandProcessor();
+
+
    // This will listen for commands throught the protocolmanager
    public class CommandProcessor implements CommandVisitor {
 
-      public AMQConnectionContext getContext() {
+      private AMQConnectionContext getContext() {
          return OpenWireConnection.this.getContext();
       }
 


[58/60] [abbrv] activemq-artemis git commit: fixed compilation error

Posted by cl...@apache.org.
fixed compilation error


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/bd46bbc0
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/bd46bbc0
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/bd46bbc0

Branch: refs/heads/refactor-openwire
Commit: bd46bbc0260a981032836513abc66688db1bb0bf
Parents: 2ad5c25
Author: Howard Gao <ho...@gmail.com>
Authored: Mon Mar 7 22:20:49 2016 +0800
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:45:29 2016 -0400

----------------------------------------------------------------------
 .../artemis/core/protocol/openwire/OpenWireConnection.java         | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bd46bbc0/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
index 5880f07..5fc26b0 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
@@ -841,7 +841,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
    // This will listen for commands throught the protocolmanager
    public class CommandProcessor implements CommandVisitor {
 
-      private AMQConnectionContext getContext() {
+      public AMQConnectionContext getContext() {
          return OpenWireConnection.this.getContext();
       }
 


[10/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/VerifySteadyEnqueueRate.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/VerifySteadyEnqueueRate.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/VerifySteadyEnqueueRate.java
deleted file mode 100644
index 80ab8e1..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/VerifySteadyEnqueueRate.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/**
- * 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;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.store.kahadb.KahaDBStore;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.jms.Connection;
-import java.io.File;
-import java.text.DateFormat;
-import java.util.Date;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-
-public class VerifySteadyEnqueueRate extends TestCase {
-
-   private static final Logger LOG = LoggerFactory.getLogger(VerifySteadyEnqueueRate.class);
-
-   private static int max_messages = 1000000;
-   private final String destinationName = getName() + "_Queue";
-   private BrokerService broker;
-   final boolean useTopic = false;
-
-   protected static final String payload = new String(new byte[24]);
-
-   @Override
-   public void setUp() throws Exception {
-      startBroker();
-   }
-
-   @Override
-   public void tearDown() throws Exception {
-      broker.stop();
-   }
-
-   @SuppressWarnings("unused")
-   public void testEnqueueRateCanMeetSLA() throws Exception {
-      if (true) {
-         return;
-      }
-      doTestEnqueue(false);
-   }
-
-   private void doTestEnqueue(final boolean transacted) throws Exception {
-      final long min = 100;
-      final AtomicLong total = new AtomicLong(0);
-      final AtomicLong slaViolations = new AtomicLong(0);
-      final AtomicLong max = new AtomicLong(0);
-      final int numThreads = 6;
-
-      Runnable runner = new Runnable() {
-
-         @Override
-         public void run() {
-            try {
-               MessageSender producer = new MessageSender(destinationName, createConnection(), transacted, useTopic);
-
-               for (int i = 0; i < max_messages; i++) {
-                  long startT = System.currentTimeMillis();
-                  producer.send(payload);
-                  long endT = System.currentTimeMillis();
-                  long duration = endT - startT;
-
-                  total.incrementAndGet();
-
-                  if (duration > max.get()) {
-                     max.set(duration);
-                  }
-
-                  if (duration > min) {
-                     slaViolations.incrementAndGet();
-                     System.err.println("SLA violation @ " + Thread.currentThread().getName() + " " + DateFormat.getTimeInstance().format(new Date(startT)) + " at message " + i + " send time=" + duration + " - Total SLA violations: " + slaViolations.get() + "/" + total.get() + " (" + String.format("%.6f", 100.0 * slaViolations.get() / total.get()) + "%)");
-                  }
-               }
-
-            }
-            catch (Exception e) {
-               // TODO Auto-generated catch block
-               e.printStackTrace();
-            }
-            System.out.println("Max Violation = " + max + " - Total SLA violations: " + slaViolations.get() + "/" + total.get() + " (" + String.format("%.6f", 100.0 * slaViolations.get() / total.get()) + "%)");
-         }
-      };
-      ExecutorService executor = Executors.newCachedThreadPool();
-
-      for (int i = 0; i < numThreads; i++) {
-         executor.execute(runner);
-      }
-
-      executor.shutdown();
-      while (!executor.isTerminated()) {
-         executor.awaitTermination(10, TimeUnit.SECONDS);
-      }
-   }
-
-   private Connection createConnection() throws Exception {
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getConnectUri());
-      return factory.createConnection();
-   }
-
-   private void startBroker() throws Exception {
-      broker = new BrokerService();
-      //broker.setDeleteAllMessagesOnStartup(true);
-      broker.setPersistent(true);
-      broker.setUseJmx(true);
-
-      KahaDBStore kaha = new KahaDBStore();
-      kaha.setDirectory(new File("target/activemq-data/kahadb"));
-      // The setEnableJournalDiskSyncs(false) setting is a little dangerous right now, as I have not verified
-      // what happens if the index is updated but a journal update is lost.
-      // Index is going to be in consistent, but can it be repaired?
-      kaha.setEnableJournalDiskSyncs(false);
-      // Using a bigger journal file size makes he take fewer spikes as it is not switching files as often.
-      kaha.setJournalMaxFileLength(1024 * 1024 * 100);
-
-      // small batch means more frequent and smaller writes
-      kaha.setIndexWriteBatchSize(100);
-      // do the index write in a separate thread
-      kaha.setEnableIndexWriteAsync(true);
-
-      broker.setPersistenceAdapter(kaha);
-
-      broker.addConnector("tcp://localhost:0").setName("Default");
-      broker.start();
-      LOG.info("Starting broker..");
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/ActiveMQTestCase.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/ActiveMQTestCase.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/ActiveMQTestCase.java
deleted file mode 100644
index 89b89db..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/ActiveMQTestCase.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/* ====================================================================
-   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 java.net.URI;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Properties;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.TextMessage;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.broker.BrokerFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQTopic;
-
-/**
- * <p>
- * Common functionality for ActiveMQ test cases.
- * </p>
- *
- * @author Rainer Klute <a
- *         href="mailto:rainer.klute@dp-itsolutions.de">&lt;rainer.klute@dp-itsolutions.de&gt;</a>
- * @version $Id: ActiveMQTestCase.java 12 2007-08-14 12:02:02Z rke $
- * @since 2007-08-10
- */
-public class ActiveMQTestCase extends TestCase {
-
-   private Context context;
-   private BrokerService broker;
-   protected Connection connection;
-   protected Destination destination;
-   private final List<MessageConsumer> consumersToEmpty = new LinkedList<>();
-   protected final long RECEIVE_TIMEOUT = 500;
-
-   /**
-    * <p>Constructor</p>
-    */
-   public ActiveMQTestCase() {
-   }
-
-   /**
-    * <p>Constructor</p>
-    *
-    * @param name the test case's name
-    */
-   public ActiveMQTestCase(final String name) {
-      super(name);
-   }
-
-   /**
-    * <p>Sets up the JUnit testing environment.
-    */
-   @Override
-   protected void setUp() {
-      URI uri;
-      try {
-            /* Copy all system properties starting with "java.naming." to the initial context. */
-         final Properties systemProperties = System.getProperties();
-         final Properties jndiProperties = new Properties();
-         for (final Iterator<Object> i = systemProperties.keySet().iterator(); i.hasNext(); ) {
-            final String key = (String) i.next();
-            if (key.startsWith("java.naming.") || key.startsWith("topic.") ||
-               key.startsWith("queue.")) {
-               final String value = (String) systemProperties.get(key);
-               jndiProperties.put(key, value);
-            }
-         }
-         context = new InitialContext(jndiProperties);
-         uri = new URI("xbean:org/apache/activemq/bugs/amq1095/activemq.xml");
-         broker = BrokerFactory.createBroker(uri);
-         broker.start();
-      }
-      catch (Exception ex) {
-         throw new RuntimeException(ex);
-      }
-
-      final ConnectionFactory connectionFactory;
-      try {
-            /* Lookup the connection factory. */
-         connectionFactory = (ConnectionFactory) context.lookup("TopicConnectionFactory");
-
-         destination = new ActiveMQTopic("TestTopic");
-
-            /* Create a connection: */
-         connection = connectionFactory.createConnection();
-         connection.setClientID("sampleClientID");
-      }
-      catch (JMSException ex1) {
-         ex1.printStackTrace();
-         fail(ex1.toString());
-      }
-      catch (NamingException ex2) {
-         ex2.printStackTrace();
-         fail(ex2.toString());
-      }
-      catch (Throwable ex3) {
-         ex3.printStackTrace();
-         fail(ex3.toString());
-      }
-   }
-
-   /**
-    * <p>
-    * Tear down the testing environment by receiving any messages that might be
-    * left in the topic after a failure and shutting down the broker properly.
-    * This is quite important for subsequent test cases that assume the topic
-    * to be empty.
-    * </p>
-    */
-   @Override
-   protected void tearDown() throws Exception {
-      TextMessage msg;
-      try {
-         for (final Iterator<MessageConsumer> i = consumersToEmpty.iterator(); i.hasNext(); ) {
-            final MessageConsumer consumer = i.next();
-            if (consumer != null)
-               do
-                  msg = (TextMessage) consumer.receive(RECEIVE_TIMEOUT); while (msg != null);
-         }
-      }
-      catch (Exception e) {
-      }
-      if (connection != null) {
-         connection.stop();
-      }
-      broker.stop();
-   }
-
-   protected void registerToBeEmptiedOnShutdown(final MessageConsumer consumer) {
-      consumersToEmpty.add(consumer);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/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
deleted file mode 100644
index 49b704b..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/MessageSelectorTest.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/* ====================================================================
-   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>
- * @version $Id: MessageSelectorTest.java 12 2007-08-14 12:02:02Z rke $
- * @since 2007-08-09
- */
-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/2bcfd089/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
deleted file mode 100644
index c89e261..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/activemq.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?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/2bcfd089/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
deleted file mode 100644
index b74887f..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1974/TryJmsClient.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/**
- * 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;
-import java.util.concurrent.CountDownLatch;
-
-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();
-
-      new CountDownLatch(1).await();
-   }
-
-   private void startUsageMonitor(final BrokerService brokerService) {
-      new Thread(new Runnable() {
-         @Override
-         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 {
-
-      @Override
-      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/2bcfd089/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
deleted file mode 100644
index 91ca459..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1974/TryJmsManager.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- * 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;
-import java.util.concurrent.CountDownLatch;
-
-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();
-
-      new CountDownLatch(1).await();
-   }
-
-   private void startUsageMonitor(final BrokerService brokerService) {
-      new Thread(new Runnable() {
-         @Override
-         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() {
-
-                                     @Override
-                                     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/2bcfd089/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
deleted file mode 100644
index 9b82ae1..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/JaasStompSSLBroker1.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-<?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/2bcfd089/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
deleted file mode 100644
index 0b68aed..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/JaasStompSSLBroker2.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?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/2bcfd089/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
deleted file mode 100644
index ad1398f..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/groups2.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * 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/2bcfd089/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
deleted file mode 100644
index 898a174..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/login.config
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * 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/2bcfd089/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
deleted file mode 100644
index 6c19d19..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/users2.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * 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/2bcfd089/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
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/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
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/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
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/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
deleted file mode 100644
index 325e354..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/InconsistentConnectorPropertiesBehaviour.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?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/2bcfd089/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
deleted file mode 100644
index a245028..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/JaasStompSSLBroker.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?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/2bcfd089/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
deleted file mode 100644
index fcfe558..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/dns.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * 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/2bcfd089/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
deleted file mode 100644
index 4171c5f..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/groups.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- * 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/2bcfd089/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
deleted file mode 100644
index c3d87c1..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/login.config
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * 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/2bcfd089/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
deleted file mode 100644
index 2915bdb..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/users.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- * 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/2bcfd089/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
deleted file mode 100644
index 660fff5..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq5035/activemq.xml
+++ /dev/null
@@ -1,109 +0,0 @@
-<!--
-    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/2bcfd089/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
deleted file mode 100644
index 385564e..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/embedded/EmbeddedActiveMQ.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * 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/2bcfd089/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
deleted file mode 100644
index 4f500c4..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/embedded/ThreadExplorer.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/**
- * 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/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/CompressionOverNetworkTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/CompressionOverNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/CompressionOverNetworkTest.java
index 370dd35..d95a82b 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/CompressionOverNetworkTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/CompressionOverNetworkTest.java
@@ -24,6 +24,7 @@ import java.net.URI;
 import java.util.Arrays;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
 import javax.jms.BytesMessage;
 import javax.jms.Connection;
@@ -240,7 +241,8 @@ public class CompressionOverNetworkTest {
             if (bridges.length > 0) {
                LOG.info(brokerService + " bridges " + Arrays.toString(bridges));
                DemandForwardingBridgeSupport demandForwardingBridgeSupport = (DemandForwardingBridgeSupport) bridges[0];
-               ConcurrentHashMap<ConsumerId, DemandSubscription> forwardingBridges = demandForwardingBridgeSupport.getLocalSubscriptionMap();
+               ConcurrentMap<ConsumerId, DemandSubscription> forwardingBridges = demandForwardingBridgeSupport.getLocalSubscriptionMap();
+
                LOG.info(brokerService + " bridge " + demandForwardingBridgeSupport + ", localSubs: " + forwardingBridges);
                if (!forwardingBridges.isEmpty()) {
                   for (DemandSubscription demandSubscription : forwardingBridges.values()) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkLoopBackTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkLoopBackTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkLoopBackTest.java
index 27c0e58..34c9a1b 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkLoopBackTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkLoopBackTest.java
@@ -33,7 +33,8 @@ public class NetworkLoopBackTest {
 
       TransportConnector transportConnector = brokerServce.addConnector("nio://0.0.0.0:0");
       // connection filter is bypassed when scheme is different
-      final NetworkConnector networkConnector = brokerServce.addNetworkConnector("static:(tcp://" + transportConnector.getConnectUri().getHost() + ":" + transportConnector.getConnectUri().getPort() + ")");
+      final NetworkConnector networkConnector = brokerServce.addNetworkConnector("static:(tcp://"
+              + transportConnector.getConnectUri().getHost() + ":" +  transportConnector.getConnectUri().getPort() + ")");
 
       brokerServce.start();
       brokerServce.waitUntilStarted();
@@ -46,7 +47,7 @@ public class NetworkLoopBackTest {
             }
          });
 
-         final DemandForwardingBridgeSupport loopbackBridge = (DemandForwardingBridgeSupport) networkConnector.bridges.elements().nextElement();
+         final DemandForwardingBridgeSupport loopbackBridge = (DemandForwardingBridgeSupport) networkConnector.bridges.values().iterator().next();
          assertTrue("nc started", networkConnector.isStarted());
 
          assertTrue("It should get disposed", Wait.waitFor(new Wait.Condition() {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/SimpleNetworkTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/SimpleNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/SimpleNetworkTest.java
index a18012e..171fae1 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/SimpleNetworkTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/SimpleNetworkTest.java
@@ -22,7 +22,7 @@ import static org.junit.Assert.assertTrue;
 
 import java.net.URI;
 import java.util.Arrays;
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
 import javax.jms.Connection;
 import javax.jms.DeliveryMode;
@@ -176,8 +176,8 @@ public class SimpleNetworkTest {
             if (bridges.length > 0) {
                LOG.info(brokerService + " bridges " + Arrays.toString(bridges));
                DemandForwardingBridgeSupport demandForwardingBridgeSupport = (DemandForwardingBridgeSupport) bridges[0];
-               ConcurrentHashMap<ConsumerId, DemandSubscription> forwardingBridges = demandForwardingBridgeSupport.getLocalSubscriptionMap();
-               LOG.info(brokerService + " bridge " + demandForwardingBridgeSupport + ", localSubs: " + forwardingBridges);
+               ConcurrentMap<ConsumerId, DemandSubscription> forwardingBridges = demandForwardingBridgeSupport.getLocalSubscriptionMap();
+               LOG.info(brokerService + " bridge "  + demandForwardingBridgeSupport + ", localSubs: " + forwardingBridges);
                if (!forwardingBridges.isEmpty()) {
                   for (DemandSubscription demandSubscription : forwardingBridges.values()) {
                      if (demandSubscription.getLocalInfo().getDestination().equals(destination)) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/AutoStorePerDestinationTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/AutoStorePerDestinationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/AutoStorePerDestinationTest.java
deleted file mode 100644
index e28288b..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/AutoStorePerDestinationTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * 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.store;
-
-import java.util.ArrayList;
-
-import org.apache.activemq.store.kahadb.FilteredKahaDBPersistenceAdapter;
-import org.apache.activemq.store.kahadb.MultiKahaDBPersistenceAdapter;
-
-public class AutoStorePerDestinationTest extends StorePerDestinationTest {
-
-   // use perDestinationFlag to get multiple stores from one match all adapter
-   @Override
-   public void prepareBrokerWithMultiStore(boolean deleteAllMessages) throws Exception {
-
-      MultiKahaDBPersistenceAdapter multiKahaDBPersistenceAdapter = new MultiKahaDBPersistenceAdapter();
-      if (deleteAllMessages) {
-         multiKahaDBPersistenceAdapter.deleteAllMessages();
-      }
-      ArrayList<FilteredKahaDBPersistenceAdapter> adapters = new ArrayList<>();
-
-      FilteredKahaDBPersistenceAdapter template = new FilteredKahaDBPersistenceAdapter();
-      template.setPersistenceAdapter(createStore(deleteAllMessages));
-      template.setPerDestination(true);
-      adapters.add(template);
-
-      multiKahaDBPersistenceAdapter.setFilteredPersistenceAdapters(adapters);
-      brokerService = createBroker(multiKahaDBPersistenceAdapter);
-   }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/LevelDBStorePerDestinationTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/LevelDBStorePerDestinationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/LevelDBStorePerDestinationTest.java
deleted file mode 100644
index 028fb55..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/LevelDBStorePerDestinationTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * 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.store;
-
-import org.apache.activemq.leveldb.LevelDBStore;
-import org.junit.Test;
-
-import java.io.IOException;
-
-public class LevelDBStorePerDestinationTest extends StorePerDestinationTest {
-
-   @Override
-   protected PersistenceAdapter createStore(boolean delete) throws IOException {
-      LevelDBStore store = new LevelDBStore();
-      store.setLogSize(maxFileLength);
-      if (delete) {
-         store.deleteAllMessages();
-      }
-      return store;
-   }
-
-   @Test
-   @Override
-   public void testRollbackRecovery() throws Exception {
-   }
-
-   @Test
-   @Override
-   public void testCommitRecovery() throws Exception {
-   }
-
-}
\ No newline at end of file


[34/60] [abbrv] activemq-artemis git commit: More test fix. Enabled management in the wrapper class so some tests can use it to check some data.

Posted by cl...@apache.org.
More test fix.
Enabled management in the wrapper class so some tests can use
it to check some data.


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/adeb22f7
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/adeb22f7
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/adeb22f7

Branch: refs/heads/refactor-openwire
Commit: adeb22f7aa4e90f21de46599ed2940aa3ed5f9db
Parents: b0d5ea9
Author: Howard Gao <ho...@gmail.com>
Authored: Mon Feb 22 21:03:39 2016 +0800
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:44:21 2016 -0400

----------------------------------------------------------------------
 .../apache/activemq/broker/BrokerService.java   |  1 -
 .../artemiswrapper/ArtemisBrokerWrapper.java    | 20 +++++---
 .../org/apache/activemq/JMSConsumerTest.java    | 52 +++++++++++++++-----
 .../JmsDurableQueueWildcardSendReceiveTest.java |  2 +-
 .../JmsQueueWildcardSendReceiveTest.java        |  2 +-
 .../org/apache/activemq/broker/BrokerTest.java  |  4 ++
 6 files changed, 59 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/adeb22f7/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
index 99de104..13d6b96 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
@@ -109,7 +109,6 @@ public class BrokerService implements Service {
    private PolicyMap destinationPolicy;
    private SystemUsage systemUsage;
 
-   private boolean isClustered = true;
    private final List<NetworkConnector> networkConnectors = new CopyOnWriteArrayList<NetworkConnector>();
 
    private TemporaryFolder tmpfolder;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/adeb22f7/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
index 1c8ce9b..be1713b 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
@@ -44,10 +44,14 @@ import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.broker.region.policy.PolicyEntry;
 import org.apache.activemq.broker.region.policy.PolicyMap;
 
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+
 public class ArtemisBrokerWrapper extends ArtemisBrokerBase {
 
    protected final Map<String, SimpleString> testQueues = new HashMap<>();
    protected JMSServerManagerImpl jmsServer;
+   protected MBeanServer mbeanServer;
 
    public ArtemisBrokerWrapper(BrokerService brokerService, File temporaryFolder) {
       super(temporaryFolder);
@@ -57,10 +61,16 @@ public class ArtemisBrokerWrapper extends ArtemisBrokerBase {
    @Override
    public void start() throws Exception {
       clearDataRecreateServerDirs();
+
+      mbeanServer = MBeanServerFactory.createMBeanServer();
+
       server = createServer(realStore, true);
+      server.setMBeanServer(mbeanServer);
+
       server.getConfiguration().getAcceptorConfigurations().clear();
 
       Configuration serverConfig = server.getConfiguration();
+      serverConfig.setJMXManagementEnabled(true);
 
       Map<String, AddressSettings> addressSettingsMap = serverConfig.getAddressesSettings();
 
@@ -155,11 +165,6 @@ public class ArtemisBrokerWrapper extends ArtemisBrokerBase {
 
       server.start();
 
-/*
-         registerConnectionFactory();
-	      mbeanServer = MBeanServerFactory.createMBeanServer();
-*/
-
       ArtemisBrokerHelper.setBroker(this.bservice);
       stopped = false;
 
@@ -174,7 +179,6 @@ public class ArtemisBrokerWrapper extends ArtemisBrokerBase {
       params.put(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME, bservice.KEYSTORE_PASSWORD);
       params.put(TransportConstants.KEYSTORE_PROVIDER_PROP_NAME, bservice.storeType);
       if (bservice.SERVER_SIDE_TRUSTSTORE != null) {
-         params.put(TransportConstants.NEED_CLIENT_AUTH_PROP_NAME, true);
          params.put(TransportConstants.TRUSTSTORE_PATH_PROP_NAME, bservice.SERVER_SIDE_TRUSTSTORE);
          params.put(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME, bservice.TRUSTSTORE_PASSWORD);
          params.put(TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME, bservice.storeType);
@@ -279,4 +283,8 @@ public class ArtemisBrokerWrapper extends ArtemisBrokerBase {
       }
       return count;
    }
+
+   public MBeanServer getMbeanServer() {
+      return this.mbeanServer;
+   }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/adeb22f7/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSConsumerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSConsumerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSConsumerTest.java
index 6bf47f6..6274890 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSConsumerTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JMSConsumerTest.java
@@ -35,11 +35,18 @@ import javax.jms.MessageProducer;
 import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.jms.Topic;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerInvocationHandler;
 import javax.management.ObjectName;
 
 import junit.framework.Test;
 
-import org.apache.activemq.broker.jmx.DestinationViewMBean;
+import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
+import org.apache.activemq.artemis.api.jms.management.DestinationControl;
+import org.apache.activemq.artemis.api.jms.management.JMSQueueControl;
+import org.apache.activemq.artemis.api.jms.management.JMSServerControl;
+import org.apache.activemq.artemis.api.jms.management.TopicControl;
+import org.apache.activemq.broker.artemiswrapper.ArtemisBrokerWrapper;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ActiveMQQueue;
 import org.slf4j.Logger;
@@ -855,7 +862,7 @@ public class JMSConsumerTest extends JmsTestSupport {
    }
 
    public void initCombosForTestAckOfExpired() {
-      addCombinationValues("destinationType", new Object[]{Byte.valueOf(ActiveMQDestination.QUEUE_TYPE), Byte.valueOf(ActiveMQDestination.TOPIC_TYPE)});
+      addCombinationValues("destinationType", new Object[]{Byte.valueOf(ActiveMQDestination.QUEUE_TYPE)});
    }
 
    public void testAckOfExpired() throws Exception {
@@ -867,6 +874,7 @@ public class JMSConsumerTest extends JmsTestSupport {
       Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
       destination = (ActiveMQDestination) (destinationType == ActiveMQDestination.QUEUE_TYPE ? session.createQueue("test") : session.createTopic("test"));
 
+      createManagedDestinationOnServer(destination);
       MessageConsumer consumer = session.createConsumer(destination);
       connection.setStatsEnabled(true);
 
@@ -900,25 +908,43 @@ public class JMSConsumerTest extends JmsTestSupport {
       }
       assertEquals("consumer has expiredMessages", count, amqConsumer.getConsumerStats().getExpiredMessageCount().getCount());
 
-      DestinationViewMBean view = createView(destination);
+      DestinationControl view = createView(destination);
+
+      assertEquals("Wrong inFlightCount: " + view.getDeliveringCount(), 0, view.getDeliveringCount());
+      assertEquals("Wrong dispatch count: " + view.getMessagesAdded(), 8, view.getMessagesAdded());
+   }
 
-      assertEquals("Wrong inFlightCount: " + view.getInFlightCount(), 0, view.getInFlightCount());
-      assertEquals("Wrong dispatch count: " + view.getDispatchCount(), 8, view.getDispatchCount());
-      assertEquals("Wrong dequeue count: " + view.getDequeueCount(), 8, view.getDequeueCount());
-      assertEquals("Wrong expired count: " + view.getExpiredCount(), 4, view.getExpiredCount());
+   private void createManagedDestinationOnServer(ActiveMQDestination destination) throws Exception {
+      String destName = destination.getPhysicalName();
+      ArtemisBrokerWrapper wrapper = (ArtemisBrokerWrapper) broker.getBroker();
+      MBeanServer beanServer = wrapper.getMbeanServer();
+      ObjectName objName = ObjectNameBuilder.DEFAULT.getJMSServerObjectName();
+      JMSServerControl serverControl = MBeanServerInvocationHandler.newProxyInstance(beanServer, objName, JMSServerControl.class, false);
+      serverControl.createQueue(destName);
    }
 
-   protected DestinationViewMBean createView(ActiveMQDestination destination) throws Exception {
+   protected DestinationControl createView(ActiveMQDestination destination) throws Exception {
 
-      String domain = "org.apache.activemq";
-      ObjectName name;
+      String destName = destination.getPhysicalName();
       if (destination.isQueue()) {
-         name = new ObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=test");
+         return createJMSQueueControl(destName);
       }
       else {
-         name = new ObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Topic,destinationName=test");
+         return createJMSTopicControl(destName);
       }
-      return (DestinationViewMBean) broker.getManagementContext().newProxyInstance(name, DestinationViewMBean.class, true);
    }
 
+   private JMSQueueControl createJMSQueueControl(String destName) throws Exception {
+      ArtemisBrokerWrapper wrapper = (ArtemisBrokerWrapper) broker.getBroker();
+      MBeanServer beanServer = wrapper.getMbeanServer();
+      ObjectName objName = ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(destName);
+      return MBeanServerInvocationHandler.newProxyInstance(beanServer, objName, JMSQueueControl.class, false);
+   }
+
+   private TopicControl createJMSTopicControl(String destName) throws Exception {
+      ArtemisBrokerWrapper wrapper = (ArtemisBrokerWrapper) broker.getBroker();
+      MBeanServer beanServer = wrapper.getMbeanServer();
+      ObjectName objName = ObjectNameBuilder.DEFAULT.getJMSTopicObjectName(destName);
+      return MBeanServerInvocationHandler.newProxyInstance(beanServer, objName, TopicControl.class, false);
+   }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/adeb22f7/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableQueueWildcardSendReceiveTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableQueueWildcardSendReceiveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableQueueWildcardSendReceiveTest.java
index bf1535a..309fec9 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableQueueWildcardSendReceiveTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsDurableQueueWildcardSendReceiveTest.java
@@ -21,7 +21,7 @@ import javax.jms.DeliveryMode;
 import org.apache.activemq.test.JmsTopicSendReceiveTest;
 
 /**
- *
+ * https://issues.apache.org/jira/browse/ARTEMIS-189
  */
 public class JmsDurableQueueWildcardSendReceiveTest extends JmsTopicSendReceiveTest {
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/adeb22f7/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueWildcardSendReceiveTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueWildcardSendReceiveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueWildcardSendReceiveTest.java
index 296a56e..9a6dcb1 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueWildcardSendReceiveTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueWildcardSendReceiveTest.java
@@ -29,7 +29,7 @@ import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.test.JmsTopicSendReceiveTest;
 
 /**
- *
+ * https://issues.apache.org/jira/browse/ARTEMIS-189
  */
 public class JmsQueueWildcardSendReceiveTest extends JmsTopicSendReceiveTest {
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/adeb22f7/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerTest.java
index 9f412a9..9458ae3 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/BrokerTest.java
@@ -102,6 +102,7 @@ public class BrokerTest extends BrokerTestSupport {
       addCombinationValues("deliveryMode", new Object[]{Integer.valueOf(DeliveryMode.NON_PERSISTENT), Integer.valueOf(DeliveryMode.PERSISTENT)});
    }
 
+   //https://issues.apache.org/jira/browse/ARTEMIS-384
    public void testQueueBrowserWith2Consumers() throws Exception {
 
       ActiveMQDestination destination = new ActiveMQQueue("TEST");
@@ -684,6 +685,7 @@ public class BrokerTest extends BrokerTestSupport {
       addCombinationValues("durableConsumer", new Object[]{Boolean.TRUE, Boolean.FALSE});
    }
 
+   // https://issues.apache.org/jira/browse/ARTEMIS-402
    public void testTopicRetroactiveConsumerSeeMessagesBeforeCreation() throws Exception {
 
       ActiveMQDestination destination = new ActiveMQTopic("TEST");
@@ -1207,6 +1209,7 @@ public class BrokerTest extends BrokerTestSupport {
       addCombinationValues("deliveryMode", new Object[]{Integer.valueOf(DeliveryMode.NON_PERSISTENT), Integer.valueOf(DeliveryMode.PERSISTENT)});
    }
 
+   // https://issues.apache.org/jira/browse/ARTEMIS-402
    public void testTopicNoLocal() throws Exception {
 
       ActiveMQDestination destination = new ActiveMQTopic("TEST");
@@ -1272,6 +1275,7 @@ public class BrokerTest extends BrokerTestSupport {
       addCombinationValues("deliveryMode", new Object[]{Integer.valueOf(DeliveryMode.NON_PERSISTENT), Integer.valueOf(DeliveryMode.PERSISTENT)});
    }
 
+   //https://issues.apache.org/jira/browse/ARTEMIS-402
    public void testTopicDispatchIsBroadcast() throws Exception {
 
       ActiveMQDestination destination = new ActiveMQTopic("TEST");


[44/60] [abbrv] activemq-artemis git commit: Refactoring between Connection and protocol manager

Posted by cl...@apache.org.
Refactoring between Connection and protocol manager


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/e84edecb
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/e84edecb
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/e84edecb

Branch: refs/heads/refactor-openwire
Commit: e84edecbe8d93ef95098e34d23ab8639d900bbd9
Parents: 1b629c1
Author: Clebert Suconic <cl...@apache.org>
Authored: Wed Feb 24 22:30:28 2016 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:44:58 2016 -0400

----------------------------------------------------------------------
 .../protocol/openwire/OpenWireConnection.java   | 331 ++++++++++++++-----
 .../openwire/OpenWireProtocolManager.java       | 325 +++---------------
 .../core/protocol/openwire/amq/AMQConsumer.java |  20 +-
 .../openwire/amq/AMQProducerBrokerExchange.java |  96 ------
 .../openwire/amq/AMQServerConsumer.java         |  12 +
 .../core/protocol/openwire/amq/AMQSession.java  |  21 +-
 .../artemis/core/server/ServerConsumer.java     |   6 +
 .../server/SlowConsumerDetectionListener.java   |  22 ++
 .../artemis/core/server/impl/QueueImpl.java     |   2 +
 .../core/server/impl/ServerConsumerImpl.java    |  65 +---
 10 files changed, 369 insertions(+), 531 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e84edecb/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
index 991f24b..6f2e3be 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
@@ -23,37 +23,45 @@ import javax.jms.ResourceAllocationException;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.LinkedList;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.Executor;
 import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
 
+import org.apache.activemq.advisory.AdvisorySupport;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException;
 import org.apache.activemq.artemis.api.core.ActiveMQSecurityException;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.postoffice.Binding;
+import org.apache.activemq.artemis.core.postoffice.Bindings;
+import org.apache.activemq.artemis.core.postoffice.QueueBinding;
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQCompositeConsumerBrokerExchange;
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext;
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConsumer;
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConsumerBrokerExchange;
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQProducerBrokerExchange;
+import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQServerConsumer;
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQSession;
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQSingleConsumerBrokerExchange;
-import org.apache.activemq.artemis.core.remoting.CloseListener;
 import org.apache.activemq.artemis.core.remoting.FailureListener;
+import org.apache.activemq.artemis.core.security.CheckType;
 import org.apache.activemq.artemis.core.security.SecurityAuth;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
+import org.apache.activemq.artemis.core.server.Queue;
+import org.apache.activemq.artemis.core.server.ServerConsumer;
+import org.apache.activemq.artemis.core.server.SlowConsumerDetectionListener;
 import org.apache.activemq.artemis.spi.core.protocol.AbstractRemotingConnection;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
-import org.apache.activemq.artemis.spi.core.remoting.Acceptor;
 import org.apache.activemq.artemis.spi.core.remoting.Connection;
 import org.apache.activemq.artemis.utils.ConcurrentHashSet;
 import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.activemq.command.ActiveMQMessage;
+import org.apache.activemq.command.ActiveMQTopic;
 import org.apache.activemq.command.BrokerInfo;
 import org.apache.activemq.command.Command;
 import org.apache.activemq.command.ConnectionControl;
@@ -102,33 +110,32 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
 
    private final OpenWireProtocolManager protocolManager;
 
-   private final List<CloseListener> closeListeners = new CopyOnWriteArrayList<>();
-
    private boolean destroyed = false;
 
    private final Object sendLock = new Object();
 
-   private final Acceptor acceptorUsed;
-
    private final OpenWireFormat wireFormat;
 
    private AMQConnectionContext context;
 
-   private Throwable stopError = null;
-
    private final AtomicBoolean stopping = new AtomicBoolean(false);
 
-   private final ReentrantReadWriteLock serviceLock = new ReentrantReadWriteLock();
-
-   protected final List<Command> dispatchQueue = new LinkedList<>();
-
    private boolean inServiceException;
 
    private final AtomicBoolean asyncException = new AtomicBoolean(false);
 
+   // Clebert: Artemis session has meta-data support, perhaps we could reuse it here
+   private Map<String, SessionId> sessionIdMap = new ConcurrentHashMap<>();
+
+
    private final Map<ConsumerId, AMQConsumerBrokerExchange> consumerExchanges = new HashMap<>();
    private final Map<ProducerId, AMQProducerBrokerExchange> producerExchanges = new HashMap<>();
 
+   // Clebert TODO: Artemis already stores the Session. Why do we need a different one here
+   private Map<SessionId, AMQSession> sessions = new ConcurrentHashMap<>();
+
+
+
    private ConnectionState state;
 
    private final Set<ActiveMQDestination> tempQueues = new ConcurrentHashSet<>();
@@ -139,14 +146,12 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
 
    private String defaultSocketURIString;
 
-   public OpenWireConnection(Acceptor acceptorUsed,
-                             Connection connection,
+   public OpenWireConnection(Connection connection,
                              Executor executor,
                              OpenWireProtocolManager openWireProtocolManager,
                              OpenWireFormat wf) {
       super(connection, executor);
       this.protocolManager = openWireProtocolManager;
-      this.acceptorUsed = acceptorUsed;
       this.wireFormat = wf;
       this.defaultSocketURIString = connection.getLocalAddress();
    }
@@ -322,8 +327,8 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
       }
    }
 
-   // throw a WireFormatInfo to the peer
-   public void init() {
+   // send a WireFormatInfo to the peer
+   public void sendHandshake() {
       WireFormatInfo info = wireFormat.getPreferedWireFormatInfo();
       sendCommand(info);
    }
@@ -590,7 +595,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
          ActiveMQServerLogger.LOGGER.connectionFailureDetected(me.getMessage(), me.getType());
       }
       try {
-         protocolManager.removeConnection(this, this.getConnectionInfo(), me);
+         protocolManager.removeConnection(this.getConnectionInfo(), me);
       }
       catch (InvalidClientIDException e) {
          ActiveMQServerLogger.LOGGER.warn("Couldn't close connection because invalid clientID", e);
@@ -681,40 +686,185 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
       context.incRefCount();
    }
 
-   /** This will answer with commands to the client */
+   /**
+    * This will answer with commands to the client
+    */
    public boolean sendCommand(final Command command) {
       if (ActiveMQServerLogger.LOGGER.isTraceEnabled()) {
          ActiveMQServerLogger.LOGGER.trace("sending " + command);
       }
-      synchronized (this) {
-         if (isDestroyed()) {
-            return false;
+
+      if (isDestroyed()) {
+         return false;
+      }
+
+      try {
+         physicalSend(command);
+      }
+      catch (Exception e) {
+         return false;
+      }
+      catch (Throwable t) {
+         return false;
+      }
+      return true;
+   }
+
+   public void addDestination(DestinationInfo info) throws Exception {
+      ActiveMQDestination dest = info.getDestination();
+      if (dest.isQueue()) {
+         SimpleString qName = OpenWireUtil.toCoreAddress(dest);
+         QueueBinding binding = (QueueBinding) protocolManager.getServer().getPostOffice().getBinding(qName);
+         if (binding == null) {
+            if (getState().getInfo() != null) {
+
+               CheckType checkType = dest.isTemporary() ? CheckType.CREATE_NON_DURABLE_QUEUE : CheckType.CREATE_DURABLE_QUEUE;
+               protocolManager.getServer().getSecurityStore().check(qName, checkType, this);
+
+               protocolManager.getServer().checkQueueCreationLimit(getUsername());
+            }
+            ConnectionInfo connInfo = getState().getInfo();
+            protocolManager.getServer().createQueue(qName, qName, null, connInfo == null ? null : SimpleString.toSimpleString(connInfo.getUserName()), false, dest.isTemporary());
          }
 
-         try {
-            physicalSend(command);
+         if (dest.isTemporary()) {
+            registerTempQueue(dest);
          }
-         catch (Exception e) {
-            return false;
+      }
+
+      if (!AdvisorySupport.isAdvisoryTopic(dest)) {
+         AMQConnectionContext context = getContext();
+         DestinationInfo advInfo = new DestinationInfo(context.getConnectionId(), DestinationInfo.ADD_OPERATION_TYPE, dest);
+
+         ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(dest);
+         protocolManager.fireAdvisory(context, topic, advInfo);
+      }
+   }
+
+
+   public void updateConsumer(ConsumerControl consumerControl) {
+      SessionId sessionId = consumerControl.getConsumerId().getParentId();
+      AMQSession amqSession = sessions.get(sessionId);
+      amqSession.updateConsumerPrefetchSize(consumerControl.getConsumerId(), consumerControl.getPrefetch());
+   }
+
+   public void addConsumer(ConsumerInfo info) throws Exception {
+      // Todo: add a destination interceptors holder here (amq supports this)
+      SessionId sessionId = info.getConsumerId().getParentId();
+      ConnectionId connectionId = sessionId.getParentId();
+      ConnectionState cs = getState();
+      if (cs == null) {
+         throw new IllegalStateException("Cannot add a consumer to a connection that had not been registered: " + connectionId);
+      }
+      SessionState ss = cs.getSessionState(sessionId);
+      if (ss == null) {
+         throw new IllegalStateException(protocolManager.getServer() + " Cannot add a consumer to a session that had not been registered: " + sessionId);
+      }
+      // Avoid replaying dup commands
+      if (!ss.getConsumerIds().contains(info.getConsumerId())) {
+
+         AMQSession amqSession = sessions.get(sessionId);
+         if (amqSession == null) {
+            throw new IllegalStateException("Session not exist! : " + sessionId);
+         }
+
+         amqSession.createConsumer(info, amqSession, new SlowConsumerDetection());
+
+         ss.addConsumer(info);
+      }
+   }
+
+   class SlowConsumerDetection implements SlowConsumerDetectionListener {
+
+      @Override
+      public void onSlowConsumer(ServerConsumer consumer) {
+         if (consumer instanceof AMQServerConsumer) {
+            AMQServerConsumer serverConsumer = (AMQServerConsumer)consumer;
+            ActiveMQTopic topic = AdvisorySupport.getSlowConsumerAdvisoryTopic(serverConsumer.getAmqConsumer().getDestination());
+            ActiveMQMessage advisoryMessage = new ActiveMQMessage();
+            try {
+               advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_CONSUMER_ID, serverConsumer.getAmqConsumer().getId().toString());
+               protocolManager.fireAdvisory(context, topic, advisoryMessage, serverConsumer.getAmqConsumer().getId());
+            }
+            catch (Exception e) {
+               // TODO-NOW: LOGGING
+               e.printStackTrace();
+            }
          }
-         catch (Throwable t) {
-            return false;
+      }
+   }
+
+   public void addSessions(Set<SessionId> sessionSet) {
+      Iterator<SessionId> iter = sessionSet.iterator();
+      while (iter.hasNext()) {
+         SessionId sid = iter.next();
+         addSession(getState().getSessionState(sid).getInfo(), true);
+      }
+   }
+
+   public AMQSession addSession(SessionInfo ss) {
+      return addSession(ss, false);
+   }
+
+   public AMQSession addSession(SessionInfo ss, boolean internal) {
+      AMQSession amqSession = new AMQSession(getState().getInfo(), ss, protocolManager.getServer(), this, protocolManager.getScheduledPool(), protocolManager);
+      amqSession.initialize();
+      amqSession.setInternal(internal);
+      sessions.put(ss.getSessionId(), amqSession);
+      sessionIdMap.put(amqSession.getCoreSession().getName(), ss.getSessionId());
+      return amqSession;
+   }
+
+   public void removeSession(AMQConnectionContext context, SessionInfo info) throws Exception {
+      AMQSession session = sessions.remove(info.getSessionId());
+      if (session != null) {
+         session.close();
+      }
+   }
+
+   public AMQSession getSession(SessionId sessionId) {
+      return sessions.get(sessionId);
+   }
+
+   public void removeDestination(ActiveMQDestination dest) throws Exception {
+      if (dest.isQueue()) {
+         SimpleString qName = new SimpleString("jms.queue." + dest.getPhysicalName());
+         protocolManager.getServer().destroyQueue(qName);
+      }
+      else {
+         Bindings bindings = protocolManager.getServer().getPostOffice().getBindingsForAddress(SimpleString.toSimpleString("jms.topic." + dest.getPhysicalName()));
+         Iterator<Binding> iterator = bindings.getBindings().iterator();
+
+         while (iterator.hasNext()) {
+            Queue b = (Queue) iterator.next().getBindable();
+            if (b.getConsumerCount() > 0) {
+               throw new Exception("Destination still has an active subscription: " + dest.getPhysicalName());
+            }
+            if (b.isDurable()) {
+               throw new Exception("Destination still has durable subscription: " + dest.getPhysicalName());
+            }
+            b.deleteQueue();
          }
-         return true;
+      }
+
+      if (!AdvisorySupport.isAdvisoryTopic(dest)) {
+         AMQConnectionContext context = getContext();
+         DestinationInfo advInfo = new DestinationInfo(context.getConnectionId(), DestinationInfo.REMOVE_OPERATION_TYPE, dest);
+
+         ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(dest);
+         protocolManager.fireAdvisory(context, topic, advInfo);
       }
    }
 
    // This will listen for commands throught the protocolmanager
    public class CommandProcessor implements CommandVisitor {
 
-
       public AMQConnectionContext getContext() {
          return OpenWireConnection.this.getContext();
       }
 
       @Override
       public Response processAddConnection(ConnectionInfo info) throws Exception {
-         //let protoclmanager handle connection add/remove
          try {
             protocolManager.addConnection(OpenWireConnection.this, info);
          }
@@ -739,7 +889,36 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
       public Response processAddProducer(ProducerInfo info) throws Exception {
          Response resp = null;
          try {
-            protocolManager.addProducer(OpenWireConnection.this, info);
+            SessionId sessionId = info.getProducerId().getParentId();
+            ConnectionId connectionId = sessionId.getParentId();
+            ConnectionState cs = getState();
+            if (cs == null) {
+               throw new IllegalStateException("Cannot add a producer to a connection that had not been registered: " + connectionId);
+            }
+            SessionState ss = cs.getSessionState(sessionId);
+            if (ss == null) {
+               throw new IllegalStateException("Cannot add a producer to a session that had not been registered: " + sessionId);
+            }
+            // Avoid replaying dup commands
+            if (!ss.getProducerIds().contains(info.getProducerId())) {
+
+               AMQSession amqSession = sessions.get(sessionId);
+               if (amqSession == null) {
+                  throw new IllegalStateException("Session not exist! : " + sessionId);
+               }
+
+               ActiveMQDestination destination = info.getDestination();
+               if (destination != null && !AdvisorySupport.isAdvisoryTopic(destination)) {
+                  if (destination.isQueue()) {
+                     OpenWireUtil.validateDestination(destination, amqSession);
+                  }
+                  DestinationInfo destInfo = new DestinationInfo(getContext().getConnectionId(), DestinationInfo.ADD_OPERATION_TYPE, destination);
+                  OpenWireConnection.this.addDestination(destInfo);
+               }
+
+               ss.addProducer(info);
+
+            }
          }
          catch (Exception e) {
             if (e instanceof ActiveMQSecurityException) {
@@ -759,7 +938,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
       public Response processAddConsumer(ConsumerInfo info) {
          Response resp = null;
          try {
-            protocolManager.addConsumer(OpenWireConnection.this, info);
+            addConsumer(info);
          }
          catch (Exception e) {
             e.printStackTrace();
@@ -776,13 +955,14 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
       @Override
       public Response processRemoveDestination(DestinationInfo info) throws Exception {
          ActiveMQDestination dest = info.getDestination();
-         protocolManager.removeDestination(OpenWireConnection.this, dest);
+         removeDestination(dest);
          return null;
       }
 
       @Override
       public Response processRemoveProducer(ProducerId id) throws Exception {
-         protocolManager.removeProducer(id);
+
+         // TODO-now: proper implement this method
          return null;
       }
 
@@ -807,7 +987,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
             }
          }
          state.removeSession(id);
-         protocolManager.removeSession(context, session.getInfo());
+         removeSession(context, session.getInfo());
          return null;
       }
 
@@ -843,7 +1023,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
       public Response processAddDestination(DestinationInfo dest) throws Exception {
          Response resp = null;
          try {
-            protocolManager.addDestination(OpenWireConnection.this, dest);
+            addDestination(dest);
          }
          catch (Exception e) {
             if (e instanceof ActiveMQSecurityException) {
@@ -860,14 +1040,8 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
       public Response processAddSession(SessionInfo info) throws Exception {
          // Avoid replaying dup commands
          if (!state.getSessionIds().contains(info.getSessionId())) {
-            protocolManager.addSession(OpenWireConnection.this, info);
-            try {
-               state.addSession(info);
-            }
-            catch (IllegalStateException e) {
-               e.printStackTrace();
-               protocolManager.removeSession(context, info);
-            }
+            addSession(info);
+            state.addSession(info);
          }
          return null;
       }
@@ -923,7 +1097,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
          //amq5 clients send this command to restore prefetchSize
          //after successful reconnect
          try {
-            protocolManager.updateConsumer(OpenWireConnection.this, consumerControl);
+            updateConsumer(consumerControl);
          }
          catch (Exception e) {
             //log error
@@ -976,33 +1150,31 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
             final ProducerInfo producerInfo = producerExchange.getProducerState().getInfo();
             boolean sendProducerAck = !messageSend.isResponseRequired() && producerInfo.getWindowSize() > 0 && !pcontext.isInRecoveryMode();
 
-            AMQSession session = protocolManager.getSession(producerId.getParentId());
+            AMQSession session = getSession(producerId.getParentId());
 
-            // TODO: canDispatch is always returning true;
-            if (producerExchange.canDispatch(messageSend)) {
-               SendingResult result = session.send(producerExchange, messageSend, sendProducerAck);
-               if (result.isBlockNextSend()) {
-                  if (!context.isNetworkConnection() && result.isSendFailIfNoSpace()) {
-                     // TODO see logging
-                     throw new ResourceAllocationException("Usage Manager Memory Limit reached. Stopping producer (" + producerId + ") to prevent flooding " + result.getBlockingAddress() + "." + " See http://activemq.apache.org/producer-flow-control.html for more info");
-                  }
+            SendingResult result = session.send(producerExchange, messageSend, sendProducerAck);
+            if (result.isBlockNextSend()) {
+               if (!context.isNetworkConnection() && result.isSendFailIfNoSpace()) {
+                  // TODO see logging
+                  throw new ResourceAllocationException("Usage Manager Memory Limit reached. Stopping producer (" + producerId + ") to prevent flooding " + result.getBlockingAddress() + "." + " See http://activemq.apache.org/producer-flow-control.html for more info");
+               }
 
-                  if (producerInfo.getWindowSize() > 0 || messageSend.isResponseRequired()) {
-                     //in that case don't send the response
-                     //this will force the client to wait until
-                     //the response is got.
-                     context.setDontSendReponse(true);
-                  }
-                  else {
-                     //hang the connection until the space is available
-                     session.blockingWaitForSpace(producerExchange, result);
-                  }
+               if (producerInfo.getWindowSize() > 0 || messageSend.isResponseRequired()) {
+                  //in that case don't send the response
+                  //this will force the client to wait until
+                  //the response is got.
+                  context.setDontSendReponse(true);
                }
-               else if (sendProducerAck) {
-                  ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), messageSend.getSize());
-                  OpenWireConnection.this.dispatchAsync(ack);
+               else {
+                  //hang the connection until the space is available
+                  session.blockingWaitForSpace(producerExchange, result);
                }
             }
+            else if (sendProducerAck) {
+               // TODO-now: send through OperationContext
+               ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), messageSend.getSize());
+               OpenWireConnection.this.dispatchAsync(ack);
+            }
          }
          catch (Throwable e) {
             if (e instanceof ActiveMQSecurityException) {
@@ -1056,15 +1228,26 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
       @Override
       public Response processRecoverTransactions(TransactionInfo info) throws Exception {
          Set<SessionId> sIds = state.getSessionIds();
-         TransactionId[] recovered = protocolManager.recoverTransactions(sIds);
-         return new DataArrayResponse(recovered);
+
+
+         List<TransactionId> recovered = new ArrayList<>();
+         if (sIds != null) {
+            for (SessionId sid : sIds) {
+               AMQSession s = sessions.get(sid);
+               if (s != null) {
+                  s.recover(recovered);
+               }
+            }
+         }
+
+         return new DataArrayResponse(recovered.toArray(new TransactionId[0]));
       }
 
       @Override
       public Response processRemoveConnection(ConnectionId id, long lastDeliveredSequenceId) throws Exception {
          //we let protocol manager to handle connection add/remove
          try {
-            protocolManager.removeConnection(OpenWireConnection.this, state.getInfo(), null);
+            protocolManager.removeConnection(state.getInfo(), null);
          }
          catch (Throwable e) {
             // log

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e84edecb/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
index add1455..bdf27f8 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
@@ -17,15 +17,12 @@
 package org.apache.activemq.artemis.core.protocol.openwire;
 
 import javax.jms.InvalidClientIDException;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
-import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.CopyOnWriteArrayList;
@@ -40,26 +37,14 @@ import org.apache.activemq.artemis.api.core.Interceptor;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.client.ClusterTopologyListener;
 import org.apache.activemq.artemis.api.core.client.TopologyMember;
-import org.apache.activemq.artemis.api.core.management.CoreNotificationType;
-import org.apache.activemq.artemis.api.core.management.ManagementHelper;
-import org.apache.activemq.artemis.core.io.IOCallback;
-import org.apache.activemq.artemis.core.postoffice.Binding;
-import org.apache.activemq.artemis.core.postoffice.Bindings;
-import org.apache.activemq.artemis.core.postoffice.QueueBinding;
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext;
-import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConsumer;
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQProducerBrokerExchange;
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQSession;
 import org.apache.activemq.artemis.core.remoting.impl.netty.NettyServerConnection;
-import org.apache.activemq.artemis.core.security.CheckType;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
-import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
-import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
 import org.apache.activemq.artemis.core.server.cluster.ClusterManager;
 import org.apache.activemq.artemis.core.server.management.ManagementService;
-import org.apache.activemq.artemis.core.server.management.Notification;
-import org.apache.activemq.artemis.core.server.management.NotificationListener;
 import org.apache.activemq.artemis.spi.core.protocol.ConnectionEntry;
 import org.apache.activemq.artemis.spi.core.protocol.MessageConverter;
 import org.apache.activemq.artemis.spi.core.protocol.ProtocolManager;
@@ -69,7 +54,6 @@ import org.apache.activemq.artemis.spi.core.remoting.Acceptor;
 import org.apache.activemq.artemis.spi.core.remoting.Connection;
 import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
 import org.apache.activemq.artemis.utils.DataConstants;
-import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ActiveMQMessage;
 import org.apache.activemq.command.ActiveMQTopic;
 import org.apache.activemq.command.BrokerId;
@@ -78,31 +62,24 @@ import org.apache.activemq.command.Command;
 import org.apache.activemq.command.ConnectionControl;
 import org.apache.activemq.command.ConnectionId;
 import org.apache.activemq.command.ConnectionInfo;
-import org.apache.activemq.command.ConsumerControl;
 import org.apache.activemq.command.ConsumerId;
-import org.apache.activemq.command.ConsumerInfo;
-import org.apache.activemq.command.DestinationInfo;
 import org.apache.activemq.command.MessageDispatch;
 import org.apache.activemq.command.MessageId;
 import org.apache.activemq.command.ProducerId;
 import org.apache.activemq.command.ProducerInfo;
 import org.apache.activemq.command.RemoveSubscriptionInfo;
-import org.apache.activemq.command.SessionId;
-import org.apache.activemq.command.SessionInfo;
 import org.apache.activemq.command.TransactionId;
 import org.apache.activemq.command.TransactionInfo;
 import org.apache.activemq.command.WireFormatInfo;
 import org.apache.activemq.command.XATransactionId;
 import org.apache.activemq.openwire.OpenWireFormat;
 import org.apache.activemq.openwire.OpenWireFormatFactory;
-import org.apache.activemq.state.ConnectionState;
 import org.apache.activemq.state.ProducerState;
-import org.apache.activemq.state.SessionState;
 import org.apache.activemq.util.IdGenerator;
 import org.apache.activemq.util.InetAddressUtil;
 import org.apache.activemq.util.LongSequenceGenerator;
 
-public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, NotificationListener, ClusterTopologyListener {
+public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, ClusterTopologyListener {
 
    private static final IdGenerator BROKER_ID_GENERATOR = new IdGenerator();
    private static final IdGenerator ID_GENERATOR = new IdGenerator();
@@ -127,21 +104,16 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
    private final CopyOnWriteArrayList<OpenWireConnection> connections = new CopyOnWriteArrayList<>();
 
    protected final ConcurrentMap<ConnectionId, ConnectionInfo> connectionInfos = new ConcurrentHashMap<>();
+
    // Clebert TODO: use ConcurrentHashMap, or maybe use the schema that's already available on Artemis upstream (unique-client-id)
    private final Map<String, AMQConnectionContext> clientIdSet = new HashMap<String, AMQConnectionContext>();
 
    private String brokerName;
 
-   // Clebert TODO: Artemis already stores the Session. Why do we need a different one here
-   private Map<SessionId, AMQSession> sessions = new ConcurrentHashMap<>();
-
    // Clebert: Artemis already has a Resource Manager. Need to remove this..
    //          The TransactionID extends XATransactionID, so all we need is to convert the XID here
    private Map<TransactionId, AMQSession> transactions = new ConcurrentHashMap<>();
 
-   // Clebert: Artemis session has meta-data support, perhaps we could reuse it here
-   private Map<String, SessionId> sessionIdMap = new ConcurrentHashMap<>();
-
    private final Map<String, TopologyMember> topologyMap = new ConcurrentHashMap<>();
 
    private final LinkedList<TopologyMember> members = new LinkedList<>();
@@ -163,9 +135,6 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
       advisoryProducerId.setConnectionId(ID_GENERATOR.generateId());
       ManagementService service = server.getManagementService();
       scheduledPool = server.getScheduledPool();
-      if (service != null) {
-         service.addNotificationListener(this);
-      }
 
       final ClusterManager clusterManager = this.server.getClusterManager();
       ClusterConnection cc = clusterManager.getDefaultConnection(null);
@@ -187,6 +156,35 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
       }
    }
 
+
+   public void removeConnection(ConnectionInfo info,
+                                Throwable error) throws InvalidClientIDException {
+      synchronized (clientIdSet) {
+         String clientId = info.getClientId();
+         if (clientId != null) {
+            AMQConnectionContext context = this.clientIdSet.get(clientId);
+            if (context != null && context.decRefCount() == 0) {
+               //connection is still there and need to close
+               context.getConnection().disconnect(error != null);
+               this.connections.remove(this);//what's that for?
+               this.clientIdSet.remove(clientId);
+            }
+         }
+         else {
+            throw new InvalidClientIDException("No clientID specified for connection disconnect request");
+         }
+      }
+   }
+
+
+   public ScheduledExecutorService getScheduledPool() {
+      return scheduledPool;
+   }
+
+   public ActiveMQServer getServer() {
+      return server;
+   }
+
    private void updateClientClusterInfo() {
 
       synchronized (members) {
@@ -219,8 +217,8 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
    @Override
    public ConnectionEntry createConnectionEntry(Acceptor acceptorUsed, Connection connection) {
       OpenWireFormat wf = (OpenWireFormat) wireFactory.createWireFormat();
-      OpenWireConnection owConn = new OpenWireConnection(acceptorUsed, connection,  server.getExecutorFactory().getExecutor(), this, wf);
-      owConn.init();
+      OpenWireConnection owConn = new OpenWireConnection(connection, server.getExecutorFactory().getExecutor(), this, wf);
+      owConn.sendHandshake();
 
       // TODO CLEBERT What is this constant here? we should get it from TTL initial pings
       return new ConnectionEntry(owConn, null, System.currentTimeMillis(), 1 * 60 * 1000);
@@ -233,7 +231,6 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
 
    @Override
    public void removeHandler(String name) {
-      // TODO Auto-generated method stub
    }
 
    @Override
@@ -276,8 +273,6 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
 
    @Override
    public void handshake(NettyServerConnection connection, ActiveMQBuffer buffer) {
-      // TODO Auto-generated method stub
-
    }
 
    public void addConnection(OpenWireConnection connection, ConnectionInfo info) throws Exception {
@@ -322,11 +317,11 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
          fireAdvisory(context, topic, copy);
 
          // init the conn
-         addSessions(context.getConnection(), context.getConnectionState().getSessionIds());
+         context.getConnection().addSessions( context.getConnectionState().getSessionIds());
       }
    }
 
-   private void fireAdvisory(AMQConnectionContext context, ActiveMQTopic topic, Command copy) throws Exception {
+   public void fireAdvisory(AMQConnectionContext context, ActiveMQTopic topic, Command copy) throws Exception {
       this.fireAdvisory(context, topic, copy, null);
    }
 
@@ -341,7 +336,7 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
    /*
     * See AdvisoryBroker.fireAdvisory()
     */
-   private void fireAdvisory(AMQConnectionContext context,
+   public void fireAdvisory(AMQConnectionContext context,
                              ActiveMQTopic topic,
                              Command command,
                              ConsumerId targetConsumerId) throws Exception {
@@ -448,198 +443,6 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
    public boolean isStopping() {
       return false;
    }
-
-   public void addProducer(OpenWireConnection theConn, ProducerInfo info) throws Exception {
-      SessionId sessionId = info.getProducerId().getParentId();
-      ConnectionId connectionId = sessionId.getParentId();
-      ConnectionState cs = theConn.getState();
-      if (cs == null) {
-         throw new IllegalStateException("Cannot add a producer to a connection that had not been registered: " + connectionId);
-      }
-      SessionState ss = cs.getSessionState(sessionId);
-      if (ss == null) {
-         throw new IllegalStateException("Cannot add a producer to a session that had not been registered: " + sessionId);
-      }
-      // Avoid replaying dup commands
-      if (!ss.getProducerIds().contains(info.getProducerId())) {
-
-         AMQSession amqSession = sessions.get(sessionId);
-         if (amqSession == null) {
-            throw new IllegalStateException("Session not exist! : " + sessionId);
-         }
-
-         ActiveMQDestination destination = info.getDestination();
-         if (destination != null && !AdvisorySupport.isAdvisoryTopic(destination)) {
-            if (destination.isQueue()) {
-               OpenWireUtil.validateDestination(destination, amqSession);
-            }
-            DestinationInfo destInfo = new DestinationInfo(theConn.getContext().getConnectionId(), DestinationInfo.ADD_OPERATION_TYPE, destination);
-            this.addDestination(theConn, destInfo);
-         }
-
-         amqSession.createProducer(info);
-
-         try {
-            ss.addProducer(info);
-         }
-         catch (IllegalStateException e) {
-            amqSession.removeProducer(info);
-         }
-
-      }
-
-   }
-
-   public void updateConsumer(OpenWireConnection theConn, ConsumerControl consumerControl) {
-      SessionId sessionId = consumerControl.getConsumerId().getParentId();
-      AMQSession amqSession = sessions.get(sessionId);
-      amqSession.updateConsumerPrefetchSize(consumerControl.getConsumerId(), consumerControl.getPrefetch());
-   }
-
-   public void addConsumer(OpenWireConnection theConn, ConsumerInfo info) throws Exception {
-      // Todo: add a destination interceptors holder here (amq supports this)
-      SessionId sessionId = info.getConsumerId().getParentId();
-      ConnectionId connectionId = sessionId.getParentId();
-      ConnectionState cs = theConn.getState();
-      if (cs == null) {
-         throw new IllegalStateException("Cannot add a consumer to a connection that had not been registered: " + connectionId);
-      }
-      SessionState ss = cs.getSessionState(sessionId);
-      if (ss == null) {
-         throw new IllegalStateException(this.server + " Cannot add a consumer to a session that had not been registered: " + sessionId);
-      }
-      // Avoid replaying dup commands
-      if (!ss.getConsumerIds().contains(info.getConsumerId())) {
-
-         AMQSession amqSession = sessions.get(sessionId);
-         if (amqSession == null) {
-            throw new IllegalStateException("Session not exist! : " + sessionId);
-         }
-
-         amqSession.createConsumer(info, amqSession);
-
-         ss.addConsumer(info);
-      }
-   }
-
-   public void addSessions(OpenWireConnection theConn, Set<SessionId> sessionSet) {
-      Iterator<SessionId> iter = sessionSet.iterator();
-      while (iter.hasNext()) {
-         SessionId sid = iter.next();
-         addSession(theConn, theConn.getState().getSessionState(sid).getInfo(), true);
-      }
-   }
-
-   public AMQSession addSession(OpenWireConnection theConn, SessionInfo ss) {
-      return addSession(theConn, ss, false);
-   }
-
-   public AMQSession addSession(OpenWireConnection theConn, SessionInfo ss, boolean internal) {
-      AMQSession amqSession = new AMQSession(theConn.getState().getInfo(), ss, server, theConn, scheduledPool, this);
-      amqSession.initialize();
-      amqSession.setInternal(internal);
-      sessions.put(ss.getSessionId(), amqSession);
-      sessionIdMap.put(amqSession.getCoreSession().getName(), ss.getSessionId());
-      return amqSession;
-   }
-
-   public void removeConnection(OpenWireConnection connection,
-                                ConnectionInfo info,
-                                Throwable error) throws InvalidClientIDException {
-      synchronized (clientIdSet) {
-         String clientId = info.getClientId();
-         if (clientId != null) {
-            AMQConnectionContext context = this.clientIdSet.get(clientId);
-            if (context != null && context.decRefCount() == 0) {
-               //connection is still there and need to close
-               this.clientIdSet.remove(clientId);
-               connection.disconnect(error != null);
-               this.connections.remove(connection);//what's that for?
-            }
-         }
-         else {
-            throw new InvalidClientIDException("No clientID specified for connection disconnect request");
-         }
-      }
-   }
-
-   public void removeSession(AMQConnectionContext context, SessionInfo info) throws Exception {
-      AMQSession session = sessions.remove(info.getSessionId());
-      if (session != null) {
-         session.close();
-      }
-   }
-
-   public void removeProducer(ProducerId id) {
-      SessionId sessionId = id.getParentId();
-      AMQSession session = sessions.get(sessionId);
-      session.removeProducer(id);
-   }
-
-   public AMQSession getSession(SessionId sessionId) {
-      return sessions.get(sessionId);
-   }
-
-   public void removeDestination(OpenWireConnection connection, ActiveMQDestination dest) throws Exception {
-      if (dest.isQueue()) {
-         SimpleString qName = new SimpleString("jms.queue." + dest.getPhysicalName());
-         this.server.destroyQueue(qName);
-      }
-      else {
-         Bindings bindings = this.server.getPostOffice().getBindingsForAddress(SimpleString.toSimpleString("jms.topic." + dest.getPhysicalName()));
-         Iterator<Binding> iterator = bindings.getBindings().iterator();
-
-         while (iterator.hasNext()) {
-            Queue b = (Queue) iterator.next().getBindable();
-            if (b.getConsumerCount() > 0) {
-               throw new Exception("Destination still has an active subscription: " + dest.getPhysicalName());
-            }
-            if (b.isDurable()) {
-               throw new Exception("Destination still has durable subscription: " + dest.getPhysicalName());
-            }
-            b.deleteQueue();
-         }
-      }
-
-      if (!AdvisorySupport.isAdvisoryTopic(dest)) {
-         AMQConnectionContext context = connection.getContext();
-         DestinationInfo advInfo = new DestinationInfo(context.getConnectionId(), DestinationInfo.REMOVE_OPERATION_TYPE, dest);
-
-         ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(dest);
-         fireAdvisory(context, topic, advInfo);
-      }
-   }
-
-   public void addDestination(OpenWireConnection connection, DestinationInfo info) throws Exception {
-      ActiveMQDestination dest = info.getDestination();
-      if (dest.isQueue()) {
-         SimpleString qName = OpenWireUtil.toCoreAddress(dest);
-         QueueBinding binding = (QueueBinding) server.getPostOffice().getBinding(qName);
-         if (binding == null) {
-            if (connection.getState().getInfo() != null) {
-
-               CheckType checkType = dest.isTemporary() ? CheckType.CREATE_NON_DURABLE_QUEUE : CheckType.CREATE_DURABLE_QUEUE;
-               server.getSecurityStore().check(qName, checkType, connection);
-
-               server.checkQueueCreationLimit(connection.getUsername());
-            }
-            ConnectionInfo connInfo = connection.getState().getInfo();
-            this.server.createQueue(qName, qName, null, connInfo == null ? null : SimpleString.toSimpleString(connInfo.getUserName()), false, dest.isTemporary());
-         }
-         if (dest.isTemporary()) {
-            connection.registerTempQueue(dest);
-         }
-      }
-
-      if (!AdvisorySupport.isAdvisoryTopic(dest)) {
-         AMQConnectionContext context = connection.getContext();
-         DestinationInfo advInfo = new DestinationInfo(context.getConnectionId(), DestinationInfo.ADD_OPERATION_TYPE, dest);
-
-         ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(dest);
-         fireAdvisory(context, topic, advInfo);
-      }
-   }
-
    public void endTransaction(TransactionInfo info) throws Exception {
       AMQSession txSession = transactions.get(info.getTransactionId());
 
@@ -682,19 +485,6 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
       transactions.remove(info.getTransactionId());
    }
 
-   public TransactionId[] recoverTransactions(Set<SessionId> sIds) {
-      List<TransactionId> recovered = new ArrayList<>();
-      if (sIds != null) {
-         for (SessionId sid : sIds) {
-            AMQSession s = this.sessions.get(sid);
-            if (s != null) {
-               s.recover(recovered);
-            }
-         }
-      }
-      return recovered.toArray(new TransactionId[0]);
-   }
-
    public boolean validateUser(String login, String passcode) {
       boolean validated = true;
 
@@ -717,50 +507,11 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
 
    /**
     * TODO: remove this, use the regular ResourceManager from the Server's
-    * */
+    */
    public void registerTx(TransactionId txId, AMQSession amqSession) {
       transactions.put(txId, amqSession);
    }
 
-   //advisory support
-   @Override
-   public void onNotification(Notification notif) {
-      try {
-         if (notif.getType() instanceof CoreNotificationType) {
-            CoreNotificationType type = (CoreNotificationType) notif.getType();
-            switch (type) {
-               case CONSUMER_SLOW:
-                  fireSlowConsumer(notif);
-                  break;
-               default:
-                  break;
-            }
-         }
-      }
-      catch (Exception e) {
-         ActiveMQServerLogger.LOGGER.error("Failed to send notification " + notif, e);
-      }
-   }
-
-   private void fireSlowConsumer(Notification notif) throws Exception {
-      SimpleString coreSessionId = notif.getProperties().getSimpleStringProperty(ManagementHelper.HDR_SESSION_NAME);
-      Long coreConsumerId = notif.getProperties().getLongProperty(ManagementHelper.HDR_CONSUMER_NAME);
-      SessionId sessionId = sessionIdMap.get(coreSessionId.toString());
-      AMQSession session = sessions.get(sessionId);
-      AMQConsumer consumer = session.getConsumer(coreConsumerId);
-      ActiveMQDestination destination = consumer.getDestination();
-
-      if (!AdvisorySupport.isAdvisoryTopic(destination)) {
-         ActiveMQTopic topic = AdvisorySupport.getSlowConsumerAdvisoryTopic(destination);
-         ConnectionId connId = sessionId.getParentId();
-         OpenWireConnection cc = this.brokerConnectionStates.get(connId);
-         ActiveMQMessage advisoryMessage = new ActiveMQMessage();
-         advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_CONSUMER_ID, consumer.getId().toString());
-
-         fireAdvisory(cc.getContext(), topic, advisoryMessage, consumer.getId());
-      }
-   }
-
    public void removeSubscription(RemoveSubscriptionInfo subInfo) throws Exception {
       SimpleString subQueueName = new SimpleString(org.apache.activemq.artemis.jms.client.ActiveMQDestination.createQueueNameForDurableSubscription(true, subInfo.getClientId(), subInfo.getSubscriptionName()));
       server.destroyQueue(subQueueName);
@@ -795,7 +546,7 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
       return this.updateClusterClients;
    }
 
-   public  void setUpdateClusterClientsOnRemove(boolean updateClusterClientsOnRemove) {
+   public void setUpdateClusterClientsOnRemove(boolean updateClusterClientsOnRemove) {
       this.updateClusterClientsOnRemove = updateClusterClientsOnRemove;
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e84edecb/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java
index b0f007a..221679f 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java
@@ -27,7 +27,14 @@ import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl;
+import org.apache.activemq.artemis.core.protocol.openwire.OpenWireMessageConverter;
+import org.apache.activemq.artemis.core.protocol.openwire.OpenWireUtil;
+import org.apache.activemq.artemis.core.server.QueueQueryResult;
+import org.apache.activemq.artemis.core.server.ServerMessage;
+import org.apache.activemq.artemis.core.server.SlowConsumerDetectionListener;
+import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
 import org.apache.activemq.command.ConsumerId;
 import org.apache.activemq.command.ConsumerInfo;
 import org.apache.activemq.command.MessageAck;
@@ -36,14 +43,9 @@ import org.apache.activemq.command.MessageId;
 import org.apache.activemq.command.MessagePull;
 import org.apache.activemq.command.TransactionId;
 import org.apache.activemq.wireformat.WireFormat;
-import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.protocol.openwire.OpenWireMessageConverter;
-import org.apache.activemq.artemis.core.protocol.openwire.OpenWireUtil;
-import org.apache.activemq.artemis.core.server.QueueQueryResult;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
 
 public class AMQConsumer implements BrowserListener {
+
    private AMQSession session;
    private org.apache.activemq.command.ActiveMQDestination actualDest;
    private ConsumerInfo info;
@@ -72,7 +74,7 @@ public class AMQConsumer implements BrowserListener {
       }
    }
 
-   public void init() throws Exception {
+   public void init(SlowConsumerDetectionListener slowConsumerDetectionListener) throws Exception {
       AMQServerSession coreSession = session.getCoreSession();
 
       SimpleString selector = info.getSelector() == null ? null : new SimpleString(info.getSelector());
@@ -127,7 +129,9 @@ public class AMQConsumer implements BrowserListener {
             coreSession.createQueue(address, subQueueName, selector, true, false);
          }
 
-         coreSession.createConsumer(nativeId, subQueueName, null, info.isBrowser(), false, -1);
+         AMQServerConsumer serverConsumer = (AMQServerConsumer) coreSession.createConsumer(nativeId, subQueueName, null, info.isBrowser(), false, -1);
+         serverConsumer.setlowConsumerDetection(slowConsumerDetectionListener);
+         serverConsumer.setAmqConsumer(this);
       }
       else {
          SimpleString queueName = new SimpleString("jms.queue." + this.actualDest.getPhysicalName());

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e84edecb/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQProducerBrokerExchange.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQProducerBrokerExchange.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQProducerBrokerExchange.java
index e9c4044..b5d8dbd 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQProducerBrokerExchange.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQProducerBrokerExchange.java
@@ -19,8 +19,6 @@ package org.apache.activemq.artemis.core.protocol.openwire.amq;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.apache.activemq.command.Message;
-import org.apache.activemq.command.MessageId;
 import org.apache.activemq.state.ProducerState;
 
 public class AMQProducerBrokerExchange {
@@ -28,7 +26,6 @@ public class AMQProducerBrokerExchange {
    private AMQConnectionContext connectionContext;
    private ProducerState producerState;
    private boolean mutable = true;
-   private AtomicLong lastSendSequenceNumber = new AtomicLong(-1);
    private final FlowControlInfo flowControlInfo = new FlowControlInfo();
 
    public AMQProducerBrokerExchange() {
@@ -57,13 +54,6 @@ public class AMQProducerBrokerExchange {
    }
 
    /**
-    * @return the mutable
-    */
-   public boolean isMutable() {
-      return this.mutable;
-   }
-
-   /**
     * @param mutable the mutable to set
     */
    public void setMutable(boolean mutable) {
@@ -84,75 +74,13 @@ public class AMQProducerBrokerExchange {
       this.producerState = producerState;
    }
 
-   /**
-    * Enforce duplicate suppression using info from persistence adapter
-    *
-    * @return false if message should be ignored as a duplicate
-    */
-   public boolean canDispatch(Message messageSend) {
-      // TODO: auditProduceSequenceIds is never true
-      boolean canDispatch = true;
-      //TODO: DEAD CODE
-//      if (auditProducerSequenceIds && messageSend.isPersistent()) {
-//         final long producerSequenceId = messageSend.getMessageId().getProducerSequenceId();
-//         if (isNetworkProducer) {
-//            // messages are multiplexed on this producer so we need to query the
-//            // persistenceAdapter
-//            long lastStoredForMessageProducer = getStoredSequenceIdForMessage(messageSend.getMessageId());
-//            if (producerSequenceId <= lastStoredForMessageProducer) {
-//               canDispatch = false;
-//            }
-//         }
-//         else if (producerSequenceId <= lastSendSequenceNumber.get()) {
-//            canDispatch = false;
-//            // TODO: WHAT IS THIS?
-//            if (messageSend.isInTransaction()) {
-//
-//
-//            }
-//            else {
-//            }
-//         }
-//         else {
-//            // track current so we can suppress duplicates later in the stream
-//            lastSendSequenceNumber.set(producerSequenceId);
-//         }
-//      }
-      return canDispatch;
-   }
-
-   private long getStoredSequenceIdForMessage(MessageId messageId) {
-      return -1;
-   }
-
    public void setLastStoredSequenceId(long l) {
    }
 
-   public void incrementSend() {
-      flowControlInfo.incrementSend();
-   }
-
    public void blockingOnFlowControl(boolean blockingOnFlowControl) {
       flowControlInfo.setBlockingOnFlowControl(blockingOnFlowControl);
    }
 
-   public boolean isBlockedForFlowControl() {
-      return flowControlInfo.isBlockingOnFlowControl();
-   }
-
-   public void resetFlowControl() {
-      flowControlInfo.reset();
-   }
-
-   public long getTotalTimeBlocked() {
-      return flowControlInfo.getTotalTimeBlocked();
-   }
-
-   public int getPercentageBlocked() {
-      double value = flowControlInfo.getSendsBlocked() / flowControlInfo.getTotalSends();
-      return (int) value * 100;
-   }
-
    public static class FlowControlInfo {
 
       private AtomicBoolean blockingOnFlowControl = new AtomicBoolean();
@@ -160,10 +88,6 @@ public class AMQProducerBrokerExchange {
       private AtomicLong sendsBlocked = new AtomicLong();
       private AtomicLong totalTimeBlocked = new AtomicLong();
 
-      public boolean isBlockingOnFlowControl() {
-         return blockingOnFlowControl.get();
-      }
-
       public void setBlockingOnFlowControl(boolean blockingOnFlowControl) {
          this.blockingOnFlowControl.set(blockingOnFlowControl);
          if (blockingOnFlowControl) {
@@ -171,30 +95,10 @@ public class AMQProducerBrokerExchange {
          }
       }
 
-      public long getTotalSends() {
-         return totalSends.get();
-      }
-
-      public void incrementSend() {
-         this.totalSends.incrementAndGet();
-      }
-
-      public long getSendsBlocked() {
-         return sendsBlocked.get();
-      }
-
       public void incrementSendBlocked() {
          this.sendsBlocked.incrementAndGet();
       }
 
-      public long getTotalTimeBlocked() {
-         return totalTimeBlocked.get();
-      }
-
-      public void incrementTimeBlocked(long time) {
-         this.totalTimeBlocked.addAndGet(time);
-      }
-
       public void reset() {
          blockingOnFlowControl.set(false);
          totalSends.set(0);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e84edecb/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerConsumer.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerConsumer.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerConsumer.java
index 3e7afa5..f198cb7 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerConsumer.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerConsumer.java
@@ -34,6 +34,18 @@ import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
 
 public class AMQServerConsumer extends ServerConsumerImpl {
 
+   // TODO-NOW: remove this once unified
+   AMQConsumer amqConsumer;
+
+   public AMQConsumer getAmqConsumer() {
+      return amqConsumer;
+   }
+
+   /** TODO-NOW: remove this once unified */
+   public void setAmqConsumer(AMQConsumer amqConsumer) {
+      this.amqConsumer = amqConsumer;
+   }
+
    public AMQServerConsumer(long consumerID,
                             AMQServerSession serverSession,
                             QueueBinding binding,

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e84edecb/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
index 0cee3d3..d16d4c8 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
@@ -30,6 +30,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.server.SlowConsumerDetectionListener;
 import org.apache.activemq.artemis.spi.core.remoting.ReadyListener;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ConnectionInfo;
@@ -71,8 +72,6 @@ public class AMQSession implements SessionCallback {
 
    private Map<Long, AMQConsumer> consumers = new ConcurrentHashMap<>();
 
-   private Map<Long, AMQProducer> producers = new HashMap<>();
-
    private AtomicBoolean started = new AtomicBoolean(false);
 
    private TransactionId txId = null;
@@ -121,7 +120,7 @@ public class AMQSession implements SessionCallback {
 
    }
 
-   public void createConsumer(ConsumerInfo info, AMQSession amqSession) throws Exception {
+   public void createConsumer(ConsumerInfo info, AMQSession amqSession, SlowConsumerDetectionListener slowConsumerDetectionListener) throws Exception {
       //check destination
       ActiveMQDestination dest = info.getDestination();
       ActiveMQDestination[] dests = null;
@@ -139,7 +138,7 @@ public class AMQSession implements SessionCallback {
          }
          AMQConsumer consumer = new AMQConsumer(this, d, info, scheduledPool);
 
-         consumer.init();
+         consumer.init(slowConsumerDetectionListener);
          consumerMap.put(d, consumer);
          consumers.put(consumer.getNativeId(), consumer);
       }
@@ -233,20 +232,6 @@ public class AMQSession implements SessionCallback {
       consumers.remove(consumerId);
    }
 
-   public void createProducer(ProducerInfo info) throws Exception {
-      AMQProducer producer = new AMQProducer(this, info);
-      producer.init();
-      producers.put(info.getProducerId().getValue(), producer);
-   }
-
-   public void removeProducer(ProducerInfo info) {
-      removeProducer(info.getProducerId());
-   }
-
-   public void removeProducer(ProducerId id) {
-      producers.remove(id.getValue());
-   }
-
    public SendingResult send(AMQProducerBrokerExchange producerExchange,
                              Message messageSend,
                              boolean sendProducerAck) throws Exception {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e84edecb/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerConsumer.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerConsumer.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerConsumer.java
index 6045e2c..d75efdd 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerConsumer.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerConsumer.java
@@ -25,6 +25,12 @@ import org.apache.activemq.artemis.core.transaction.Transaction;
  */
 public interface ServerConsumer extends Consumer {
 
+   void setlowConsumerDetection(SlowConsumerDetectionListener listener);
+
+   SlowConsumerDetectionListener getSlowConsumerDetecion();
+
+   void fireSlowConsumer();
+
    /**
     * @param protocolContext
     * @see #getProtocolContext()

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e84edecb/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/SlowConsumerDetectionListener.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/SlowConsumerDetectionListener.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/SlowConsumerDetectionListener.java
new file mode 100644
index 0000000..0c60f25
--- /dev/null
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/SlowConsumerDetectionListener.java
@@ -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.
+ */
+
+package org.apache.activemq.artemis.core.server;
+
+public interface SlowConsumerDetectionListener {
+   void onSlowConsumer(ServerConsumer consumer);
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e84edecb/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
index 8bf5d08..86ca36c 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java
@@ -2930,6 +2930,8 @@ public class QueueImpl implements Queue {
                      }
                   }
 
+                  serverConsumer.fireSlowConsumer();
+
                   if (connection != null) {
                      ActiveMQServerLogger.LOGGER.slowConsumerDetected(serverConsumer.getSessionID(), serverConsumer.getID(), getName().toString(), connection.getRemoteAddress(), threshold, consumerRate);
                      if (policy.equals(SlowConsumerPolicy.KILL)) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e84edecb/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
index 422d324..545b4dc 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
@@ -50,6 +50,7 @@ import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.ServerConsumer;
 import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.ServerSession;
+import org.apache.activemq.artemis.core.server.SlowConsumerDetectionListener;
 import org.apache.activemq.artemis.core.server.management.ManagementService;
 import org.apache.activemq.artemis.core.server.management.Notification;
 import org.apache.activemq.artemis.core.transaction.Transaction;
@@ -88,8 +89,6 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
 
    private Object protocolContext;
 
-   private final ActiveMQServer server;
-
    /**
     * We get a readLock when a message is handled, and return the readLock when the message is finally delivered
     * When stopping the consumer we need to get a writeLock to make sure we had all delivery finished
@@ -152,9 +151,8 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
                              final SessionCallback callback,
                              final boolean preAcknowledge,
                              final boolean strictUpdateDeliveryCount,
-                             final ManagementService managementService,
-                             final ActiveMQServer server) throws Exception {
-      this(id, session, binding, filter, started, browseOnly, storageManager, callback, preAcknowledge, strictUpdateDeliveryCount, managementService, true, null, server);
+                             final ManagementService managementService) throws Exception {
+      this(id, session, binding, filter, started, browseOnly, storageManager, callback, preAcknowledge, strictUpdateDeliveryCount, managementService, true, null);
    }
 
    public ServerConsumerImpl(final long id,
@@ -169,8 +167,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
                              final boolean strictUpdateDeliveryCount,
                              final ManagementService managementService,
                              final boolean supportLargeMessage,
-                             final Integer credits,
-                             final ActiveMQServer server) throws Exception {
+                             final Integer credits) throws Exception {
       this.id = id;
 
       this.filter = filter;
@@ -215,8 +212,6 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
             availableCredits.set(credits);
          }
       }
-
-      this.server = server;
    }
 
    @Override
@@ -386,9 +381,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
       }
       finally {
          lockDelivery.readLock().unlock();
-         callback.afterDelivery();
       }
-
    }
 
    @Override
@@ -569,19 +562,12 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
    @Override
    public void setStarted(final boolean started) {
       synchronized (lock) {
-         boolean locked = lockDelivery();
-
-         // This is to make sure nothing would sneak to the client while started = false
-         // the client will stop the session and perform a rollback in certain cases.
-         // in case something sneaks to the client you could get to messaging delivering forever until
-         // you restart the server
+         lockDelivery.writeLock().lock();
          try {
             this.started = browseOnly || started;
          }
          finally {
-            if (locked) {
-               lockDelivery.writeLock().unlock();
-            }
+            lockDelivery.writeLock().unlock();
          }
       }
 
@@ -591,39 +577,22 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
       }
    }
 
-   private boolean lockDelivery() {
-      try {
-         if (!lockDelivery.writeLock().tryLock(30, TimeUnit.SECONDS)) {
-            ActiveMQServerLogger.LOGGER.timeoutLockingConsumer();
-            if (server != null) {
-               server.threadDump();
-            }
-            return false;
-         }
-         return true;
-      }
-      catch (Exception e) {
-         ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e);
-         return false;
-      }
-   }
-
    @Override
    public void setTransferring(final boolean transferring) {
       synchronized (lock) {
-         // This is to make sure that the delivery process has finished any pending delivery
-         // otherwise a message may sneak in on the client while we are trying to stop the consumer
-         boolean locked = lockDelivery();
-         try {
-            this.transferring = transferring;
-         }
-         finally {
-            if (locked) {
-               lockDelivery.writeLock().unlock();
-            }
-         }
+         this.transferring = transferring;
       }
 
+      // This is to make sure that the delivery process has finished any pending delivery
+      // otherwise a message may sneak in on the client while we are trying to stop the consumer
+      try {
+         lockDelivery.writeLock().lock();
+      }
+      finally {
+         lockDelivery.writeLock().unlock();
+      }
+
+
       // Outside the lock
       if (transferring) {
          // And we must wait for any force delivery to be executed - this is executed async so we add a future to the


[06/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/perf/TempKahaStoreQueueTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/perf/TempKahaStoreQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/perf/TempKahaStoreQueueTest.java
deleted file mode 100644
index 2575afd..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/perf/TempKahaStoreQueueTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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.store.kahadb.perf;
-
-import java.io.File;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.perf.SimpleQueueTest;
-import org.apache.activemq.store.kahadb.TempKahaDBStore;
-
-/**
- *
- */
-public class TempKahaStoreQueueTest extends SimpleQueueTest {
-
-   @Override
-   protected void configureBroker(BrokerService answer, String uri) throws Exception {
-      File dataFileDir = new File("target/test-amq-data/perfTest/temp-amqdb");
-      dataFileDir.mkdirs();
-      answer.setDeleteAllMessagesOnStartup(true);
-
-      TempKahaDBStore adaptor = new TempKahaDBStore();
-      adaptor.setDirectory(dataFileDir);
-
-      answer.setDataDirectoryFile(dataFileDir);
-      answer.setPersistenceAdapter(adaptor);
-      answer.addConnector(uri);
-   }
-
-}
-

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/plist/KahaDBFilePendingMessageCursorTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/plist/KahaDBFilePendingMessageCursorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/plist/KahaDBFilePendingMessageCursorTest.java
deleted file mode 100644
index 6626603..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/plist/KahaDBFilePendingMessageCursorTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * 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.store.kahadb.plist;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.*;
-import org.apache.activemq.broker.region.cursors.FilePendingMessageCursor;
-import org.apache.activemq.broker.region.cursors.FilePendingMessageCursorTestSupport;
-import org.apache.activemq.command.ActiveMQMessage;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.MessageId;
-import org.apache.activemq.store.kahadb.disk.page.PageFile;
-import org.apache.activemq.usage.SystemUsage;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-
-/**
- * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
- */
-public class KahaDBFilePendingMessageCursorTest extends FilePendingMessageCursorTestSupport {
-
-   @Test
-   public void testAddRemoveAddIndexSize() throws Exception {
-      brokerService = new BrokerService();
-      brokerService.setUseJmx(false);
-      SystemUsage usage = brokerService.getSystemUsage();
-      usage.getMemoryUsage().setLimit(1024 * 150);
-      String body = new String(new byte[1024]);
-      Destination destination = new Queue(brokerService, new ActiveMQQueue("Q"), null, new DestinationStatistics(), null);
-
-      underTest = new FilePendingMessageCursor(brokerService.getBroker(), "test", false);
-      underTest.setSystemUsage(usage);
-
-      LOG.info("start");
-      final PageFile pageFile = ((PListImpl) underTest.getDiskList()).getPageFile();
-      LOG.info("page count: " + pageFile.getPageCount());
-      LOG.info("free count: " + pageFile.getFreePageCount());
-      LOG.info("content size: " + pageFile.getPageContentSize());
-
-      final long initialPageCount = pageFile.getPageCount();
-
-      final int numMessages = 1000;
-
-      for (int j = 0; j < 10; j++) {
-         // ensure free pages are reused
-         for (int i = 0; i < numMessages; i++) {
-            ActiveMQMessage mqMessage = new ActiveMQMessage();
-            mqMessage.setStringProperty("body", body);
-            mqMessage.setMessageId(new MessageId("1:2:3:" + i));
-            mqMessage.setMemoryUsage(usage.getMemoryUsage());
-            mqMessage.setRegionDestination(destination);
-            underTest.addMessageLast(new IndirectMessageReference(mqMessage));
-         }
-         assertFalse("cursor is not full " + usage.getTempUsage(), underTest.isFull());
-
-         underTest.reset();
-         long receivedCount = 0;
-         while (underTest.hasNext()) {
-            MessageReference ref = underTest.next();
-            underTest.remove();
-            ref.decrementReferenceCount();
-            assertEquals("id is correct", receivedCount++, ref.getMessageId().getProducerSequenceId());
-         }
-         assertEquals("got all messages back", receivedCount, numMessages);
-         LOG.info("page count: " + pageFile.getPageCount());
-         LOG.info("free count: " + pageFile.getFreePageCount());
-         LOG.info("content size: " + pageFile.getPageContentSize());
-      }
-
-      assertEquals("expected page usage", initialPageCount, pageFile.getPageCount() - pageFile.getFreePageCount());
-
-      LOG.info("Destroy");
-      underTest.destroy();
-      LOG.info("page count: " + pageFile.getPageCount());
-      LOG.info("free count: " + pageFile.getFreePageCount());
-      LOG.info("content size: " + pageFile.getPageContentSize());
-      assertEquals("expected page usage", initialPageCount - 1, pageFile.getPageCount() - pageFile.getFreePageCount());
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/plist/PListTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/plist/PListTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/plist/PListTest.java
deleted file mode 100644
index 73adb52..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/plist/PListTest.java
+++ /dev/null
@@ -1,669 +0,0 @@
-/**
- * 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.store.kahadb.plist;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.*;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.activemq.store.PList;
-import org.apache.activemq.store.PListEntry;
-import org.apache.activemq.util.ByteSequence;
-import org.apache.activemq.util.IOHelper;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class PListTest {
-
-   static final Logger LOG = LoggerFactory.getLogger(PListTest.class);
-   private PListStoreImpl store;
-   private PListImpl plist;
-   final ByteSequence payload = new ByteSequence(new byte[400]);
-   final String idSeed = new String("Seed" + Arrays.toString(new byte[1024]));
-   final Vector<Throwable> exceptions = new Vector<>();
-   ExecutorService executor;
-
-   private PListEntry getFirst(PList plist) throws IOException {
-      PList.PListIterator iterator = plist.iterator();
-      try {
-         if (iterator.hasNext()) {
-            return iterator.next();
-         }
-         else {
-            return null;
-         }
-      }
-      finally {
-         iterator.release();
-      }
-   }
-
-   @Test
-   public void testAddLast() throws Exception {
-      final int COUNT = 1000;
-      Map<String, ByteSequence> map = new LinkedHashMap<>();
-      for (int i = 0; i < COUNT; i++) {
-         String test = new String("test" + i);
-         ByteSequence bs = new ByteSequence(test.getBytes());
-         map.put(test, bs);
-         plist.addLast(test, bs);
-      }
-      assertEquals(plist.size(), COUNT);
-      int count = 0;
-      for (ByteSequence bs : map.values()) {
-         String origStr = new String(bs.getData(), bs.getOffset(), bs.getLength());
-         PListEntry entry = plist.get(count);
-         String plistString = new String(entry.getByteSequence().getData(), entry.getByteSequence().getOffset(), entry.getByteSequence().getLength());
-         assertEquals(origStr, plistString);
-         count++;
-      }
-   }
-
-   @Test
-   public void testAddFirst() throws Exception {
-      final int COUNT = 1000;
-      Map<String, ByteSequence> map = new LinkedHashMap<>();
-      for (int i = 0; i < COUNT; i++) {
-         String test = new String("test" + i);
-         ByteSequence bs = new ByteSequence(test.getBytes());
-         map.put(test, bs);
-         plist.addFirst(test, bs);
-      }
-      assertEquals(plist.size(), COUNT);
-      long count = plist.size() - 1;
-      for (ByteSequence bs : map.values()) {
-         String origStr = new String(bs.getData(), bs.getOffset(), bs.getLength());
-         PListEntry entry = plist.get(count);
-         String plistString = new String(entry.getByteSequence().getData(), entry.getByteSequence().getOffset(), entry.getByteSequence().getLength());
-         assertEquals(origStr, plistString);
-         count--;
-      }
-   }
-
-   @Test
-   public void testRemove() throws IOException {
-      doTestRemove(2000);
-   }
-
-   protected void doTestRemove(final int COUNT) throws IOException {
-      Map<String, ByteSequence> map = new LinkedHashMap<>();
-      for (int i = 0; i < COUNT; i++) {
-         String test = new String("test" + i);
-         ByteSequence bs = new ByteSequence(test.getBytes());
-         map.put(test, bs);
-         plist.addLast(test, bs);
-      }
-      assertEquals(plist.size(), COUNT);
-      PListEntry entry = plist.getFirst();
-      while (entry != null) {
-         plist.remove(entry.getId());
-         entry = plist.getFirst();
-      }
-      assertEquals(0, plist.size());
-   }
-
-   @Test
-   public void testDestroy() throws Exception {
-      doTestRemove(1);
-      plist.destroy();
-      assertEquals(0, plist.size());
-   }
-
-   @Test
-   public void testDestroyNonEmpty() throws Exception {
-      final int COUNT = 1000;
-      Map<String, ByteSequence> map = new LinkedHashMap<>();
-      for (int i = 0; i < COUNT; i++) {
-         String test = new String("test" + i);
-         ByteSequence bs = new ByteSequence(test.getBytes());
-         map.put(test, bs);
-         plist.addLast(test, bs);
-      }
-      plist.destroy();
-      assertEquals(0, plist.size());
-   }
-
-   @Test
-   public void testRemoveSecond() throws Exception {
-      plist.addLast("First", new ByteSequence("A".getBytes()));
-      plist.addLast("Second", new ByteSequence("B".getBytes()));
-
-      assertTrue(plist.remove("Second"));
-      assertTrue(plist.remove("First"));
-      assertFalse(plist.remove("doesNotExist"));
-   }
-
-   @Test
-   public void testRemoveSingleEntry() throws Exception {
-      plist.addLast("First", new ByteSequence("A".getBytes()));
-
-      Iterator<PListEntry> iterator = plist.iterator();
-      while (iterator.hasNext()) {
-         iterator.next();
-         iterator.remove();
-      }
-   }
-
-   @Test
-   public void testRemoveSecondPosition() throws Exception {
-      plist.addLast("First", new ByteSequence("A".getBytes()));
-      plist.addLast("Second", new ByteSequence("B".getBytes()));
-
-      assertTrue(plist.remove(1));
-      assertTrue(plist.remove(0));
-      assertFalse(plist.remove(0));
-   }
-
-   @Test
-   public void testConcurrentAddRemove() throws Exception {
-      File directory = store.getDirectory();
-      store.stop();
-      IOHelper.mkdirs(directory);
-      IOHelper.deleteChildren(directory);
-      store = new PListStoreImpl();
-      store.setCleanupInterval(400);
-      store.setDirectory(directory);
-      store.setJournalMaxFileLength(1024 * 5);
-      store.setLazyInit(false);
-      store.start();
-
-      final ByteSequence payload = new ByteSequence(new byte[1024 * 2]);
-
-      final Vector<Throwable> exceptions = new Vector<>();
-      final int iterations = 1000;
-      final int numLists = 10;
-
-      final PList[] lists = new PList[numLists];
-      String threadName = Thread.currentThread().getName();
-      for (int i = 0; i < numLists; i++) {
-         Thread.currentThread().setName("C:" + String.valueOf(i));
-         lists[i] = store.getPList(String.valueOf(i));
-      }
-      Thread.currentThread().setName(threadName);
-
-      executor = Executors.newFixedThreadPool(100);
-      class A implements Runnable {
-
-         @Override
-         public void run() {
-            final String threadName = Thread.currentThread().getName();
-            try {
-               for (int i = 0; i < iterations; i++) {
-                  PList candidate = lists[i % numLists];
-                  Thread.currentThread().setName("ALRF:" + candidate.getName());
-                  synchronized (plistLocks(candidate)) {
-                     Object locator = candidate.addLast(String.valueOf(i), payload);
-                     getFirst(candidate);
-                     assertTrue(candidate.remove(locator));
-                  }
-               }
-            }
-            catch (Exception error) {
-               LOG.error("Unexpcted ex", error);
-               error.printStackTrace();
-               exceptions.add(error);
-            }
-            finally {
-               Thread.currentThread().setName(threadName);
-            }
-         }
-      }
-
-      class B implements Runnable {
-
-         @Override
-         public void run() {
-            final String threadName = Thread.currentThread().getName();
-            try {
-               for (int i = 0; i < iterations; i++) {
-                  PList candidate = lists[i % numLists];
-                  Thread.currentThread().setName("ALRF:" + candidate.getName());
-                  synchronized (plistLocks(candidate)) {
-                     Object locator = candidate.addLast(String.valueOf(i), payload);
-                     getFirst(candidate);
-                     assertTrue(candidate.remove(locator));
-                  }
-               }
-            }
-            catch (Exception error) {
-               error.printStackTrace();
-               exceptions.add(error);
-            }
-            finally {
-               Thread.currentThread().setName(threadName);
-            }
-         }
-      }
-
-      executor.execute(new A());
-      executor.execute(new A());
-      executor.execute(new A());
-      executor.execute(new B());
-      executor.execute(new B());
-      executor.execute(new B());
-
-      executor.shutdown();
-      boolean finishedInTime = executor.awaitTermination(30, TimeUnit.SECONDS);
-
-      assertTrue("no exceptions", exceptions.isEmpty());
-      assertTrue("finished ok", finishedInTime);
-   }
-
-   @Test
-   public void testConcurrentAddLast() throws Exception {
-      File directory = store.getDirectory();
-      store.stop();
-      IOHelper.mkdirs(directory);
-      IOHelper.deleteChildren(directory);
-      store = new PListStoreImpl();
-      store.setDirectory(directory);
-      store.start();
-
-      final int numThreads = 20;
-      final int iterations = 1000;
-      executor = Executors.newFixedThreadPool(100);
-      for (int i = 0; i < numThreads; i++) {
-         new Job(i, PListTest.TaskType.ADD, iterations).run();
-      }
-
-      for (int i = 0; i < numThreads; i++) {
-         executor.execute(new Job(i, PListTest.TaskType.ITERATE, iterations));
-      }
-
-      for (int i = 0; i < 100; i++) {
-         executor.execute(new Job(i + 20, PListTest.TaskType.ADD, 100));
-      }
-
-      executor.shutdown();
-      boolean finishedInTime = executor.awaitTermination(60 * 5, TimeUnit.SECONDS);
-      assertTrue("finished ok", finishedInTime);
-   }
-
-   @Test
-   public void testOverFlow() throws Exception {
-      File directory = store.getDirectory();
-      store.stop();
-      IOHelper.mkdirs(directory);
-      IOHelper.deleteChildren(directory);
-      store = new PListStoreImpl();
-      store.setDirectory(directory);
-      store.start();
-
-      for (int i = 0; i < 2000; i++) {
-         new Job(i, PListTest.TaskType.ADD, 5).run();
-
-      }
-      LOG.info("After Load index file: " + store.pageFile.getFile().length());
-      LOG.info("After remove index file: " + store.pageFile.getFile().length());
-   }
-
-   @Test
-   public void testConcurrentAddRemoveWithPreload() throws Exception {
-      File directory = store.getDirectory();
-      store.stop();
-      IOHelper.mkdirs(directory);
-      IOHelper.deleteChildren(directory);
-      store = new PListStoreImpl();
-      store.setDirectory(directory);
-      store.setJournalMaxFileLength(1024 * 5);
-      store.setCleanupInterval(5000);
-      store.setIndexWriteBatchSize(500);
-      store.start();
-
-      final int iterations = 500;
-      final int numLists = 10;
-
-      // prime the store
-
-      // create/delete
-      LOG.info("create");
-      for (int i = 0; i < numLists; i++) {
-         new Job(i, PListTest.TaskType.CREATE, iterations).run();
-      }
-
-      LOG.info("delete");
-      for (int i = 0; i < numLists; i++) {
-         new Job(i, PListTest.TaskType.DELETE, iterations).run();
-      }
-
-      LOG.info("fill");
-      for (int i = 0; i < numLists; i++) {
-         new Job(i, PListTest.TaskType.ADD, iterations).run();
-      }
-      LOG.info("remove");
-      for (int i = 0; i < numLists; i++) {
-         new Job(i, PListTest.TaskType.REMOVE, iterations).run();
-      }
-
-      LOG.info("check empty");
-      for (int i = 0; i < numLists; i++) {
-         assertEquals("empty " + i, 0, store.getPList("List-" + i).size());
-      }
-
-      LOG.info("delete again");
-      for (int i = 0; i < numLists; i++) {
-         new Job(i, PListTest.TaskType.DELETE, iterations).run();
-      }
-
-      LOG.info("fill again");
-      for (int i = 0; i < numLists; i++) {
-         new Job(i, PListTest.TaskType.ADD, iterations).run();
-      }
-
-      LOG.info("parallel add and remove");
-      executor = Executors.newFixedThreadPool(numLists * 2);
-      for (int i = 0; i < numLists * 2; i++) {
-         executor.execute(new Job(i, i >= numLists ? PListTest.TaskType.ADD : PListTest.TaskType.REMOVE, iterations));
-      }
-
-      executor.shutdown();
-      LOG.info("wait for parallel work to complete");
-      boolean finishedInTime = executor.awaitTermination(60 * 5, TimeUnit.SECONDS);
-      assertTrue("no exceptions", exceptions.isEmpty());
-      assertTrue("finished ok", finishedInTime);
-   }
-
-   // for non determinant issues, increasing this may help diagnose
-   final int numRepeats = 1;
-
-   @Test
-   public void testRepeatStressWithCache() throws Exception {
-      for (int i = 0; i < numRepeats; i++) {
-         do_testConcurrentAddIterateRemove(true);
-      }
-   }
-
-   @Test
-   public void testRepeatStressWithOutCache() throws Exception {
-      for (int i = 0; i < numRepeats; i++) {
-         do_testConcurrentAddIterateRemove(false);
-      }
-   }
-
-   public void do_testConcurrentAddIterateRemove(boolean enablePageCache) throws Exception {
-      File directory = store.getDirectory();
-      store.stop();
-      IOHelper.mkdirs(directory);
-      IOHelper.deleteChildren(directory);
-      store = new PListStoreImpl();
-      store.setIndexEnablePageCaching(enablePageCache);
-      store.setIndexPageSize(2 * 1024);
-      store.setDirectory(directory);
-      store.start();
-
-      final int iterations = 500;
-      final int numLists = 10;
-
-      LOG.info("create");
-      for (int i = 0; i < numLists; i++) {
-         new Job(i, PListTest.TaskType.CREATE, iterations).run();
-      }
-
-      LOG.info("fill");
-      for (int i = 0; i < numLists; i++) {
-         new Job(i, PListTest.TaskType.ADD, iterations).run();
-      }
-
-      LOG.info("parallel add and remove");
-      executor = Executors.newFixedThreadPool(400);
-      final int numProducer = 5;
-      final int numConsumer = 10;
-      for (int i = 0; i < numLists; i++) {
-         for (int j = 0; j < numProducer; j++) {
-            executor.execute(new Job(i, PListTest.TaskType.ADD, iterations * 2));
-         }
-         for (int k = 0; k < numConsumer; k++) {
-            executor.execute(new Job(i, TaskType.ITERATE_REMOVE, iterations / 4));
-         }
-      }
-
-      for (int i = numLists; i < numLists * 10; i++) {
-         executor.execute(new Job(i, PListTest.TaskType.ADD, iterations));
-      }
-
-      executor.shutdown();
-      LOG.info("wait for parallel work to complete");
-      boolean shutdown = executor.awaitTermination(60 * 60, TimeUnit.SECONDS);
-      assertTrue("no exceptions: " + exceptions, exceptions.isEmpty());
-      assertTrue("test did not  timeout ", shutdown);
-   }
-
-   @Test
-   public void testConcurrentAddIterate() throws Exception {
-      File directory = store.getDirectory();
-      store.stop();
-      IOHelper.mkdirs(directory);
-      IOHelper.deleteChildren(directory);
-      store = new PListStoreImpl();
-      store.setIndexPageSize(2 * 1024);
-      store.setJournalMaxFileLength(1024 * 1024);
-      store.setDirectory(directory);
-      store.setCleanupInterval(-1);
-      store.setIndexEnablePageCaching(false);
-      store.setIndexWriteBatchSize(100);
-      store.start();
-
-      final int iterations = 250;
-      final int numLists = 10;
-
-      LOG.info("create");
-      for (int i = 0; i < numLists; i++) {
-         new Job(i, PListTest.TaskType.CREATE, iterations).run();
-      }
-
-      LOG.info("parallel add and iterate");
-      // We want a lot of adds occurring so that new free pages get created
-      // along
-      // with overlapping seeks from the iterators so that we are likely to
-      // seek into
-      // some bad area in the page file.
-      executor = Executors.newFixedThreadPool(100);
-      final int numProducer = 30;
-      final int numConsumer = 10;
-      for (int i = 0; i < numLists; i++) {
-         for (int j = 0; j < numProducer; j++) {
-            executor.execute(new Job(i, PListTest.TaskType.ADD, iterations));
-         }
-         for (int k = 0; k < numConsumer; k++) {
-            executor.execute(new Job(i, TaskType.ITERATE, iterations * 2));
-         }
-      }
-
-      executor.shutdown();
-      LOG.info("wait for parallel work to complete");
-      boolean shutdown = executor.awaitTermination(5 * 60, TimeUnit.SECONDS);
-      assertTrue("no exceptions: " + exceptions, exceptions.isEmpty());
-      assertTrue("test did not  timeout ", shutdown);
-      LOG.info("Num dataFiles:" + store.getJournal().getFiles().size());
-   }
-
-   enum TaskType {
-      CREATE, DELETE, ADD, REMOVE, ITERATE, ITERATE_REMOVE
-   }
-
-   class Job implements Runnable {
-
-      int id;
-      TaskType task;
-      int iterations;
-
-      public Job(int id, TaskType t, int iterations) {
-         this.id = id;
-         this.task = t;
-         this.iterations = iterations;
-      }
-
-      @Override
-      public void run() {
-         final String threadName = Thread.currentThread().getName();
-         try {
-            PListImpl plist = null;
-            switch (task) {
-               case CREATE:
-                  Thread.currentThread().setName("C:" + id);
-                  plist = store.getPList(String.valueOf(id));
-                  LOG.info("Job-" + id + ", CREATE");
-                  break;
-               case DELETE:
-                  Thread.currentThread().setName("D:" + id);
-                  store.removePList(String.valueOf(id));
-                  break;
-               case ADD:
-                  Thread.currentThread().setName("A:" + id);
-                  plist = store.getPList(String.valueOf(id));
-
-                  for (int j = 0; j < iterations; j++) {
-                     synchronized (plistLocks(plist)) {
-                        if (exceptions.isEmpty()) {
-                           plist.addLast("PL>" + id + idSeed + "-" + j, payload);
-                        }
-                        else {
-                           break;
-                        }
-                     }
-                  }
-
-                  if (exceptions.isEmpty()) {
-                     LOG.info("Job-" + id + ", Add, done: " + iterations);
-                  }
-                  break;
-               case REMOVE:
-                  Thread.currentThread().setName("R:" + id);
-                  plist = store.getPList(String.valueOf(id));
-                  synchronized (plistLocks(plist)) {
-
-                     for (int j = iterations - 1; j >= 0; j--) {
-                        plist.remove("PL>" + id + idSeed + "-" + j);
-                        if (j > 0 && j % (iterations / 2) == 0) {
-                           LOG.info("Job-" + id + " Done remove: " + j);
-                        }
-                     }
-                  }
-                  break;
-               case ITERATE:
-                  Thread.currentThread().setName("I:" + id);
-                  plist = store.getPList(String.valueOf(id));
-                  int iterateCount = 0;
-                  synchronized (plistLocks(plist)) {
-                     if (exceptions.isEmpty()) {
-                        Iterator<PListEntry> iterator = plist.iterator();
-                        while (iterator.hasNext() && exceptions.isEmpty()) {
-                           iterator.next();
-                           iterateCount++;
-                        }
-
-                        // LOG.info("Job-" + id + " Done iterate: it=" +
-                        // iterator + ", count:" + iterateCount +
-                        // ", size:" + plist.size());
-                        if (plist.size() != iterateCount) {
-                           System.err.println("Count Wrong: " + iterator);
-                        }
-                        assertEquals("iterate got all " + id + " iterator:" + iterator, plist.size(), iterateCount);
-                     }
-                  }
-                  break;
-
-               case ITERATE_REMOVE:
-                  Thread.currentThread().setName("IRM:" + id);
-                  plist = store.getPList(String.valueOf(id));
-
-                  int removeCount = 0;
-                  synchronized (plistLocks(plist)) {
-
-                     Iterator<PListEntry> removeIterator = plist.iterator();
-
-                     while (removeIterator.hasNext()) {
-                        removeIterator.next();
-                        removeIterator.remove();
-                        if (removeCount++ > iterations) {
-                           break;
-                        }
-                     }
-                  }
-                  LOG.info("Job-" + id + " Done remove: " + removeCount);
-                  break;
-
-               default:
-            }
-
-         }
-         catch (Exception e) {
-            LOG.warn("Job[" + id + "] caught exception: " + e.getMessage());
-            e.printStackTrace();
-            exceptions.add(e);
-            if (executor != null) {
-               executor.shutdownNow();
-            }
-         }
-         finally {
-            Thread.currentThread().setName(threadName);
-         }
-      }
-   }
-
-   final Map<PList, Object> locks = new HashMap<>();
-
-   private Object plistLocks(PList plist) {
-      Object lock = null;
-      synchronized (locks) {
-         if (locks.containsKey(plist)) {
-            lock = locks.get(plist);
-         }
-         else {
-            lock = new Object();
-            locks.put(plist, lock);
-         }
-      }
-      return lock;
-   }
-
-   @Before
-   public void setUp() throws Exception {
-      File directory = new File("target/test/PlistDB");
-      IOHelper.mkdirs(directory);
-      IOHelper.deleteChildren(directory);
-      startStore(directory);
-
-   }
-
-   protected void startStore(File directory) throws Exception {
-      store = new PListStoreImpl();
-      store.setDirectory(directory);
-      store.start();
-      plist = store.getPList("main");
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      if (executor != null) {
-         executor.shutdownNow();
-      }
-      store.stop();
-      exceptions.clear();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/shared.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/shared.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/shared.xml
deleted file mode 100644
index 5042df8..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/shared.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?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">
-
-    <!-- normal ActiveMQ XML config which is less verbose & can be validated -->
-    <amq:broker brokerName="brokerConfigTest" populateJMSXUserID="false"
-                useLoggingForShutdownErrors="true" useJmx="true"
-                persistent="true" vmConnectorURI="vm://javacoola"
-                useShutdownHook="false" deleteAllMessagesOnStartup="true">
-
-        <amq:persistenceAdapter>
-            <amq:kahaDB directory = "target/activemq-data">
-                <amq:locker>
-                    <amq:shared-file-locker lockAcquireSleepInterval="5000"/>
-                </amq:locker>
-            </amq:kahaDB>
-        </amq:persistenceAdapter>
-
-        <amq:systemUsage>
-            <amq:systemUsage>
-                <amq:memoryUsage>
-                    <amq:memoryUsage limit="10 mb" percentUsageMinDelta="20"/>
-                </amq:memoryUsage>
-                <amq:storeUsage>
-                    <amq:storeUsage limit="1 gb" name="foo"/>
-                </amq:storeUsage>
-                <amq:tempUsage>
-                    <amq:tempUsage limit="100 mb"/>
-                </amq:tempUsage>
-            </amq:systemUsage>
-        </amq:systemUsage>
-
-        <amq:transportConnectors>
-            <amq:transportConnector uri="tcp://localhost:61635"/>
-        </amq:transportConnectors>
-
-    </amq:broker>
-
-</beans>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/leveldb/LevelDBNegativeQueueTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/leveldb/LevelDBNegativeQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/leveldb/LevelDBNegativeQueueTest.java
deleted file mode 100644
index 3c28b3d..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/leveldb/LevelDBNegativeQueueTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 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.store.leveldb;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.cursors.NegativeQueueTest;
-import org.apache.activemq.leveldb.LevelDBStore;
-import org.apache.activemq.util.IOHelper;
-
-import java.io.File;
-
-public class LevelDBNegativeQueueTest extends NegativeQueueTest {
-
-   @Override
-   protected void configureBroker(BrokerService answer) throws Exception {
-      super.configureBroker(answer);
-      LevelDBStore levelDBStore = new LevelDBStore();
-      File directory = new File("target/activemq-data/leveldb");
-      IOHelper.deleteChildren(directory);
-      levelDBStore.setDirectory(directory);
-      levelDBStore.deleteAllMessages();
-      answer.setPersistenceAdapter(levelDBStore);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/leveldb/LevelDBStoreBrokerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/leveldb/LevelDBStoreBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/leveldb/LevelDBStoreBrokerTest.java
deleted file mode 100644
index 99583d5..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/leveldb/LevelDBStoreBrokerTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * 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.store.leveldb;
-
-import java.io.File;
-
-import junit.framework.Test;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.BrokerTest;
-import org.apache.activemq.store.kahadb.KahaDBStore;
-import org.apache.activemq.util.IOHelper;
-import org.apache.activemq.leveldb.LevelDBStore;
-
-/**
- * Once the wire format is completed we can test against real persistence storage.
- */
-public class LevelDBStoreBrokerTest extends BrokerTest {
-
-   @Override
-   protected void setUp() throws Exception {
-      this.setAutoFail(true);
-      super.setUp();
-   }
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      BrokerService broker = new BrokerService();
-      LevelDBStore levelDBStore = new LevelDBStore();
-      File directory = new File("target/activemq-data/leveldb");
-      IOHelper.deleteChildren(directory);
-      levelDBStore.setDirectory(directory);
-      levelDBStore.deleteAllMessages();
-      broker.setPersistenceAdapter(levelDBStore);
-      return broker;
-   }
-
-   protected BrokerService createRestartedBroker() throws Exception {
-      BrokerService broker = new BrokerService();
-      KahaDBStore kaha = new KahaDBStore();
-      kaha.setDirectory(new File("target/activemq-data/leveldb"));
-      broker.setPersistenceAdapter(kaha);
-      return broker;
-   }
-
-   public static Test suite() {
-      return suite(LevelDBStoreBrokerTest.class);
-   }
-
-   public static void main(String[] args) {
-      junit.textui.TestRunner.run(suite());
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/schedulerDB/legacy/db-1.log
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/schedulerDB/legacy/db-1.log b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/schedulerDB/legacy/db-1.log
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/schedulerDB/legacy/scheduleDB.data
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/schedulerDB/legacy/scheduleDB.data b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/schedulerDB/legacy/scheduleDB.data
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/schedulerDB/legacy/scheduleDB.redo
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/schedulerDB/legacy/scheduleDB.redo b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/schedulerDB/legacy/scheduleDB.redo
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/streams/JMSInputStreamTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/streams/JMSInputStreamTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/streams/JMSInputStreamTest.java
deleted file mode 100644
index 38f0213..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/streams/JMSInputStreamTest.java
+++ /dev/null
@@ -1,286 +0,0 @@
-/**
- * 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.streams;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-
-import junit.framework.Test;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQInputStream;
-import org.apache.activemq.ActiveMQOutputStream;
-import org.apache.activemq.JmsTestSupport;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-
-/**
- * JMSInputStreamTest
- */
-@Deprecated
-public class JMSInputStreamTest extends JmsTestSupport {
-
-   public Destination destination;
-   protected DataOutputStream out;
-   protected DataInputStream in;
-   private ActiveMQConnection connection2;
-
-   private ActiveMQInputStream amqIn;
-   private ActiveMQOutputStream amqOut;
-
-   public static Test suite() {
-      return suite(JMSInputStreamTest.class);
-   }
-
-   public static void main(String[] args) {
-      junit.textui.TestRunner.run(suite());
-   }
-
-   public void initCombos() {
-      addCombinationValues("destination", new Object[]{new ActiveMQQueue("TEST.QUEUE"), new ActiveMQTopic("TEST.TOPIC")});
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      super.setAutoFail(true);
-      super.setUp();
-   }
-
-   private void setUpConnection(Map<String, Object> props, long timeout) throws JMSException {
-      connection2 = (ActiveMQConnection) factory.createConnection(userName, password);
-      connections.add(connection2);
-      if (props != null) {
-         amqOut = (ActiveMQOutputStream) connection.createOutputStream(destination, props, Message.DEFAULT_DELIVERY_MODE, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
-      }
-      else {
-         amqOut = (ActiveMQOutputStream) connection.createOutputStream(destination);
-      }
-
-      out = new DataOutputStream(amqOut);
-      if (timeout == -1) {
-         amqIn = (ActiveMQInputStream) connection2.createInputStream(destination);
-      }
-      else {
-         amqIn = (ActiveMQInputStream) connection2.createInputStream(destination, null, false, timeout);
-      }
-      in = new DataInputStream(amqIn);
-   }
-
-   /*
-    * @see TestCase#tearDown()
-    */
-   @Override
-   protected void tearDown() throws Exception {
-      super.tearDown();
-   }
-
-   /**
-    * Test for AMQ-3010
-    */
-   public void testInputStreamTimeout() throws Exception {
-      long timeout = 500;
-
-      setUpConnection(null, timeout);
-      try {
-         in.read();
-         fail();
-      }
-      catch (ActiveMQInputStream.ReadTimeoutException e) {
-         // timeout reached, everything ok
-      }
-      in.close();
-   }
-
-   // Test for AMQ-2988
-   public void testStreamsWithProperties() throws Exception {
-      String name1 = "PROPERTY_1";
-      String name2 = "PROPERTY_2";
-      String value1 = "VALUE_1";
-      String value2 = "VALUE_2";
-      Map<String, Object> jmsProperties = new HashMap<>();
-      jmsProperties.put(name1, value1);
-      jmsProperties.put(name2, value2);
-      setUpConnection(jmsProperties, -1);
-
-      out.writeInt(4);
-      out.flush();
-      assertTrue(in.readInt() == 4);
-      out.writeFloat(2.3f);
-      out.flush();
-      assertTrue(in.readFloat() == 2.3f);
-      String str = "this is a test string";
-      out.writeUTF(str);
-      out.flush();
-      assertTrue(in.readUTF().equals(str));
-      for (int i = 0; i < 100; i++) {
-         out.writeLong(i);
-      }
-      out.flush();
-
-      // check properties before we try to read the stream
-      checkProperties(jmsProperties);
-
-      for (int i = 0; i < 100; i++) {
-         assertTrue(in.readLong() == i);
-      }
-
-      // check again after read was done
-      checkProperties(jmsProperties);
-   }
-
-   public void testStreamsWithPropertiesOnlyOnFirstMessage() throws Exception {
-      String name1 = "PROPERTY_1";
-      String name2 = "PROPERTY_2";
-      String value1 = "VALUE_1";
-      String value2 = "VALUE_2";
-      Map<String, Object> jmsProperties = new HashMap<>();
-      jmsProperties.put(name1, value1);
-      jmsProperties.put(name2, value2);
-
-      ActiveMQDestination dest = (ActiveMQDestination) destination;
-
-      if (dest.isQueue()) {
-         destination = new ActiveMQQueue(dest.getPhysicalName() + "?producer.addPropertiesOnFirstMsgOnly=true");
-      }
-      else {
-         destination = new ActiveMQTopic(dest.getPhysicalName() + "?producer.addPropertiesOnFirstMsgOnly=true");
-      }
-
-      setUpConnection(jmsProperties, -1);
-
-      assertTrue(amqOut.isAddPropertiesOnFirstMsgOnly());
-
-      out.writeInt(4);
-      out.flush();
-      assertTrue(in.readInt() == 4);
-      out.writeFloat(2.3f);
-      out.flush();
-      assertTrue(in.readFloat() == 2.3f);
-      String str = "this is a test string";
-      out.writeUTF(str);
-      out.flush();
-      assertTrue(in.readUTF().equals(str));
-      for (int i = 0; i < 100; i++) {
-         out.writeLong(i);
-      }
-      out.flush();
-
-      // check properties before we try to read the stream
-      checkProperties(jmsProperties);
-
-      for (int i = 0; i < 100; i++) {
-         assertTrue(in.readLong() == i);
-      }
-
-      // check again after read was done
-      checkProperties(jmsProperties);
-   }
-
-   // check if the received stream has the properties set
-   // Test for AMQ-2988
-   private void checkProperties(Map<String, Object> jmsProperties) throws IOException {
-      Map<String, Object> receivedJmsProps = amqIn.getJMSProperties();
-
-      // we should at least have the same amount or more properties
-      assertTrue(jmsProperties.size() <= receivedJmsProps.size());
-
-      // check the properties to see if we have everything in there
-      Iterator<String> propsIt = jmsProperties.keySet().iterator();
-      while (propsIt.hasNext()) {
-         String key = propsIt.next();
-         assertTrue(receivedJmsProps.containsKey(key));
-         assertEquals(jmsProperties.get(key), receivedJmsProps.get(key));
-      }
-   }
-
-   public void testLarge() throws Exception {
-      setUpConnection(null, -1);
-
-      final int testData = 23;
-      final int dataLength = 4096;
-      final int count = 1024;
-      byte[] data = new byte[dataLength];
-      for (int i = 0; i < data.length; i++) {
-         data[i] = testData;
-      }
-      final AtomicBoolean complete = new AtomicBoolean(false);
-      Thread runner = new Thread(new Runnable() {
-         @Override
-         public void run() {
-            try {
-               for (int x = 0; x < count; x++) {
-                  byte[] b = new byte[2048];
-                  in.readFully(b);
-                  for (int i = 0; i < b.length; i++) {
-                     assertTrue(b[i] == testData);
-                  }
-               }
-               complete.set(true);
-               synchronized (complete) {
-                  complete.notify();
-               }
-            }
-            catch (Exception ex) {
-               ex.printStackTrace();
-            }
-         }
-      });
-      runner.start();
-      for (int i = 0; i < count; i++) {
-         out.write(data);
-      }
-      out.flush();
-      synchronized (complete) {
-         while (!complete.get()) {
-            complete.wait(30000);
-         }
-      }
-      assertTrue(complete.get());
-   }
-
-   public void testStreams() throws Exception {
-      setUpConnection(null, -1);
-      out.writeInt(4);
-      out.flush();
-      assertTrue(in.readInt() == 4);
-      out.writeFloat(2.3f);
-      out.flush();
-      assertTrue(in.readFloat() == 2.3f);
-      String str = "this is a test string";
-      out.writeUTF(str);
-      out.flush();
-      assertTrue(in.readUTF().equals(str));
-      for (int i = 0; i < 100; i++) {
-         out.writeLong(i);
-      }
-      out.flush();
-
-      for (int i = 0; i < 100; i++) {
-         assertTrue(in.readLong() == i);
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsResourceProvider.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsResourceProvider.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsResourceProvider.java
new file mode 100755
index 0000000..45be088
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsResourceProvider.java
@@ -0,0 +1,258 @@
+/**
+ * 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.test;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionConsumer;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.ServerSessionPool;
+import javax.jms.Session;
+import javax.jms.Topic;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+
+/**
+ *
+ */
+public class JmsResourceProvider {
+
+    private String serverUri = "vm://localhost?broker.persistent=false";
+    private boolean transacted;
+    private int ackMode = Session.AUTO_ACKNOWLEDGE;
+    private boolean isTopic;
+    private int deliveryMode = DeliveryMode.PERSISTENT;
+    private String durableName = "DummyName";
+    private String clientID = getClass().getName();
+
+    /**
+     * Creates a connection factory.
+     *
+     * @see org.apache.activemq.test.JmsResourceProvider#createConnectionFactory()
+     */
+    public ConnectionFactory createConnectionFactory() throws Exception {
+        return new ActiveMQConnectionFactory(serverUri);
+    }
+
+    /**
+     * Creates a connection.
+     *
+     * @see org.apache.activemq.test.JmsResourceProvider#createConnection(javax.jms.ConnectionFactory)
+     */
+    public Connection createConnection(ConnectionFactory cf) throws JMSException {
+        Connection connection = cf.createConnection();
+        if (getClientID() != null) {
+            connection.setClientID(getClientID());
+        }
+        return connection;
+    }
+
+    /**
+     * @see org.apache.activemq.test.JmsResourceProvider#createSession(javax.jms.Connection)
+     */
+    public Session createSession(Connection conn) throws JMSException {
+        return conn.createSession(transacted, ackMode);
+    }
+
+    /**
+     * @see org.apache.activemq.test.JmsResourceProvider#createConsumer(javax.jms.Session,
+     *      javax.jms.Destination)
+     */
+    public MessageConsumer createConsumer(Session session, Destination destination) throws JMSException {
+        if (isDurableSubscriber()) {
+            return session.createDurableSubscriber((Topic)destination, durableName);
+        }
+        return session.createConsumer(destination);
+    }
+
+    /**
+     * Creates a connection for a consumer.
+     *
+     * @param ssp - ServerSessionPool
+     * @return ConnectionConsumer
+     */
+    public ConnectionConsumer createConnectionConsumer(Connection connection, Destination destination, ServerSessionPool ssp) throws JMSException {
+        return connection.createConnectionConsumer(destination, null, ssp, 1);
+    }
+
+    /**
+     * Creates a producer.
+     *
+     * @see org.apache.activemq.test.JmsResourceProvider#createProducer(javax.jms.Session,
+     *      javax.jms.Destination)
+     */
+    public MessageProducer createProducer(Session session, Destination destination) throws JMSException {
+        MessageProducer producer = session.createProducer(destination);
+        producer.setDeliveryMode(deliveryMode);
+        return producer;
+    }
+
+    /**
+     * Creates a destination, which can either a topic or a queue.
+     *
+     * @see org.apache.activemq.test.JmsResourceProvider#createDestination(javax.jms.Session,
+     *      String)
+     */
+    public Destination createDestination(Session session, String name) throws JMSException {
+        if (isTopic) {
+            return session.createTopic("TOPIC." + name);
+        } else {
+            return session.createQueue("QUEUE." + name);
+        }
+    }
+
+    /**
+     * Returns true if the subscriber is durable.
+     *
+     * @return isDurableSubscriber
+     */
+    public boolean isDurableSubscriber() {
+        return isTopic && durableName != null;
+    }
+
+    /**
+     * Returns the acknowledgement mode.
+     *
+     * @return Returns the ackMode.
+     */
+    public int getAckMode() {
+        return ackMode;
+    }
+
+    /**
+     * Sets the acnknowledgement mode.
+     *
+     * @param ackMode The ackMode to set.
+     */
+    public void setAckMode(int ackMode) {
+        this.ackMode = ackMode;
+    }
+
+    /**
+     * Returns true if the destination is a topic, false if the destination is a
+     * queue.
+     *
+     * @return Returns the isTopic.
+     */
+    public boolean isTopic() {
+        return isTopic;
+    }
+
+    /**
+     * @param isTopic The isTopic to set.
+     */
+    public void setTopic(boolean isTopic) {
+        this.isTopic = isTopic;
+    }
+
+    /**
+     * Returns the server URI.
+     *
+     * @return Returns the serverUri.
+     */
+    public String getServerUri() {
+        return serverUri;
+    }
+
+    /**
+     * Sets the server URI.
+     *
+     * @param serverUri - the server URI to set.
+     */
+    public void setServerUri(String serverUri) {
+        this.serverUri = serverUri;
+    }
+
+    /**
+     * Return true if the session is transacted.
+     *
+     * @return Returns the transacted.
+     */
+    public boolean isTransacted() {
+        return transacted;
+    }
+
+    /**
+     * Sets the session to be transacted.
+     *
+     * @param transacted
+     */
+    public void setTransacted(boolean transacted) {
+        this.transacted = transacted;
+        if (transacted) {
+            setAckMode(Session.SESSION_TRANSACTED);
+        }
+    }
+
+    /**
+     * Returns the delivery mode.
+     *
+     * @return deliveryMode
+     */
+    public int getDeliveryMode() {
+        return deliveryMode;
+    }
+
+    /**
+     * Sets the delivery mode.
+     *
+     * @param deliveryMode
+     */
+    public void setDeliveryMode(int deliveryMode) {
+        this.deliveryMode = deliveryMode;
+    }
+
+    /**
+     * Returns the client id.
+     *
+     * @return clientID
+     */
+    public String getClientID() {
+        return clientID;
+    }
+
+    /**
+     * Sets the client id.
+     *
+     * @param clientID
+     */
+    public void setClientID(String clientID) {
+        this.clientID = clientID;
+    }
+
+    /**
+     * Returns the durable name of the provider.
+     *
+     * @return durableName
+     */
+    public String getDurableName() {
+        return durableName;
+    }
+
+    /**
+     * Sets the durable name of the provider.
+     *
+     * @param durableName
+     */
+    public void setDurableName(String durableName) {
+        this.durableName = durableName;
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/TestSupport.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/TestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/TestSupport.java
new file mode 100755
index 0000000..be32877
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/TestSupport.java
@@ -0,0 +1,256 @@
+/**
+ * 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.test;
+
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.TextMessage;
+import java.io.File;
+import java.lang.reflect.Array;
+
+import junit.framework.TestCase;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.command.ActiveMQMessage;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.command.ActiveMQTopic;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Useful base class for unit test cases
+ *
+ *
+ */
+public abstract class TestSupport extends TestCase {
+    private static final Logger LOG = LoggerFactory.getLogger(TestSupport.class);
+
+    protected ActiveMQConnectionFactory connectionFactory;
+    protected boolean topic = true;
+
+    public TestSupport() {
+        super();
+    }
+
+    public TestSupport(String name) {
+        super(name);
+    }
+
+    /**
+     * Creates an ActiveMQMessage.
+     *
+     * @return ActiveMQMessage
+     */
+    protected ActiveMQMessage createMessage() {
+        return new ActiveMQMessage();
+    }
+
+    /**
+     * Creates a destination.
+     *
+     * @param subject - topic or queue name.
+     * @return Destination - either an ActiveMQTopic or ActiveMQQUeue.
+     */
+    protected Destination createDestination(String subject) {
+        if (topic) {
+            return new ActiveMQTopic(subject);
+        } else {
+            return new ActiveMQQueue(subject);
+        }
+    }
+
+    /**
+     * Tests if firstSet and secondSet are equal.
+     *
+     * @param messsage - string to be displayed when the assertion fails.
+     * @param firstSet[] - set of messages to be compared with its counterpart
+     *                in the secondset.
+     * @param secondSet[] - set of messages to be compared with its counterpart
+     *                in the firstset.
+     * @throws javax.jms.JMSException
+     */
+    protected void assertTextMessagesEqual(Message[] firstSet, Message[] secondSet) throws JMSException {
+        assertTextMessagesEqual("", firstSet, secondSet);
+    }
+
+    /**
+     * Tests if firstSet and secondSet are equal.
+     *
+     * @param messsage - string to be displayed when the assertion fails.
+     * @param firstSet[] - set of messages to be compared with its counterpart
+     *                in the secondset.
+     * @param secondSet[] - set of messages to be compared with its counterpart
+     *                in the firstset.
+     */
+    protected void assertTextMessagesEqual(String messsage, Message[] firstSet, Message[] secondSet) throws JMSException {
+        assertEquals("Message count does not match: " + messsage, firstSet.length, secondSet.length);
+
+        for (int i = 0; i < secondSet.length; i++) {
+            TextMessage m1 = (TextMessage)firstSet[i];
+            TextMessage m2 = (TextMessage)secondSet[i];
+            assertTextMessageEqual("Message " + (i + 1) + " did not match : ", m1, m2);
+        }
+    }
+
+    /**
+     * Tests if m1 and m2 are equal.
+     *
+     * @param m1 - message to be compared with m2.
+     * @param m2 - message to be compared with m1.
+     * @throws javax.jms.JMSException
+     */
+    protected void assertEquals(TextMessage m1, TextMessage m2) throws JMSException {
+        assertEquals("", m1, m2);
+    }
+
+    /**
+     * Tests if m1 and m2 are equal.
+     *
+     * @param message - string to be displayed when the assertion fails.
+     * @param m1 - message to be compared with m2.
+     * @param m2 - message to be compared with m1.
+     */
+    protected void assertTextMessageEqual(String message, TextMessage m1, TextMessage m2) throws JMSException {
+        assertFalse(message + ": expected {" + m1 + "}, but was {" + m2 + "}", m1 == null ^ m2 == null);
+
+        if (m1 == null) {
+            return;
+        }
+
+        assertEquals(message, m1.getText(), m2.getText());
+    }
+
+    /**
+     * Tests if m1 and m2 are equal.
+     *
+     * @param m1 - message to be compared with m2.
+     * @param m2 - message to be compared with m1.
+     * @throws javax.jms.JMSException
+     */
+    protected void assertEquals(Message m1, Message m2) throws JMSException {
+        assertEquals("", m1, m2);
+    }
+
+    /**
+     * Tests if m1 and m2 are equal.
+     *
+     * @param message - error message.
+     * @param m1 - message to be compared with m2.
+     * @param m2 -- message to be compared with m1.
+     */
+    protected void assertEquals(String message, Message m1, Message m2) throws JMSException {
+        assertFalse(message + ": expected {" + m1 + "}, but was {" + m2 + "}", m1 == null ^ m2 == null);
+
+        if (m1 == null) {
+            return;
+        }
+
+        assertTrue(message + ": expected {" + m1 + "}, but was {" + m2 + "}", m1.getClass() == m2.getClass());
+
+        if (m1 instanceof TextMessage) {
+            assertTextMessageEqual(message, (TextMessage)m1, (TextMessage)m2);
+        } else {
+            assertEquals(message, m1, m2);
+        }
+    }
+
+    /**
+     * Test if base directory contains spaces
+     */
+    protected void assertBaseDirectoryContainsSpaces() {
+    	assertFalse("Base directory cannot contain spaces.", new File(System.getProperty("basedir", ".")).getAbsoluteFile().toString().contains(" "));
+    }
+
+    /**
+     * Creates an ActiveMQConnectionFactory.
+     *
+     * @return ActiveMQConnectionFactory
+     * @throws Exception
+     */
+    protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
+        return new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
+    }
+
+    /**
+     * Factory method to create a new connection.
+     *
+     * @return connection
+     * @throws Exception
+     */
+    protected Connection createConnection() throws Exception {
+        return getConnectionFactory().createConnection();
+    }
+
+    /**
+     * Creates an ActiveMQ connection factory.
+     *
+     * @return connectionFactory
+     * @throws Exception
+     */
+    public ActiveMQConnectionFactory getConnectionFactory() throws Exception {
+        if (connectionFactory == null) {
+            connectionFactory = createConnectionFactory();
+            assertTrue("Should have created a connection factory!", connectionFactory != null);
+        }
+
+        return connectionFactory;
+    }
+
+    /**
+     * Returns the consumer subject.
+     *
+     * @return String
+     */
+    protected String getConsumerSubject() {
+        return getSubject();
+    }
+
+    /**
+     * Returns the producer subject.
+     *
+     * @return String
+     */
+    protected String getProducerSubject() {
+        return getSubject();
+    }
+
+    /**
+     * Returns the subject.
+     *
+     * @return String
+     */
+    protected String getSubject() {
+        return getClass().getName() + "." + getName();
+    }
+
+    protected void assertArrayEqual(String message, Object[] expected, Object[] actual) {
+        assertEquals(message + ". Array length", expected.length, actual.length);
+        for (int i = 0; i < expected.length; i++) {
+            assertEquals(message + ". element: " + i, expected[i], actual[i]);
+        }
+    }
+
+    protected void assertPrimitiveArrayEqual(String message, Object expected, Object actual) {
+        int length = Array.getLength(expected);
+        assertEquals(message + ". Array length", length, Array.getLength(actual));
+        for (int i = 0; i < length; i++) {
+            assertEquals(message + ". element: " + i, Array.get(expected, i), Array.get(actual, i));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/QueueClusterTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/QueueClusterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/QueueClusterTest.java
index 9902bd2..56d1546 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/QueueClusterTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/QueueClusterTest.java
@@ -16,13 +16,16 @@
  */
 package org.apache.activemq.transport;
 
+import org.junit.Before;
+
 /**
  *
  */
 public class QueueClusterTest extends TopicClusterTest {
 
    @Override
-   protected void setUp() throws Exception {
+   @Before
+   public void setUp() throws Exception {
       topic = false;
       super.setUp();
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/SoWriteTimeoutClientTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/SoWriteTimeoutClientTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/SoWriteTimeoutClientTest.java
index 1b95006..3506ff0 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/SoWriteTimeoutClientTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/SoWriteTimeoutClientTest.java
@@ -21,42 +21,50 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
 import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
 import javax.jms.Session;
 
-import junit.framework.Test;
-
 import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.JmsTestSupport;
-import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
 import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
 import org.apache.activemq.util.SocketProxy;
-import org.apache.activemq.util.URISupport;
-import org.apache.activemq.util.Wait;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class SoWriteTimeoutClientTest extends JmsTestSupport {
+public class SoWriteTimeoutClientTest extends OpenwireArtemisBaseTest {
 
    private static final Logger LOG = LoggerFactory.getLogger(SoWriteTimeoutClientTest.class);
+   private String messageTextPrefix = "";
+   private EmbeddedJMS server;
+
+   @Before
+   public void setUp() throws Exception {
+      Configuration config = this.createConfig(0);
+      server = new EmbeddedJMS().setConfiguration(config).setJmsConfiguration(new JMSConfigurationImpl());
+      server.start();
+   }
 
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      BrokerService broker = new BrokerService();
-      broker.setDeleteAllMessagesOnStartup(true);
-      KahaDBPersistenceAdapter adapter = new KahaDBPersistenceAdapter();
-      adapter.setConcurrentStoreAndDispatchQueues(false);
-      broker.setPersistenceAdapter(adapter);
-      broker.addConnector("tcp://localhost:0?wireFormat.maxInactivityDuration=0");
-      return broker;
+   @After
+   public void tearDown() throws Exception {
+      server.stop();
    }
 
+   @Test
    public void testSendWithClientWriteTimeout() throws Exception {
       final ActiveMQQueue dest = new ActiveMQQueue("testClientWriteTimeout");
       messageTextPrefix = initMessagePrefix(80 * 1024);
 
-      URI tcpBrokerUri = URISupport.removeQuery(broker.getTransportConnectors().get(0).getConnectUri());
+      URI tcpBrokerUri = new URI(newURI(0));
       LOG.info("consuming using uri: " + tcpBrokerUri);
 
       ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(tcpBrokerUri);
@@ -92,25 +100,34 @@ public class SoWriteTimeoutClientTest extends JmsTestSupport {
       TimeUnit.SECONDS.sleep(8);
       proxy.goOn();
       for (int i = 0; i < messageCount; i++) {
-         assertNotNull("Got message " + i + " after reconnect", consumer.receive(5000));
+         Assert.assertNotNull("Got message " + i + " after reconnect", consumer.receive(10000));
       }
 
-      assertTrue("no pending messages when done", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
+      Assert.assertNull(consumer.receive(5000));
 
-            LOG.info("current total message count: " + broker.getAdminView().getTotalMessageCount());
-            return broker.getAdminView().getTotalMessageCount() == 0;
-         }
-      }));
+   }
+
+   protected void sendMessages(Connection connection, Destination destination, int count) throws JMSException {
+      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      sendMessages(session, destination, count);
+      session.close();
+   }
+
+   protected void sendMessages(Session session, Destination destination, int count) throws JMSException {
+      MessageProducer producer = session.createProducer(destination);
+      sendMessages(session, producer, count);
+      producer.close();
+   }
+
+   protected void sendMessages(Session session, MessageProducer producer, int count) throws JMSException {
+      for (int i = 0; i < count; i++) {
+         producer.send(session.createTextMessage(messageTextPrefix + i));
+      }
    }
 
    private String initMessagePrefix(int i) {
       byte[] content = new byte[i];
       return new String(content);
    }
+}
 
-   public static Test suite() {
-      return suite(SoWriteTimeoutClientTest.class);
-   }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/TopicClusterTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/TopicClusterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/TopicClusterTest.java
index 5157c33..c2a7d24 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/TopicClusterTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/TopicClusterTest.java
@@ -17,9 +17,6 @@
 
 package org.apache.activemq.transport;
 
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.jms.Connection;
@@ -33,22 +30,23 @@ import javax.jms.MessageProducer;
 import javax.jms.Session;
 import javax.jms.TextMessage;
 
-import junit.framework.TestCase;
-
 import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.TransportConnector;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
 import org.apache.activemq.command.ActiveMQQueue;
 import org.apache.activemq.command.ActiveMQTextMessage;
 import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.util.ServiceStopper;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  *
  */
-public class TopicClusterTest extends TestCase implements MessageListener {
+public class TopicClusterTest extends OpenwireArtemisBaseTest implements MessageListener {
 
    protected static final int MESSAGE_COUNT = 50;
    protected static final int NUMBER_IN_CLUSTER = 3;
@@ -60,11 +58,11 @@ public class TopicClusterTest extends TestCase implements MessageListener {
    protected int deliveryMode = DeliveryMode.NON_PERSISTENT;
    protected MessageProducer[] producers;
    protected Connection[] connections;
-   protected List<BrokerService> services = new ArrayList<>();
+   protected EmbeddedJMS[] servers = new EmbeddedJMS[NUMBER_IN_CLUSTER];
    protected String groupId;
 
-   @Override
-   protected void setUp() throws Exception {
+   @Before
+   public void setUp() throws Exception {
       groupId = "topic-cluster-test-" + System.currentTimeMillis();
       connections = new Connection[NUMBER_IN_CLUSTER];
       producers = new MessageProducer[NUMBER_IN_CLUSTER];
@@ -73,11 +71,13 @@ public class TopicClusterTest extends TestCase implements MessageListener {
       if (root == null) {
          root = "target/store";
       }
+
+      this.setUpClusterServers(servers);
       try {
          for (int i = 0; i < NUMBER_IN_CLUSTER; i++) {
 
             System.setProperty("activemq.store.dir", root + "_broker_" + i);
-            connections[i] = createConnection("broker-" + i);
+            connections[i] = createConnection(i);
             connections[i].setClientID("ClusterTest" + i);
             connections[i].start();
             Session session = connections[i].createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -95,42 +95,35 @@ public class TopicClusterTest extends TestCase implements MessageListener {
       }
    }
 
-   @Override
-   protected void tearDown() throws Exception {
+   @After
+   public void tearDown() throws Exception {
       if (connections != null) {
          for (int i = 0; i < connections.length; i++) {
-            connections[i].close();
+            try {
+               connections[i].close();
+            } catch (Exception e) {
+               //ignore.
+            }
          }
       }
-      ServiceStopper stopper = new ServiceStopper();
-      stopper.stopServices(services);
+      this.shutDownClusterServers(servers);
    }
 
    protected MessageConsumer createMessageConsumer(Session session, Destination destination) throws JMSException {
       return session.createConsumer(destination);
    }
 
-   protected ActiveMQConnectionFactory createGenericClusterFactory(String brokerName) throws Exception {
-      BrokerService container = new BrokerService();
-      container.setBrokerName(brokerName);
-
-      String url = "tcp://localhost:0";
-      TransportConnector connector = container.addConnector(url);
-      connector.setDiscoveryUri(new URI("multicast://default?group=" + groupId));
-      container.addNetworkConnector("multicast://default?group=" + groupId);
-      container.start();
-
-      services.add(container);
-
-      return new ActiveMQConnectionFactory("vm://" + brokerName);
+   protected ActiveMQConnectionFactory createGenericClusterFactory(int serverID) throws Exception {
+      String url = newURI(serverID);
+      return new ActiveMQConnectionFactory(url);
    }
 
    protected int expectedReceiveCount() {
       return MESSAGE_COUNT * NUMBER_IN_CLUSTER * NUMBER_IN_CLUSTER;
    }
 
-   protected Connection createConnection(String name) throws Exception {
-      return createGenericClusterFactory(name).createConnection();
+   protected Connection createConnection(int serverID) throws Exception {
+      return createGenericClusterFactory(serverID).createConnection();
    }
 
    protected Destination createDestination() {
@@ -146,10 +139,6 @@ public class TopicClusterTest extends TestCase implements MessageListener {
       }
    }
 
-   /**
-    * @param msg
-    */
-   @Override
    public void onMessage(Message msg) {
       // log.info("GOT: " + msg);
       receivedMessageCount.incrementAndGet();
@@ -160,9 +149,7 @@ public class TopicClusterTest extends TestCase implements MessageListener {
       }
    }
 
-   /**
-    * @throws Exception
-    */
+   @Test
    public void testSendReceive() throws Exception {
       for (int i = 0; i < MESSAGE_COUNT; i++) {
          TextMessage textMessage = new ActiveMQTextMessage();
@@ -178,8 +165,8 @@ public class TopicClusterTest extends TestCase implements MessageListener {
       }
       // sleep a little - to check we don't get too many messages
       Thread.sleep(2000);
-      LOG.info("GOT: " + receivedMessageCount.get());
-      assertEquals("Expected message count not correct", expectedReceiveCount(), receivedMessageCount.get());
+      LOG.info("GOT: " + receivedMessageCount.get() + " Expected: " + expectedReceiveCount());
+      Assert.assertEquals("Expected message count not correct", expectedReceiveCount(), receivedMessageCount.get());
    }
 
 }


[40/60] [abbrv] activemq-artemis git commit: fixing tests and removing new Executor().run(...) usages

Posted by cl...@apache.org.
fixing tests and removing new Executor().run(...) usages


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/f150638e
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/f150638e
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/f150638e

Branch: refs/heads/refactor-openwire
Commit: f150638eed3672540eed1d3ac3563f17c3ad0c8a
Parents: bc25518
Author: Clebert Suconic <cl...@apache.org>
Authored: Wed Feb 24 13:17:03 2016 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:44:21 2016 -0400

----------------------------------------------------------------------
 .../FailoverConsumerOutstandingCommitTest.java  | 14 +++----
 .../FailoverConsumerUnconsumedTest.java         | 16 ++++----
 .../failover/FailoverDuplicateTest.java         |  8 ++--
 .../failover/FailoverPrefetchZeroTest.java      |  8 ++--
 .../failover/FailoverTransactionTest.java       | 40 ++++++++++----------
 .../TwoBrokerQueueClientsReconnectTest.java     |  8 ++--
 6 files changed, 47 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f150638e/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java
index 705c033..5a160ab 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java
@@ -139,7 +139,7 @@ public class FailoverConsumerOutstandingCommitTest extends OpenwireArtemisBaseTe
       });
 
       // may block if broker shutodwn happens quickly
-      Executors.newSingleThreadExecutor().execute(new Runnable() {
+      new Thread() {
          public void run() {
             LOG.info("producer started");
             try {
@@ -153,9 +153,9 @@ public class FailoverConsumerOutstandingCommitTest extends OpenwireArtemisBaseTe
             }
             LOG.info("producer done");
          }
-      });
+      }.start();
 
-      // will be stopped by the plugin
+   // will be stopped by the plugin
       brokerStopLatch.await();
       server.stop();
       server = createBroker();
@@ -253,7 +253,7 @@ public class FailoverConsumerOutstandingCommitTest extends OpenwireArtemisBaseTe
       });
 
       // may block if broker shutdown happens quickly
-      Executors.newSingleThreadExecutor().execute(new Runnable() {
+      new Thread() {
          public void run() {
             LOG.info("producer started");
             try {
@@ -267,7 +267,7 @@ public class FailoverConsumerOutstandingCommitTest extends OpenwireArtemisBaseTe
             }
             LOG.info("producer done");
          }
-      });
+      }.start();
 
       // will be stopped by the plugin
       brokerStopLatch.await();
@@ -364,7 +364,7 @@ public class FailoverConsumerOutstandingCommitTest extends OpenwireArtemisBaseTe
 
    public static void stopServerInTransaction() {
       if (doByteman.get()) {
-         Executors.newSingleThreadExecutor().execute(new Runnable() {
+         new Thread() {
             public void run() {
                LOG.info("Stopping broker in transaction...");
                try {
@@ -377,7 +377,7 @@ public class FailoverConsumerOutstandingCommitTest extends OpenwireArtemisBaseTe
                   brokerStopLatch.countDown();
                }
             }
-         });
+         }.start();
       }
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f150638e/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerUnconsumedTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerUnconsumedTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerUnconsumedTest.java
index 10927f2..fb9479c 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerUnconsumedTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerUnconsumedTest.java
@@ -180,7 +180,7 @@ public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest {
 
       final CountDownLatch shutdownConsumerAdded = new CountDownLatch(1);
 
-      Executors.newSingleThreadExecutor().execute(new Runnable() {
+      new Thread() {
          public void run() {
             try {
                LOG.info("add last consumer...");
@@ -204,7 +204,7 @@ public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest {
                e.printStackTrace();
             }
          }
-      });
+      }.start();
 
       brokerStopLatch.await();
       doByteman.set(false);
@@ -272,7 +272,7 @@ public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest {
 
       final CountDownLatch shutdownConsumerAdded = new CountDownLatch(1);
 
-      Executors.newSingleThreadExecutor().execute(new Runnable() {
+      new Thread() {
          public void run() {
             try {
                LOG.info("add last consumer...");
@@ -284,7 +284,7 @@ public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest {
                e.printStackTrace();
             }
          }
-      });
+      }.start();
 
       // verify interrupt
       assertTrue("add messages dispatched and unconsumed are cleaned up", Wait.waitFor(new Wait.Condition() {
@@ -364,7 +364,7 @@ public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest {
       if (doByteman.get()) {
          if (consumerCount.incrementAndGet() == maxConsumers) {
             context.getContext().setDontSendReponse(true);
-            Executors.newSingleThreadExecutor().execute(new Runnable() {
+            new Thread() {
                public void run() {
                   try {
                      broker.stop();
@@ -374,7 +374,7 @@ public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest {
                      e.printStackTrace();
                   }
                }
-            });
+            }.start();
          }
       }
    }
@@ -383,7 +383,7 @@ public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest {
       if (doByteman.get()) {
          if (consumerCount.incrementAndGet() == maxConsumers + (watchTopicAdvisories.get() ? 1 : 0)) {
             context.getContext().setDontSendReponse(true);
-            Executors.newSingleThreadExecutor().execute(new Runnable() {
+            new Thread() {
                public void run() {
                   try {
                      broker.stop();
@@ -394,7 +394,7 @@ public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest {
                      e.printStackTrace();
                   }
                }
-            });
+            }.start();
          }
       }
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f150638e/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverDuplicateTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverDuplicateTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverDuplicateTest.java
index 89d006a..2e40459 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverDuplicateTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverDuplicateTest.java
@@ -131,7 +131,7 @@ public class FailoverDuplicateTest extends OpenwireArtemisBaseTest {
 
       final CountDownLatch sendDoneLatch = new CountDownLatch(1);
       // broker will die on send reply so this will hang till restart
-      Executors.newSingleThreadExecutor().execute(new Runnable() {
+      new Thread() {
          @Override
          public void run() {
             LOG.info("doing async send...");
@@ -145,7 +145,7 @@ public class FailoverDuplicateTest extends OpenwireArtemisBaseTest {
             sendDoneLatch.countDown();
             LOG.info("done async send");
          }
-      });
+      }.start();
 
       Assert.assertTrue("one message got through on time", gotMessageLatch.await(20, TimeUnit.SECONDS));
       // send more messages, blow producer audit
@@ -215,7 +215,7 @@ public class FailoverDuplicateTest extends OpenwireArtemisBaseTest {
       if (doByteman.get()) {
          if (first.compareAndSet(false, true)) {
             context.getContext().setDontSendReponse(true);
-            Executors.newSingleThreadExecutor().execute(new Runnable() {
+            new Thread() {
                @Override
                public void run() {
                   try {
@@ -229,7 +229,7 @@ public class FailoverDuplicateTest extends OpenwireArtemisBaseTest {
                      e.printStackTrace();
                   }
                }
-            });
+            }.start();
          }
       }
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f150638e/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPrefetchZeroTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPrefetchZeroTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPrefetchZeroTest.java
index 5981845..64c1ccd 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPrefetchZeroTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPrefetchZeroTest.java
@@ -101,7 +101,7 @@ public class FailoverPrefetchZeroTest extends OpenwireArtemisBaseTest {
 
       final CountDownLatch receiveDone = new CountDownLatch(1);
       final Vector<Message> received = new Vector<>();
-      Executors.newSingleThreadExecutor().execute(new Runnable() {
+      new Thread() {
          public void run() {
             try {
                LOG.info("receive one...");
@@ -116,7 +116,7 @@ public class FailoverPrefetchZeroTest extends OpenwireArtemisBaseTest {
                e.printStackTrace();
             }
          }
-      });
+      }.start();
 
       // will be stopped by the plugin
       assertTrue("pull completed on broker", pullDone.await(30, TimeUnit.SECONDS));
@@ -146,7 +146,7 @@ public class FailoverPrefetchZeroTest extends OpenwireArtemisBaseTest {
       if (doByteman.get()) {
          context.getContext().setDontSendReponse(true);
          pullDone.countDown();
-         Executors.newSingleThreadExecutor().execute(new Runnable() {
+         new Thread() {
             public void run() {
                try {
                   broker.stop();
@@ -158,7 +158,7 @@ public class FailoverPrefetchZeroTest extends OpenwireArtemisBaseTest {
                   brokerStopLatch.countDown();
                }
             }
-         });
+         }.start();
       }
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f150638e/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
index a3e023a..6cd6942 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
@@ -162,7 +162,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
 
       final CountDownLatch commitDoneLatch = new CountDownLatch(1);
       // broker will die on commit reply so this will hang till restart
-      Executors.newSingleThreadExecutor().execute(new Runnable() {
+      new Thread() {
          public void run() {
             LOG.info("doing async commit...");
             try {
@@ -175,7 +175,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
             commitDoneLatch.countDown();
             LOG.info("done async commit");
          }
-      });
+      }.start();
 
       // will be stopped by the plugin
       brokerStopLatch.await();
@@ -256,7 +256,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
       MessageConsumer consumer = session.createConsumer(destination);
       final CountDownLatch sendDoneLatch = new CountDownLatch(1);
       // broker will die on send reply so this will hang till restart
-      Executors.newSingleThreadExecutor().execute(new Runnable() {
+      new Thread() {
          public void run() {
             LOG.info("doing async send...");
             try {
@@ -270,7 +270,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
             sendDoneLatch.countDown();
             LOG.info("done async send");
          }
-      });
+      }.start();
 
       // will be stopped by the plugin
       brokerStopLatch.await();
@@ -345,7 +345,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
       MessageConsumer consumer = session.createConsumer(destination);
       final CountDownLatch sendDoneLatch = new CountDownLatch(1);
       // proxy connection will die on send reply so this will hang on failover reconnect till open
-      Executors.newSingleThreadExecutor().execute(new Runnable() {
+      new Thread() {
          public void run() {
             LOG.info("doing async send...");
             try {
@@ -358,7 +358,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
             sendDoneLatch.countDown();
             LOG.info("done async send");
          }
-      });
+      }.start();
 
       // will be closed by the plugin
       Assert.assertTrue("proxy was closed", proxy.waitUntilClosed(30));
@@ -568,7 +568,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
       final Vector<Message> receivedMessages = new Vector<>();
       final CountDownLatch commitDoneLatch = new CountDownLatch(1);
       final AtomicBoolean gotTransactionRolledBackException = new AtomicBoolean(false);
-      Executors.newSingleThreadExecutor().execute(new Runnable() {
+      new Thread() {
          public void run() {
             LOG.info("doing async commit after consume...");
             try {
@@ -615,7 +615,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
                e.printStackTrace();
             }
          }
-      });
+      }.start();
 
       // will be stopped by the plugin
       brokerStopLatch.await();
@@ -684,7 +684,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
                            targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor",
                            targetMethod = "processRemoveConsumer",
                            targetLocation = "ENTRY",
-                           action = "org.apache.activemq.transport.failover.FailoverTransactionTest.stopBrokerOnCounter($0)")
+                           action = "org.apache.activemq.transport.failover.FailoverTransactionTest.stopBrokerOnCounter()")
            }
    )
    public void testPoolingNConsumesAfterReconnect() throws Exception {
@@ -873,7 +873,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
 
       final CountDownLatch commitDone = new CountDownLatch(1);
       // will block pending re-deliveries
-      Executors.newSingleThreadExecutor().execute(new Runnable() {
+      new Thread() {
          public void run() {
             LOG.info("doing async commit...");
             try {
@@ -883,7 +883,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
             catch (JMSException ignored) {
             }
          }
-      });
+      }.start();
 
       broker.stop();
       broker = createBroker();
@@ -928,7 +928,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
       final Vector<Exception> exceptions = new Vector<>();
 
       // commit may fail if other consumer gets the message on restart
-      Executors.newSingleThreadExecutor().execute(new Runnable() {
+      new Thread() {
          public void run() {
             LOG.info("doing async commit...");
             try {
@@ -941,7 +941,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
                commitDone.countDown();
             }
          }
-      });
+      }.start();
 
       Assert.assertTrue("commit completed ", commitDone.await(15, TimeUnit.SECONDS));
 
@@ -975,7 +975,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
    public static void holdResponseAndStopBroker(final OpenWireConnection.CommandProcessor context) {
       if (doByteman.get()) {
          context.getContext().setDontSendReponse(true);
-         Executors.newSingleThreadExecutor().execute(new Runnable() {
+         new Thread() {
             public void run() {
                LOG.info("Stopping broker post commit...");
                try {
@@ -988,7 +988,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
                   brokerStopLatch.countDown();
                }
             }
-         });
+         }.start();
       }
    }
 
@@ -997,7 +997,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
          if (firstSend) {
             firstSend = false;
             context.getContext().setDontSendReponse(true);
-            Executors.newSingleThreadExecutor().execute(new Runnable() {
+            new Thread() {
                public void run() {
                   LOG.info("Stopping connection post send...");
                   try {
@@ -1007,15 +1007,15 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
                      e.printStackTrace();
                   }
                }
-            });
+            }.start();
          }
       }
    }
 
-   public static void stopBrokerOnCounter(final AMQConnectionContext context) {
+   public static void stopBrokerOnCounter() {
       if (doByteman.get()) {
          if (count++ == 1) {
-            Executors.newSingleThreadExecutor().execute(new Runnable() {
+            new Thread() {
                public void run() {
                   try {
                      broker.stop();
@@ -1027,7 +1027,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
                      brokerStopLatch.countDown();
                   }
                }
-            });
+            }.start();
          }
       }
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f150638e/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueClientsReconnectTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueClientsReconnectTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueClientsReconnectTest.java
index e78ab2f..534e68b 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueClientsReconnectTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueClientsReconnectTest.java
@@ -390,7 +390,7 @@ public class TwoBrokerQueueClientsReconnectTest extends JmsMultipleBrokersTestSu
             super.send(producerExchange, messageSend);
             if (first.compareAndSet(false, true)) {
                producerExchange.getConnectionContext().setDontSendReponse(true);
-               Executors.newSingleThreadExecutor().execute(new Runnable() {
+               new Thread() {
                   @Override
                   public void run() {
                      try {
@@ -403,7 +403,7 @@ public class TwoBrokerQueueClientsReconnectTest extends JmsMultipleBrokersTestSu
                         e.printStackTrace();
                      }
                   }
-               });
+               }.start();
             }
          }
       }});
@@ -465,7 +465,7 @@ public class TwoBrokerQueueClientsReconnectTest extends JmsMultipleBrokersTestSu
             super.send(producerExchange, messageSend);
             if (first.compareAndSet(false, true)) {
                producerExchange.getConnectionContext().setDontSendReponse(true);
-               Executors.newSingleThreadExecutor().execute(new Runnable() {
+               new Thread() {
                   @Override
                   public void run() {
                      try {
@@ -478,7 +478,7 @@ public class TwoBrokerQueueClientsReconnectTest extends JmsMultipleBrokersTestSu
                         e.printStackTrace();
                      }
                   }
-               });
+               }.start();
             }
          }
       }});


[28/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
deleted file mode 100644
index 98afe30..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
+++ /dev/null
@@ -1,1505 +0,0 @@
-/**
- * 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.broker.jmx;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.net.URI;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.jms.TopicSubscriber;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerInvocationHandler;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.TabularData;
-
-import junit.textui.TestRunner;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQPrefetchPolicy;
-import org.apache.activemq.ActiveMQSession;
-import org.apache.activemq.BlobMessage;
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.BaseDestination;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.broker.region.policy.SharedDeadLetterStrategy;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTempQueue;
-import org.apache.activemq.util.JMXSupport;
-import org.apache.activemq.util.URISupport;
-import org.apache.activemq.util.Wait;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A test case of the various MBeans in ActiveMQ. If you want to look at the
- * various MBeans after the test has been run then run this test case as a
- * command line application.
- */
-public class MBeanTest extends EmbeddedBrokerTestSupport {
-
-   private static final Logger LOG = LoggerFactory.getLogger(MBeanTest.class);
-
-   private static boolean waitForKeyPress;
-
-   protected MBeanServer mbeanServer;
-   protected String domain = "org.apache.activemq";
-   protected String clientID = "foo";
-
-   protected Connection connection;
-   protected boolean transacted;
-   protected int authMode = Session.AUTO_ACKNOWLEDGE;
-   protected static final int MESSAGE_COUNT = 2 * BaseDestination.MAX_PAGE_SIZE;
-   final static String QUEUE_WITH_OPTIONS = "QueueWithOptions";
-
-   /**
-    * When you run this test case from the command line it will pause before
-    * terminating so that you can look at the MBeans state for debugging
-    * purposes.
-    */
-   public static void main(String[] args) {
-      waitForKeyPress = true;
-      TestRunner.run(MBeanTest.class);
-   }
-
-   public void testConnectors() throws Exception {
-      ObjectName brokerName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost");
-      BrokerViewMBean broker = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);
-
-      assertEquals("openwire URL port doesn't equal bind Address", new URI(broker.getTransportConnectorByType("tcp")).getPort(), new URI(this.broker.getTransportConnectors().get(0).getPublishableConnectString()).getPort());
-   }
-
-   public void testMBeans() throws Exception {
-      connection = connectionFactory.createConnection();
-      useConnection(connection);
-
-      // test all the various MBeans now we have a producer, consumer and
-      // messages on a queue
-      assertSendViaMBean();
-      assertSendCsnvViaMBean();
-      assertQueueBrowseWorks();
-      assertCreateAndDestroyDurableSubscriptions();
-      assertConsumerCounts();
-      assertProducerCounts();
-   }
-
-   public void testMoveMessages() throws Exception {
-      connection = connectionFactory.createConnection();
-      useConnection(connection);
-
-      ObjectName queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + getDestinationString());
-
-      QueueViewMBean queue = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-
-      CompositeData[] compdatalist = queue.browse();
-      int initialQueueSize = compdatalist.length;
-      if (initialQueueSize == 0) {
-         fail("There is no message in the queue:");
-      }
-      else {
-         echo("Current queue size: " + initialQueueSize);
-      }
-      int messageCount = initialQueueSize;
-      String[] messageIDs = new String[messageCount];
-      for (int i = 0; i < messageCount; i++) {
-         CompositeData cdata = compdatalist[i];
-         String messageID = (String) cdata.get("JMSMessageID");
-         assertNotNull("Should have a message ID for message " + i, messageID);
-         messageIDs[i] = messageID;
-      }
-
-      assertTrue("dest has some memory usage", queue.getMemoryPercentUsage() > 0);
-
-      echo("About to move " + messageCount + " messages");
-
-      String newDestination = getSecondDestinationString();
-      for (String messageID : messageIDs) {
-         //echo("Moving message: " + messageID);
-         queue.moveMessageTo(messageID, newDestination);
-      }
-
-      echo("Now browsing the queue");
-      compdatalist = queue.browse();
-      int actualCount = compdatalist.length;
-      echo("Current queue size: " + actualCount);
-      assertEquals("Should now have empty queue but was", initialQueueSize - messageCount, actualCount);
-
-      echo("Now browsing the second queue");
-
-      queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + newDestination);
-      QueueViewMBean queueNew = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-
-      long newQueuesize = queueNew.getQueueSize();
-      echo("Second queue size: " + newQueuesize);
-      assertEquals("Unexpected number of messages ", messageCount, newQueuesize);
-
-      // check memory usage migration
-      assertTrue("new dest has some memory usage", queueNew.getMemoryPercentUsage() > 0);
-      assertEquals("old dest has no memory usage", 0, queue.getMemoryPercentUsage());
-      assertTrue("use cache", queueNew.isUseCache());
-      assertTrue("cache enabled", queueNew.isCacheEnabled());
-      assertEquals("no forwards", 0, queueNew.getForwardCount());
-   }
-
-   public void testRemoveMessages() throws Exception {
-      ObjectName brokerName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost");
-      BrokerViewMBean broker = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);
-      broker.addQueue(getDestinationString());
-
-      ObjectName queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + getDestinationString());
-
-      QueueViewMBean queue = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-      String msg1 = queue.sendTextMessage("message 1");
-      String msg2 = queue.sendTextMessage("message 2");
-
-      assertTrue(queue.removeMessage(msg2));
-
-      connection = connectionFactory.createConnection();
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      ActiveMQDestination dest = createDestination();
-
-      MessageConsumer consumer = session.createConsumer(dest);
-      Message message = consumer.receive(1000);
-      assertNotNull(message);
-      assertEquals(msg1, message.getJMSMessageID());
-
-      String msg3 = queue.sendTextMessage("message 3");
-      message = consumer.receive(1000);
-      assertNotNull(message);
-      assertEquals(msg3, message.getJMSMessageID());
-
-      message = consumer.receive(1000);
-      assertNull(message);
-
-   }
-
-   public void testRemoveQueue() throws Exception {
-      String queueName = "TEST";
-      ObjectName brokerName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost");
-      BrokerViewMBean broker = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);
-      broker.addQueue(queueName);
-
-      ObjectName queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + queueName);
-
-      QueueViewMBean queue = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-      queue.sendTextMessage("message 1");
-      queue.sendTextMessage("message 2");
-
-      assertEquals(2, broker.getTotalMessageCount());
-
-      broker.removeQueue(queueName);
-
-      assertEquals(0, broker.getTotalMessageCount());
-
-   }
-
-   public void testRetryMessages() throws Exception {
-      // lets speed up redelivery
-      ActiveMQConnectionFactory factory = (ActiveMQConnectionFactory) connectionFactory;
-      factory.getRedeliveryPolicy().setCollisionAvoidancePercent((short) 0);
-      factory.getRedeliveryPolicy().setMaximumRedeliveries(1);
-      factory.getRedeliveryPolicy().setInitialRedeliveryDelay(0);
-      factory.getRedeliveryPolicy().setUseCollisionAvoidance(false);
-      factory.getRedeliveryPolicy().setUseExponentialBackOff(false);
-      factory.getRedeliveryPolicy().setBackOffMultiplier((short) 0);
-
-      connection = connectionFactory.createConnection();
-      useConnection(connection);
-
-      ObjectName queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + getDestinationString());
-      QueueViewMBean queue = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-
-      long initialQueueSize = queue.getQueueSize();
-      echo("current queue size: " + initialQueueSize);
-      assertTrue("dest has some memory usage", queue.getMemoryPercentUsage() > 0);
-
-      // lets create a duff consumer which keeps rolling back...
-      Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-      MessageConsumer consumer = session.createConsumer(new ActiveMQQueue(getDestinationString()));
-      Message message = consumer.receive(5000);
-      while (message != null) {
-         echo("Message: " + message.getJMSMessageID() + " redelivered " + message.getJMSRedelivered() + " counter " + message.getObjectProperty("JMSXDeliveryCount"));
-         session.rollback();
-         message = consumer.receive(2000);
-      }
-      consumer.close();
-      session.close();
-
-      // now lets get the dead letter queue
-      Thread.sleep(1000);
-
-      ObjectName dlqQueueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + SharedDeadLetterStrategy.DEFAULT_DEAD_LETTER_QUEUE_NAME);
-      QueueViewMBean dlq = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, dlqQueueViewMBeanName, QueueViewMBean.class, true);
-
-      long initialDlqSize = dlq.getQueueSize();
-      CompositeData[] compdatalist = dlq.browse();
-      int dlqQueueSize = compdatalist.length;
-      if (dlqQueueSize == 0) {
-         fail("There are no messages in the queue:");
-      }
-      else {
-         echo("Current DLQ queue size: " + dlqQueueSize);
-      }
-      int messageCount = dlqQueueSize;
-      String[] messageIDs = new String[messageCount];
-      for (int i = 0; i < messageCount; i++) {
-         CompositeData cdata = compdatalist[i];
-         String messageID = (String) cdata.get("JMSMessageID");
-         assertNotNull("Should have a message ID for message " + i, messageID);
-         messageIDs[i] = messageID;
-      }
-
-      int dlqMemUsage = dlq.getMemoryPercentUsage();
-      assertTrue("dlq has some memory usage", dlqMemUsage > 0);
-      assertEquals("dest has no memory usage", 0, queue.getMemoryPercentUsage());
-
-      echo("About to retry " + messageCount + " messages");
-
-      for (String messageID : messageIDs) {
-         echo("Retrying message: " + messageID);
-         dlq.retryMessage(messageID);
-      }
-
-      long queueSize = queue.getQueueSize();
-      compdatalist = queue.browse();
-      int actualCount = compdatalist.length;
-      echo("Original queue size is now " + queueSize);
-      echo("Original browse queue size: " + actualCount);
-
-      long dlqSize = dlq.getQueueSize();
-      echo("DLQ size: " + dlqSize);
-
-      assertEquals("DLQ size", initialDlqSize - messageCount, dlqSize);
-      assertEquals("queue size", initialQueueSize, queueSize);
-      assertEquals("browse queue size", initialQueueSize, actualCount);
-
-      assertEquals("dest has some memory usage", dlqMemUsage, queue.getMemoryPercentUsage());
-   }
-
-   public void testMoveMessagesBySelector() throws Exception {
-      connection = connectionFactory.createConnection();
-      useConnection(connection);
-
-      ObjectName queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + getDestinationString());
-
-      QueueViewMBean queue = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-
-      String newDestination = getSecondDestinationString();
-      queue.moveMatchingMessagesTo("counter > 2", newDestination);
-
-      queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + newDestination);
-
-      queue = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-      int movedSize = MESSAGE_COUNT - 3;
-      assertEquals("Unexpected number of messages ", movedSize, queue.getQueueSize());
-
-      // now lets remove them by selector
-      queue.removeMatchingMessages("counter > 2");
-
-      assertEquals("Should have no more messages in the queue: " + queueViewMBeanName, 0, queue.getQueueSize());
-      assertEquals("dest has no memory usage", 0, queue.getMemoryPercentUsage());
-   }
-
-   public void testCopyMessagesBySelector() throws Exception {
-      connection = connectionFactory.createConnection();
-      useConnection(connection);
-
-      ObjectName queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + getDestinationString());
-
-      QueueViewMBean queue = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-
-      String newDestination = getSecondDestinationString();
-      long queueSize = queue.getQueueSize();
-      assertTrue(queueSize > 0);
-      queue.copyMatchingMessagesTo("counter > 2", newDestination);
-
-      queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + newDestination);
-
-      queue = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-
-      LOG.info("Queue: " + queueViewMBeanName + " now has: " + queue.getQueueSize() + " message(s)");
-      assertEquals("Expected messages in a queue: " + queueViewMBeanName, MESSAGE_COUNT - 3, queue.getQueueSize());
-      // now lets remove them by selector
-      queue.removeMatchingMessages("counter > 2");
-
-      assertEquals("Should have no more messages in the queue: " + queueViewMBeanName, 0, queue.getQueueSize());
-      assertEquals("dest has no memory usage", 0, queue.getMemoryPercentUsage());
-   }
-
-   public void testCreateDestinationWithSpacesAtEnds() throws Exception {
-      ObjectName brokerName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost");
-      BrokerViewMBean broker = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);
-
-      assertTrue("broker is not a slave", !broker.isSlave());
-      // create 2 topics
-      broker.addTopic(getDestinationString() + "1 ");
-      broker.addTopic(" " + getDestinationString() + "2");
-      broker.addTopic(" " + getDestinationString() + "3 ");
-
-      assertNotRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Topic,destinationName=" + getDestinationString() + "1 ");
-      assertNotRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Topic,destinationName= " + getDestinationString() + "2");
-      assertNotRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Topic,destinationName= " + getDestinationString() + "3 ");
-
-      ObjectName topicObjName1 = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Topic,destinationName=" + getDestinationString() + "1");
-      ObjectName topicObjName2 = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Topic,destinationName=" + getDestinationString() + "2");
-      ObjectName topicObjName3 = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Topic,destinationName=" + getDestinationString() + "3");
-
-      TopicViewMBean topic1 = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, topicObjName1, TopicViewMBean.class, true);
-      TopicViewMBean topic2 = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, topicObjName2, TopicViewMBean.class, true);
-      TopicViewMBean topic3 = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, topicObjName3, TopicViewMBean.class, true);
-
-      assertEquals("topic1 Durable subscriber count", 0, topic1.getConsumerCount());
-      assertEquals("topic2 Durable subscriber count", 0, topic2.getConsumerCount());
-      assertEquals("topic3 Durable subscriber count", 0, topic3.getConsumerCount());
-
-      String topicName = getDestinationString();
-      String selector = null;
-
-      // create 1 subscriber for each topic
-      broker.createDurableSubscriber(clientID, "topic1.subscriber1", topicName + "1", selector);
-      broker.createDurableSubscriber(clientID, "topic2.subscriber1", topicName + "2", selector);
-      broker.createDurableSubscriber(clientID, "topic3.subscriber1", topicName + "3", selector);
-
-      assertEquals("topic1 Durable subscriber count", 1, topic1.getConsumerCount());
-      assertEquals("topic2 Durable subscriber count", 1, topic2.getConsumerCount());
-      assertEquals("topic3 Durable subscriber count", 1, topic3.getConsumerCount());
-   }
-
-   protected void assertSendViaMBean() throws Exception {
-      String queueName = getDestinationString() + ".SendMBBean";
-
-      ObjectName brokerName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost");
-      echo("Create QueueView MBean...");
-      BrokerViewMBean broker = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);
-      broker.addQueue(queueName);
-
-      ObjectName queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + queueName);
-
-      echo("Create QueueView MBean...");
-      QueueViewMBean proxy = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-
-      proxy.purge();
-
-      int count = 5;
-      for (int i = 0; i < count; i++) {
-         String body = "message:" + i;
-
-         Map<String, Object> headers = new HashMap<>();
-         headers.put("JMSCorrelationID", "MyCorrId");
-         headers.put("JMSDeliveryMode", Boolean.FALSE);
-         headers.put("JMSXGroupID", "MyGroupID");
-         headers.put("JMSXGroupSeq", 1234);
-         headers.put("JMSPriority", i + 1);
-         headers.put("JMSType", "MyType");
-         headers.put("MyHeader", i);
-         headers.put("MyStringHeader", "StringHeader" + i);
-
-         proxy.sendTextMessage(headers, body);
-      }
-
-      browseAndVerify(proxy);
-   }
-
-   private void browseAndVerify(QueueViewMBean proxy) throws Exception {
-      browseAndVerifyTypes(proxy, false);
-   }
-
-   @SuppressWarnings("rawtypes")
-   private void browseAndVerifyTypes(QueueViewMBean proxy, boolean allStrings) throws Exception {
-      CompositeData[] compdatalist = proxy.browse();
-      if (compdatalist.length == 0) {
-         fail("There is no message in the queue:");
-      }
-
-      for (int i = 0; i < compdatalist.length; i++) {
-         CompositeData cdata = compdatalist[i];
-
-         if (i == 0) {
-            echo("Columns: " + cdata.getCompositeType().keySet());
-         }
-
-         assertComplexData(i, cdata, "JMSCorrelationID", "MyCorrId");
-         assertComplexData(i, cdata, "JMSPriority", i + 1);
-         assertComplexData(i, cdata, "JMSType", "MyType");
-         assertComplexData(i, cdata, "JMSCorrelationID", "MyCorrId");
-         assertComplexData(i, cdata, "JMSDeliveryMode", "NON-PERSISTENT");
-         String expected = "{MyStringHeader=StringHeader" + i + ", MyHeader=" + i + "}";
-         // The order of the properties is different when using the ibm jdk.
-         if (System.getProperty("java.vendor").equals("IBM Corporation")) {
-            expected = "{MyHeader=" + i + ", MyStringHeader=StringHeader" + i + "}";
-         }
-         assertComplexData(i, cdata, "PropertiesText", expected);
-
-         if (allStrings) {
-            Map stringProperties = CompositeDataHelper.getTabularMap(cdata, CompositeDataConstants.STRING_PROPERTIES);
-            assertEquals("stringProperties size()", 2, stringProperties.size());
-            assertEquals("stringProperties.MyHeader", "StringHeader" + i, stringProperties.get("MyStringHeader"));
-            assertEquals("stringProperties.MyHeader", "" + i, stringProperties.get("MyHeader"));
-
-         }
-         else {
-            Map intProperties = CompositeDataHelper.getTabularMap(cdata, CompositeDataConstants.INT_PROPERTIES);
-            assertEquals("intProperties size()", 1, intProperties.size());
-            assertEquals("intProperties.MyHeader", i, intProperties.get("MyHeader"));
-
-            Map stringProperties = CompositeDataHelper.getTabularMap(cdata, CompositeDataConstants.STRING_PROPERTIES);
-            assertEquals("stringProperties size()", 1, stringProperties.size());
-            assertEquals("stringProperties.MyHeader", "StringHeader" + i, stringProperties.get("MyStringHeader"));
-         }
-
-         Map properties = CompositeDataHelper.getMessageUserProperties(cdata);
-         assertEquals("properties size()", 2, properties.size());
-         assertEquals("properties.MyHeader", allStrings ? "" + i : i, properties.get("MyHeader"));
-         assertEquals("properties.MyHeader", "StringHeader" + i, properties.get("MyStringHeader"));
-
-         assertComplexData(i, cdata, "JMSXGroupSeq", 1234);
-         assertComplexData(i, cdata, "JMSXGroupID", "MyGroupID");
-         assertComplexData(i, cdata, "Text", "message:" + i);
-      }
-   }
-
-   protected void assertSendCsnvViaMBean() throws Exception {
-      String queueName = getDestinationString() + ".SendMBBean";
-
-      ObjectName brokerName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost");
-      echo("Create QueueView MBean...");
-      BrokerViewMBean broker = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);
-      broker.addQueue(queueName);
-
-      ObjectName queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + queueName);
-
-      echo("Create QueueView MBean...");
-      QueueViewMBean proxy = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-
-      proxy.purge();
-
-      int count = 5;
-      for (int i = 0; i < count; i++) {
-         String props = "body=message:" + i;
-
-         props += ",JMSCorrelationID=MyCorrId";
-         props += ",JMSDeliveryMode=1";
-         props += ",JMSXGroupID=MyGroupID";
-         props += ",JMSXGroupSeq=1234";
-         props += ",JMSPriority=" + (i + 1);
-         props += ",JMSType=MyType";
-         props += ",MyHeader=" + i;
-         props += ",MyStringHeader=StringHeader" + i;
-
-         proxy.sendTextMessageWithProperties(props);
-      }
-
-      browseAndVerifyTypes(proxy, true);
-   }
-
-   protected void assertComplexData(int messageIndex, CompositeData cdata, String name, Object expected) {
-      Object value = cdata.get(name);
-      assertEquals("Message " + messageIndex + " CData field: " + name, expected, value);
-   }
-
-   protected void assertQueueBrowseWorks() throws Exception {
-      Integer mbeancnt = mbeanServer.getMBeanCount();
-      echo("Mbean count :" + mbeancnt);
-
-      ObjectName queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + getDestinationString());
-
-      echo("Create QueueView MBean...");
-      QueueViewMBean proxy = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-
-      long concount = proxy.getConsumerCount();
-      echo("Consumer Count :" + concount);
-      long messcount = proxy.getQueueSize();
-      echo("current number of messages in the queue :" + messcount);
-
-      // lets browse
-      CompositeData[] compdatalist = proxy.browse();
-      if (compdatalist.length == 0) {
-         fail("There is no message in the queue:");
-      }
-      String[] messageIDs = new String[compdatalist.length];
-
-      for (int i = 0; i < compdatalist.length; i++) {
-         CompositeData cdata = compdatalist[i];
-
-         if (i == 0) {
-            echo("Columns: " + cdata.getCompositeType().keySet());
-         }
-         messageIDs[i] = (String) cdata.get("JMSMessageID");
-         echo("message " + i + " : " + cdata.values());
-      }
-
-      TabularData table = proxy.browseAsTable();
-      echo("Found tabular data: " + table);
-      assertTrue("Table should not be empty!", table.size() > 0);
-
-      assertEquals("Queue size", MESSAGE_COUNT, proxy.getQueueSize());
-
-      String messageID = messageIDs[0];
-      String newDestinationName = "queue://dummy.test.cheese";
-      echo("Attempting to copy: " + messageID + " to destination: " + newDestinationName);
-      proxy.copyMessageTo(messageID, newDestinationName);
-
-      assertEquals("Queue size", MESSAGE_COUNT, proxy.getQueueSize());
-
-      messageID = messageIDs[1];
-      echo("Attempting to remove: " + messageID);
-      proxy.removeMessage(messageID);
-
-      assertEquals("Queue size", MESSAGE_COUNT - 1, proxy.getQueueSize());
-
-      echo("Worked!");
-   }
-
-   protected void assertCreateAndDestroyDurableSubscriptions() throws Exception {
-      // lets create a new topic
-      ObjectName brokerName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost");
-      echo("Create QueueView MBean...");
-      BrokerViewMBean broker = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);
-
-      broker.addTopic(getDestinationString());
-
-      assertEquals("Durable subscriber count", 0, broker.getDurableTopicSubscribers().length);
-
-      String topicName = getDestinationString();
-      String selector = null;
-      ObjectName name1 = broker.createDurableSubscriber(clientID, "subscriber1", topicName, selector);
-      broker.createDurableSubscriber(clientID, "subscriber2", topicName, selector);
-      assertEquals("Durable subscriber count", 2, broker.getInactiveDurableTopicSubscribers().length);
-
-      assertNotNull("Should have created an mbean name for the durable subscriber!", name1);
-
-      LOG.info("Created durable subscriber with name: " + name1);
-
-      // now lets try destroy it
-      broker.destroyDurableSubscriber(clientID, "subscriber1");
-      assertEquals("Durable subscriber count", 1, broker.getInactiveDurableTopicSubscribers().length);
-   }
-
-   protected void assertConsumerCounts() throws Exception {
-      ObjectName brokerName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost");
-      BrokerViewMBean broker = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);
-
-      assertTrue("broker is not a slave", !broker.isSlave());
-      // create 2 topics
-      broker.addTopic(getDestinationString() + "1");
-      broker.addTopic(getDestinationString() + "2");
-
-      ObjectName topicObjName1 = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Topic,destinationName=" + getDestinationString() + "1");
-      ObjectName topicObjName2 = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Topic,destinationName=" + getDestinationString() + "2");
-      TopicViewMBean topic1 = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, topicObjName1, TopicViewMBean.class, true);
-      TopicViewMBean topic2 = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, topicObjName2, TopicViewMBean.class, true);
-
-      assertEquals("topic1 Durable subscriber count", 0, topic1.getConsumerCount());
-      assertEquals("topic2 Durable subscriber count", 0, topic2.getConsumerCount());
-
-      String topicName = getDestinationString();
-      String selector = null;
-
-      // create 1 subscriber for each topic
-      broker.createDurableSubscriber(clientID, "topic1.subscriber1", topicName + "1", selector);
-      broker.createDurableSubscriber(clientID, "topic2.subscriber1", topicName + "2", selector);
-
-      assertEquals("topic1 Durable subscriber count", 1, topic1.getConsumerCount());
-      assertEquals("topic2 Durable subscriber count", 1, topic2.getConsumerCount());
-
-      // create 1 more subscriber for topic1
-      broker.createDurableSubscriber(clientID, "topic1.subscriber2", topicName + "1", selector);
-
-      assertEquals("topic1 Durable subscriber count", 2, topic1.getConsumerCount());
-      assertEquals("topic2 Durable subscriber count", 1, topic2.getConsumerCount());
-
-      // destroy topic1 subscriber
-      broker.destroyDurableSubscriber(clientID, "topic1.subscriber1");
-
-      assertEquals("topic1 Durable subscriber count", 1, topic1.getConsumerCount());
-      assertEquals("topic2 Durable subscriber count", 1, topic2.getConsumerCount());
-
-      // destroy topic2 subscriber
-      broker.destroyDurableSubscriber(clientID, "topic2.subscriber1");
-
-      assertEquals("topic1 Durable subscriber count", 1, topic1.getConsumerCount());
-      assertEquals("topic2 Durable subscriber count", 0, topic2.getConsumerCount());
-
-      // destroy remaining topic1 subscriber
-      broker.destroyDurableSubscriber(clientID, "topic1.subscriber2");
-
-      assertEquals("topic1 Durable subscriber count", 0, topic1.getConsumerCount());
-      assertEquals("topic2 Durable subscriber count", 0, topic2.getConsumerCount());
-   }
-
-   protected void assertProducerCounts() throws Exception {
-      ObjectName brokerName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost");
-      BrokerViewMBean broker = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);
-
-      assertTrue("broker is not a slave", !broker.isSlave());
-      // create 2 topics
-      broker.addTopic(getDestinationString() + "1");
-      broker.addTopic(getDestinationString() + "2");
-
-      ObjectName topicObjName1 = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Topic,destinationName=" + getDestinationString() + "1");
-      ObjectName topicObjName2 = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Topic,destinationName=" + getDestinationString() + "2");
-      TopicViewMBean topic1 = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, topicObjName1, TopicViewMBean.class, true);
-      TopicViewMBean topic2 = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, topicObjName2, TopicViewMBean.class, true);
-
-      assertEquals("topic1 Producer count", 0, topic1.getProducerCount());
-      assertEquals("topic2 Producer count", 0, topic2.getProducerCount());
-      assertEquals("broker Topic Producer count", 0, broker.getTopicProducers().length);
-
-      // create 1 producer for each topic
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Destination dest1 = session.createTopic(getDestinationString() + "1");
-      Destination dest2 = session.createTopic(getDestinationString() + "2");
-      MessageProducer producer1 = session.createProducer(dest1);
-      MessageProducer producer2 = session.createProducer(dest2);
-      Thread.sleep(500);
-
-      assertEquals("topic1 Producer count", 1, topic1.getProducerCount());
-      assertEquals("topic2 Producer count", 1, topic2.getProducerCount());
-
-      assertEquals("broker Topic Producer count", 2, broker.getTopicProducers().length);
-
-      // create 1 more producer for topic1
-      MessageProducer producer3 = session.createProducer(dest1);
-      Thread.sleep(500);
-
-      assertEquals("topic1 Producer count", 2, topic1.getProducerCount());
-      assertEquals("topic2 Producer count", 1, topic2.getProducerCount());
-
-      assertEquals("broker Topic Producer count", 3, broker.getTopicProducers().length);
-
-      // destroy topic1 producer
-      producer1.close();
-      Thread.sleep(500);
-
-      assertEquals("topic1 Producer count", 1, topic1.getProducerCount());
-      assertEquals("topic2 Producer count", 1, topic2.getProducerCount());
-
-      assertEquals("broker Topic Producer count", 2, broker.getTopicProducers().length);
-
-      // destroy topic2 producer
-      producer2.close();
-      Thread.sleep(500);
-
-      assertEquals("topic1 Producer count", 1, topic1.getProducerCount());
-      assertEquals("topic2 Producer count", 0, topic2.getProducerCount());
-
-      assertEquals("broker Topic Producer count", 1, broker.getTopicProducers().length);
-
-      // destroy remaining topic1 producer
-      producer3.close();
-      Thread.sleep(500);
-
-      assertEquals("topic1 Producer count", 0, topic1.getProducerCount());
-      assertEquals("topic2 Producer count", 0, topic2.getProducerCount());
-
-      MessageProducer producer4 = session.createProducer(null);
-      Thread.sleep(500);
-      assertEquals(1, broker.getDynamicDestinationProducers().length);
-      producer4.close();
-      Thread.sleep(500);
-
-      assertEquals("broker Topic Producer count", 0, broker.getTopicProducers().length);
-   }
-
-   protected ObjectName assertRegisteredObjectName(String name) throws MalformedObjectNameException, Exception {
-      final ObjectName objectName = new ObjectName(name);
-      final AtomicBoolean result = new AtomicBoolean(false);
-      assertTrue("Bean registered: " + objectName, Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            try {
-               result.set(mbeanServer.isRegistered(objectName));
-            }
-            catch (Exception ignored) {
-               LOG.debug(ignored.toString());
-            }
-            return result.get();
-         }
-      }));
-      return objectName;
-   }
-
-   protected ObjectName assertNotRegisteredObjectName(String name) throws MalformedObjectNameException, NullPointerException {
-      ObjectName objectName = new ObjectName(name);
-      if (mbeanServer.isRegistered(objectName)) {
-         fail("Found the MBean!: " + objectName);
-      }
-      else {
-         echo("Bean not registered Registered: " + objectName);
-      }
-      return objectName;
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      bindAddress = "tcp://localhost:0";
-      useTopic = false;
-      super.setUp();
-      ManagementContext managementContext = broker.getManagementContext();
-      mbeanServer = managementContext.getMBeanServer();
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      if (waitForKeyPress) {
-         // We are running from the command line so let folks browse the
-         // mbeans...
-         System.out.println();
-         System.out.println("Press enter to terminate the program.");
-         System.out.println("In the meantime you can use your JMX console to view the current MBeans");
-         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
-         reader.readLine();
-      }
-
-      if (connection != null) {
-         connection.close();
-         connection = null;
-      }
-      super.tearDown();
-   }
-
-   @Override
-   protected ConnectionFactory createConnectionFactory() throws Exception {
-      return new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString());
-   }
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      BrokerService answer = new BrokerService();
-      answer.setPersistent(false);
-      answer.setDeleteAllMessagesOnStartup(true);
-      answer.setUseJmx(true);
-
-      // apply memory limit so that %usage is visible
-      PolicyMap policyMap = new PolicyMap();
-      PolicyEntry defaultEntry = new PolicyEntry();
-      defaultEntry.setMemoryLimit(1024 * 1024 * 4);
-      policyMap.setDefaultEntry(defaultEntry);
-      answer.setDestinationPolicy(policyMap);
-
-      // allow options to be visible via jmx
-      answer.setDestinations(new ActiveMQDestination[]{new ActiveMQQueue(QUEUE_WITH_OPTIONS + "?topQueue=true&hasOptions=2")});
-
-      answer.addConnector(bindAddress);
-      return answer;
-   }
-
-   protected void useConnection(Connection connection) throws Exception {
-      connection.setClientID(clientID);
-      connection.start();
-      Session session = connection.createSession(transacted, authMode);
-      destination = createDestination();
-      MessageProducer producer = session.createProducer(destination);
-      for (int i = 0; i < MESSAGE_COUNT; i++) {
-         Message message = session.createTextMessage("Message: " + i);
-         message.setIntProperty("counter", i);
-         message.setJMSCorrelationID("MyCorrelationID");
-         message.setJMSReplyTo(new ActiveMQQueue("MyReplyTo"));
-         message.setJMSType("MyType");
-         message.setJMSPriority(5);
-         producer.send(message);
-      }
-      Thread.sleep(1000);
-   }
-
-   protected void useConnectionWithBlobMessage(Connection connection) throws Exception {
-      connection.setClientID(clientID);
-      connection.start();
-      ActiveMQSession session = (ActiveMQSession) connection.createSession(transacted, authMode);
-      destination = createDestination();
-      MessageProducer producer = session.createProducer(destination);
-      for (int i = 0; i < MESSAGE_COUNT; i++) {
-         BlobMessage message = session.createBlobMessage(new URL("http://foo.bar/test"));
-         message.setIntProperty("counter", i);
-         message.setJMSCorrelationID("MyCorrelationID");
-         message.setJMSReplyTo(new ActiveMQQueue("MyReplyTo"));
-         message.setJMSType("MyType");
-         message.setJMSPriority(5);
-         producer.send(message);
-      }
-      Thread.sleep(1000);
-   }
-
-   protected void useConnectionWithByteMessage(Connection connection) throws Exception {
-      connection.setClientID(clientID);
-      connection.start();
-      ActiveMQSession session = (ActiveMQSession) connection.createSession(transacted, authMode);
-      destination = createDestination();
-      MessageProducer producer = session.createProducer(destination);
-      for (int i = 0; i < MESSAGE_COUNT; i++) {
-         BytesMessage message = session.createBytesMessage();
-         message.writeBytes(("Message: " + i).getBytes());
-         message.setIntProperty("counter", i);
-         message.setJMSCorrelationID("MyCorrelationID");
-         message.setJMSReplyTo(new ActiveMQQueue("MyReplyTo"));
-         message.setJMSType("MyType");
-         message.setJMSPriority(5);
-         producer.send(message);
-      }
-      Thread.sleep(1000);
-   }
-
-   protected void echo(String text) {
-      //LOG.info(text);
-   }
-
-   protected String getSecondDestinationString() {
-      return "test.new.destination." + getClass() + "." + getName();
-   }
-
-   public void testDynamicProducerView() throws Exception {
-      connection = connectionFactory.createConnection();
-
-      ObjectName brokerName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost");
-      BrokerViewMBean broker = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);
-
-      assertEquals(0, broker.getDynamicDestinationProducers().length);
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = session.createProducer(null);
-
-      Destination dest1 = session.createTopic("DynamicDest-1");
-      Destination dest2 = session.createTopic("DynamicDest-2");
-      Destination dest3 = session.createQueue("DynamicDest-3");
-
-      // Wait a bit to let the producer get registered.
-      Thread.sleep(100);
-
-      assertEquals(1, broker.getDynamicDestinationProducers().length);
-
-      ObjectName viewName = broker.getDynamicDestinationProducers()[0];
-      assertNotNull(viewName);
-      ProducerViewMBean view = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, viewName, ProducerViewMBean.class, true);
-      assertNotNull(view);
-
-      assertEquals("NOTSET", view.getDestinationName());
-
-      producer.send(dest1, session.createTextMessage("Test Message 1"));
-      Thread.sleep(200);
-      assertEquals(((ActiveMQDestination) dest1).getPhysicalName(), view.getDestinationName());
-      assertTrue(view.isDestinationTopic());
-      assertFalse(view.isDestinationQueue());
-      assertFalse(view.isDestinationTemporary());
-
-      producer.send(dest2, session.createTextMessage("Test Message 2"));
-      Thread.sleep(200);
-      assertEquals(((ActiveMQDestination) dest2).getPhysicalName(), view.getDestinationName());
-      assertTrue(view.isDestinationTopic());
-      assertFalse(view.isDestinationQueue());
-      assertFalse(view.isDestinationTemporary());
-
-      producer.send(dest3, session.createTextMessage("Test Message 3"));
-      Thread.sleep(200);
-      assertEquals(((ActiveMQDestination) dest3).getPhysicalName(), view.getDestinationName());
-      assertTrue(view.isDestinationQueue());
-      assertFalse(view.isDestinationTopic());
-      assertFalse(view.isDestinationTemporary());
-
-      producer.close();
-      Thread.sleep(200);
-      assertEquals(0, broker.getDynamicDestinationProducers().length);
-   }
-
-   public void testTempQueueJMXDelete() throws Exception {
-      connection = connectionFactory.createConnection();
-
-      connection.setClientID(clientID);
-      connection.start();
-      Session session = connection.createSession(transacted, authMode);
-      ActiveMQTempQueue tQueue = (ActiveMQTempQueue) session.createTemporaryQueue();
-      Thread.sleep(1000);
-
-      ObjectName queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=" + JMXSupport.encodeObjectNamePart(tQueue.getDestinationTypeAsString()) + ",destinationName=" + JMXSupport.encodeObjectNamePart(tQueue.getPhysicalName()));
-
-      // should not throw an exception
-
-      mbeanServer.getObjectInstance(queueViewMBeanName);
-
-      tQueue.delete();
-      Thread.sleep(1000);
-      try {
-         // should throw an exception
-         mbeanServer.getObjectInstance(queueViewMBeanName);
-
-         fail("should be deleted already!");
-      }
-      catch (Exception e) {
-         // expected!
-      }
-   }
-
-   // Test for AMQ-3029
-   public void testBrowseBlobMessages() throws Exception {
-      connection = connectionFactory.createConnection();
-      useConnectionWithBlobMessage(connection);
-
-      ObjectName queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + getDestinationString());
-
-      QueueViewMBean queue = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-
-      CompositeData[] compdatalist = queue.browse();
-      int initialQueueSize = compdatalist.length;
-      if (initialQueueSize == 0) {
-         fail("There is no message in the queue:");
-      }
-      else {
-         echo("Current queue size: " + initialQueueSize);
-      }
-      int messageCount = initialQueueSize;
-      String[] messageIDs = new String[messageCount];
-      for (int i = 0; i < messageCount; i++) {
-         CompositeData cdata = compdatalist[i];
-         String messageID = (String) cdata.get("JMSMessageID");
-         assertNotNull("Should have a message ID for message " + i, messageID);
-
-         messageIDs[i] = messageID;
-      }
-
-      assertTrue("dest has some memory usage", queue.getMemoryPercentUsage() > 0);
-   }
-
-   public void testDestinationOptionsAreVisible() throws Exception {
-      ObjectName queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + QUEUE_WITH_OPTIONS);
-
-      QueueViewMBean queue = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-
-      assertEquals("name match", QUEUE_WITH_OPTIONS, queue.getName());
-
-      String options = queue.getOptions();
-      LOG.info("Got options: " + options);
-
-      Map<String, String> optionsMap = URISupport.parseQuery(options);
-      assertEquals("got a map", 2, optionsMap.size());
-      assertTrue("matches our options", optionsMap.containsKey("hasOptions"));
-      assertTrue("matches our options", optionsMap.containsKey("topQueue"));
-
-      assertTrue("matches our options", optionsMap.containsValue("true"));
-      assertTrue("matches our options", optionsMap.containsValue("2"));
-   }
-
-   public void testSubscriptionViewToConnectionMBean() throws Exception {
-
-      connection = connectionFactory.createConnection("admin", "admin");
-      connection.setClientID("MBeanTest");
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Destination queue = session.createQueue(getDestinationString() + ".Queue");
-      MessageConsumer queueConsumer = session.createConsumer(queue);
-      MessageProducer producer = session.createProducer(queue);
-
-      ObjectName brokerName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost");
-      BrokerViewMBean broker = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);
-
-      Thread.sleep(100);
-
-      assertTrue(broker.getQueueSubscribers().length == 1);
-
-      ObjectName subscriptionName = broker.getQueueSubscribers()[0];
-      LOG.info("Looking for Subscription: " + subscriptionName);
-
-      SubscriptionViewMBean subscriberView = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, subscriptionName, SubscriptionViewMBean.class, true);
-      assertNotNull(subscriberView);
-
-      ObjectName connectionName = subscriberView.getConnection();
-      LOG.info("Looking for Connection: " + connectionName);
-      assertNotNull(connectionName);
-      ConnectionViewMBean connectionView = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, connectionName, ConnectionViewMBean.class, true);
-      assertNotNull(connectionView);
-
-      // Our consumer plus one advisory consumer.
-      assertEquals(2, connectionView.getConsumers().length);
-
-      assertEquals("client id match", "MBeanTest", connectionView.getClientId());
-
-      // Check that the subscription view we found earlier is in this list.
-      boolean found = false;
-      for (ObjectName name : connectionView.getConsumers()) {
-         if (name.equals(subscriptionName)) {
-            found = true;
-         }
-      }
-      assertTrue("We should have found: " + subscriptionName, found);
-
-      // Our producer and no others.
-      assertEquals(1, connectionView.getProducers().length);
-
-      // Bean should detect the updates.
-      queueConsumer.close();
-      producer.close();
-
-      Thread.sleep(200);
-
-      // Only an advisory consumers now.
-      assertEquals(1, connectionView.getConsumers().length);
-      assertEquals(0, connectionView.getProducers().length);
-   }
-
-   public void testCreateAndUnsubscribeDurableSubscriptions() throws Exception {
-
-      connection = connectionFactory.createConnection("admin", "admin");
-      connection.setClientID("MBeanTest");
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      String topicName = getDestinationString() + ".DurableTopic";
-      Topic topic = session.createTopic(topicName);
-
-      ObjectName brokerName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost");
-      echo("Create QueueView MBean...");
-      BrokerViewMBean broker = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);
-
-      assertEquals("Durable subscriber count", 0, broker.getDurableTopicSubscribers().length);
-      assertEquals("Durable subscriber count", 0, broker.getInactiveDurableTopicSubscribers().length);
-
-      MessageConsumer durableConsumer1 = session.createDurableSubscriber(topic, "subscription1");
-      MessageConsumer durableConsumer2 = session.createDurableSubscriber(topic, "subscription2");
-
-      Thread.sleep(100);
-
-      assertEquals("Durable subscriber count", 2, broker.getDurableTopicSubscribers().length);
-      assertEquals("Durable subscriber count", 0, broker.getInactiveDurableTopicSubscribers().length);
-
-      durableConsumer1.close();
-      durableConsumer2.close();
-
-      Thread.sleep(100);
-
-      assertEquals("Durable subscriber count", 0, broker.getDurableTopicSubscribers().length);
-      assertEquals("Durable subscriber count", 2, broker.getInactiveDurableTopicSubscribers().length);
-
-      session.unsubscribe("subscription1");
-
-      Thread.sleep(100);
-
-      assertEquals("Inactive Durable subscriber count", 1, broker.getInactiveDurableTopicSubscribers().length);
-
-      session.unsubscribe("subscription2");
-
-      assertEquals("Inactive Durable subscriber count", 0, broker.getInactiveDurableTopicSubscribers().length);
-   }
-
-   public void testUserNamePopulated() throws Exception {
-      doTestUserNameInMBeans(true);
-   }
-
-   public void testUserNameNotPopulated() throws Exception {
-      doTestUserNameInMBeans(false);
-   }
-
-   @SuppressWarnings("unused")
-   private void doTestUserNameInMBeans(boolean expect) throws Exception {
-      broker.setPopulateUserNameInMBeans(expect);
-
-      connection = connectionFactory.createConnection("admin", "admin");
-      connection.setClientID("MBeanTest");
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Destination queue = session.createQueue(getDestinationString() + ".Queue");
-      Topic topic = session.createTopic(getDestinationString() + ".Topic");
-      MessageProducer producer = session.createProducer(queue);
-      MessageConsumer queueConsumer = session.createConsumer(queue);
-      MessageConsumer topicConsumer = session.createConsumer(topic);
-      MessageConsumer durable = session.createDurableSubscriber(topic, "Durable");
-
-      ObjectName brokerName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost");
-      BrokerViewMBean broker = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);
-
-      Thread.sleep(100);
-
-      assertTrue(broker.getQueueProducers().length == 1);
-      assertTrue(broker.getTopicSubscribers().length == 2);
-      assertTrue(broker.getQueueSubscribers().length == 1);
-
-      ObjectName producerName = broker.getQueueProducers()[0];
-      ProducerViewMBean producerView = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, producerName, ProducerViewMBean.class, true);
-      assertNotNull(producerView);
-
-      if (expect) {
-         assertEquals("admin", producerView.getUserName());
-      }
-      else {
-         assertNull(producerView.getUserName());
-      }
-
-      for (ObjectName name : broker.getTopicSubscribers()) {
-         SubscriptionViewMBean subscriberView = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, name, SubscriptionViewMBean.class, true);
-         if (expect) {
-            assertEquals("admin", subscriberView.getUserName());
-         }
-         else {
-            assertNull(subscriberView.getUserName());
-         }
-      }
-
-      for (ObjectName name : broker.getQueueSubscribers()) {
-         SubscriptionViewMBean subscriberView = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, name, SubscriptionViewMBean.class, true);
-         if (expect) {
-            assertEquals("admin", subscriberView.getUserName());
-         }
-         else {
-            assertNull(subscriberView.getUserName());
-         }
-      }
-      ObjectName query = //new ObjectName(domain + ":type=Broker,brokerName=localhost,connector=*," + "connectorName=*,connectionName=MBeanTest");
-         BrokerMBeanSupport.createConnectionQuery(domain, "localhost", connection.getClientID());
-
-      Set<ObjectName> names = mbeanServer.queryNames(query, null);
-      boolean found = false;
-      for (ObjectName name : names) {
-         if (name.toString().endsWith("connectionName=MBeanTest")) {
-
-            ConnectionViewMBean connectionView = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, name, ConnectionViewMBean.class, true);
-            assertNotNull(connectionView);
-
-            if (expect) {
-               assertEquals("admin", connectionView.getUserName());
-            }
-            else {
-               assertNull(connectionView.getUserName());
-            }
-
-            found = true;
-            break;
-         }
-      }
-
-      assertTrue("Should find the connection's ManagedTransportConnection", found);
-   }
-
-   public void testMoveMessagesToRetainOrder() throws Exception {
-      connection = connectionFactory.createConnection();
-      useConnection(connection);
-
-      ObjectName queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + getDestinationString());
-
-      QueueViewMBean queue = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-
-      String newDestination = getSecondDestinationString();
-      queue.moveMatchingMessagesTo("", newDestination);
-
-      queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + newDestination);
-
-      queue = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-      int movedSize = MESSAGE_COUNT;
-      assertEquals("Unexpected number of messages ", movedSize, queue.getQueueSize());
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Destination destination = session.createQueue(newDestination);
-      MessageConsumer consumer = session.createConsumer(destination);
-
-      int last = -1;
-      int current = -1;
-      Message message = null;
-      while ((message = consumer.receive(2000)) != null) {
-         if (message.propertyExists("counter")) {
-            current = message.getIntProperty("counter");
-            assertEquals(last, current - 1);
-            last = current;
-         }
-      }
-
-      // now lets remove them by selector
-      queue.removeMatchingMessages("");
-
-      assertEquals("Should have no more messages in the queue: " + queueViewMBeanName, 0, queue.getQueueSize());
-      assertEquals("dest has no memory usage", 0, queue.getMemoryPercentUsage());
-   }
-
-   public void testConnectionCounts() throws Exception {
-
-      ObjectName brokerName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost");
-      BrokerViewMBean broker = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);
-
-      assertEquals(0, broker.getCurrentConnectionsCount());
-
-      connection = connectionFactory.createConnection();
-      useConnection(connection);
-
-      assertEquals(1, broker.getCurrentConnectionsCount());
-      connection.close();
-      assertEquals(0, broker.getCurrentConnectionsCount());
-      assertEquals(1, broker.getTotalConnectionsCount());
-   }
-
-   public void testCopyMessagesToRetainOrder() throws Exception {
-      connection = connectionFactory.createConnection();
-      useConnection(connection);
-
-      ObjectName queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + getDestinationString());
-
-      QueueViewMBean queue = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-
-      String newDestination = getSecondDestinationString();
-      queue.copyMatchingMessagesTo("", newDestination);
-
-      queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + newDestination);
-
-      queue = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-      int movedSize = MESSAGE_COUNT;
-      assertEquals("Unexpected number of messages ", movedSize, queue.getQueueSize());
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Destination destination = session.createQueue(newDestination);
-      MessageConsumer consumer = session.createConsumer(destination);
-
-      int last = -1;
-      int current = -1;
-      Message message = null;
-      while ((message = consumer.receive(2000)) != null) {
-         if (message.propertyExists("counter")) {
-            current = message.getIntProperty("counter");
-            assertEquals(last, current - 1);
-            last = current;
-         }
-      }
-
-      // now lets remove them by selector
-      queue.removeMatchingMessages("");
-
-      assertEquals("Should have no more messages in the queue: " + queueViewMBeanName, 0, queue.getQueueSize());
-      assertEquals("dest has no memory usage", 0, queue.getMemoryPercentUsage());
-   }
-
-   public void testRemoveMatchingMessageRetainOrder() throws Exception {
-      connection = connectionFactory.createConnection();
-      useConnection(connection);
-
-      ObjectName queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + getDestinationString());
-
-      QueueViewMBean queue = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-
-      String queueName = getDestinationString();
-      queue.removeMatchingMessages("counter < 10");
-
-      int newSize = MESSAGE_COUNT - 10;
-      assertEquals("Unexpected number of messages ", newSize, queue.getQueueSize());
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Destination destination = session.createQueue(queueName);
-      MessageConsumer consumer = session.createConsumer(destination);
-
-      int last = 9;
-      int current = 0;
-      Message message = null;
-      while ((message = consumer.receive(2000)) != null) {
-         if (message.propertyExists("counter")) {
-            current = message.getIntProperty("counter");
-            assertEquals(last, current - 1);
-            last = current;
-         }
-      }
-
-      // now lets remove them by selector
-      queue.removeMatchingMessages("");
-
-      assertEquals("Should have no more messages in the queue: " + queueViewMBeanName, 0, queue.getQueueSize());
-      assertEquals("dest has no memory usage", 0, queue.getMemoryPercentUsage());
-   }
-
-   public void testBrowseBytesMessages() throws Exception {
-      connection = connectionFactory.createConnection();
-      useConnectionWithByteMessage(connection);
-
-      ObjectName queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + getDestinationString());
-
-      QueueViewMBean queue = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-
-      CompositeData[] compdatalist = queue.browse();
-      int initialQueueSize = compdatalist.length;
-      if (initialQueueSize == 0) {
-         fail("There is no message in the queue:");
-      }
-      else {
-         echo("Current queue size: " + initialQueueSize);
-      }
-      int messageCount = initialQueueSize;
-      String[] messageIDs = new String[messageCount];
-      for (int i = 0; i < messageCount; i++) {
-         CompositeData cdata = compdatalist[i];
-         String messageID = (String) cdata.get("JMSMessageID");
-         assertNotNull("Should have a message ID for message " + i, messageID);
-         messageIDs[i] = messageID;
-
-         Byte[] preview = (Byte[]) cdata.get(CompositeDataConstants.BODY_PREVIEW);
-         assertNotNull("should be a preview", preview);
-         assertTrue("not empty", preview.length > 0);
-      }
-
-      assertTrue("dest has some memory usage", queue.getMemoryPercentUsage() > 0);
-
-      // consume all the messages
-      echo("Attempting to consume all bytes messages from: " + destination);
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer consumer = session.createConsumer(destination);
-      for (int i = 0; i < MESSAGE_COUNT; i++) {
-         Message message = consumer.receive(5000);
-         assertNotNull(message);
-         assertTrue(message instanceof BytesMessage);
-      }
-      consumer.close();
-      session.close();
-   }
-
-   public void testBrowseOrder() throws Exception {
-      connection = connectionFactory.createConnection();
-      ActiveMQPrefetchPolicy prefetchPolicy = new ActiveMQPrefetchPolicy();
-      prefetchPolicy.setAll(20);
-      ((ActiveMQConnection) connection).setPrefetchPolicy(prefetchPolicy);
-      useConnection(connection);
-
-      ObjectName queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + getDestinationString());
-
-      QueueViewMBean queue = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-
-      CompositeData[] compdatalist = queue.browse();
-      int initialQueueSize = compdatalist.length;
-      assertEquals("expected", MESSAGE_COUNT, initialQueueSize);
-
-      int messageCount = initialQueueSize;
-      for (int i = 0; i < messageCount; i++) {
-         CompositeData cdata = compdatalist[i];
-         String messageID = (String) cdata.get("JMSMessageID");
-         assertNotNull("Should have a message ID for message " + i, messageID);
-
-         Map intProperties = CompositeDataHelper.getTabularMap(cdata, CompositeDataConstants.INT_PROPERTIES);
-         assertTrue("not empty", intProperties.size() > 0);
-         assertEquals("counter in order", i, intProperties.get("counter"));
-      }
-
-      echo("Attempting to consume 5 bytes messages from: " + destination);
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer consumer = session.createConsumer(destination);
-      for (int i = 0; i < 5; i++) {
-         Message message = consumer.receive(5000);
-         assertNotNull(message);
-         assertEquals("ordered", i, message.getIntProperty("counter"));
-         echo("Consumed: " + message.getIntProperty("counter"));
-      }
-      consumer.close();
-      session.close();
-      connection.close();
-
-      // browse again and verify order
-      compdatalist = queue.browse();
-      initialQueueSize = compdatalist.length;
-      assertEquals("5 gone", MESSAGE_COUNT - 5, initialQueueSize);
-
-      messageCount = initialQueueSize;
-      for (int i = 0; i < messageCount - 4; i++) {
-         CompositeData cdata = compdatalist[i];
-
-         Map intProperties = CompositeDataHelper.getTabularMap(cdata, CompositeDataConstants.INT_PROPERTIES);
-         assertTrue("not empty", intProperties.size() > 0);
-         assertEquals("counter in order", i + 5, intProperties.get("counter"));
-         echo("Got: " + intProperties.get("counter"));
-      }
-   }
-
-   public void testAddRemoveConnectorBrokerView() throws Exception {
-
-      ObjectName brokerName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost");
-      BrokerViewMBean brokerView = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);
-
-      Map<String, String> connectors = brokerView.getTransportConnectors();
-      LOG.info("Connectors: " + connectors);
-      assertEquals("one connector", 1, connectors.size());
-
-      ConnectorViewMBean connector = getProxyToConnectionView("tcp");
-      assertNotNull(connector);
-
-      String name = connectors.keySet().iterator().next().toString();
-
-      brokerView.removeConnector(name);
-
-      connectors = brokerView.getTransportConnectors();
-      assertEquals("empty", 0, connectors.size());
-
-      name = brokerView.addConnector("tcp://0.0.0.0:0");
-
-      connector = getProxyToConnectionView("tcp");
-      assertNotNull(connector);
-
-      connectors = brokerView.getTransportConnectors();
-      LOG.info("Connectors: " + connectors);
-      assertEquals("one connector", 1, connectors.size());
-      assertTrue("name is in map: " + connectors.keySet(), connectors.keySet().contains(name));
-   }
-
-   public void testConnectorView() throws Exception {
-      ConnectorViewMBean connector = getProxyToConnectionView("tcp");
-      assertNotNull(connector);
-
-      assertFalse(connector.isRebalanceClusterClients());
-      assertFalse(connector.isUpdateClusterClientsOnRemove());
-      assertFalse(connector.isUpdateClusterClients());
-      assertFalse(connector.isAllowLinkStealingEnabled());
-   }
-
-   protected ConnectorViewMBean getProxyToConnectionView(String connectionType) throws Exception {
-      ObjectName connectorQuery = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost,connector=clientConnectors,connectorName=" + connectionType + "_//*");
-
-      Set<ObjectName> results = broker.getManagementContext().queryNames(connectorQuery, null);
-
-      if (results == null || results.isEmpty() || results.size() > 1) {
-         throw new Exception("Unable to find the exact Connector instance.");
-      }
-
-      ConnectorViewMBean proxy = (ConnectorViewMBean) broker.getManagementContext().newProxyInstance(results.iterator().next(), ConnectorViewMBean.class, true);
-      return proxy;
-   }
-
-   public void testDynamicProducers() throws Exception {
-      connection = connectionFactory.createConnection();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = session.createProducer(null);
-
-      ObjectName query = new ObjectName(domain + ":type=Broker,brokerName=localhost,endpoint=dynamicProducer,*");
-      Set<ObjectInstance> mbeans = mbeanServer.queryMBeans(query, null);
-      assertEquals(mbeans.size(), 1);
-      producer.close();
-   }
-
-   public void testDurableSubQuery() throws Exception {
-      connection = connectionFactory.createConnection();
-      connection.setClientID("test");
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      TopicSubscriber sub = session.createDurableSubscriber(session.createTopic("test.topic"), "test.consumer");
-
-      ObjectName query = new ObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Topic,destinationName=test.topic,endpoint=Consumer,consumerId=Durable(*),*");
-      Set<ObjectInstance> mbeans = mbeanServer.queryMBeans(query, null);
-      assertEquals(mbeans.size(), 1);
-      sub.close();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/PurgeTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/PurgeTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/PurgeTest.java
deleted file mode 100644
index 54e5793..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/PurgeTest.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/**
- * 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.broker.jmx;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerInvocationHandler;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import junit.framework.Test;
-
-import junit.textui.TestRunner;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.store.PersistenceAdapter;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.store.memory.MemoryPersistenceAdapter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A specific test of Queue.purge() functionality
- */
-public class PurgeTest extends EmbeddedBrokerTestSupport {
-
-   private static final Logger LOG = LoggerFactory.getLogger(PurgeTest.class);
-
-   protected MBeanServer mbeanServer;
-   protected String domain = "org.apache.activemq";
-   protected String clientID = "foo";
-
-   protected Connection connection;
-   protected boolean transacted;
-   protected int authMode = Session.AUTO_ACKNOWLEDGE;
-   protected int messageCount = 10;
-   public PersistenceAdapter persistenceAdapter;
-
-   public static void main(String[] args) {
-      TestRunner.run(PurgeTest.class);
-   }
-
-   public static Test suite() {
-      return suite(PurgeTest.class);
-   }
-
-   public void testPurge() throws Exception {
-      // Send some messages
-      connection = connectionFactory.createConnection();
-      connection.setClientID(clientID);
-      connection.start();
-      Session session = connection.createSession(transacted, authMode);
-      destination = createDestination();
-      MessageProducer producer = session.createProducer(destination);
-      for (int i = 0; i < messageCount; i++) {
-         Message message = session.createTextMessage("Message: " + i);
-         producer.send(message);
-      }
-
-      // Now get the QueueViewMBean and purge
-      String objectNameStr = broker.getBrokerObjectName().toString();
-      objectNameStr += ",destinationType=Queue,destinationName=" + getDestinationString();
-      ObjectName queueViewMBeanName = assertRegisteredObjectName(objectNameStr);
-      QueueViewMBean proxy = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-
-      long count = proxy.getQueueSize();
-      assertEquals("Queue size", count, messageCount);
-
-      proxy.purge();
-      count = proxy.getQueueSize();
-      assertEquals("Queue size", count, 0);
-      assertEquals("Browse size", proxy.browseMessages().size(), 0);
-
-      // Queues have a special case once there are more than a thousand
-      // dead messages, make sure we hit that.
-      messageCount += 1000;
-      for (int i = 0; i < messageCount; i++) {
-         Message message = session.createTextMessage("Message: " + i);
-         producer.send(message);
-      }
-
-      count = proxy.getQueueSize();
-      assertEquals("Queue size", count, messageCount);
-
-      proxy.purge();
-      count = proxy.getQueueSize();
-      assertEquals("Queue size", count, 0);
-      assertEquals("Browse size", proxy.browseMessages().size(), 0);
-
-      producer.close();
-   }
-
-   public void initCombosForTestDelete() {
-      addCombinationValues("persistenceAdapter", new Object[]{new MemoryPersistenceAdapter(), new KahaDBPersistenceAdapter()});
-   }
-
-   public void testDeleteSameProducer() throws Exception {
-      connection = connectionFactory.createConnection();
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      destination = createDestination();
-
-      MessageProducer producer = session.createProducer(destination);
-      Message message = session.createTextMessage("Test Message");
-      producer.send(message);
-
-      MessageConsumer consumer = session.createConsumer(destination);
-
-      Message received = consumer.receive(1000);
-      assertEquals(message, received);
-
-      ObjectName brokerViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost");
-      BrokerViewMBean brokerProxy = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerViewMBeanName, BrokerViewMBean.class, true);
-
-      brokerProxy.removeQueue(getDestinationString());
-      producer.send(message);
-
-      received = consumer.receive(1000);
-
-      assertNotNull("Message not received", received);
-      assertEquals(message, received);
-   }
-
-   public void testDelete() throws Exception {
-      // Send some messages
-      connection = connectionFactory.createConnection();
-      connection.setClientID(clientID);
-      connection.start();
-      Session session = connection.createSession(transacted, authMode);
-      destination = createDestination();
-      sendMessages(session, messageCount);
-
-      // Now get the QueueViewMBean and purge
-
-      ObjectName queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + getDestinationString());
-      QueueViewMBean queueProxy = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-
-      ObjectName brokerViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost");
-      BrokerViewMBean brokerProxy = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerViewMBeanName, BrokerViewMBean.class, true);
-
-      long count = queueProxy.getQueueSize();
-      assertEquals("Queue size", count, messageCount);
-
-      brokerProxy.removeQueue(getDestinationString());
-
-      sendMessages(session, messageCount);
-
-      queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + getDestinationString());
-      queueProxy = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-
-      count = queueProxy.getQueueSize();
-      assertEquals("Queue size", count, messageCount);
-
-      queueProxy.purge();
-
-      // Queue have a special case once there are more than a thousand
-      // dead messages, make sure we hit that.
-      messageCount += 1000;
-      sendMessages(session, messageCount);
-
-      count = queueProxy.getQueueSize();
-      assertEquals("Queue size", count, messageCount);
-
-      brokerProxy.removeQueue(getDestinationString());
-
-      sendMessages(session, messageCount);
-
-      queueViewMBeanName = assertRegisteredObjectName(domain + ":type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + getDestinationString());
-      queueProxy = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-
-      count = queueProxy.getQueueSize();
-      assertEquals("Queue size", count, messageCount);
-   }
-
-   private void sendMessages(Session session, int count) throws Exception {
-      MessageProducer producer = session.createProducer(destination);
-      for (int i = 0; i < messageCount; i++) {
-         Message message = session.createTextMessage("Message: " + i);
-         producer.send(message);
-      }
-   }
-
-   protected ObjectName assertRegisteredObjectName(String name) throws MalformedObjectNameException, NullPointerException {
-      ObjectName objectName = new ObjectName(name);
-      if (mbeanServer.isRegistered(objectName)) {
-         echo("Bean Registered: " + objectName);
-      }
-      else {
-         fail("Could not find MBean!: " + objectName);
-      }
-      return objectName;
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      bindAddress = "tcp://localhost:0";
-      useTopic = false;
-      super.setUp();
-      mbeanServer = broker.getManagementContext().getMBeanServer();
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      if (connection != null) {
-         connection.close();
-         connection = null;
-      }
-      super.tearDown();
-   }
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      BrokerService answer = new BrokerService();
-      answer.setUseJmx(true);
-      answer.setEnableStatistics(true);
-      answer.addConnector(bindAddress);
-      answer.setPersistenceAdapter(persistenceAdapter);
-      answer.deleteAllMessages();
-      return answer;
-   }
-
-   @Override
-   protected ConnectionFactory createConnectionFactory() throws Exception {
-      return new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString());
-   }
-
-   protected void echo(String text) {
-      LOG.info(text);
-   }
-
-   /**
-    * Returns the name of the destination used in this test case
-    */
-   @Override
-   protected String getDestinationString() {
-      return getClass().getName() + "." + getName(true);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/TransportConnectorMBeanTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/TransportConnectorMBeanTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/TransportConnectorMBeanTest.java
deleted file mode 100644
index 3653bf7..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/TransportConnectorMBeanTest.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/**
- * 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.broker.jmx;
-
-import static junit.framework.TestCase.assertTrue;
-import static org.junit.Assert.assertEquals;
-
-import java.net.Socket;
-import java.util.Set;
-
-import javax.management.ObjectName;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.network.NetworkConnector;
-import org.apache.activemq.util.JMXSupport;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class TransportConnectorMBeanTest {
-
-   private static final Logger LOG = LoggerFactory.getLogger(TransportConnectorMBeanTest.class);
-
-   BrokerService broker;
-
-   @Test
-   public void verifyRemoteAddressInMbeanName() throws Exception {
-      doVerifyRemoteAddressInMbeanName(true);
-   }
-
-   @Test
-   public void verifyRemoteAddressNotInMbeanName() throws Exception {
-      doVerifyRemoteAddressInMbeanName(false);
-   }
-
-   @Test
-   public void verifyClientIdNetwork() throws Exception {
-      doVerifyClientIdNetwork(false);
-   }
-
-   @Test
-   public void verifyClientIdDuplexNetwork() throws Exception {
-      doVerifyClientIdNetwork(true);
-   }
-
-   private void doVerifyClientIdNetwork(boolean duplex) throws Exception {
-      createBroker(true);
-
-      BrokerService networked = new BrokerService();
-      networked.setBrokerName("networked");
-      networked.setPersistent(false);
-      NetworkConnector nc = networked.addNetworkConnector("static:" + broker.getTransportConnectors().get(0).getPublishableConnectString());
-      nc.setDuplex(duplex);
-      networked.start();
-
-      try {
-         assertTrue("presence of mbean with clientId", Wait.waitFor(new Wait.Condition() {
-            @Override
-            public boolean isSatisified() throws Exception {
-               Set<ObjectName> registeredMbeans = getRegisteredMbeans();
-               return match("_outbound", registeredMbeans);
-            }
-         }));
-
-      }
-      finally {
-         networked.stop();
-      }
-   }
-
-   private void doVerifyRemoteAddressInMbeanName(boolean allowRemoteAddress) throws Exception {
-      createBroker(allowRemoteAddress);
-      ActiveMQConnection connection = createConnection();
-      Set<ObjectName> registeredMbeans = getRegisteredMbeans();
-      assertEquals("presence of mbean with clientId", true, match(connection.getClientID(), registeredMbeans));
-      assertEquals("presence of mbean with local port", allowRemoteAddress, match(extractLocalPort(connection), registeredMbeans));
-   }
-
-   @After
-   public void stopBroker() throws Exception {
-      if (broker != null) {
-         broker.stop();
-      }
-   }
-
-   private boolean match(String s, Set<ObjectName> registeredMbeans) {
-      String encodedName = JMXSupport.encodeObjectNamePart(s);
-      for (ObjectName name : registeredMbeans) {
-         LOG.info("checking for match:" + encodedName + ", with: " + name.toString());
-         if (name.toString().contains(encodedName)) {
-            return true;
-         }
-      }
-      return false;
-   }
-
-   private String extractLocalPort(ActiveMQConnection connection) throws Exception {
-      Socket socket = connection.getTransport().narrow(Socket.class);
-      return String.valueOf(socket.getLocalPort());
-   }
-
-   private Set<ObjectName> getRegisteredMbeans() throws Exception {
-      // need a little sleep to ensure JMX is up to date
-      Thread.sleep(200);
-      return broker.getManagementContext().queryNames(null, null);
-   }
-
-   private ActiveMQConnection createConnection() throws Exception {
-      final String opts = "?jms.watchTopicAdvisories=false";
-      ActiveMQConnection connection = (ActiveMQConnection) new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getConnectUri() + opts).createConnection();
-      connection.start();
-      return connection;
-   }
-
-   private void createBroker(boolean allowRemoteAddressInMbeanNames) throws Exception {
-      broker = new BrokerService();
-      broker.setPersistent(false);
-      broker.addConnector("tcp://localhost:0");
-      broker.getManagementContext().setAllowRemoteAddressInMBeanNames(allowRemoteAddressInMbeanNames);
-      broker.start();
-   }
-
-}


[54/60] [abbrv] activemq-artemis git commit: Investigation XA Test

Posted by cl...@apache.org.
Investigation XA Test


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/4bbe9838
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/4bbe9838
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/4bbe9838

Branch: refs/heads/refactor-openwire
Commit: 4bbe9838c08fb729f5cd974db71d19809071543b
Parents: 35c14e1
Author: Clebert Suconic <cl...@apache.org>
Authored: Fri Mar 4 16:45:37 2016 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:45:29 2016 -0400

----------------------------------------------------------------------
 .../InvestigationOpenwireTest.java              | 28 ++++++++++++++++++++
 1 file changed, 28 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4bbe9838/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/investigations/InvestigationOpenwireTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/investigations/InvestigationOpenwireTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/investigations/InvestigationOpenwireTest.java
index 1599a2c..da4ecb3 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/investigations/InvestigationOpenwireTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/investigations/InvestigationOpenwireTest.java
@@ -26,6 +26,7 @@ import javax.jms.TextMessage;
 import javax.jms.XAConnection;
 import javax.jms.XASession;
 import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
 import java.util.Collection;
 import java.util.LinkedList;
 
@@ -215,4 +216,31 @@ public class InvestigationOpenwireTest extends BasicOpenWireTest {
          e.printStackTrace();
       }
    }
+
+   @Test
+   public void testXAPrepare() throws Exception {
+      try {
+
+         XAConnection connection = xaFactory.createXAConnection();
+         //      Thread.sleep(5000);
+
+
+         XASession session = connection.createXASession();
+
+         Xid xid = newXID();
+         session.getXAResource().start(xid, XAResource.TMNOFLAGS);
+         Queue queue = session.createQueue(queueName);
+         MessageProducer producer = session.createProducer(queue);
+         producer.send(session.createTextMessage("hello"));
+         session.getXAResource().end(xid, XAResource.TMSUCCESS);
+         session.getXAResource().prepare(xid);
+
+         connection.close();
+
+         System.err.println("Done!!!");
+      }
+      catch (Exception e) {
+         e.printStackTrace();
+      }
+   }
 }


[08/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCMessagePriorityTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCMessagePriorityTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCMessagePriorityTest.java
deleted file mode 100644
index ae0ac1f..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCMessagePriorityTest.java
+++ /dev/null
@@ -1,451 +0,0 @@
-/**
- * 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.store.jdbc;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Vector;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.TopicSubscriber;
-
-import junit.framework.Test;
-
-import org.apache.activemq.command.ActiveMQMessage;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.store.MessagePriorityTest;
-import org.apache.activemq.store.PersistenceAdapter;
-import org.apache.activemq.util.Wait;
-import org.apache.derby.jdbc.EmbeddedDataSource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class JDBCMessagePriorityTest extends MessagePriorityTest {
-
-   private static final Logger LOG = LoggerFactory.getLogger(JDBCMessagePriorityTest.class);
-   EmbeddedDataSource dataSource;
-   JDBCPersistenceAdapter jdbc;
-
-   @Override
-   protected PersistenceAdapter createPersistenceAdapter(boolean delete) throws Exception {
-      jdbc = new JDBCPersistenceAdapter();
-      dataSource = new EmbeddedDataSource();
-      dataSource.setDatabaseName("derbyDb");
-      dataSource.setCreateDatabase("create");
-      dataSource.setShutdownDatabase(null);
-      jdbc.setDataSource(dataSource);
-      jdbc.deleteAllMessages();
-      jdbc.setCleanupPeriod(2000);
-      return jdbc;
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      super.tearDown();
-      try {
-         if (dataSource != null) {
-            // ref http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCDataSource.java?view=markup
-            dataSource.setShutdownDatabase("shutdown");
-            dataSource.getConnection();
-         }
-      }
-      catch (Exception ignored) {
-      }
-      finally {
-         dataSource.setShutdownDatabase(null);
-      }
-
-   }
-
-   // this cannot be a general test as kahaDB just has support for 3 priority levels
-   public void testDurableSubsReconnectWithFourLevels() throws Exception {
-      ActiveMQTopic topic = (ActiveMQTopic) sess.createTopic("TEST");
-      final String subName = "priorityDisconnect";
-      TopicSubscriber sub = sess.createDurableSubscriber(topic, subName);
-      sub.close();
-
-      final int MED_PRI = LOW_PRI + 1;
-      final int MED_HIGH_PRI = HIGH_PRI - 1;
-
-      ProducerThread lowPri = new ProducerThread(topic, MSG_NUM, LOW_PRI);
-      ProducerThread medPri = new ProducerThread(topic, MSG_NUM, MED_PRI);
-      ProducerThread medHighPri = new ProducerThread(topic, MSG_NUM, MED_HIGH_PRI);
-      ProducerThread highPri = new ProducerThread(topic, MSG_NUM, HIGH_PRI);
-
-      lowPri.start();
-      highPri.start();
-      medPri.start();
-      medHighPri.start();
-
-      lowPri.join();
-      highPri.join();
-      medPri.join();
-      medHighPri.join();
-
-      final int closeFrequency = MSG_NUM;
-      final int[] priorities = new int[]{HIGH_PRI, MED_HIGH_PRI, MED_PRI, LOW_PRI};
-      sub = sess.createDurableSubscriber(topic, subName);
-      for (int i = 0; i < MSG_NUM * 4; i++) {
-         Message msg = sub.receive(10000);
-         LOG.debug("received i=" + i + ", m=" + (msg != null ? msg.getJMSMessageID() + ", priority: " + msg.getJMSPriority() : null));
-         assertNotNull("Message " + i + " was null", msg);
-         assertEquals("Message " + i + " has wrong priority", priorities[i / MSG_NUM], msg.getJMSPriority());
-         if (i > 0 && i % closeFrequency == 0) {
-            LOG.info("Closing durable sub.. on: " + i);
-            sub.close();
-            sub = sess.createDurableSubscriber(topic, subName);
-         }
-      }
-      LOG.info("closing on done!");
-      sub.close();
-   }
-
-   public void initCombosForTestConcurrentDurableSubsReconnectWithXLevels() {
-      addCombinationValues("prioritizeMessages", new Object[]{Boolean.TRUE, Boolean.FALSE});
-   }
-
-   public void testConcurrentDurableSubsReconnectWithXLevels() throws Exception {
-      ActiveMQTopic topic = (ActiveMQTopic) sess.createTopic("TEST");
-      final String subName = "priorityDisconnect";
-      Connection consumerConn = factory.createConnection();
-      consumerConn.setClientID("priorityDisconnect");
-      consumerConn.start();
-      Session consumerSession = consumerConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      TopicSubscriber sub = consumerSession.createDurableSubscriber(topic, subName);
-      sub.close();
-
-      final int maxPriority = 5;
-
-      final AtomicInteger[] messageCounts = new AtomicInteger[maxPriority];
-      final long[] messageIds = new long[maxPriority];
-      Vector<ProducerThread> producers = new Vector<>();
-      for (int priority = 0; priority < maxPriority; priority++) {
-         producers.add(new ProducerThread(topic, MSG_NUM, priority));
-         messageCounts[priority] = new AtomicInteger(0);
-         messageIds[priority] = 1L;
-      }
-
-      for (ProducerThread producer : producers) {
-         producer.start();
-      }
-
-      final int closeFrequency = MSG_NUM / 2;
-      HashMap<String, String> dups = new HashMap<>();
-      sub = consumerSession.createDurableSubscriber(topic, subName);
-      for (int i = 0; i < MSG_NUM * maxPriority; i++) {
-         Message msg = sub.receive(10000);
-         LOG.debug("received i=" + i + ", m=" + (msg != null ? msg.getJMSMessageID() + ", priority: " + msg.getJMSPriority() : null));
-         assertNotNull("Message " + i + " was null, counts: " + Arrays.toString(messageCounts), msg);
-         assertNull("no duplicate message failed on : " + msg.getJMSMessageID(), dups.put(msg.getJMSMessageID(), subName));
-         messageCounts[msg.getJMSPriority()].incrementAndGet();
-         assertEquals("message is in order : " + msg, messageIds[msg.getJMSPriority()], ((ActiveMQMessage) msg).getMessageId().getProducerSequenceId());
-         messageIds[msg.getJMSPriority()]++;
-         if (i > 0 && i % closeFrequency == 0) {
-            LOG.info("Closing durable sub.. on: " + i + ", counts: " + Arrays.toString(messageCounts));
-            sub.close();
-            sub = consumerSession.createDurableSubscriber(topic, subName);
-         }
-      }
-      LOG.info("closing on done!");
-      sub.close();
-      consumerSession.close();
-      consumerConn.close();
-
-      for (ProducerThread producer : producers) {
-         producer.join();
-      }
-   }
-
-   public void initCombosForTestConcurrentRate() {
-      addCombinationValues("prefetchVal", new Object[]{new Integer(1), new Integer(500)});
-   }
-
-   public void testConcurrentRate() throws Exception {
-      ActiveMQTopic topic = (ActiveMQTopic) sess.createTopic("TEST");
-      final String subName = "priorityConcurrent";
-      Connection consumerConn = factory.createConnection();
-      consumerConn.setClientID("subName");
-      consumerConn.start();
-      Session consumerSession = consumerConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      TopicSubscriber sub = consumerSession.createDurableSubscriber(topic, subName);
-      sub.close();
-
-      final int TO_SEND = 2000;
-      final Vector<Message> duplicates = new Vector<>();
-      final int[] dups = new int[TO_SEND * 4];
-      long start;
-      double max = 0, sum = 0;
-      MessageProducer messageProducer = sess.createProducer(topic);
-      TextMessage message = sess.createTextMessage();
-      for (int i = 0; i < TO_SEND; i++) {
-         int priority = i % 10;
-         message.setText(i + "-" + priority);
-         message.setIntProperty("seq", i);
-         message.setJMSPriority(priority);
-         if (i > 0 && i % 1000 == 0) {
-            LOG.info("Max send time: " + max + ". Sending message: " + message.getText());
-         }
-         start = System.currentTimeMillis();
-         messageProducer.send(message, DeliveryMode.PERSISTENT, message.getJMSPriority(), 0);
-         long duration = System.currentTimeMillis() - start;
-         max = Math.max(max, duration);
-         if (duration == max) {
-            LOG.info("new max: " + max + " on i=" + i + ", " + message.getText());
-         }
-         sum += duration;
-      }
-
-      LOG.info("Sent: " + TO_SEND + ", max send time: " + max);
-
-      double noConsumerAve = (sum * 100 / TO_SEND);
-      sub = consumerSession.createDurableSubscriber(topic, subName);
-      final AtomicInteger count = new AtomicInteger();
-      sub.setMessageListener(new MessageListener() {
-         @Override
-         public void onMessage(Message message) {
-            try {
-               count.incrementAndGet();
-               if (count.get() % 100 == 0) {
-                  LOG.info("onMessage: count: " + count.get() + ", " + ((TextMessage) message).getText() + ", seqNo " + message.getIntProperty("seq") + ", " + message.getJMSMessageID());
-               }
-               int seqNo = message.getIntProperty("seq");
-               if (dups[seqNo] == 0) {
-                  dups[seqNo] = 1;
-               }
-               else {
-                  LOG.error("Duplicate: " + ((TextMessage) message).getText() + ", " + message.getJMSMessageID());
-                  duplicates.add(message);
-               }
-            }
-            catch (Exception e) {
-               e.printStackTrace();
-            }
-         }
-      });
-
-      LOG.info("Activated consumer");
-      sum = max = 0;
-      for (int i = TO_SEND; i < (TO_SEND * 2); i++) {
-         int priority = i % 10;
-         message.setText(i + "-" + priority);
-         message.setIntProperty("seq", i);
-         message.setJMSPriority(priority);
-         if (i > 0 && i % 1000 == 0) {
-            LOG.info("Max send time: " + max + ". Sending message: " + message.getText());
-         }
-         start = System.currentTimeMillis();
-         messageProducer.send(message, DeliveryMode.PERSISTENT, message.getJMSPriority(), 0);
-         long duration = System.currentTimeMillis() - start;
-         max = Math.max(max, duration);
-         if (duration == max) {
-            LOG.info("new max: " + max + " on i=" + i + ", " + message.getText());
-         }
-         sum += duration;
-      }
-      LOG.info("Sent another: " + TO_SEND + ", max send time: " + max);
-
-      double withConsumerAve = (sum * 100 / TO_SEND);
-      final int reasonableMultiplier = 4; // not so reasonable, but on slow disks it can be
-      assertTrue("max X times as slow with consumer:" + withConsumerAve + " , noConsumerMax:" + noConsumerAve, withConsumerAve < noConsumerAve * reasonableMultiplier);
-      Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            LOG.info("count: " + count.get());
-            return TO_SEND * 2 == count.get();
-         }
-      }, 60 * 1000);
-
-      assertTrue("No duplicates : " + duplicates, duplicates.isEmpty());
-      assertEquals("got all messages", TO_SEND * 2, count.get());
-   }
-
-   public void testCleanupPriorityDestination() throws Exception {
-      assertEquals("no messages pending", 0, messageTableCount());
-
-      ActiveMQTopic topic = (ActiveMQTopic) sess.createTopic("TEST");
-      final String subName = "priorityConcurrent";
-      Connection consumerConn = factory.createConnection();
-      consumerConn.setClientID("subName");
-      consumerConn.start();
-      Session consumerSession = consumerConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      TopicSubscriber sub = consumerSession.createDurableSubscriber(topic, subName);
-      sub.close();
-
-      MessageProducer messageProducer = sess.createProducer(topic);
-      Message message = sess.createTextMessage();
-      message.setJMSPriority(2);
-      messageProducer.send(message, DeliveryMode.PERSISTENT, message.getJMSPriority(), 0);
-      message.setJMSPriority(5);
-      messageProducer.send(message, DeliveryMode.PERSISTENT, message.getJMSPriority(), 0);
-
-      assertEquals("two messages pending", 2, messageTableCount());
-
-      sub = consumerSession.createDurableSubscriber(topic, subName);
-
-      message = sub.receive(5000);
-      assertEquals("got high priority", 5, message.getJMSPriority());
-
-      waitForAck(5);
-
-      for (int i = 0; i < 10; i++) {
-         jdbc.cleanup();
-      }
-      assertEquals("one messages pending", 1, messageTableCount());
-
-      message = sub.receive(5000);
-      assertEquals("got high priority", 2, message.getJMSPriority());
-
-      waitForAck(2);
-
-      for (int i = 0; i < 10; i++) {
-         jdbc.cleanup();
-      }
-      assertEquals("no messages pending", 0, messageTableCount());
-   }
-
-   public void testCleanupNonPriorityDestination() throws Exception {
-      assertEquals("no messages pending", 0, messageTableCount());
-
-      ActiveMQTopic topic = (ActiveMQTopic) sess.createTopic("TEST_CLEANUP_NO_PRIORITY");
-      final String subName = "subName";
-      Connection consumerConn = factory.createConnection();
-      consumerConn.setClientID("subName");
-      consumerConn.start();
-      Session consumerSession = consumerConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      TopicSubscriber sub = consumerSession.createDurableSubscriber(topic, subName);
-      sub.close();
-
-      MessageProducer messageProducer = sess.createProducer(topic);
-      Message message = sess.createTextMessage("ToExpire");
-      messageProducer.send(message, DeliveryMode.PERSISTENT, Message.DEFAULT_PRIORITY, 4000);
-
-      message = sess.createTextMessage("A");
-      messageProducer.send(message);
-      message = sess.createTextMessage("B");
-      messageProducer.send(message);
-      message = null;
-
-      assertEquals("three messages pending", 3, messageTableCount());
-
-      // let first message expire
-      TimeUnit.SECONDS.sleep(5);
-
-      sub = consumerSession.createDurableSubscriber(topic, subName);
-      message = sub.receive(5000);
-      assertNotNull("got message", message);
-      LOG.info("Got: " + message);
-
-      waitForAck(0, 1);
-
-      for (int i = 0; i < 10; i++) {
-         jdbc.cleanup();
-      }
-      assertEquals("one messages pending", 1, messageTableCount());
-
-      message = sub.receive(5000);
-      assertNotNull("got message two", message);
-      LOG.info("Got: " + message);
-
-      waitForAck(0, 2);
-
-      for (int i = 0; i < 10; i++) {
-         jdbc.cleanup();
-      }
-      assertEquals("no messages pending", 0, messageTableCount());
-   }
-
-   private int messageTableCount() throws Exception {
-      int count = -1;
-      java.sql.Connection c = dataSource.getConnection();
-      try {
-         PreparedStatement s = c.prepareStatement("SELECT COUNT(*) FROM ACTIVEMQ_MSGS");
-         ResultSet rs = s.executeQuery();
-         if (rs.next()) {
-            count = rs.getInt(1);
-         }
-      }
-      finally {
-         if (c != null) {
-            c.close();
-         }
-      }
-      return count;
-   }
-
-   private void waitForAck(final int priority) throws Exception {
-      waitForAck(priority, 0);
-   }
-
-   private void waitForAck(final int priority, final int minId) throws Exception {
-      assertTrue("got ack for " + priority, Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            int id = 0;
-            java.sql.Connection c = dataSource.getConnection();
-            try {
-               PreparedStatement s = c.prepareStatement("SELECT LAST_ACKED_ID FROM ACTIVEMQ_ACKS WHERE PRIORITY=" + priority);
-               ResultSet rs = s.executeQuery();
-               if (rs.next()) {
-                  id = rs.getInt(1);
-               }
-            }
-            finally {
-               if (c != null) {
-                  c.close();
-               }
-            }
-            return id > minId;
-         }
-      }));
-   }
-
-   @SuppressWarnings("unused")
-   private int messageTableDump() throws Exception {
-      int count = -1;
-      java.sql.Connection c = dataSource.getConnection();
-      try {
-         PreparedStatement s = c.prepareStatement("SELECT * FROM ACTIVEMQ_MSGS");
-         ResultSet rs = s.executeQuery();
-         if (rs.next()) {
-            count = rs.getInt(1);
-         }
-      }
-      finally {
-         if (c != null) {
-            c.close();
-         }
-      }
-      return count;
-   }
-
-   public static Test suite() {
-      return suite(JDBCMessagePriorityTest.class);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCNegativeQueueTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCNegativeQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCNegativeQueueTest.java
deleted file mode 100644
index e41cf13..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCNegativeQueueTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * 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.store.jdbc;
-
-import java.io.PrintStream;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.cursors.NegativeQueueTest;
-import org.apache.derby.jdbc.EmbeddedDataSource;
-
-public class JDBCNegativeQueueTest extends NegativeQueueTest {
-
-   EmbeddedDataSource dataSource;
-
-   @Override
-   protected void configureBroker(BrokerService answer) throws Exception {
-      super.configureBroker(answer);
-      JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter();
-      dataSource = new EmbeddedDataSource();
-      dataSource.setDatabaseName("derbyDb");
-      dataSource.setCreateDatabase("create");
-      jdbc.setDataSource(dataSource);
-      answer.setPersistenceAdapter(jdbc);
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      if (DEBUG) {
-         printQuery("Select * from ACTIVEMQ_MSGS", System.out);
-      }
-      super.tearDown();
-   }
-
-   private void printQuery(String query, PrintStream out) throws SQLException {
-      Connection conn = dataSource.getConnection();
-      printQuery(conn.prepareStatement(query), out);
-      conn.close();
-   }
-
-   private void printQuery(PreparedStatement s, PrintStream out) throws SQLException {
-
-      ResultSet set = null;
-      try {
-         set = s.executeQuery();
-         ResultSetMetaData metaData = set.getMetaData();
-         for (int i = 1; i <= metaData.getColumnCount(); i++) {
-            if (i == 1)
-               out.print("||");
-            out.print(metaData.getColumnName(i) + "||");
-         }
-         out.println();
-         while (set.next()) {
-            for (int i = 1; i <= metaData.getColumnCount(); i++) {
-               if (i == 1)
-                  out.print("|");
-               out.print(set.getString(i) + "|");
-            }
-            out.println();
-         }
-      }
-      finally {
-         try {
-            set.close();
-         }
-         catch (Throwable ignore) {
-         }
-         try {
-            s.close();
-         }
-         catch (Throwable ignore) {
-         }
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCNetworkBrokerDetachTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCNetworkBrokerDetachTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCNetworkBrokerDetachTest.java
deleted file mode 100644
index 8e0c387..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCNetworkBrokerDetachTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * 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.store.jdbc;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.network.NetworkBrokerDetachTest;
-import org.apache.derby.jdbc.EmbeddedDataSource;
-
-public class JDBCNetworkBrokerDetachTest extends NetworkBrokerDetachTest {
-
-   @Override
-   protected void configureBroker(BrokerService broker) throws Exception {
-      JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter();
-      EmbeddedDataSource dataSource = new EmbeddedDataSource();
-      dataSource.setDatabaseName(broker.getBrokerName());
-      dataSource.setCreateDatabase("create");
-      jdbc.setDataSource(dataSource);
-      jdbc.deleteAllMessages();
-      broker.setPersistenceAdapter(jdbc);
-      broker.setUseVirtualTopics(false);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapterTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapterTest.java
deleted file mode 100644
index 59c447b..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapterTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * 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.store.jdbc;
-
-import java.io.IOException;
-
-import junit.framework.AssertionFailedError;
-
-import org.apache.activemq.store.PersistenceAdapter;
-import org.apache.activemq.store.PersistenceAdapterTestSupport;
-import org.apache.derby.jdbc.EmbeddedDataSource;
-
-public class JDBCPersistenceAdapterTest extends PersistenceAdapterTestSupport {
-
-   @Override
-   protected PersistenceAdapter createPersistenceAdapter(boolean delete) throws IOException {
-      JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter();
-
-      // explicitly enable audit as it is now off by default
-      // due to org.apache.activemq.broker.ProducerBrokerExchange.canDispatch(Message)
-      jdbc.setEnableAudit(true);
-
-      brokerService.setSchedulerSupport(false);
-      brokerService.setPersistenceAdapter(jdbc);
-      jdbc.setBrokerService(brokerService);
-      EmbeddedDataSource dataSource = new EmbeddedDataSource();
-      dataSource.setDatabaseName("derbyDb");
-      dataSource.setCreateDatabase("create");
-      jdbc.setDataSource(dataSource);
-      if (delete) {
-         jdbc.deleteAllMessages();
-      }
-      return jdbc;
-   }
-
-   public void testAuditOff() throws Exception {
-      pa.stop();
-      pa = createPersistenceAdapter(true);
-      ((JDBCPersistenceAdapter) pa).setEnableAudit(false);
-      pa.start();
-      boolean failed = true;
-      try {
-         testStoreCanHandleDupMessages();
-         failed = false;
-      }
-      catch (AssertionFailedError e) {
-      }
-
-      if (!failed) {
-         fail("Should have failed with audit turned off");
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCStoreAutoCommitTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCStoreAutoCommitTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCStoreAutoCommitTest.java
deleted file mode 100644
index de57cbc..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCStoreAutoCommitTest.java
+++ /dev/null
@@ -1,515 +0,0 @@
-/**
- * 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.store.jdbc;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.net.URI;
-import java.sql.Array;
-import java.sql.Blob;
-import java.sql.CallableStatement;
-import java.sql.Clob;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.NClob;
-import java.sql.PreparedStatement;
-import java.sql.SQLClientInfoException;
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
-import java.sql.SQLWarning;
-import java.sql.SQLXML;
-import java.sql.Savepoint;
-import java.sql.Statement;
-import java.sql.Struct;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.Executor;
-import java.util.logging.Logger;
-
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.derby.jdbc.EmbeddedDataSource;
-import org.junit.Test;
-
-/**
- * to be compliant with JDBC spec; officially commit is not supposed to be
- * called on a connection that uses autocommit.The oracle v12 driver does a
- * check for autocommitSpecCompliance and it causes issues
- * <br>
- * To test; wrap the datasource used by the broker and check for autocommit
- * before delegating to real datasource. If commit is called on connection with
- * autocommit, wrapper throws a SQLException.
- */
-
-public class JDBCStoreAutoCommitTest {
-
-   private static final String BROKER_NAME = "AutoCommitTest";
-   private static final String TEST_DEST = "commitCheck";
-   private static final String MSG_TEXT = "JDBCStoreAutoCommitTest TEST";
-
-   /**
-    * verify dropping and recreating tables
-    *
-    * @throws Exception
-    */
-   @Test
-   public void testDeleteAllMessages() throws Exception {
-      BrokerService broker = createBrokerService();
-      broker.getPersistenceAdapter().deleteAllMessages();
-      broker.setUseJmx(false);
-      broker.start();
-      broker.waitUntilStarted();
-      broker.stop();
-      broker.waitUntilStopped();
-   }
-
-   /**
-    * Send message and consume message, JMS session is not transacted
-    *
-    * @throws Exception
-    */
-   @Test
-   public void testSendConsume() throws Exception {
-      this.doSendConsume(false);
-   }
-
-   /**
-    * send message and consume message, JMS session is transacted
-    *
-    * @throws Exception
-    */
-   @Test
-   public void testSendConsumeTransacted() throws Exception {
-      this.doSendConsume(true);
-   }
-
-   private void doSendConsume(boolean transacted) throws Exception {
-
-      BrokerService broker = createBrokerService();
-      broker.setUseJmx(false);
-      broker.start();
-      broker.waitUntilStarted();
-
-      ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(new URI("vm:" + BROKER_NAME));
-      ActiveMQConnection c1 = (ActiveMQConnection) cf.createConnection();
-      c1.start();
-
-      try {
-         // message send
-         Session session1 = c1.createSession(transacted, Session.AUTO_ACKNOWLEDGE);
-         MessageProducer messageProducer = session1.createProducer(session1.createQueue(TEST_DEST));
-         TextMessage textMessage = session1.createTextMessage(MSG_TEXT);
-         messageProducer.send(textMessage);
-
-         if (transacted) {
-            session1.commit();
-         }
-
-         // consume
-         Session session2 = c1.createSession(transacted, Session.AUTO_ACKNOWLEDGE);
-         MessageConsumer messageConsumer = session2.createConsumer(session2.createQueue(TEST_DEST));
-         TextMessage messageReceived = (TextMessage) messageConsumer.receive(1000);
-
-         assertEquals("check message received", MSG_TEXT, messageReceived.getText());
-      }
-      finally {
-         c1.close();
-         broker.stop();
-         broker.waitUntilStopped();
-      }
-   }
-
-   private BrokerService createBrokerService() throws IOException {
-      BrokerService broker = new BrokerService();
-      broker.setBrokerName(BROKER_NAME);
-      broker.setUseJmx(false);
-
-      JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter();
-      EmbeddedDataSource embeddedDataSource = new EmbeddedDataSource();
-      embeddedDataSource.setDatabaseName("derbyDb");
-      embeddedDataSource.setCreateDatabase("create");
-
-      javax.sql.DataSource wrappedDataSource = new TestDataSource(embeddedDataSource);
-
-      jdbc.setDataSource(wrappedDataSource);
-
-      broker.setPersistenceAdapter(jdbc);
-      return broker;
-   }
-
-   private class TestDataSource implements javax.sql.DataSource {
-
-      private final javax.sql.DataSource realDataSource;
-
-      public TestDataSource(javax.sql.DataSource dataSource) {
-         realDataSource = dataSource;
-      }
-
-      @Override
-      public Connection getConnection() throws SQLException {
-         Connection autoCommitCheckConnection = new AutoCommitCheckConnection(realDataSource.getConnection());
-         return autoCommitCheckConnection;
-      }
-
-      @Override
-      public Connection getConnection(String username, String password) throws SQLException {
-         Connection autoCommitCheckConnection = new AutoCommitCheckConnection(realDataSource.getConnection(username, password));
-
-         return autoCommitCheckConnection;
-      }
-
-      @Override
-      public PrintWriter getLogWriter() throws SQLException {
-         return realDataSource.getLogWriter();
-      }
-
-      @Override
-      public void setLogWriter(PrintWriter out) throws SQLException {
-         realDataSource.setLogWriter(out);
-      }
-
-      @Override
-      public void setLoginTimeout(int seconds) throws SQLException {
-         realDataSource.setLoginTimeout(seconds);
-      }
-
-      @Override
-      public int getLoginTimeout() throws SQLException {
-         return realDataSource.getLoginTimeout();
-      }
-
-      @Override
-      public Logger getParentLogger() throws SQLFeatureNotSupportedException {
-         return realDataSource.getParentLogger();
-      }
-
-      @Override
-      public <T> T unwrap(Class<T> iface) throws SQLException {
-         return realDataSource.unwrap(iface);
-      }
-
-      @Override
-      public boolean isWrapperFor(Class<?> iface) throws SQLException {
-         return realDataSource.isWrapperFor(iface);
-      }
-   }
-
-   private class AutoCommitCheckConnection implements Connection {
-
-      private final Connection realConnection;
-
-      public AutoCommitCheckConnection(Connection connection) {
-         this.realConnection = connection;
-      }
-
-      // verify commit is not called on an auto-commit connection
-      @Override
-      public void commit() throws SQLException {
-         if (getAutoCommit() == true) {
-            throw new SQLException("AutoCommitCheckConnection: Called commit on autoCommit Connection");
-         }
-         realConnection.commit();
-      }
-
-      // Just plumbing for wrapper. Might have been better to do a Dynamic Proxy here.
-
-      @Override
-      public Statement createStatement() throws SQLException {
-         return realConnection.createStatement();
-      }
-
-      @Override
-      public PreparedStatement prepareStatement(String sql) throws SQLException {
-         return realConnection.prepareStatement(sql);
-      }
-
-      @Override
-      public CallableStatement prepareCall(String sql) throws SQLException {
-         return realConnection.prepareCall(sql);
-      }
-
-      @Override
-      public String nativeSQL(String sql) throws SQLException {
-         return realConnection.nativeSQL(sql);
-      }
-
-      @Override
-      public void setAutoCommit(boolean autoCommit) throws SQLException {
-         realConnection.setAutoCommit(autoCommit);
-      }
-
-      @Override
-      public boolean getAutoCommit() throws SQLException {
-         return realConnection.getAutoCommit();
-      }
-
-      @Override
-      public void rollback() throws SQLException {
-         realConnection.rollback();
-      }
-
-      @Override
-      public void close() throws SQLException {
-         realConnection.close();
-      }
-
-      @Override
-      public boolean isClosed() throws SQLException {
-         return realConnection.isClosed();
-      }
-
-      @Override
-      public DatabaseMetaData getMetaData() throws SQLException {
-         return realConnection.getMetaData();
-      }
-
-      @Override
-      public void setReadOnly(boolean readOnly) throws SQLException {
-         realConnection.setReadOnly(readOnly);
-      }
-
-      @Override
-      public boolean isReadOnly() throws SQLException {
-         return realConnection.isReadOnly();
-      }
-
-      @Override
-      public void setCatalog(String catalog) throws SQLException {
-         realConnection.setCatalog(catalog);
-      }
-
-      @Override
-      public String getCatalog() throws SQLException {
-         return realConnection.getCatalog();
-      }
-
-      @Override
-      public void setTransactionIsolation(int level) throws SQLException {
-         realConnection.setTransactionIsolation(level);
-      }
-
-      @Override
-      public int getTransactionIsolation() throws SQLException {
-         return realConnection.getTransactionIsolation();
-      }
-
-      @Override
-      public SQLWarning getWarnings() throws SQLException {
-         return realConnection.getWarnings();
-      }
-
-      @Override
-      public void clearWarnings() throws SQLException {
-         realConnection.clearWarnings();
-      }
-
-      @Override
-      public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
-         return realConnection.createStatement(resultSetType, resultSetConcurrency);
-      }
-
-      @Override
-      public PreparedStatement prepareStatement(String sql,
-                                                int resultSetType,
-                                                int resultSetConcurrency) throws SQLException {
-         return realConnection.prepareStatement(sql, resultSetType, resultSetConcurrency);
-      }
-
-      @Override
-      public CallableStatement prepareCall(String sql,
-                                           int resultSetType,
-                                           int resultSetConcurrency) throws SQLException {
-         return realConnection.prepareCall(sql, resultSetType, resultSetConcurrency);
-      }
-
-      @Override
-      public Map<String, Class<?>> getTypeMap() throws SQLException {
-         return realConnection.getTypeMap();
-      }
-
-      @Override
-      public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
-         realConnection.setTypeMap(map);
-      }
-
-      @Override
-      public void setHoldability(int holdability) throws SQLException {
-         realConnection.setHoldability(holdability);
-      }
-
-      @Override
-      public int getHoldability() throws SQLException {
-         return realConnection.getHoldability();
-      }
-
-      @Override
-      public Savepoint setSavepoint() throws SQLException {
-         return realConnection.setSavepoint();
-      }
-
-      @Override
-      public Savepoint setSavepoint(String name) throws SQLException {
-         return realConnection.setSavepoint(name);
-      }
-
-      @Override
-      public void rollback(Savepoint savepoint) throws SQLException {
-         realConnection.rollback();
-      }
-
-      @Override
-      public void releaseSavepoint(Savepoint savepoint) throws SQLException {
-         realConnection.releaseSavepoint(savepoint);
-      }
-
-      @Override
-      public Statement createStatement(int resultSetType,
-                                       int resultSetConcurrency,
-                                       int resultSetHoldability) throws SQLException {
-         return realConnection.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
-      }
-
-      @Override
-      public PreparedStatement prepareStatement(String sql,
-                                                int resultSetType,
-                                                int resultSetConcurrency,
-                                                int resultSetHoldability) throws SQLException {
-         return realConnection.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
-      }
-
-      @Override
-      public CallableStatement prepareCall(String sql,
-                                           int resultSetType,
-                                           int resultSetConcurrency,
-                                           int resultSetHoldability) throws SQLException {
-         return realConnection.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
-      }
-
-      @Override
-      public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
-         return realConnection.prepareStatement(sql, autoGeneratedKeys);
-      }
-
-      @Override
-      public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
-         return realConnection.prepareStatement(sql, columnIndexes);
-      }
-
-      @Override
-      public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
-         return realConnection.prepareStatement(sql, columnNames);
-      }
-
-      @Override
-      public Clob createClob() throws SQLException {
-         return realConnection.createClob();
-      }
-
-      @Override
-      public Blob createBlob() throws SQLException {
-         return realConnection.createBlob();
-      }
-
-      @Override
-      public NClob createNClob() throws SQLException {
-         return realConnection.createNClob();
-      }
-
-      @Override
-      public SQLXML createSQLXML() throws SQLException {
-         return realConnection.createSQLXML();
-      }
-
-      @Override
-      public boolean isValid(int timeout) throws SQLException {
-         return realConnection.isValid(timeout);
-      }
-
-      @Override
-      public void setClientInfo(String name, String value) throws SQLClientInfoException {
-         realConnection.setClientInfo(name, value);
-      }
-
-      @Override
-      public void setClientInfo(Properties properties) throws SQLClientInfoException {
-         realConnection.setClientInfo(properties);
-      }
-
-      @Override
-      public String getClientInfo(String name) throws SQLException {
-         return realConnection.getClientInfo(name);
-      }
-
-      @Override
-      public Properties getClientInfo() throws SQLException {
-         return realConnection.getClientInfo();
-      }
-
-      @Override
-      public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
-         return realConnection.createArrayOf(typeName, elements);
-      }
-
-      @Override
-      public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
-         return realConnection.createStruct(typeName, attributes);
-      }
-
-      @Override
-      public void setSchema(String schema) throws SQLException {
-         realConnection.setSchema(schema);
-      }
-
-      @Override
-      public String getSchema() throws SQLException {
-         return realConnection.getSchema();
-      }
-
-      @Override
-      public void abort(Executor executor) throws SQLException {
-         realConnection.abort(executor);
-      }
-
-      @Override
-      public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {
-         realConnection.setNetworkTimeout(executor, milliseconds);
-      }
-
-      @Override
-      public int getNetworkTimeout() throws SQLException {
-         return realConnection.getNetworkTimeout();
-      }
-
-      @Override
-      public <T> T unwrap(Class<T> iface) throws SQLException {
-         return realConnection.unwrap(iface);
-      }
-
-      @Override
-      public boolean isWrapperFor(Class<?> iface) throws SQLException {
-         return realConnection.isWrapperFor(iface);
-      }
-   }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCStoreBrokerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCStoreBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCStoreBrokerTest.java
deleted file mode 100644
index 0c86237..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCStoreBrokerTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * 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.store.jdbc;
-
-import junit.framework.Test;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.BrokerTest;
-import org.apache.derby.jdbc.EmbeddedDataSource;
-
-public class JDBCStoreBrokerTest extends BrokerTest {
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      BrokerService broker = new BrokerService();
-      JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter();
-      EmbeddedDataSource dataSource = new EmbeddedDataSource();
-      dataSource.setDatabaseName("derbyDb");
-      dataSource.setCreateDatabase("create");
-      jdbc.setDataSource(dataSource);
-
-      jdbc.deleteAllMessages();
-      broker.setPersistenceAdapter(jdbc);
-      return broker;
-   }
-
-   protected BrokerService createRestartedBroker() throws Exception {
-      BrokerService broker = new BrokerService();
-      JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter();
-      EmbeddedDataSource dataSource = new EmbeddedDataSource();
-      dataSource.setDatabaseName("derbyDb");
-      dataSource.setCreateDatabase("create");
-      jdbc.setDataSource(dataSource);
-      broker.setPersistenceAdapter(jdbc);
-      return broker;
-   }
-
-   public static Test suite() {
-      return suite(JDBCStoreBrokerTest.class);
-   }
-
-   public static void main(String[] args) {
-      junit.textui.TestRunner.run(suite());
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCStoreOrderTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCStoreOrderTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCStoreOrderTest.java
deleted file mode 100644
index 17310cb..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCStoreOrderTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * 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.store.jdbc;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.Message;
-import org.apache.activemq.openwire.OpenWireFormat;
-import org.apache.activemq.store.StoreOrderTest;
-import org.apache.activemq.util.ByteSequence;
-import org.apache.activemq.wireformat.WireFormat;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.derby.jdbc.EmbeddedDataSource;
-
-//  https://issues.apache.org/activemq/browse/AMQ-2594
-public class JDBCStoreOrderTest extends StoreOrderTest {
-
-   private static final Logger LOG = LoggerFactory.getLogger(JDBCStoreOrderTest.class);
-
-   @Override
-   protected void dumpMessages() throws Exception {
-      WireFormat wireFormat = new OpenWireFormat();
-      java.sql.Connection conn = ((JDBCPersistenceAdapter) broker.getPersistenceAdapter()).getDataSource().getConnection();
-      PreparedStatement statement = conn.prepareStatement("SELECT ID, MSG FROM ACTIVEMQ_MSGS");
-      ResultSet result = statement.executeQuery();
-      while (result.next()) {
-         long id = result.getLong(1);
-         Message message = (Message) wireFormat.unmarshal(new ByteSequence(result.getBytes(2)));
-         LOG.info("id: " + id + ", message SeqId: " + message.getMessageId().getBrokerSequenceId() + ", MSG: " + message);
-      }
-      statement.close();
-      conn.close();
-   }
-
-   @Override
-   protected void setPersistentAdapter(BrokerService brokerService) throws Exception {
-      JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter();
-      EmbeddedDataSource dataSource = new EmbeddedDataSource();
-      dataSource.setDatabaseName("derbyDb");
-      dataSource.setCreateDatabase("create");
-      jdbc.setDataSource(dataSource);
-      brokerService.setPersistenceAdapter(jdbc);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCTablePrefixAssignedTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCTablePrefixAssignedTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCTablePrefixAssignedTest.java
deleted file mode 100644
index 7ac10b5..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCTablePrefixAssignedTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * 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.store.jdbc;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jms.Destination;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.Message;
-import org.apache.activemq.openwire.OpenWireFormat;
-import org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter;
-import org.apache.activemq.util.ByteSequence;
-import org.apache.activemq.wireformat.WireFormat;
-import org.apache.derby.jdbc.EmbeddedDataSource;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class JDBCTablePrefixAssignedTest {
-
-   private static final Logger LOG = LoggerFactory.getLogger(JDBCTablePrefixAssignedTest.class);
-
-   private BrokerService service;
-
-   @Before
-   public void setUp() throws Exception {
-      service = createBroker();
-      service.start();
-      service.waitUntilStarted();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      service.stop();
-      service.waitUntilStopped();
-   }
-
-   @Test
-   public void testTablesHave() throws Exception {
-
-      ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost?create=false");
-      ActiveMQConnection connection = (ActiveMQConnection) cf.createConnection();
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Destination destination = session.createQueue("TEST.FOO");
-      MessageProducer producer = session.createProducer(destination);
-
-      for (int i = 0; i < 10; ++i) {
-         producer.send(session.createTextMessage("test"));
-      }
-      producer.close();
-      connection.close();
-
-      List<Message> queuedMessages = null;
-      try {
-         queuedMessages = dumpMessages();
-      }
-      catch (Exception ex) {
-         LOG.info("Caught ex: ", ex);
-         fail("Should not have thrown an exception");
-      }
-
-      assertNotNull(queuedMessages);
-      assertEquals("Should have found 10 messages", 10, queuedMessages.size());
-   }
-
-   protected List<Message> dumpMessages() throws Exception {
-      WireFormat wireFormat = new OpenWireFormat();
-      java.sql.Connection conn = ((JDBCPersistenceAdapter) service.getPersistenceAdapter()).getDataSource().getConnection();
-      PreparedStatement statement = conn.prepareStatement("SELECT ID, MSG FROM MYPREFIX_ACTIVEMQ_MSGS");
-      ResultSet result = statement.executeQuery();
-      ArrayList<Message> results = new ArrayList<>();
-      while (result.next()) {
-         long id = result.getLong(1);
-         Message message = (Message) wireFormat.unmarshal(new ByteSequence(result.getBytes(2)));
-         LOG.info("id: " + id + ", message SeqId: " + message.getMessageId().getBrokerSequenceId() + ", MSG: " + message);
-         results.add(message);
-      }
-      statement.close();
-      conn.close();
-
-      return results;
-   }
-
-   protected BrokerService createBroker() throws Exception {
-      BrokerService broker = new BrokerService();
-      JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter();
-      EmbeddedDataSource dataSource = new EmbeddedDataSource();
-      dataSource.setDatabaseName("derbyDb");
-      dataSource.setCreateDatabase("create");
-
-      DefaultJDBCAdapter adapter = new DefaultJDBCAdapter();
-      jdbc.setAdapter(adapter);
-
-      Statements statements = new Statements();
-      statements.setTablePrefix("MYPREFIX_");
-      jdbc.setStatements(statements);
-
-      jdbc.setUseLock(false);
-      jdbc.setDataSource(dataSource);
-      jdbc.deleteAllMessages();
-      broker.setPersistenceAdapter(jdbc);
-      return broker;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCTestMemory.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCTestMemory.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCTestMemory.java
deleted file mode 100644
index a8ced99..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCTestMemory.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/**
- * 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.store.jdbc;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.derby.jdbc.EmbeddedDataSource;
-import org.junit.Ignore;
-
-public class JDBCTestMemory extends TestCase {
-
-   ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
-   Connection conn;
-   Session sess;
-   Destination dest;
-
-   BrokerService broker;
-
-   @Override
-   protected void setUp() throws Exception {
-      broker = createBroker();
-      broker.start();
-      broker.waitUntilStarted();
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      broker.stop();
-   }
-
-   protected BrokerService createBroker() throws Exception {
-      BrokerService broker = new BrokerService();
-      broker.setUseJmx(true);
-      JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter();
-      EmbeddedDataSource dataSource = new EmbeddedDataSource();
-      dataSource.setDatabaseName("derbyDb");
-      dataSource.setCreateDatabase("create");
-      jdbc.setDataSource(dataSource);
-
-      jdbc.deleteAllMessages();
-      broker.setPersistenceAdapter(jdbc);
-      broker.addConnector("tcp://0.0.0.0:61616");
-      return broker;
-   }
-
-   protected BrokerService createRestartedBroker() throws Exception {
-      BrokerService broker = new BrokerService();
-      broker.setUseJmx(true);
-      JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter();
-      EmbeddedDataSource dataSource = new EmbeddedDataSource();
-      dataSource.setDatabaseName("derbyDb");
-      dataSource.setCreateDatabase("create");
-      jdbc.setDataSource(dataSource);
-      broker.setPersistenceAdapter(jdbc);
-      broker.addConnector("tcp://0.0.0.0:61616");
-      return broker;
-   }
-
-   public void init() throws Exception {
-      conn = factory.createConnection();
-      conn.start();
-      sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      dest = sess.createQueue("test");
-   }
-
-   @Ignore("requires human input to terminate!")
-   public void testRecovery() throws Exception {
-      init();
-      MessageProducer producer = sess.createProducer(dest);
-      for (int i = 0; i < 1000; i++) {
-         producer.send(sess.createTextMessage("test"));
-      }
-      producer.close();
-      sess.close();
-      conn.close();
-
-      broker.stop();
-      broker.waitUntilStopped();
-      broker = createRestartedBroker();
-      broker.start();
-      broker.waitUntilStarted();
-
-      init();
-
-      for (int i = 0; i < 10; i++) {
-         new Thread("Producer " + i) {
-
-            @Override
-            public void run() {
-               try {
-                  MessageProducer producer = sess.createProducer(dest);
-                  for (int i = 0; i < 15000; i++) {
-                     producer.send(sess.createTextMessage("test"));
-                     if (i % 100 == 0) {
-                        System.out.println(getName() + " sent message " + i);
-                     }
-                  }
-                  producer.close();
-               }
-               catch (Exception e) {
-                  e.printStackTrace();
-               }
-            }
-
-         }.start();
-
-         new Thread("Consumer " + i) {
-
-            @Override
-            public void run() {
-               try {
-                  MessageConsumer consumer = sess.createConsumer(dest);
-                  for (int i = 0; i < 15000; i++) {
-                     consumer.receive(2000);
-                     if (i % 100 == 0) {
-                        System.out.println(getName() + " received message " + i);
-                     }
-                  }
-                  consumer.close();
-               }
-               catch (Exception e) {
-                  e.printStackTrace();
-               }
-            }
-
-         }.start();
-      }
-
-      // Check out JConsole
-      System.in.read();
-      sess.close();
-      conn.close();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCXACommitExceptionTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCXACommitExceptionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCXACommitExceptionTest.java
deleted file mode 100644
index ecc07ae..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCXACommitExceptionTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- * 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.store.jdbc;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.XAConnection;
-import javax.jms.XASession;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-import org.apache.activemq.ActiveMQXAConnectionFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-// https://issues.apache.org/activemq/browse/AMQ-2880
-public class JDBCXACommitExceptionTest extends JDBCCommitExceptionTest {
-
-   private static final Logger LOG = LoggerFactory.getLogger(JDBCXACommitExceptionTest.class);
-
-   private long txGenerator = System.currentTimeMillis();
-
-   protected ActiveMQXAConnectionFactory factory;
-
-   boolean onePhase = true;
-
-   @Override
-   public void setUp() throws Exception {
-      super.setUp();
-
-      factory = new ActiveMQXAConnectionFactory(connectionUri + "?jms.prefetchPolicy.all=0&jms.redeliveryPolicy.maximumRedeliveries=" + messagesExpected);
-   }
-
-   public void testTwoPhaseSqlException() throws Exception {
-      onePhase = false;
-      doTestSqlException();
-   }
-
-   @Override
-   protected int receiveMessages(int messagesExpected) throws Exception {
-      XAConnection connection = factory.createXAConnection();
-      connection.start();
-      XASession session = connection.createXASession();
-
-      jdbc.setShouldBreak(true);
-
-      // first try and receive these messages, they'll continually fail
-      receiveMessages(messagesExpected, session, onePhase);
-
-      jdbc.setShouldBreak(false);
-
-      // now that the store is sane, try and get all the messages sent
-      return receiveMessages(messagesExpected, session, onePhase);
-   }
-
-   protected int receiveMessages(int messagesExpected, XASession session, boolean onePhase) throws Exception {
-      int messagesReceived = 0;
-
-      for (int i = 0; i < messagesExpected; i++) {
-         Destination destination = session.createQueue("TEST");
-         MessageConsumer consumer = session.createConsumer(destination);
-
-         XAResource resource = session.getXAResource();
-         resource.recover(XAResource.TMSTARTRSCAN);
-         resource.recover(XAResource.TMNOFLAGS);
-
-         Xid tid = createXid();
-
-         Message message = null;
-         try {
-            LOG.debug("Receiving message " + (messagesReceived + 1) + " of " + messagesExpected);
-            resource.start(tid, XAResource.TMNOFLAGS);
-            message = consumer.receive(2000);
-            LOG.info("Received : " + message);
-            resource.end(tid, XAResource.TMSUCCESS);
-            if (message != null) {
-               if (onePhase) {
-                  resource.commit(tid, true);
-               }
-               else {
-                  resource.prepare(tid);
-                  resource.commit(tid, false);
-               }
-               messagesReceived++;
-            }
-         }
-         catch (Exception e) {
-            LOG.debug("Caught exception:", e);
-
-            try {
-               LOG.debug("Rolling back transaction (just in case, no need to do this as it is implicit in a 1pc commit failure) " + tid);
-               resource.rollback(tid);
-            }
-            catch (XAException ex) {
-               try {
-                  LOG.debug("Caught exception during rollback: " + ex + " forgetting transaction " + tid);
-                  resource.forget(tid);
-               }
-               catch (XAException ex1) {
-                  LOG.debug("rollback/forget failed: " + ex1.errorCode);
-               }
-            }
-         }
-         finally {
-            if (consumer != null) {
-               consumer.close();
-            }
-         }
-      }
-      return messagesReceived;
-   }
-
-   public Xid createXid() throws IOException {
-
-      ByteArrayOutputStream baos = new ByteArrayOutputStream();
-      DataOutputStream os = new DataOutputStream(baos);
-      os.writeLong(++txGenerator);
-      os.close();
-      final byte[] bs = baos.toByteArray();
-
-      return new Xid() {
-         @Override
-         public int getFormatId() {
-            return 86;
-         }
-
-         @Override
-         public byte[] getGlobalTransactionId() {
-            return bs;
-         }
-
-         @Override
-         public byte[] getBranchQualifier() {
-            return bs;
-         }
-      };
-
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/LeaseDatabaseLockerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/LeaseDatabaseLockerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/LeaseDatabaseLockerTest.java
deleted file mode 100644
index 5db2c05..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/LeaseDatabaseLockerTest.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/**
- * 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.store.jdbc;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.Timestamp;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.apache.activemq.broker.AbstractLocker;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter;
-import org.apache.activemq.util.Wait;
-import org.apache.derby.jdbc.EmbeddedDataSource;
-import org.jmock.Expectations;
-import org.jmock.Mockery;
-import org.jmock.lib.legacy.ClassImposteriser;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class LeaseDatabaseLockerTest {
-
-   private static final Logger LOG = LoggerFactory.getLogger(LeaseDatabaseLockerTest.class);
-
-   JDBCPersistenceAdapter jdbc;
-   BrokerService brokerService;
-   EmbeddedDataSource dataSource;
-
-   @Before
-   public void setUpStore() throws Exception {
-      dataSource = new EmbeddedDataSource();
-      dataSource.setDatabaseName("derbyDb");
-      dataSource.setCreateDatabase("create");
-      jdbc = new JDBCPersistenceAdapter();
-      jdbc.setDataSource(dataSource);
-      brokerService = new BrokerService();
-      jdbc.setBrokerService(brokerService);
-      jdbc.getAdapter().doCreateTables(jdbc.getTransactionContext());
-   }
-
-   @Test
-   public void testLockInterleave() throws Exception {
-
-      LeaseDatabaseLocker lockerA = new LeaseDatabaseLocker();
-      lockerA.setLeaseHolderId("First");
-      jdbc.setLocker(lockerA);
-
-      final LeaseDatabaseLocker lockerB = new LeaseDatabaseLocker();
-      lockerB.setLeaseHolderId("Second");
-      jdbc.setLocker(lockerB);
-      final AtomicBoolean blocked = new AtomicBoolean(true);
-
-      final Connection connection = dataSource.getConnection();
-      printLockTable(connection);
-      lockerA.start();
-      printLockTable(connection);
-
-      assertTrue("First has lock", lockerA.keepAlive());
-
-      final CountDownLatch lockerBStarting = new CountDownLatch(1);
-      ExecutorService executor = Executors.newCachedThreadPool();
-      executor.execute(new Runnable() {
-         @Override
-         public void run() {
-            try {
-               lockerBStarting.countDown();
-               lockerB.start();
-               blocked.set(false);
-               printLockTable(connection);
-
-            }
-            catch (Exception e) {
-               e.printStackTrace();
-            }
-         }
-      });
-
-      Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return lockerBStarting.await(1, TimeUnit.SECONDS);
-         }
-      });
-
-      TimeUnit.MILLISECONDS.sleep(lockerB.getLockAcquireSleepInterval() / 2);
-      assertTrue("B is blocked", blocked.get());
-
-      assertTrue("A is good", lockerA.keepAlive());
-      printLockTable(connection);
-
-      lockerA.stop();
-      printLockTable(connection);
-
-      TimeUnit.MILLISECONDS.sleep(2 * lockerB.getLockAcquireSleepInterval());
-      assertFalse("lockerB has the lock", blocked.get());
-      lockerB.stop();
-      printLockTable(connection);
-   }
-
-   @Test
-   public void testLockAcquireRace() throws Exception {
-
-      // build a fake lock
-      final String fakeId = "Anon";
-      final Connection connection = dataSource.getConnection();
-      printLockTable(connection);
-      PreparedStatement statement = connection.prepareStatement(jdbc.getStatements().getLeaseObtainStatement());
-
-      final long now = System.currentTimeMillis();
-      statement.setString(1, fakeId);
-      statement.setLong(2, now + 30000);
-      statement.setLong(3, now);
-
-      assertEquals("we got the lease", 1, statement.executeUpdate());
-      printLockTable(connection);
-
-      final LeaseDatabaseLocker lockerA = new LeaseDatabaseLocker();
-      lockerA.setLeaseHolderId("A");
-      jdbc.setLocker(lockerA);
-
-      final LeaseDatabaseLocker lockerB = new LeaseDatabaseLocker();
-      lockerB.setLeaseHolderId("B");
-      jdbc.setLocker(lockerB);
-
-      final Set<LeaseDatabaseLocker> lockedSet = new HashSet<>();
-      ExecutorService executor = Executors.newCachedThreadPool();
-      executor.execute(new Runnable() {
-         @Override
-         public void run() {
-            try {
-               lockerA.start();
-               lockedSet.add(lockerA);
-               printLockTable(connection);
-
-            }
-            catch (Exception e) {
-               e.printStackTrace();
-            }
-         }
-      });
-
-      executor.execute(new Runnable() {
-         @Override
-         public void run() {
-            try {
-               lockerB.start();
-               lockedSet.add(lockerB);
-               printLockTable(connection);
-
-            }
-            catch (Exception e) {
-               e.printStackTrace();
-            }
-         }
-      });
-
-      // sleep for a bit till both are alive
-      TimeUnit.SECONDS.sleep(2);
-      assertTrue("no start", lockedSet.isEmpty());
-      assertFalse("A is blocked", lockerA.keepAlive());
-      assertFalse("B is blocked", lockerB.keepAlive());
-
-      LOG.info("releasing phony lock " + fakeId);
-
-      statement = connection.prepareStatement(jdbc.getStatements().getLeaseUpdateStatement());
-      statement.setString(1, null);
-      statement.setLong(2, 0L);
-      statement.setString(3, fakeId);
-      assertEquals("we released " + fakeId, 1, statement.executeUpdate());
-      LOG.info("released " + fakeId);
-      printLockTable(connection);
-
-      TimeUnit.MILLISECONDS.sleep(AbstractLocker.DEFAULT_LOCK_ACQUIRE_SLEEP_INTERVAL);
-      assertEquals("one locker started", 1, lockedSet.size());
-
-      assertTrue("one isAlive", lockerA.keepAlive() || lockerB.keepAlive());
-
-      LeaseDatabaseLocker winner = lockedSet.iterator().next();
-      winner.stop();
-      lockedSet.remove(winner);
-
-      TimeUnit.MILLISECONDS.sleep(AbstractLocker.DEFAULT_LOCK_ACQUIRE_SLEEP_INTERVAL);
-      assertEquals("one locker started", 1, lockedSet.size());
-
-      lockedSet.iterator().next().stop();
-      printLockTable(connection);
-   }
-
-   @Test
-   public void testDiffOffsetAhead() throws Exception {
-      LeaseDatabaseLocker underTest = new LeaseDatabaseLocker();
-      assertTrue("when ahead of db adjustment is negative", callDiffOffset(underTest, System.currentTimeMillis() - 60000) < 0);
-   }
-
-   @Test
-   public void testDiffOffsetBehind() throws Exception {
-      LeaseDatabaseLocker underTest = new LeaseDatabaseLocker();
-      assertTrue("when behind db adjustment is positive", callDiffOffset(underTest, System.currentTimeMillis() + 60000) > 0);
-   }
-
-   @Test
-   public void testDiffIngoredIfLessthanMaxAllowableDiffFromDBTime() throws Exception {
-      LeaseDatabaseLocker underTest = new LeaseDatabaseLocker();
-      underTest.setMaxAllowableDiffFromDBTime(60000);
-      assertEquals("no adjust when under limit", 0, callDiffOffset(underTest, System.currentTimeMillis() - 40000));
-   }
-
-   public long callDiffOffset(LeaseDatabaseLocker underTest, final long dbTime) throws Exception {
-
-      Mockery context = new Mockery() {{
-         setImposteriser(ClassImposteriser.INSTANCE);
-      }};
-      final Statements statements = context.mock(Statements.class);
-      final JDBCPersistenceAdapter jdbcPersistenceAdapter = context.mock(JDBCPersistenceAdapter.class);
-      final Connection connection = context.mock(Connection.class);
-      final PreparedStatement preparedStatement = context.mock(PreparedStatement.class);
-      final ResultSet resultSet = context.mock(ResultSet.class);
-      final Timestamp timestamp = context.mock(Timestamp.class);
-
-      context.checking(new Expectations() {{
-         allowing(jdbcPersistenceAdapter).getStatements();
-         will(returnValue(statements));
-         allowing(jdbcPersistenceAdapter);
-         allowing(statements);
-         allowing(connection).prepareStatement(with(any(String.class)));
-         will(returnValue(preparedStatement));
-         allowing(connection);
-         allowing(preparedStatement).executeQuery();
-         will(returnValue(resultSet));
-         allowing(resultSet).next();
-         will(returnValue(true));
-         allowing(resultSet).getTimestamp(1);
-         will(returnValue(timestamp));
-         allowing(timestamp).getTime();
-         will(returnValue(dbTime));
-      }});
-
-      underTest.configure(jdbcPersistenceAdapter);
-      underTest.setLockable(jdbcPersistenceAdapter);
-      return underTest.determineTimeDifference(connection);
-   }
-
-   private void printLockTable(Connection connection) throws Exception {
-      DefaultJDBCAdapter.printQuery(connection, "SELECT * from ACTIVEMQ_LOCK", System.err);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/CustomLockerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/CustomLockerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/CustomLockerTest.java
deleted file mode 100644
index 8136eb6..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/CustomLockerTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * 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.store.kahadb;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.broker.BrokerFactory;
-import org.apache.activemq.broker.BrokerService;
-
-public class CustomLockerTest extends TestCase {
-
-   public void testCustomLocker() throws Exception {
-      BrokerService broker = BrokerFactory.createBroker("xbean:org/apache/activemq/store/kahadb/shared.xml");
-      broker.waitUntilStarted();
-      broker.stop();
-      broker.waitUntilStopped();
-   }
-}


[15/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4887Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4887Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4887Test.java
deleted file mode 100644
index 657d7a2..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4887Test.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import javax.jms.BytesMessage;
-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 javax.jms.StreamMessage;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ4887Test {
-
-   private static final transient Logger LOG = LoggerFactory.getLogger(AMQ4887Test.class);
-   private static final Integer ITERATIONS = 10;
-
-   @Rule
-   public TestName name = new TestName();
-
-   @Test
-   public void testBytesMessageSetPropertyBeforeCopy() throws Exception {
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost");
-      ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection();
-      connection.start();
-      doTestBytesMessageSetPropertyBeforeCopy(connection);
-   }
-
-   @Test
-   public void testBytesMessageSetPropertyBeforeCopyCompressed() throws Exception {
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost");
-      connectionFactory.setUseCompression(true);
-      ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection();
-      connection.start();
-      doTestBytesMessageSetPropertyBeforeCopy(connection);
-   }
-
-   public void doTestBytesMessageSetPropertyBeforeCopy(Connection connection) throws Exception {
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Destination destination = session.createQueue(name.toString());
-      MessageConsumer consumer = session.createConsumer(destination);
-      MessageProducer producer = session.createProducer(destination);
-
-      BytesMessage message = session.createBytesMessage();
-
-      for (int i = 0; i < ITERATIONS; i++) {
-
-         long sendTime = System.currentTimeMillis();
-         message.setLongProperty("sendTime", sendTime);
-         producer.send(message);
-
-         LOG.debug("Receiving message " + i);
-         Message receivedMessage = consumer.receive(5000);
-         assertNotNull("On message " + i, receivedMessage);
-         assertTrue("On message " + i, receivedMessage instanceof BytesMessage);
-
-         BytesMessage receivedBytesMessage = (BytesMessage) receivedMessage;
-
-         int numElements = 0;
-         try {
-            while (true) {
-               receivedBytesMessage.readBoolean();
-               numElements++;
-            }
-         }
-         catch (Exception ex) {
-         }
-
-         LOG.info("Iteration [{}]: Received Message contained {} boolean values.", i, numElements);
-         assertEquals(i, numElements);
-
-         long receivedSendTime = receivedBytesMessage.getLongProperty("sendTime");
-         assertEquals("On message " + i, receivedSendTime, sendTime);
-
-         // Add a new bool value on each iteration.
-         message.writeBoolean(true);
-      }
-   }
-
-   @Test
-   public void testStreamMessageSetPropertyBeforeCopy() throws Exception {
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost");
-      ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection();
-      connection.start();
-      doTestStreamMessageSetPropertyBeforeCopy(connection);
-   }
-
-   @Test
-   public void testStreamMessageSetPropertyBeforeCopyCompressed() throws Exception {
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost");
-      connectionFactory.setUseCompression(true);
-      ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection();
-      connection.start();
-      doTestStreamMessageSetPropertyBeforeCopy(connection);
-   }
-
-   public void doTestStreamMessageSetPropertyBeforeCopy(Connection connection) throws Exception {
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Destination destination = session.createQueue(name.toString());
-      MessageConsumer consumer = session.createConsumer(destination);
-      MessageProducer producer = session.createProducer(destination);
-
-      StreamMessage message = session.createStreamMessage();
-
-      for (int i = 0; i < ITERATIONS; i++) {
-
-         long sendTime = System.currentTimeMillis();
-         message.setLongProperty("sendTime", sendTime);
-         producer.send(message);
-
-         LOG.debug("Receiving message " + i);
-         Message receivedMessage = consumer.receive(5000);
-         assertNotNull("On message " + i, receivedMessage);
-         assertTrue("On message " + i, receivedMessage instanceof StreamMessage);
-
-         StreamMessage receivedStreamMessage = (StreamMessage) receivedMessage;
-
-         int numElements = 0;
-         try {
-            while (true) {
-               receivedStreamMessage.readBoolean();
-               numElements++;
-            }
-         }
-         catch (Exception ex) {
-         }
-
-         LOG.info("Iteration [{}]: Received Message contained {} boolean values.", i, numElements);
-         assertEquals(i, numElements);
-
-         long receivedSendTime = receivedStreamMessage.getLongProperty("sendTime");
-         assertEquals("On message " + i, receivedSendTime, sendTime);
-
-         // Add a new bool value on each iteration.
-         message.writeBoolean(true);
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4893Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4893Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4893Test.java
deleted file mode 100644
index ba65ab7..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4893Test.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * 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;
-
-import java.io.IOException;
-import java.util.Map;
-
-import javax.jms.JMSException;
-
-import org.apache.activemq.command.ActiveMQObjectMessage;
-import org.apache.activemq.openwire.OpenWireFormat;
-import org.apache.activemq.util.ByteSequence;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ4893Test {
-
-   private static final transient Logger LOG = LoggerFactory.getLogger(AMQ4893Test.class);
-
-   @Test
-   public void testPropertiesInt() throws Exception {
-      ActiveMQObjectMessage message = new ActiveMQObjectMessage();
-      message.setIntProperty("TestProp", 333);
-      fakeUnmarshal(message);
-      roundTripProperties(message);
-   }
-
-   @Test
-   public void testPropertiesString() throws Exception {
-      ActiveMQObjectMessage message = new ActiveMQObjectMessage();
-      message.setStringProperty("TestProp", "Value");
-      fakeUnmarshal(message);
-      roundTripProperties(message);
-   }
-
-   @Test
-   public void testPropertiesObject() throws Exception {
-      ActiveMQObjectMessage message = new ActiveMQObjectMessage();
-      message.setObjectProperty("TestProp", "Value");
-      fakeUnmarshal(message);
-      roundTripProperties(message);
-   }
-
-   @Test
-   public void testPropertiesObjectNoMarshalling() throws Exception {
-      ActiveMQObjectMessage message = new ActiveMQObjectMessage();
-      message.setObjectProperty("TestProp", "Value");
-      roundTripProperties(message);
-   }
-
-   private void roundTripProperties(ActiveMQObjectMessage message) throws IOException, JMSException {
-      ActiveMQObjectMessage copy = new ActiveMQObjectMessage();
-      for (Map.Entry<String, Object> prop : message.getProperties().entrySet()) {
-         LOG.debug("{} -> {}", prop.getKey(), prop.getValue().getClass());
-         copy.setObjectProperty(prop.getKey(), prop.getValue());
-      }
-   }
-
-   private void fakeUnmarshal(ActiveMQObjectMessage message) throws IOException {
-      // we need to force the unmarshalled property field to be set so it
-      // gives us a hawtbuffer for the string
-      OpenWireFormat format = new OpenWireFormat();
-      message.beforeMarshall(format);
-      message.afterMarshall(format);
-
-      ByteSequence seq = message.getMarshalledProperties();
-      message.clearProperties();
-      message.setMarshalledProperties(seq);
-   }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4899Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4899Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4899Test.java
deleted file mode 100644
index fe336eb..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4899Test.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/**
- * 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;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerFactory;
-import org.apache.activemq.broker.BrokerPlugin;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.DestinationInterceptor;
-import org.apache.activemq.broker.region.virtual.VirtualDestination;
-import org.apache.activemq.broker.region.virtual.VirtualDestinationInterceptor;
-import org.apache.activemq.broker.region.virtual.VirtualTopic;
-import org.apache.activemq.plugin.SubQueueSelectorCacheBrokerPlugin;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.Assert.assertEquals;
-
-public class AMQ4899Test {
-
-   protected static final Logger LOG = LoggerFactory.getLogger(AMQ4899Test.class);
-   private static final String QUEUE_NAME = "AMQ4899TestQueue";
-   private static final String CONSUMER_QUEUE = "Consumer.Orders.VirtualOrders." + QUEUE_NAME;
-   private static final String PRODUCER_DESTINATION_NAME = "VirtualOrders." + QUEUE_NAME;
-
-   private static final Integer MESSAGE_LIMIT = 20;
-   public static final String CONSUMER_A_SELECTOR = "Order < " + 10;
-   public static String CONSUMER_B_SELECTOR = "Order >= " + 10;
-   private CountDownLatch consumersStarted = new CountDownLatch(2);
-   private CountDownLatch consumerAtoConsumeCount = new CountDownLatch(10);
-   private CountDownLatch consumerBtoConsumeCount = new CountDownLatch(10);
-
-   private BrokerService broker;
-
-   @Before
-   public void setUp() {
-      setupBroker("broker://()/localhost?");
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-      }
-   }
-
-   @Test(timeout = 60 * 1000)
-   public void testVirtualTopicMultipleSelectors() throws Exception {
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
-      Connection connection = factory.createConnection();
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      Queue consumerQueue = session.createQueue(CONSUMER_QUEUE);
-
-      MessageListener listenerA = new AMQ4899Listener("A", consumersStarted, consumerAtoConsumeCount);
-      MessageConsumer consumerA = session.createConsumer(consumerQueue, CONSUMER_A_SELECTOR);
-      consumerA.setMessageListener(listenerA);
-
-      MessageListener listenerB = new AMQ4899Listener("B", consumersStarted, consumerBtoConsumeCount);
-      MessageConsumer consumerB = session.createConsumer(consumerQueue, CONSUMER_B_SELECTOR);
-      consumerB.setMessageListener(listenerB);
-
-      consumersStarted.await(10, TimeUnit.SECONDS);
-      assertEquals("Not all consumers started in time", 0, consumersStarted.getCount());
-
-      Destination producerDestination = session.createTopic(PRODUCER_DESTINATION_NAME);
-      MessageProducer producer = session.createProducer(producerDestination);
-      int messageIndex = 0;
-      for (int i = 0; i < MESSAGE_LIMIT; i++) {
-         if (i == 3) {
-            LOG.debug("Stopping consumerA");
-            consumerA.close();
-         }
-
-         if (i == 14) {
-            LOG.debug("Stopping consumer B");
-            consumerB.close();
-         }
-         String messageText = "hello " + messageIndex++ + " sent at " + new java.util.Date().toString();
-         TextMessage message = session.createTextMessage(messageText);
-         message.setIntProperty("Order", i);
-         LOG.debug("Sending message [{}]", messageText);
-         producer.send(message);
-         Thread.sleep(100);
-      }
-      Thread.sleep(1 * 1000);
-
-      // restart consumerA
-      LOG.debug("Restarting consumerA");
-      consumerA = session.createConsumer(consumerQueue, CONSUMER_A_SELECTOR);
-      consumerA.setMessageListener(listenerA);
-
-      // restart consumerB
-      LOG.debug("restarting consumerB");
-      consumerB = session.createConsumer(consumerQueue, CONSUMER_B_SELECTOR);
-      consumerB.setMessageListener(listenerB);
-
-      consumerAtoConsumeCount.await(5, TimeUnit.SECONDS);
-      consumerBtoConsumeCount.await(5, TimeUnit.SECONDS);
-
-      LOG.debug("Unconsumed messages for consumerA {} consumerB {}", consumerAtoConsumeCount.getCount(), consumerBtoConsumeCount.getCount());
-
-      assertEquals("Consumer A did not consume all messages", 0, consumerAtoConsumeCount.getCount());
-      assertEquals("Consumer B did not consume all messages", 0, consumerBtoConsumeCount.getCount());
-
-      connection.close();
-   }
-
-   /**
-    * Setup broker with VirtualTopic configured
-    */
-   private void setupBroker(String uri) {
-      try {
-         broker = BrokerFactory.createBroker(uri);
-
-         VirtualDestinationInterceptor interceptor = new VirtualDestinationInterceptor();
-         VirtualTopic virtualTopic = new VirtualTopic();
-         virtualTopic.setName("VirtualOrders.>");
-         virtualTopic.setSelectorAware(true);
-         VirtualDestination[] virtualDestinations = {virtualTopic};
-         interceptor.setVirtualDestinations(virtualDestinations);
-         broker.setDestinationInterceptors(new DestinationInterceptor[]{interceptor});
-
-         SubQueueSelectorCacheBrokerPlugin subQueueSelectorCacheBrokerPlugin = new SubQueueSelectorCacheBrokerPlugin();
-         BrokerPlugin[] updatedPlugins = {subQueueSelectorCacheBrokerPlugin};
-         broker.setPlugins(updatedPlugins);
-
-         broker.start();
-         broker.waitUntilStarted();
-      }
-      catch (Exception e) {
-         LOG.error("Failed creating broker", e);
-      }
-   }
-}
-
-class AMQ4899Listener implements MessageListener {
-
-   Logger LOG = LoggerFactory.getLogger(AMQ4899Listener.class);
-   CountDownLatch toConsume;
-   String id;
-
-   public AMQ4899Listener(String id, CountDownLatch started, CountDownLatch toConsume) {
-      this.id = id;
-      this.toConsume = toConsume;
-      started.countDown();
-   }
-
-   @Override
-   public void onMessage(Message message) {
-      toConsume.countDown();
-      try {
-         if (message instanceof TextMessage) {
-            TextMessage textMessage = (TextMessage) message;
-            LOG.debug("Listener {} received [{}]", id, textMessage.getText());
-         }
-         else {
-            LOG.error("Listener {} Expected a TextMessage, got {}", id, message.getClass().getCanonicalName());
-         }
-      }
-      catch (JMSException e) {
-         LOG.error("Unexpected JMSException in Listener " + id, e);
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4930Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4930Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4930Test.java
deleted file mode 100644
index 4805873..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4930Test.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/**
- * 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;
-
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.QueueViewMBean;
-import org.apache.activemq.broker.region.Queue;
-import org.apache.activemq.broker.region.RegionBroker;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.Message;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ4930Test extends TestCase {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ4930Test.class);
-   final int messageCount = 150;
-   final int messageSize = 1024 * 1024;
-   final int maxBrowsePageSize = 50;
-   final ActiveMQQueue bigQueue = new ActiveMQQueue("BIG");
-   BrokerService broker;
-   ActiveMQConnectionFactory factory;
-
-   protected void configureBroker() throws Exception {
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.setAdvisorySupport(false);
-      broker.getSystemUsage().getMemoryUsage().setLimit(1 * 1024 * 1024);
-
-      PolicyMap pMap = new PolicyMap();
-      PolicyEntry policy = new PolicyEntry();
-      // disable expriy processing as this will call browse in parallel
-      policy.setExpireMessagesPeriod(0);
-      policy.setMaxPageSize(maxBrowsePageSize);
-      policy.setMaxBrowsePageSize(maxBrowsePageSize);
-      pMap.setDefaultEntry(policy);
-
-      broker.setDestinationPolicy(pMap);
-   }
-
-   public void testBrowsePendingNonPersistent() throws Exception {
-      doTestBrowsePending(DeliveryMode.NON_PERSISTENT);
-   }
-
-   public void testBrowsePendingPersistent() throws Exception {
-      doTestBrowsePending(DeliveryMode.PERSISTENT);
-   }
-
-   public void testWithStatsDisabled() throws Exception {
-      ((RegionBroker) broker.getRegionBroker()).getDestinationStatistics().setEnabled(false);
-      doTestBrowsePending(DeliveryMode.PERSISTENT);
-   }
-
-   public void doTestBrowsePending(int deliveryMode) throws Exception {
-
-      Connection connection = factory.createConnection();
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = session.createProducer(bigQueue);
-      producer.setDeliveryMode(deliveryMode);
-      BytesMessage bytesMessage = session.createBytesMessage();
-      bytesMessage.writeBytes(new byte[messageSize]);
-
-      for (int i = 0; i < messageCount; i++) {
-         producer.send(bigQueue, bytesMessage);
-      }
-
-      final QueueViewMBean queueViewMBean = (QueueViewMBean) broker.getManagementContext().newProxyInstance(broker.getAdminView().getQueues()[0], QueueViewMBean.class, false);
-
-      LOG.info(queueViewMBean.getName() + " Size: " + queueViewMBean.getEnqueueCount());
-
-      connection.close();
-
-      assertFalse("Cache disabled on q", queueViewMBean.isCacheEnabled());
-
-      // ensure repeated browse does now blow mem
-
-      final Queue underTest = (Queue) ((RegionBroker) broker.getRegionBroker()).getQueueRegion().getDestinationMap().get(bigQueue);
-
-      // do twice to attempt to pull in 2*maxBrowsePageSize which uses up the system memory limit
-      Message[] browsed = underTest.browse();
-      LOG.info("Browsed: " + browsed.length);
-      assertEquals("maxBrowsePageSize", maxBrowsePageSize, browsed.length);
-      browsed = underTest.browse();
-      LOG.info("Browsed: " + browsed.length);
-      assertEquals("maxBrowsePageSize", maxBrowsePageSize, browsed.length);
-      Runtime.getRuntime().gc();
-      long free = Runtime.getRuntime().freeMemory() / 1024;
-      LOG.info("free at start of check: " + free);
-      // check for memory growth
-      for (int i = 0; i < 10; i++) {
-         LOG.info("free: " + Runtime.getRuntime().freeMemory() / 1024);
-         browsed = underTest.browse();
-         LOG.info("Browsed: " + browsed.length);
-         assertEquals("maxBrowsePageSize", maxBrowsePageSize, browsed.length);
-         Runtime.getRuntime().gc();
-         Runtime.getRuntime().gc();
-         assertTrue("No growth: " + Runtime.getRuntime().freeMemory() / 1024 + " >= " + (free - (free * 0.2)), Runtime.getRuntime().freeMemory() / 1024 >= (free - (free * 0.2)));
-      }
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      super.setUp();
-      broker = new BrokerService();
-      broker.setBrokerName("thisOne");
-      configureBroker();
-      broker.start();
-      factory = new ActiveMQConnectionFactory("vm://thisOne?jms.alwaysSyncSend=true");
-      factory.setWatchTopicAdvisories(false);
-
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      super.tearDown();
-      if (broker != null) {
-         broker.stop();
-         broker = null;
-      }
-   }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4950Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4950Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4950Test.java
deleted file mode 100644
index 74d0817..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4950Test.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/**
- * 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;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.XASession;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-import org.apache.activemq.ActiveMQXAConnection;
-import org.apache.activemq.ActiveMQXAConnectionFactory;
-import org.apache.activemq.broker.BrokerPlugin;
-import org.apache.activemq.broker.BrokerPluginSupport;
-import org.apache.activemq.broker.BrokerRegistry;
-import org.apache.activemq.broker.BrokerRestartTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.ConnectionContext;
-import org.apache.activemq.broker.TransactionBroker;
-import org.apache.activemq.broker.TransportConnection;
-import org.apache.activemq.command.ConnectionId;
-import org.apache.activemq.command.TransactionId;
-import org.apache.activemq.command.TransactionInfo;
-import org.apache.activemq.command.XATransactionId;
-import org.apache.activemq.transport.failover.FailoverTransport;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Test for AMQ-4950.
- * Simulates an error during XA prepare call.
- */
-public class AMQ4950Test extends BrokerRestartTestSupport {
-
-   protected static final Logger LOG = LoggerFactory.getLogger(AMQ4950Test.class);
-   protected static final String simulatedExceptionMessage = "Simulating error inside tx prepare().";
-   public boolean prioritySupport = false;
-   protected String connectionUri = null;
-
-   @Override
-   protected void configureBroker(BrokerService broker) throws Exception {
-      broker.setDestinationPolicy(policyMap);
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.setUseJmx(false);
-      connectionUri = broker.addConnector("tcp://localhost:0").getPublishableConnectString();
-      broker.setPlugins(new BrokerPlugin[]{new BrokerPluginSupport() {
-
-         @Override
-         public int prepareTransaction(ConnectionContext context, TransactionId xid) throws Exception {
-            getNext().prepareTransaction(context, xid);
-            LOG.debug("BrokerPlugin.prepareTransaction() will throw an exception.");
-            throw new XAException(simulatedExceptionMessage);
-         }
-
-         @Override
-         public void commitTransaction(ConnectionContext context,
-                                       TransactionId xid,
-                                       boolean onePhase) throws Exception {
-            LOG.debug("BrokerPlugin.commitTransaction().");
-            super.commitTransaction(context, xid, onePhase);
-         }
-      }});
-   }
-
-   /**
-    * Creates XA transaction and invokes XA prepare().
-    * Due to registered BrokerFilter prepare will be handled by broker
-    * but then throw an exception.
-    * Prior to fixing AMQ-4950, this resulted in a ClassCastException
-    * in ConnectionStateTracker.PrepareReadonlyTransactionAction.onResponse()
-    * causing the failover transport to reconnect and replay the XA prepare().
-    */
-   public void testXAPrepareFailure() throws Exception {
-
-      assertNotNull(connectionUri);
-      ActiveMQXAConnectionFactory cf = new ActiveMQXAConnectionFactory("failover:(" + connectionUri + ")");
-      ActiveMQXAConnection xaConnection = (ActiveMQXAConnection) cf.createConnection();
-      xaConnection.start();
-      XASession session = xaConnection.createXASession();
-      XAResource resource = session.getXAResource();
-      Xid tid = createXid();
-      resource.start(tid, XAResource.TMNOFLAGS);
-
-      MessageProducer producer = session.createProducer(session.createQueue(this.getClass().getName()));
-      Message message = session.createTextMessage("Sample Message");
-      producer.send(message);
-      resource.end(tid, XAResource.TMSUCCESS);
-      try {
-         LOG.debug("Calling XA prepare(), expecting an exception");
-         int ret = resource.prepare(tid);
-         if (XAResource.XA_OK == ret)
-            resource.commit(tid, false);
-      }
-      catch (XAException xae) {
-         LOG.info("Received excpected XAException: {}", xae.getMessage());
-         LOG.info("Rolling back transaction {}", tid);
-
-         // with bug AMQ-4950 the thrown error reads "Cannot call prepare now"
-         // we check that we receive the original exception message as
-         // thrown by the BrokerPlugin
-         assertEquals(simulatedExceptionMessage, xae.getMessage());
-         resource.rollback(tid);
-      }
-      // couple of assertions
-      assertTransactionGoneFromBroker(tid);
-      assertTransactionGoneFromConnection(broker.getBrokerName(), xaConnection.getClientID(), xaConnection.getConnectionInfo().getConnectionId(), tid);
-      assertTransactionGoneFromFailoverState(xaConnection, tid);
-
-      //cleanup
-      producer.close();
-      session.close();
-      xaConnection.close();
-      LOG.debug("testXAPrepareFailure() finished.");
-   }
-
-   public Xid createXid() throws IOException {
-      ByteArrayOutputStream baos = new ByteArrayOutputStream();
-      DataOutputStream os = new DataOutputStream(baos);
-      os.writeLong(++txGenerator);
-      os.close();
-      final byte[] bs = baos.toByteArray();
-
-      return new Xid() {
-         @Override
-         public int getFormatId() {
-            return 86;
-         }
-
-         @Override
-         public byte[] getGlobalTransactionId() {
-            return bs;
-         }
-
-         @Override
-         public byte[] getBranchQualifier() {
-            return bs;
-         }
-      };
-   }
-
-   private void assertTransactionGoneFromFailoverState(ActiveMQXAConnection connection1, Xid tid) throws Exception {
-
-      FailoverTransport transport = connection1.getTransport().narrow(FailoverTransport.class);
-      TransactionInfo info = new TransactionInfo(connection1.getConnectionInfo().getConnectionId(), new XATransactionId(tid), TransactionInfo.COMMIT_ONE_PHASE);
-      assertNull("transaction should not exist in the state tracker", transport.getStateTracker().processCommitTransactionOnePhase(info));
-   }
-
-   private void assertTransactionGoneFromBroker(Xid tid) throws Exception {
-      BrokerService broker = BrokerRegistry.getInstance().lookup("localhost");
-      TransactionBroker transactionBroker = (TransactionBroker) broker.getBroker().getAdaptor(TransactionBroker.class);
-      try {
-         transactionBroker.getTransaction(null, new XATransactionId(tid), false);
-         fail("expected exception on tx not found");
-      }
-      catch (XAException expectedOnNotFound) {
-      }
-   }
-
-   private void assertTransactionGoneFromConnection(String brokerName,
-                                                    String clientId,
-                                                    ConnectionId connectionId,
-                                                    Xid tid) throws Exception {
-      BrokerService broker = BrokerRegistry.getInstance().lookup(brokerName);
-      CopyOnWriteArrayList<TransportConnection> connections = broker.getTransportConnectors().get(0).getConnections();
-      for (TransportConnection connection : connections) {
-         if (connection.getConnectionId().equals(clientId)) {
-            try {
-               connection.processPrepareTransaction(new TransactionInfo(connectionId, new XATransactionId(tid), TransactionInfo.PREPARE));
-               fail("did not get expected excepton on missing transaction, it must be still there in error!");
-            }
-            catch (IllegalStateException expectedOnNoTransaction) {
-            }
-         }
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4952Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4952Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4952Test.java
deleted file mode 100644
index 0b74979..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4952Test.java
+++ /dev/null
@@ -1,511 +0,0 @@
-/**
- * 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;
-
-import java.net.URI;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.sql.DataSource;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.Broker;
-import org.apache.activemq.broker.BrokerFilter;
-import org.apache.activemq.broker.BrokerPlugin;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.ProducerBrokerExchange;
-import org.apache.activemq.broker.TransportConnector;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.network.ConditionalNetworkBridgeFilterFactory;
-import org.apache.activemq.network.NetworkConnector;
-import org.apache.activemq.store.jdbc.JDBCPersistenceAdapter;
-import org.apache.activemq.util.IntrospectionSupport;
-import org.apache.activemq.util.Wait;
-import org.apache.derby.jdbc.EmbeddedDataSource;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.*;
-
-/**
- * Test creates a broker network with two brokers - producerBroker (with a
- * message producer attached) and consumerBroker (with consumer attached)
- * <br>
- * Simulates network duplicate message by stopping and restarting the
- * consumerBroker after message (with message ID ending in 120) is persisted to
- * consumerBrokerstore BUT BEFORE ack sent to the producerBroker over the
- * network connection. When the network connection is reestablished the
- * producerBroker resends message (with messageID ending in 120).
- * <br>
- * Expectation:
- * <br>
- * With the following policy entries set, would expect the duplicate message to
- * be read from the store and dispatched to the consumer - where the duplicate
- * could be detected by consumer.
- * <br>
- * PolicyEntry policy = new PolicyEntry(); policy.setQueue(">");
- * policy.setEnableAudit(false); policy.setUseCache(false);
- * policy.setExpireMessagesPeriod(0);
- * <br>
- * <br>
- * Note 1: Network needs to use replaywhenNoConsumers so enabling the
- * networkAudit to avoid this scenario is not feasible.
- * <br>
- * NOTE 2: Added a custom plugin to the consumerBroker so that the
- * consumerBroker shutdown will occur after a message has been persisted to
- * consumerBroker store but before an ACK is sent back to ProducerBroker. This
- * is just a hack to ensure producerBroker will resend the message after
- * shutdown.
- */
-
-@RunWith(value = Parameterized.class)
-public class AMQ4952Test {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ4952Test.class);
-
-   protected static final int MESSAGE_COUNT = 1;
-
-   protected BrokerService consumerBroker;
-   protected BrokerService producerBroker;
-
-   protected ActiveMQQueue QUEUE_NAME = new ActiveMQQueue("duptest.store");
-
-   private final CountDownLatch stopConsumerBroker = new CountDownLatch(1);
-   private final CountDownLatch consumerBrokerRestarted = new CountDownLatch(1);
-   private final CountDownLatch consumerRestartedAndMessageForwarded = new CountDownLatch(1);
-
-   private EmbeddedDataSource localDataSource;
-
-   @Parameterized.Parameter(0)
-   public boolean enableCursorAudit;
-
-   @Parameterized.Parameters(name = "enableAudit={0}")
-   public static Iterable<Object[]> getTestParameters() {
-      return Arrays.asList(new Object[][]{{Boolean.TRUE}, {Boolean.FALSE}});
-   }
-
-   @Test
-   public void testConsumerBrokerRestart() throws Exception {
-
-      Callable consumeMessageTask = new Callable() {
-         @Override
-         public Object call() throws Exception {
-
-            int receivedMessageCount = 0;
-
-            ActiveMQConnectionFactory consumerFactory = new ActiveMQConnectionFactory("failover:(tcp://localhost:2006)?randomize=false&backup=false");
-            Connection consumerConnection = consumerFactory.createConnection();
-
-            try {
-
-               consumerConnection.setClientID("consumer");
-               consumerConnection.start();
-
-               Session consumerSession = consumerConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-               MessageConsumer messageConsumer = consumerSession.createConsumer(QUEUE_NAME);
-
-               while (true) {
-                  TextMessage textMsg = (TextMessage) messageConsumer.receive(5000);
-
-                  if (textMsg == null) {
-                     return receivedMessageCount;
-                  }
-
-                  receivedMessageCount++;
-                  LOG.info("*** receivedMessageCount {} message has MessageID {} ", receivedMessageCount, textMsg.getJMSMessageID());
-
-                  // on first delivery ensure the message is pending an
-                  // ack when it is resent from the producer broker
-                  if (textMsg.getJMSMessageID().endsWith("1") && receivedMessageCount == 1) {
-                     LOG.info("Waiting for restart...");
-                     consumerRestartedAndMessageForwarded.await(90, TimeUnit.SECONDS);
-                  }
-
-                  textMsg.acknowledge();
-               }
-            }
-            finally {
-               consumerConnection.close();
-            }
-         }
-      };
-
-      Runnable consumerBrokerResetTask = new Runnable() {
-         @Override
-         public void run() {
-
-            try {
-               // wait for signal
-               stopConsumerBroker.await();
-
-               LOG.info("********* STOPPING CONSUMER BROKER");
-
-               consumerBroker.stop();
-               consumerBroker.waitUntilStopped();
-
-               LOG.info("***** STARTING CONSUMER BROKER");
-               // do not delete messages on startup
-               consumerBroker = createConsumerBroker(false);
-
-               LOG.info("***** CONSUMER BROKER STARTED!!");
-               consumerBrokerRestarted.countDown();
-
-               assertTrue("message forwarded on time", Wait.waitFor(new Wait.Condition() {
-                  @Override
-                  public boolean isSatisified() throws Exception {
-                     LOG.info("ProducerBroker totalMessageCount: " + producerBroker.getAdminView().getTotalMessageCount());
-                     return producerBroker.getAdminView().getTotalMessageCount() == 0;
-                  }
-               }));
-               consumerRestartedAndMessageForwarded.countDown();
-
-            }
-            catch (Exception e) {
-               LOG.error("Exception when stopping/starting the consumerBroker ", e);
-            }
-
-         }
-      };
-
-      ExecutorService executor = Executors.newFixedThreadPool(2);
-
-      // start consumerBroker start/stop task
-      executor.execute(consumerBrokerResetTask);
-
-      // start consuming messages
-      Future<Integer> numberOfConsumedMessage = executor.submit(consumeMessageTask);
-
-      produceMessages();
-
-      // Wait for consumer to finish
-      int totalMessagesConsumed = numberOfConsumedMessage.get();
-
-      StringBuffer contents = new StringBuffer();
-      boolean messageInStore = isMessageInJDBCStore(localDataSource, contents);
-      LOG.debug("****number of messages received " + totalMessagesConsumed);
-
-      assertEquals("number of messages received", 2, totalMessagesConsumed);
-      assertEquals("messages left in store", true, messageInStore);
-      assertTrue("message is in dlq: " + contents.toString(), contents.toString().contains("DLQ"));
-   }
-
-   private void produceMessages() throws JMSException {
-
-      ActiveMQConnectionFactory producerFactory = new ActiveMQConnectionFactory("failover:(tcp://localhost:2003)?randomize=false&backup=false");
-      Connection producerConnection = producerFactory.createConnection();
-
-      try {
-         producerConnection.setClientID("producer");
-         producerConnection.start();
-
-         Session producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-         final MessageProducer remoteProducer = producerSession.createProducer(QUEUE_NAME);
-
-         int i = 0;
-         while (MESSAGE_COUNT > i) {
-            String payload = "test msg " + i;
-            TextMessage msg = producerSession.createTextMessage(payload);
-            remoteProducer.send(msg);
-            i++;
-         }
-
-      }
-      finally {
-         producerConnection.close();
-      }
-   }
-
-   @Before
-   public void setUp() throws Exception {
-      LOG.debug("Running with enableCursorAudit set to {}", this.enableCursorAudit);
-      doSetUp();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      doTearDown();
-   }
-
-   protected void doTearDown() throws Exception {
-
-      try {
-         producerBroker.stop();
-      }
-      catch (Exception ex) {
-      }
-      try {
-         consumerBroker.stop();
-      }
-      catch (Exception ex) {
-      }
-   }
-
-   protected void doSetUp() throws Exception {
-      producerBroker = createProducerBroker();
-      consumerBroker = createConsumerBroker(true);
-   }
-
-   /**
-    * Producer broker listens on localhost:2003 networks to consumerBroker -
-    * localhost:2006
-    *
-    * @return
-    * @throws Exception
-    */
-   protected BrokerService createProducerBroker() throws Exception {
-
-      String networkToPorts[] = new String[]{"2006"};
-      HashMap<String, String> networkProps = new HashMap<>();
-
-      networkProps.put("networkTTL", "10");
-      networkProps.put("conduitSubscriptions", "true");
-      networkProps.put("decreaseNetworkConsumerPriority", "true");
-      networkProps.put("dynamicOnly", "true");
-
-      BrokerService broker = new BrokerService();
-      broker.getManagementContext().setCreateConnector(false);
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.setBrokerName("BP");
-      broker.setAdvisorySupport(false);
-
-      // lazy init listener on broker start
-      TransportConnector transportConnector = new TransportConnector();
-      transportConnector.setUri(new URI("tcp://localhost:2003"));
-      List<TransportConnector> transportConnectors = new ArrayList<>();
-      transportConnectors.add(transportConnector);
-      broker.setTransportConnectors(transportConnectors);
-
-      // network to consumerBroker
-
-      if (networkToPorts.length > 0) {
-         StringBuilder builder = new StringBuilder("static:(failover:(tcp://localhost:2006)?maxReconnectAttempts=0)?useExponentialBackOff=false");
-         NetworkConnector nc = broker.addNetworkConnector(builder.toString());
-         IntrospectionSupport.setProperties(nc, networkProps);
-         nc.setStaticallyIncludedDestinations(Arrays.<ActiveMQDestination>asList(new ActiveMQQueue[]{QUEUE_NAME}));
-      }
-
-      // Persistence adapter
-
-      JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter();
-      EmbeddedDataSource remoteDataSource = new EmbeddedDataSource();
-      remoteDataSource.setDatabaseName("target/derbyDBRemoteBroker");
-      remoteDataSource.setCreateDatabase("create");
-      jdbc.setDataSource(remoteDataSource);
-      broker.setPersistenceAdapter(jdbc);
-
-      // set Policy entries
-      PolicyEntry policy = new PolicyEntry();
-
-      policy.setQueue(">");
-      policy.setEnableAudit(false);
-      policy.setUseCache(false);
-      policy.setExpireMessagesPeriod(0);
-
-      // set replay with no consumers
-      ConditionalNetworkBridgeFilterFactory conditionalNetworkBridgeFilterFactory = new ConditionalNetworkBridgeFilterFactory();
-      conditionalNetworkBridgeFilterFactory.setReplayWhenNoConsumers(true);
-      policy.setNetworkBridgeFilterFactory(conditionalNetworkBridgeFilterFactory);
-
-      PolicyMap pMap = new PolicyMap();
-      pMap.setDefaultEntry(policy);
-      broker.setDestinationPolicy(pMap);
-
-      broker.start();
-      broker.waitUntilStarted();
-
-      return broker;
-   }
-
-   /**
-    * consumerBroker - listens on localhost:2006
-    *
-    * @param deleteMessages - drop messages when broker instance is created
-    * @return
-    * @throws Exception
-    */
-   protected BrokerService createConsumerBroker(boolean deleteMessages) throws Exception {
-
-      String scheme = "tcp";
-      String listenPort = "2006";
-
-      BrokerService broker = new BrokerService();
-      broker.getManagementContext().setCreateConnector(false);
-      broker.setDeleteAllMessagesOnStartup(deleteMessages);
-      broker.setBrokerName("BC");
-      // lazy init listener on broker start
-      TransportConnector transportConnector = new TransportConnector();
-      transportConnector.setUri(new URI(scheme + "://localhost:" + listenPort));
-      List<TransportConnector> transportConnectors = new ArrayList<>();
-      transportConnectors.add(transportConnector);
-      broker.setTransportConnectors(transportConnectors);
-
-      // policy entries
-
-      PolicyEntry policy = new PolicyEntry();
-
-      policy.setQueue(">");
-      policy.setEnableAudit(enableCursorAudit);
-      policy.setExpireMessagesPeriod(0);
-
-      // set replay with no consumers
-      ConditionalNetworkBridgeFilterFactory conditionalNetworkBridgeFilterFactory = new ConditionalNetworkBridgeFilterFactory();
-      conditionalNetworkBridgeFilterFactory.setReplayWhenNoConsumers(true);
-      policy.setNetworkBridgeFilterFactory(conditionalNetworkBridgeFilterFactory);
-
-      PolicyMap pMap = new PolicyMap();
-
-      pMap.setDefaultEntry(policy);
-      broker.setDestinationPolicy(pMap);
-
-      // Persistence adapter
-      JDBCPersistenceAdapter localJDBCPersistentAdapter = new JDBCPersistenceAdapter();
-      EmbeddedDataSource localDataSource = new EmbeddedDataSource();
-      localDataSource.setDatabaseName("target/derbyDBLocalBroker");
-      localDataSource.setCreateDatabase("create");
-      localJDBCPersistentAdapter.setDataSource(localDataSource);
-      broker.setPersistenceAdapter(localJDBCPersistentAdapter);
-
-      if (deleteMessages) {
-         // no plugin on restart
-         broker.setPlugins(new BrokerPlugin[]{new MyTestPlugin()});
-      }
-
-      this.localDataSource = localDataSource;
-
-      broker.start();
-      broker.waitUntilStarted();
-
-      return broker;
-   }
-
-   /**
-    * Query JDBC Store to see if messages are left
-    *
-    * @param dataSource
-    * @return
-    * @throws SQLException
-    */
-   private boolean isMessageInJDBCStore(DataSource dataSource, StringBuffer stringBuffer) throws SQLException {
-
-      boolean tableHasData = false;
-      String query = "select * from ACTIVEMQ_MSGS";
-
-      java.sql.Connection conn = dataSource.getConnection();
-      PreparedStatement s = conn.prepareStatement(query);
-
-      ResultSet set = null;
-
-      try {
-         StringBuffer headers = new StringBuffer();
-         set = s.executeQuery();
-         ResultSetMetaData metaData = set.getMetaData();
-         for (int i = 1; i <= metaData.getColumnCount(); i++) {
-
-            if (i == 1) {
-               headers.append("||");
-            }
-            headers.append(metaData.getColumnName(i) + "||");
-         }
-         LOG.error(headers.toString());
-
-         while (set.next()) {
-            tableHasData = true;
-
-            for (int i = 1; i <= metaData.getColumnCount(); i++) {
-               if (i == 1) {
-                  stringBuffer.append("|");
-               }
-               stringBuffer.append(set.getString(i) + "|");
-            }
-            LOG.error(stringBuffer.toString());
-         }
-      }
-      finally {
-         try {
-            set.close();
-         }
-         catch (Throwable ignore) {
-         }
-         try {
-            s.close();
-         }
-         catch (Throwable ignore) {
-         }
-
-         conn.close();
-      }
-
-      return tableHasData;
-   }
-
-   /**
-    * plugin used to ensure consumerbroker is restared before the network
-    * message from producerBroker is acked
-    */
-   class MyTestPlugin implements BrokerPlugin {
-
-      @Override
-      public Broker installPlugin(Broker broker) throws Exception {
-         return new MyTestBroker(broker);
-      }
-   }
-
-   class MyTestBroker extends BrokerFilter {
-
-      public MyTestBroker(Broker next) {
-         super(next);
-      }
-
-      @Override
-      public void send(ProducerBrokerExchange producerExchange,
-                       org.apache.activemq.command.Message messageSend) throws Exception {
-
-         super.send(producerExchange, messageSend);
-         LOG.error("Stopping broker on send:  " + messageSend.getMessageId().getProducerSequenceId());
-         stopConsumerBroker.countDown();
-         producerExchange.getConnectionContext().setDontSendReponse(true);
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5035Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5035Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5035Test.java
deleted file mode 100644
index beab4c3..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5035Test.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertNotNull;
-
-import javax.jms.Connection;
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.BrokerViewMBean;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AMQ5035Test {
-
-   private static final String CLIENT_ID = "amq-test-client-id";
-   private static final String DURABLE_SUB_NAME = "testDurable";
-
-   private final String xbean = "xbean:";
-   private final String confBase = "src/test/resources/org/apache/activemq/bugs/amq5035";
-
-   private static BrokerService brokerService;
-   private String connectionUri;
-
-   @Before
-   public void setUp() throws Exception {
-      brokerService = BrokerFactory.createBroker(xbean + confBase + "/activemq.xml");
-      connectionUri = brokerService.getTransportConnectorByScheme("tcp").getPublishableConnectString();
-      brokerService.setDeleteAllMessagesOnStartup(true);
-      brokerService.start();
-      brokerService.waitUntilStarted();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      brokerService.stop();
-      brokerService.waitUntilStopped();
-   }
-
-   @Test
-   public void testFoo() throws Exception {
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri);
-      Connection connection = factory.createConnection();
-      connection.setClientID(CLIENT_ID);
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Topic topic = session.createTopic("Test.Topic");
-      MessageConsumer consumer = session.createDurableSubscriber(topic, DURABLE_SUB_NAME);
-      consumer.close();
-
-      BrokerViewMBean brokerView = getBrokerView(DURABLE_SUB_NAME);
-      brokerView.destroyDurableSubscriber(CLIENT_ID, DURABLE_SUB_NAME);
-   }
-
-   private BrokerViewMBean getBrokerView(String testDurable) throws MalformedObjectNameException {
-      ObjectName brokerName = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost");
-      BrokerViewMBean view = (BrokerViewMBean) brokerService.getManagementContext().newProxyInstance(brokerName, BrokerViewMBean.class, true);
-      assertNotNull(view);
-      return view;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5136Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5136Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5136Test.java
deleted file mode 100644
index 8596683..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5136Test.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * 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;
-
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.Topic;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerRegistry;
-import org.apache.activemq.broker.BrokerService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AMQ5136Test {
-
-   BrokerService brokerService;
-
-   @Before
-   public void startBroker() throws Exception {
-      brokerService = new BrokerService();
-      brokerService.setPersistent(false);
-      brokerService.start();
-   }
-
-   @After
-   public void stopBroker() throws Exception {
-      brokerService.stop();
-   }
-
-   @Test
-   public void memoryUsageOnCommit() throws Exception {
-      sendMessagesAndAssertMemoryUsage(new TransactionHandler() {
-         @Override
-         public void finishTransaction(Session session) throws JMSException {
-            session.commit();
-         }
-      });
-   }
-
-   @Test
-   public void memoryUsageOnRollback() throws Exception {
-      sendMessagesAndAssertMemoryUsage(new TransactionHandler() {
-         @Override
-         public void finishTransaction(Session session) throws JMSException {
-            session.rollback();
-         }
-      });
-   }
-
-   private void sendMessagesAndAssertMemoryUsage(TransactionHandler transactionHandler) throws Exception {
-      ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost");
-      Connection connection = connectionFactory.createConnection();
-      Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-      Topic destination = session.createTopic("ActiveMQBug");
-      MessageProducer producer = session.createProducer(destination);
-      for (int i = 0; i < 100; i++) {
-         BytesMessage message = session.createBytesMessage();
-         message.writeBytes(generateBytes());
-         producer.send(message);
-         transactionHandler.finishTransaction(session);
-      }
-      connection.close();
-      org.junit.Assert.assertEquals(0, BrokerRegistry.getInstance().findFirst().getSystemUsage().getMemoryUsage().getPercentUsage());
-   }
-
-   private byte[] generateBytes() {
-      byte[] bytes = new byte[100000];
-      for (int i = 0; i < 100000; i++) {
-         bytes[i] = (byte) i;
-      }
-      return bytes;
-   }
-
-   private static interface TransactionHandler {
-
-      void finishTransaction(Session session) throws JMSException;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5212Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5212Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5212Test.java
deleted file mode 100644
index dc37c79..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5212Test.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/**
- * 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;
-
-import java.util.Arrays;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQMessageProducer;
-import org.apache.activemq.ActiveMQSession;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTextMessage;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-@RunWith(value = Parameterized.class)
-public class AMQ5212Test {
-
-   BrokerService brokerService;
-
-   @Parameterized.Parameter(0)
-   public boolean concurrentStoreAndDispatchQ = true;
-
-   @Parameterized.Parameters(name = "concurrentStoreAndDispatch={0}")
-   public static Iterable<Object[]> getTestParameters() {
-      return Arrays.asList(new Object[][]{{Boolean.TRUE}, {Boolean.FALSE}});
-   }
-
-   @Before
-   public void setUp() throws Exception {
-      start(true);
-   }
-
-   public void start(boolean deleteAllMessages) throws Exception {
-      brokerService = new BrokerService();
-      if (deleteAllMessages) {
-         brokerService.deleteAllMessages();
-      }
-      ((KahaDBPersistenceAdapter) brokerService.getPersistenceAdapter()).setConcurrentStoreAndDispatchQueues(concurrentStoreAndDispatchQ);
-      brokerService.addConnector("tcp://localhost:0");
-      brokerService.setAdvisorySupport(false);
-      brokerService.start();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      brokerService.stop();
-   }
-
-   @Test
-   public void verifyDuplicateSuppressionWithConsumer() throws Exception {
-      doVerifyDuplicateSuppression(100, 100, true);
-   }
-
-   @Test
-   public void verifyDuplicateSuppression() throws Exception {
-      doVerifyDuplicateSuppression(100, 100, false);
-   }
-
-   public void doVerifyDuplicateSuppression(final int numToSend,
-                                            final int expectedTotalEnqueue,
-                                            final boolean demand) throws Exception {
-      final ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerService.getTransportConnectors().get(0).getPublishableConnectString());
-      connectionFactory.setCopyMessageOnSend(false);
-      connectionFactory.setWatchTopicAdvisories(false);
-
-      final int concurrency = 40;
-      final AtomicInteger workCount = new AtomicInteger(numToSend);
-      ExecutorService executorService = Executors.newFixedThreadPool(concurrency);
-      for (int i = 0; i < concurrency; i++) {
-         executorService.execute(new Runnable() {
-            @Override
-            public void run() {
-               try {
-                  int i;
-                  while ((i = workCount.getAndDecrement()) > 0) {
-                     ActiveMQConnection activeMQConnection = (ActiveMQConnection) connectionFactory.createConnection();
-                     activeMQConnection.start();
-                     ActiveMQSession activeMQSession = (ActiveMQSession) activeMQConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
-                     ActiveMQQueue dest = new ActiveMQQueue("queue-" + i + "-" + AMQ5212Test.class.getSimpleName());
-                     ActiveMQMessageProducer activeMQMessageProducer = (ActiveMQMessageProducer) activeMQSession.createProducer(dest);
-                     if (demand) {
-                        // create demand so page in will happen
-                        activeMQSession.createConsumer(dest);
-                     }
-                     ActiveMQTextMessage message = new ActiveMQTextMessage();
-                     message.setDestination(dest);
-                     activeMQMessageProducer.send(message, null);
-
-                     // send a duplicate
-                     activeMQConnection.syncSendPacket(message);
-                     activeMQConnection.close();
-
-                  }
-               }
-               catch (Exception e) {
-                  e.printStackTrace();
-               }
-            }
-         });
-      }
-      TimeUnit.SECONDS.sleep(1);
-      executorService.shutdown();
-      executorService.awaitTermination(5, TimeUnit.MINUTES);
-
-      Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return expectedTotalEnqueue == brokerService.getAdminView().getTotalEnqueueCount();
-         }
-      });
-      assertEquals("total enqueue as expected", expectedTotalEnqueue, brokerService.getAdminView().getTotalEnqueueCount());
-   }
-
-   @Test
-   public void verifyConsumptionOnDuplicate() throws Exception {
-
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerService.getTransportConnectors().get(0).getPublishableConnectString());
-      connectionFactory.setCopyMessageOnSend(false);
-      connectionFactory.setWatchTopicAdvisories(false);
-
-      ActiveMQConnection activeMQConnection = (ActiveMQConnection) connectionFactory.createConnection();
-      activeMQConnection.start();
-      ActiveMQSession activeMQSession = (ActiveMQSession) activeMQConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      ActiveMQQueue dest = new ActiveMQQueue("Q");
-      ActiveMQMessageProducer activeMQMessageProducer = (ActiveMQMessageProducer) activeMQSession.createProducer(dest);
-      ActiveMQTextMessage message = new ActiveMQTextMessage();
-      message.setDestination(dest);
-      activeMQMessageProducer.send(message, null);
-
-      // send a duplicate
-      activeMQConnection.syncSendPacket(message);
-
-      activeMQConnection.close();
-
-      // verify original can be consumed after restart
-      brokerService.stop();
-      brokerService.start(false);
-
-      connectionFactory = new ActiveMQConnectionFactory(brokerService.getTransportConnectors().get(0).getPublishableConnectString());
-      connectionFactory.setCopyMessageOnSend(false);
-      connectionFactory.setWatchTopicAdvisories(false);
-
-      activeMQConnection = (ActiveMQConnection) connectionFactory.createConnection();
-      activeMQConnection.start();
-      activeMQSession = (ActiveMQSession) activeMQConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      MessageConsumer messageConsumer = activeMQSession.createConsumer(dest);
-      Message received = messageConsumer.receive(4000);
-      assertNotNull("Got message", received);
-      assertEquals("match", message.getJMSMessageID(), received.getJMSMessageID());
-
-      activeMQConnection.close();
-   }
-
-   @Test
-   public void verifyClientAckConsumptionOnDuplicate() throws Exception {
-
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerService.getTransportConnectors().get(0).getPublishableConnectString());
-      connectionFactory.setCopyMessageOnSend(false);
-      connectionFactory.setWatchTopicAdvisories(false);
-
-      ActiveMQConnection activeMQConnection = (ActiveMQConnection) connectionFactory.createConnection();
-      activeMQConnection.start();
-      ActiveMQSession activeMQSession = (ActiveMQSession) activeMQConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
-      ActiveMQQueue dest = new ActiveMQQueue("Q");
-
-      MessageConsumer messageConsumer = activeMQSession.createConsumer(dest);
-
-      ActiveMQMessageProducer activeMQMessageProducer = (ActiveMQMessageProducer) activeMQSession.createProducer(dest);
-      ActiveMQTextMessage message = new ActiveMQTextMessage();
-      message.setDestination(dest);
-      activeMQMessageProducer.send(message, null);
-
-      // send a duplicate
-      activeMQConnection.syncSendPacket(message);
-
-      Message received = messageConsumer.receive(4000);
-      assertNotNull("Got message", received);
-      assertEquals("match", message.getJMSMessageID(), received.getJMSMessageID());
-      messageConsumer.close();
-
-      messageConsumer = activeMQSession.createConsumer(dest);
-      received = messageConsumer.receive(4000);
-      assertNotNull("Got message", received);
-      assertEquals("match", message.getJMSMessageID(), received.getJMSMessageID());
-      received.acknowledge();
-
-      activeMQConnection.close();
-   }
-}


[47/60] [abbrv] activemq-artemis git commit: fixing SlowConsumerDetection

Posted by cl...@apache.org.
fixing SlowConsumerDetection


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/e7f743b6
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/e7f743b6
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/e7f743b6

Branch: refs/heads/refactor-openwire
Commit: e7f743b645685fc488bcb868d330f8a65cd558f8
Parents: e6d51b7
Author: Clebert Suconic <cl...@apache.org>
Authored: Thu Feb 25 14:40:04 2016 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:45:29 2016 -0400

----------------------------------------------------------------------
 .../core/protocol/openwire/OpenWireConnection.java | 12 +++++++++---
 .../protocol/openwire/OpenWireProtocolManager.java | 17 ++++-------------
 .../core/server/impl/ServerConsumerImpl.java       | 17 +++++++++++++++++
 3 files changed, 30 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e7f743b6/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
index 6f2e3be..dc2a8a6 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
@@ -204,6 +204,11 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
 
          boolean responseRequired = command.isResponseRequired();
          int commandId = command.getCommandId();
+
+
+         // TODO-NOW: the server should send packets to the client based on the requested times
+         //           need to look at what Andy did on AMQP
+
          // the connection handles pings, negotiations directly.
          // and delegate all other commands to manager.
          if (command.getClass() == KeepAliveInfo.class) {
@@ -1196,12 +1201,12 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
 
       @Override
       public Response processMessageDispatch(MessageDispatch arg0) throws Exception {
-         throw new IllegalStateException("not implemented! ");
+         return null;
       }
 
       @Override
       public Response processMessageDispatchNotification(MessageDispatchNotification arg0) throws Exception {
-         throw new IllegalStateException("not implemented! ");
+         return null;
       }
 
       @Override
@@ -1222,7 +1227,8 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
 
       @Override
       public Response processProducerAck(ProducerAck arg0) throws Exception {
-         throw new IllegalStateException("not implemented! ");
+         // a broker doesn't do producers.. this shouldn't happen
+         return null;
       }
 
       @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e7f743b6/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
index bdf27f8..514a2b9 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
@@ -17,14 +17,12 @@
 package org.apache.activemq.artemis.core.protocol.openwire;
 
 import javax.jms.InvalidClientIDException;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.ScheduledExecutorService;
 
@@ -44,7 +42,6 @@ import org.apache.activemq.artemis.core.remoting.impl.netty.NettyServerConnectio
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
 import org.apache.activemq.artemis.core.server.cluster.ClusterManager;
-import org.apache.activemq.artemis.core.server.management.ManagementService;
 import org.apache.activemq.artemis.spi.core.protocol.ConnectionEntry;
 import org.apache.activemq.artemis.spi.core.protocol.MessageConverter;
 import org.apache.activemq.artemis.spi.core.protocol.ProtocolManager;
@@ -60,7 +57,6 @@ import org.apache.activemq.command.BrokerId;
 import org.apache.activemq.command.BrokerInfo;
 import org.apache.activemq.command.Command;
 import org.apache.activemq.command.ConnectionControl;
-import org.apache.activemq.command.ConnectionId;
 import org.apache.activemq.command.ConnectionInfo;
 import org.apache.activemq.command.ConsumerId;
 import org.apache.activemq.command.MessageDispatch;
@@ -91,21 +87,14 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, Cl
 
    private OpenWireFormatFactory wireFactory;
 
-   private boolean tightEncodingEnabled = true;
-
    private boolean prefixPacketSize = true;
 
    private BrokerId brokerId;
    protected final ProducerId advisoryProducerId = new ProducerId();
 
-   // from broker
-   protected final Map<ConnectionId, OpenWireConnection> brokerConnectionStates = Collections.synchronizedMap(new HashMap<ConnectionId, OpenWireConnection>());
-
    private final CopyOnWriteArrayList<OpenWireConnection> connections = new CopyOnWriteArrayList<>();
 
-   protected final ConcurrentMap<ConnectionId, ConnectionInfo> connectionInfos = new ConcurrentHashMap<>();
-
-   // Clebert TODO: use ConcurrentHashMap, or maybe use the schema that's already available on Artemis upstream (unique-client-id)
+   // TODO-NOW: this can probably go away
    private final Map<String, AMQConnectionContext> clientIdSet = new HashMap<String, AMQConnectionContext>();
 
    private String brokerName;
@@ -133,11 +122,13 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, Cl
       // preferred prop, should be done via config
       wireFactory.setCacheEnabled(false);
       advisoryProducerId.setConnectionId(ID_GENERATOR.generateId());
-      ManagementService service = server.getManagementService();
       scheduledPool = server.getScheduledPool();
 
       final ClusterManager clusterManager = this.server.getClusterManager();
+
+      // TODO-NOW: use a property name for the cluster connection
       ClusterConnection cc = clusterManager.getDefaultConnection(null);
+
       if (cc != null) {
          cc.addClusterTopologyListener(this);
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e7f743b6/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
index 545b4dc..b5ea5d9 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
@@ -89,6 +89,8 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
 
    private Object protocolContext;
 
+   private SlowConsumerDetectionListener slowConsumerListener;
+
    /**
     * We get a readLock when a message is handled, and return the readLock when the message is finally delivered
     * When stopping the consumer we need to get a writeLock to make sure we had all delivery finished
@@ -223,6 +225,21 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
    // ----------------------------------------------------------------------
 
    @Override
+   public void setlowConsumerDetection(SlowConsumerDetectionListener listener) {
+      this.slowConsumerListener = listener;
+   }
+
+   @Override
+   public SlowConsumerDetectionListener getSlowConsumerDetecion() {
+      return slowConsumerListener;
+   }
+
+   @Override
+   public void fireSlowConsumer() {
+      slowConsumerListener.onSlowConsumer(this);
+   }
+
+   @Override
    public Object getProtocolContext() {
       return protocolContext;
    }


[20/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3622Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3622Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3622Test.java
deleted file mode 100644
index 7556def..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3622Test.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.FilePendingSubscriberMessageStoragePolicy;
-import org.apache.activemq.broker.region.policy.LastImageSubscriptionRecoveryPolicy;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.transport.stomp.Stomp;
-import org.apache.activemq.transport.stomp.StompConnection;
-import org.apache.activemq.util.DefaultTestAppender;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Logger;
-import org.apache.log4j.spi.LoggingEvent;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AMQ3622Test {
-
-   protected BrokerService broker;
-   protected AtomicBoolean failed = new AtomicBoolean(false);
-   protected String connectionUri;
-   protected Appender appender = new DefaultTestAppender() {
-
-      @Override
-      public void doAppend(LoggingEvent event) {
-         System.err.println(event.getMessage());
-         if (event.getThrowableInformation() != null) {
-            if (event.getThrowableInformation().getThrowable() instanceof NullPointerException) {
-               failed.set(true);
-            }
-         }
-      }
-   };
-
-   @Before
-   public void before() throws Exception {
-      Logger.getRootLogger().addAppender(appender);
-
-      broker = new BrokerService();
-      broker.setDataDirectory("target" + File.separator + "activemq-data");
-      broker.setPersistent(true);
-      broker.setDeleteAllMessagesOnStartup(true);
-      PolicyEntry policy = new PolicyEntry();
-      policy.setTopic(">");
-      policy.setProducerFlowControl(false);
-      policy.setMemoryLimit(1 * 1024 * 1024);
-      policy.setPendingSubscriberPolicy(new FilePendingSubscriberMessageStoragePolicy());
-      policy.setSubscriptionRecoveryPolicy(new LastImageSubscriptionRecoveryPolicy());
-      policy.setExpireMessagesPeriod(500);
-      List<PolicyEntry> entries = new ArrayList<>();
-
-      entries.add(policy);
-      PolicyMap pMap = new PolicyMap();
-      pMap.setPolicyEntries(entries);
-      broker.setDestinationPolicy(pMap);
-
-      connectionUri = broker.addConnector("stomp://localhost:0").getPublishableConnectString();
-
-      broker.start();
-      broker.waitUntilStarted();
-   }
-
-   @After
-   public void after() throws Exception {
-      broker.stop();
-      broker.waitUntilStopped();
-      Logger.getRootLogger().removeAppender(appender);
-   }
-
-   @Test
-   public void go() throws Exception {
-      StompConnection connection = new StompConnection();
-      Integer port = Integer.parseInt(connectionUri.split(":")[2]);
-      connection.open("localhost", port);
-      connection.connect("", "");
-      connection.subscribe("/topic/foobar", Stomp.Headers.Subscribe.AckModeValues.CLIENT);
-      connection.disconnect();
-      Thread.sleep(1000);
-
-      if (failed.get()) {
-         fail("Received NullPointerException");
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3625Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3625Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3625Test.java
deleted file mode 100644
index 188b48c..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3625Test.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * 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;
-
-import org.apache.activemq.broker.BrokerFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.util.DefaultTestAppender;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Logger;
-import org.apache.log4j.spi.LoggingEvent;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- */
-
-public class AMQ3625Test {
-
-   protected BrokerService broker1;
-   protected BrokerService broker2;
-
-   protected AtomicBoolean authenticationFailed = new AtomicBoolean(false);
-   protected AtomicBoolean gotNPE = new AtomicBoolean(false);
-
-   protected String java_security_auth_login_config = "java.security.auth.login.config";
-   protected String xbean = "xbean:";
-   protected String base = "src/test/resources/org/apache/activemq/bugs/amq3625";
-   protected String conf = "conf";
-   protected String keys = "keys";
-   protected String JaasStompSSLBroker1_xml = "JaasStompSSLBroker1.xml";
-   protected String JaasStompSSLBroker2_xml = "JaasStompSSLBroker2.xml";
-
-   protected String oldLoginConf = null;
-
-   @Before
-   public void before() throws Exception {
-      if (System.getProperty(java_security_auth_login_config) != null) {
-         oldLoginConf = System.getProperty(java_security_auth_login_config);
-      }
-      System.setProperty(java_security_auth_login_config, base + "/" + conf + "/" + "login.config");
-      broker1 = BrokerFactory.createBroker(xbean + base + "/" + conf + "/" + JaasStompSSLBroker1_xml);
-      broker2 = BrokerFactory.createBroker(xbean + base + "/" + conf + "/" + JaasStompSSLBroker2_xml);
-
-      broker1.start();
-      broker1.waitUntilStarted();
-      broker2.start();
-      broker2.waitUntilStarted();
-   }
-
-   @After
-   public void after() throws Exception {
-      broker1.stop();
-      broker2.stop();
-
-      if (oldLoginConf != null) {
-         System.setProperty(java_security_auth_login_config, oldLoginConf);
-      }
-   }
-
-   @Test
-   public void go() throws Exception {
-      Appender appender = new DefaultTestAppender() {
-         @Override
-         public void doAppend(LoggingEvent event) {
-            if (event.getThrowableInformation() != null) {
-               Throwable t = event.getThrowableInformation().getThrowable();
-               if (t instanceof SecurityException) {
-                  authenticationFailed.set(true);
-               }
-               if (t instanceof NullPointerException) {
-                  gotNPE.set(true);
-               }
-            }
-         }
-      };
-      Logger.getRootLogger().addAppender(appender);
-
-      String connectURI = broker1.getConnectorByName("openwire").getConnectUri().toString();
-      connectURI = connectURI.replace("?needClientAuth=true", "");
-      broker2.addNetworkConnector("static:(" + connectURI + ")").start();
-
-      Thread.sleep(10 * 1000);
-
-      Logger.getRootLogger().removeAppender(appender);
-
-      assertTrue(authenticationFailed.get());
-      assertFalse(gotNPE.get());
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3674Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3674Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3674Test.java
deleted file mode 100644
index c691c42..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3674Test.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.*;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TopicSubscriber;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.TransportConnector;
-import org.apache.activemq.broker.jmx.BrokerView;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ3674Test {
-
-   private static Logger LOG = LoggerFactory.getLogger(AMQ3674Test.class);
-
-   private final static int deliveryMode = DeliveryMode.NON_PERSISTENT;
-   private final static ActiveMQTopic destination = new ActiveMQTopic("XYZ");
-
-   private ActiveMQConnectionFactory factory;
-   private BrokerService broker;
-
-   @Test
-   public void removeSubscription() throws Exception {
-
-      final Connection producerConnection = factory.createConnection();
-      producerConnection.start();
-      final Connection consumerConnection = factory.createConnection();
-
-      consumerConnection.setClientID("subscriber1");
-      Session consumerMQSession = consumerConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-      TopicSubscriber activeConsumer = consumerMQSession.createDurableSubscriber(destination, "myTopic");
-      consumerConnection.start();
-
-      Session session = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = session.createProducer(destination);
-      producer.setDeliveryMode(deliveryMode);
-
-      final BrokerView brokerView = broker.getAdminView();
-
-      assertEquals(1, brokerView.getDurableTopicSubscribers().length);
-
-      LOG.info("Current Durable Topic Subscriptions: " + brokerView.getDurableTopicSubscribers().length);
-
-      try {
-         brokerView.destroyDurableSubscriber("subscriber1", "myTopic");
-         fail("Expected Exception for Durable consumer is in use");
-      }
-      catch (Exception e) {
-         LOG.info("Received expected exception: " + e.getMessage());
-      }
-
-      LOG.info("Current Durable Topic Subscriptions: " + brokerView.getDurableTopicSubscribers().length);
-
-      assertEquals(1, brokerView.getDurableTopicSubscribers().length);
-
-      activeConsumer.close();
-      consumerConnection.stop();
-
-      assertTrue("The subscription should be in the inactive state.", Wait.waitFor(new Wait.Condition() {
-
-         @Override
-         public boolean isSatisified() throws Exception {
-            return brokerView.getInactiveDurableTopicSubscribers().length == 1;
-         }
-      }));
-
-      try {
-         brokerView.destroyDurableSubscriber("subscriber1", "myTopic");
-      }
-      finally {
-         producer.close();
-         producerConnection.close();
-      }
-   }
-
-   @Before
-   public void setUp() throws Exception {
-      broker = new BrokerService();
-      broker.setPersistent(false);
-      broker.setUseJmx(true);
-      broker.setDeleteAllMessagesOnStartup(true);
-      TransportConnector connector = broker.addConnector("tcp://localhost:0");
-      broker.start();
-
-      factory = new ActiveMQConnectionFactory(connector.getPublishableConnectString());
-      factory.setAlwaysSyncSend(true);
-      factory.setDispatchAsync(false);
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      broker.stop();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3675Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3675Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3675Test.java
deleted file mode 100644
index 6815923..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3675Test.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.*;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TopicSubscriber;
-import javax.management.ObjectName;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.TransportConnector;
-import org.apache.activemq.broker.jmx.BrokerView;
-import org.apache.activemq.broker.jmx.TopicViewMBean;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ3675Test {
-
-   private static Logger LOG = LoggerFactory.getLogger(AMQ3675Test.class);
-
-   private final static int deliveryMode = DeliveryMode.NON_PERSISTENT;
-   private final static ActiveMQTopic destination = new ActiveMQTopic("XYZ");
-
-   private ActiveMQConnectionFactory factory;
-   private BrokerService broker;
-
-   public TopicViewMBean getTopicView() throws Exception {
-      ObjectName destinationName = broker.getAdminView().getTopics()[0];
-      TopicViewMBean topicView = (TopicViewMBean) broker.getManagementContext().newProxyInstance(destinationName, TopicViewMBean.class, true);
-      return topicView;
-   }
-
-   @Test
-   public void countConsumers() throws Exception {
-
-      final Connection producerConnection = factory.createConnection();
-      producerConnection.start();
-      final Connection consumerConnection = factory.createConnection();
-
-      consumerConnection.setClientID("subscriber1");
-      Session consumerMQSession = consumerConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-      TopicSubscriber consumer = consumerMQSession.createDurableSubscriber(destination, "myTopic");
-      consumerConnection.start();
-
-      Session session = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = session.createProducer(destination);
-      producer.setDeliveryMode(deliveryMode);
-
-      final BrokerView brokerView = broker.getAdminView();
-      final TopicViewMBean topicView = getTopicView();
-
-      assertTrue("Should have one consumer on topic: ", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return topicView.getConsumerCount() == 1;
-         }
-      }));
-
-      consumer.close();
-
-      assertTrue("Durable consumer should now be inactive.", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return brokerView.getInactiveDurableTopicSubscribers().length == 1;
-         }
-      }));
-
-      try {
-         brokerView.removeTopic(destination.getTopicName());
-      }
-      catch (Exception e1) {
-         fail("Unable to remove destination:" + destination.getPhysicalName());
-      }
-
-      assertTrue("Should have no topics on the broker", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return brokerView.getTopics().length == 0;
-         }
-      }));
-
-      try {
-         brokerView.destroyDurableSubscriber("subscriber1", "myTopic");
-      }
-      catch (Exception e) {
-         fail("Exception not expected when attempting to delete Durable consumer.");
-      }
-
-      assertTrue("Should be no durable consumers active or inactive.", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return brokerView.getInactiveDurableTopicSubscribers().length == 0 && brokerView.getDurableTopicSubscribers().length == 0;
-         }
-      }));
-
-      consumer = consumerMQSession.createDurableSubscriber(destination, "myTopic");
-
-      consumer.close();
-
-      assertTrue("Should be one consumer on the Topic.", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            LOG.info("Number of inactive consumers: " + brokerView.getInactiveDurableTopicSubscribers().length);
-            return brokerView.getInactiveDurableTopicSubscribers().length == 1;
-         }
-      }));
-
-      final TopicViewMBean recreatedTopicView = getTopicView();
-
-      assertTrue("Should have one consumer on topic: ", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return recreatedTopicView.getConsumerCount() == 1;
-         }
-      }));
-   }
-
-   @Before
-   public void setUp() throws Exception {
-      broker = new BrokerService();
-      broker.setPersistent(false);
-      broker.setUseJmx(true);
-      broker.setAdvisorySupport(false);
-      broker.setDeleteAllMessagesOnStartup(true);
-      TransportConnector connector = broker.addConnector("tcp://localhost:0");
-      broker.start();
-
-      factory = new ActiveMQConnectionFactory(connector.getPublishableConnectString());
-      factory.setAlwaysSyncSend(true);
-      factory.setDispatchAsync(false);
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      broker.stop();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3678Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3678Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3678Test.java
deleted file mode 100644
index 26bef7d..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3678Test.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/**
- * 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;
-
-import java.io.IOException;
-import java.lang.management.ManagementFactory;
-import java.net.ServerSocket;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQTopicSubscriber;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.ManagementContext;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.fail;
-
-public class AMQ3678Test implements MessageListener {
-
-   public int deliveryMode = DeliveryMode.NON_PERSISTENT;
-
-   private BrokerService broker;
-
-   AtomicInteger messagesSent = new AtomicInteger(0);
-   AtomicInteger messagesReceived = new AtomicInteger(0);
-
-   ActiveMQTopic destination = new ActiveMQTopic("XYZ");
-
-   int port;
-   int jmxport;
-
-   final CountDownLatch latch = new CountDownLatch(2);
-
-   public static void main(String[] args) throws Exception {
-
-   }
-
-   public static int findFreePort() throws IOException {
-      ServerSocket socket = null;
-
-      try {
-         // 0 is open a socket on any free port
-         socket = new ServerSocket(0);
-         return socket.getLocalPort();
-      }
-      finally {
-         if (socket != null) {
-            socket.close();
-         }
-      }
-   }
-
-   @Test
-   public void countConsumers() throws JMSException {
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:" + port);
-      factory.setAlwaysSyncSend(true);
-      factory.setDispatchAsync(false);
-
-      final Connection producerConnection = factory.createConnection();
-      producerConnection.start();
-
-      final Connection consumerConnection = factory.createConnection();
-
-      consumerConnection.setClientID("subscriber1");
-      Session consumerMQSession = consumerConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
-      ActiveMQTopicSubscriber activeConsumer = (ActiveMQTopicSubscriber) consumerMQSession.createDurableSubscriber(destination, "myTopic?consumer.prefetchSize=1");
-
-      activeConsumer.setMessageListener(this);
-
-      consumerConnection.start();
-
-      final Session producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      final MessageProducer producer = producerSession.createProducer(destination);
-      producer.setDeliveryMode(deliveryMode);
-
-      Thread t = new Thread(new Runnable() {
-
-         private boolean done = false;
-
-         @Override
-         public void run() {
-            while (!done) {
-               if (messagesSent.get() == 50) {
-                  try {
-                     broker.getAdminView().removeTopic(destination.getTopicName());
-                  }
-                  catch (Exception e1) {
-                     // TODO Auto-generated catch block
-                     e1.printStackTrace();
-                     System.err.flush();
-                     fail("Unable to remove destination:" + destination.getPhysicalName());
-                  }
-               }
-
-               try {
-                  producer.send(producerSession.createTextMessage());
-                  int val = messagesSent.incrementAndGet();
-
-                  System.out.println("sent message (" + val + ")");
-                  System.out.flush();
-
-                  if (val == 100) {
-                     done = true;
-                     latch.countDown();
-                     producer.close();
-                     producerSession.close();
-
-                  }
-               }
-               catch (JMSException e) {
-                  // TODO Auto-generated catch block
-                  e.printStackTrace();
-               }
-            }
-         }
-      });
-
-      t.start();
-
-      try {
-         if (!latch.await(10, TimeUnit.SECONDS)) {
-            fail("did not receive all the messages");
-         }
-      }
-      catch (InterruptedException e) {
-         // TODO Auto-generated catch block
-         fail("did not receive all the messages, exception waiting for latch");
-         e.printStackTrace();
-      }
-
-      //
-
-   }
-
-   @Before
-   public void setUp() throws Exception {
-
-      try {
-         port = findFreePort();
-         jmxport = findFreePort();
-      }
-      catch (Exception e) {
-         fail("Unable to obtain a free port on which to start the broker");
-      }
-
-      System.out.println("Starting broker");
-      System.out.flush();
-      broker = new BrokerService();
-      broker.setPersistent(false);
-      ManagementContext ctx = new ManagementContext(ManagementFactory.getPlatformMBeanServer());
-      ctx.setConnectorPort(jmxport);
-      broker.setManagementContext(ctx);
-      broker.setUseJmx(true);
-      //        broker.setAdvisorySupport(false);
-      //        broker.setDeleteAllMessagesOnStartup(true);
-
-      broker.addConnector("tcp://localhost:" + port).setName("Default");
-      broker.start();
-
-      System.out.println("End of Broker Setup");
-      System.out.flush();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      broker.stop();
-   }
-
-   @Override
-   public void onMessage(Message message) {
-      try {
-         message.acknowledge();
-         int val = messagesReceived.incrementAndGet();
-         System.out.println("received message (" + val + ")");
-         System.out.flush();
-         if (messagesReceived.get() == 100) {
-            latch.countDown();
-         }
-      }
-      catch (JMSException e) {
-         // TODO Auto-generated catch block
-         e.printStackTrace();
-      }
-
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3732Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3732Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3732Test.java
deleted file mode 100644
index d0f6692..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3732Test.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Random;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-
-import javax.jms.Connection;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQSession;
-import org.apache.activemq.broker.BrokerService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ3732Test {
-
-   private static Logger LOG = LoggerFactory.getLogger(AMQ3732Test.class);
-
-   private ActiveMQConnectionFactory connectionFactory;
-   private Connection connection;
-   private Session session;
-   private BrokerService broker;
-   private String connectionUri;
-
-   private final Random pause = new Random();
-   private final long NUM_MESSAGES = 25000;
-   private final AtomicLong totalConsumed = new AtomicLong();
-
-   @Before
-   public void startBroker() throws Exception {
-      broker = new BrokerService();
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.setPersistent(false);
-      broker.setUseJmx(false);
-      broker.addConnector("tcp://0.0.0.0:0");
-      broker.start();
-      broker.waitUntilStarted();
-
-      connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
-
-      connectionFactory = new ActiveMQConnectionFactory(connectionUri);
-      connectionFactory.getPrefetchPolicy().setAll(0);
-   }
-
-   @After
-   public void stopBroker() throws Exception {
-      connection.close();
-
-      broker.stop();
-      broker.waitUntilStopped();
-   }
-
-   @Test(timeout = 1200000)
-   public void testInterruptionAffects() throws Exception {
-
-      connection = connectionFactory.createConnection();
-      connection.start();
-      session = connection.createSession(false, ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE);
-
-      Queue queue = session.createQueue("AMQ3732Test");
-
-      final LinkedBlockingQueue<Message> workQueue = new LinkedBlockingQueue<>();
-
-      final MessageConsumer consumer1 = session.createConsumer(queue);
-      final MessageConsumer consumer2 = session.createConsumer(queue);
-      final MessageProducer producer = session.createProducer(queue);
-
-      Thread consumer1Thread = new Thread(new Runnable() {
-
-         @Override
-         public void run() {
-            try {
-               while (totalConsumed.get() < NUM_MESSAGES) {
-                  Message message = consumer1.receiveNoWait();
-                  if (message != null) {
-                     workQueue.add(message);
-                  }
-               }
-            }
-            catch (Exception e) {
-               LOG.error("Caught an unexpected error: ", e);
-            }
-         }
-      });
-      consumer1Thread.start();
-
-      Thread consumer2Thread = new Thread(new Runnable() {
-
-         @Override
-         public void run() {
-            try {
-               while (totalConsumed.get() < NUM_MESSAGES) {
-                  Message message = consumer2.receive(50);
-                  if (message != null) {
-                     workQueue.add(message);
-                  }
-               }
-            }
-            catch (Exception e) {
-               LOG.error("Caught an unexpected error: ", e);
-            }
-         }
-      });
-      consumer2Thread.start();
-
-      Thread producerThread = new Thread(new Runnable() {
-
-         @Override
-         public void run() {
-            try {
-               for (int i = 0; i < NUM_MESSAGES; ++i) {
-                  producer.send(session.createTextMessage("TEST"));
-                  TimeUnit.MILLISECONDS.sleep(pause.nextInt(10));
-               }
-            }
-            catch (Exception e) {
-               LOG.error("Caught an unexpected error: ", e);
-            }
-         }
-      });
-      producerThread.start();
-
-      Thread ackingThread = new Thread(new Runnable() {
-
-         @Override
-         public void run() {
-            try {
-               while (totalConsumed.get() < NUM_MESSAGES) {
-                  Message message = workQueue.take();
-                  message.acknowledge();
-                  totalConsumed.incrementAndGet();
-                  if ((totalConsumed.get() % 100) == 0) {
-                     LOG.info("Consumed " + totalConsumed.get() + " messages so far.");
-                  }
-               }
-            }
-            catch (Exception e) {
-               LOG.error("Caught an unexpected error: ", e);
-            }
-         }
-      });
-      ackingThread.start();
-
-      producerThread.join();
-      consumer1Thread.join();
-      consumer2Thread.join();
-      ackingThread.join();
-
-      assertEquals(NUM_MESSAGES, totalConsumed.get());
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3779Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3779Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3779Test.java
deleted file mode 100644
index fa354c9..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3779Test.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * 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;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.AutoFailTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.util.LoggingBrokerPlugin;
-import org.apache.activemq.util.DefaultTestAppender;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Logger;
-import org.apache.log4j.spi.LoggingEvent;
-
-public class AMQ3779Test extends AutoFailTestSupport {
-
-   private static final Logger logger = Logger.getLogger(AMQ3779Test.class);
-   private static final String qName = "QNameToFind";
-
-   public void testLogPerDest() throws Exception {
-
-      final AtomicBoolean ok = new AtomicBoolean(false);
-      Appender appender = new DefaultTestAppender() {
-         @Override
-         public void doAppend(LoggingEvent event) {
-            if (event.getLoggerName().toString().contains(qName)) {
-               ok.set(true);
-            }
-         }
-      };
-      Logger.getRootLogger().addAppender(appender);
-
-      try {
-
-         BrokerService broker = new BrokerService();
-         LoggingBrokerPlugin loggingBrokerPlugin = new LoggingBrokerPlugin();
-         loggingBrokerPlugin.setPerDestinationLogger(true);
-         loggingBrokerPlugin.setLogAll(true);
-         broker.setPlugins(new LoggingBrokerPlugin[]{loggingBrokerPlugin});
-         broker.start();
-
-         Connection connection = new ActiveMQConnectionFactory(broker.getVmConnectorURI()).createConnection();
-         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageProducer messageProducer = session.createProducer(session.createQueue(qName));
-         messageProducer.setDeliveryMode(DeliveryMode.PERSISTENT);
-         connection.start();
-
-         messageProducer.send(session.createTextMessage("Hi"));
-         connection.close();
-
-         assertTrue("got expected log message", ok.get());
-      }
-      finally {
-         logger.removeAppender(appender);
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3841Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3841Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3841Test.java
deleted file mode 100644
index 4824855..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3841Test.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.ArrayList;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.store.PersistenceAdapter;
-import org.apache.activemq.store.kahadb.FilteredKahaDBPersistenceAdapter;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.store.kahadb.MultiKahaDBPersistenceAdapter;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ3841Test {
-
-   static final Logger LOG = LoggerFactory.getLogger(AMQ3841Test.class);
-   private final static int maxFileLength = 1024 * 1024 * 32;
-   private final static String destinationName = "TEST.QUEUE";
-   BrokerService broker;
-
-   @Before
-   public void setUp() throws Exception {
-      prepareBrokerWithMultiStore(true);
-      broker.start();
-      broker.waitUntilStarted();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      broker.stop();
-   }
-
-   protected BrokerService createBroker(PersistenceAdapter kaha) throws Exception {
-      BrokerService broker = new BrokerService();
-      broker.setUseJmx(true);
-      broker.setBrokerName("localhost");
-      broker.setPersistenceAdapter(kaha);
-      return broker;
-   }
-
-   @Test
-   public void testRestartAfterQueueDelete() throws Exception {
-
-      // Ensure we have an Admin View.
-      assertTrue("Broker doesn't have an Admin View.", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return (broker.getAdminView()) != null;
-         }
-      }));
-
-      broker.getAdminView().addQueue(destinationName);
-
-      assertNotNull(broker.getDestination(new ActiveMQQueue(destinationName)));
-
-      broker.getAdminView().removeQueue(destinationName);
-
-      broker.stop();
-      broker.waitUntilStopped();
-
-      prepareBrokerWithMultiStore(false);
-      broker.start();
-
-      broker.getAdminView().addQueue(destinationName);
-      assertNotNull(broker.getDestination(new ActiveMQQueue(destinationName)));
-
-   }
-
-   protected KahaDBPersistenceAdapter createStore(boolean delete) throws IOException {
-      KahaDBPersistenceAdapter kaha = new KahaDBPersistenceAdapter();
-      kaha.setJournalMaxFileLength(maxFileLength);
-      kaha.setCleanupInterval(5000);
-      if (delete) {
-         kaha.deleteAllMessages();
-      }
-      return kaha;
-   }
-
-   public void prepareBrokerWithMultiStore(boolean deleteAllMessages) throws Exception {
-
-      MultiKahaDBPersistenceAdapter multiKahaDBPersistenceAdapter = new MultiKahaDBPersistenceAdapter();
-      if (deleteAllMessages) {
-         multiKahaDBPersistenceAdapter.deleteAllMessages();
-      }
-      ArrayList<FilteredKahaDBPersistenceAdapter> adapters = new ArrayList<>();
-
-      FilteredKahaDBPersistenceAdapter template = new FilteredKahaDBPersistenceAdapter();
-      template.setPersistenceAdapter(createStore(deleteAllMessages));
-      template.setPerDestination(true);
-      adapters.add(template);
-
-      multiKahaDBPersistenceAdapter.setFilteredPersistenceAdapters(adapters);
-      broker = createBroker(multiKahaDBPersistenceAdapter);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3879Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3879Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3879Test.java
deleted file mode 100644
index 071897c..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3879Test.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertNotNull;
-
-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.ActiveMQConnectionFactory;
-import org.apache.activemq.advisory.AdvisorySupport;
-import org.apache.activemq.broker.BrokerService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ3879Test {
-
-   static final Logger LOG = LoggerFactory.getLogger(AMQ3841Test.class);
-   private BrokerService broker;
-
-   private ActiveMQConnectionFactory factory;
-
-   @Before
-   public void setUp() throws Exception {
-      broker = createBroker();
-      broker.start();
-      broker.waitUntilStarted();
-
-      factory = new ActiveMQConnectionFactory("vm://localhost");
-      factory.setAlwaysSyncSend(true);
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      broker.stop();
-      broker.waitUntilStopped();
-      broker = null;
-   }
-
-   protected BrokerService createBroker() throws Exception {
-      BrokerService broker = new BrokerService();
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.setPersistent(false);
-      broker.setUseJmx(false);
-      broker.setBrokerName("localhost");
-      broker.addConnector("vm://localhost");
-      return broker;
-   }
-
-   @Test
-   public void testConnectionDletesWrongTempDests() throws Exception {
-
-      final Connection connection1 = factory.createConnection();
-      final Connection connection2 = factory.createConnection();
-
-      Session session1 = connection1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Session session2 = connection2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      Destination tempDestAdvisory = AdvisorySupport.TEMP_QUEUE_ADVISORY_TOPIC;
-
-      MessageConsumer advisoryConsumer = session1.createConsumer(tempDestAdvisory);
-      connection1.start();
-
-      Destination tempQueue = session2.createTemporaryQueue();
-      MessageProducer tempProducer = session2.createProducer(tempQueue);
-
-      assertNotNull(advisoryConsumer.receive(5000));
-
-      Thread t = new Thread(new Runnable() {
-
-         @Override
-         public void run() {
-            try {
-               Thread.sleep(20);
-               connection1.close();
-            }
-            catch (Exception e) {
-            }
-         }
-      });
-
-      t.start();
-
-      for (int i = 0; i < 256; ++i) {
-         Message msg = session2.createTextMessage("Temp Data");
-         tempProducer.send(msg);
-         Thread.sleep(2);
-      }
-
-      t.join();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3903Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3903Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3903Test.java
deleted file mode 100644
index c7b4bdb..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3903Test.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertNotNull;
-
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.ResourceAllocationException;
-import javax.jms.Session;
-import javax.jms.TemporaryQueue;
-import javax.jms.Topic;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.advisory.AdvisorySupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ3903Test {
-
-   private static final transient Logger LOG = LoggerFactory.getLogger(AMQ3903Test.class);
-
-   private static final String bindAddress = "tcp://0.0.0.0:0";
-   private BrokerService broker;
-   private ActiveMQConnectionFactory cf;
-
-   private static final int MESSAGE_COUNT = 100;
-
-   @Before
-   public void setUp() throws Exception {
-      broker = this.createBroker();
-      String address = broker.getTransportConnectors().get(0).getPublishableConnectString();
-      broker.start();
-      broker.waitUntilStarted();
-
-      cf = new ActiveMQConnectionFactory(address);
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-      }
-   }
-
-   @Test
-   public void testAdvisoryForFastGenericProducer() throws Exception {
-      doTestAdvisoryForFastProducer(true);
-   }
-
-   @Test
-   public void testAdvisoryForFastDedicatedProducer() throws Exception {
-      doTestAdvisoryForFastProducer(false);
-   }
-
-   public void doTestAdvisoryForFastProducer(boolean genericProducer) throws Exception {
-
-      Connection connection = cf.createConnection();
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      final TemporaryQueue queue = session.createTemporaryQueue();
-
-      final Topic advisoryTopic = AdvisorySupport.getFastProducerAdvisoryTopic((ActiveMQDestination) queue);
-      final Topic advisoryWhenFullTopic = AdvisorySupport.getFullAdvisoryTopic((ActiveMQDestination) queue);
-
-      MessageConsumer advisoryConsumer = session.createConsumer(advisoryTopic);
-      MessageConsumer advisoryWhenFullConsumer = session.createConsumer(advisoryWhenFullTopic);
-
-      MessageProducer producer = session.createProducer(genericProducer ? null : queue);
-
-      try {
-         // send lots of messages to the tempQueue
-         for (int i = 0; i < MESSAGE_COUNT; i++) {
-            BytesMessage m = session.createBytesMessage();
-            m.writeBytes(new byte[1024]);
-            if (genericProducer) {
-               producer.send(queue, m, DeliveryMode.PERSISTENT, 4, 0);
-            }
-            else {
-               producer.send(m);
-            }
-         }
-      }
-      catch (ResourceAllocationException expectedOnLimitReachedAfterFastAdvisory) {
-      }
-
-      // check one advisory message has produced on the advisoryTopic
-      Message advCmsg = advisoryConsumer.receive(4000);
-      assertNotNull(advCmsg);
-
-      advCmsg = advisoryWhenFullConsumer.receive(4000);
-      assertNotNull(advCmsg);
-
-      connection.close();
-      LOG.debug("Connection closed, destinations should now become inactive.");
-   }
-
-   protected BrokerService createBroker() throws Exception {
-      BrokerService answer = new BrokerService();
-      answer.setPersistent(false);
-      answer.setUseJmx(false);
-
-      PolicyEntry entry = new PolicyEntry();
-      entry.setAdvisoryForFastProducers(true);
-      entry.setAdvisoryWhenFull(true);
-      entry.setMemoryLimit(10000);
-      PolicyMap map = new PolicyMap();
-      map.setDefaultEntry(entry);
-
-      answer.setDestinationPolicy(map);
-      answer.addConnector(bindAddress);
-
-      answer.getSystemUsage().setSendFailIfNoSpace(true);
-
-      return answer;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3932Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3932Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3932Test.java
deleted file mode 100644
index f29ad94..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3932Test.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.TransportConnector;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ3932Test {
-
-   static final Logger LOG = LoggerFactory.getLogger(AMQ3932Test.class);
-   private Connection connection;
-   private BrokerService broker;
-
-   @Before
-   public void setUp() throws Exception {
-      broker = new BrokerService();
-      broker.setPersistent(false);
-      broker.setUseJmx(false);
-      TransportConnector tcpConnector = broker.addConnector("tcp://localhost:0");
-      broker.start();
-
-      ConnectionFactory factory = new ActiveMQConnectionFactory("failover:(" + tcpConnector.getPublishableConnectString() + ")?jms.prefetchPolicy.queuePrefetch=0");
-      connection = factory.createConnection();
-      connection.start();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      connection.close();
-
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-         broker = null;
-      }
-   }
-
-   @Test
-   public void testPlainReceiveBlocks() throws Exception {
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      final MessageConsumer consumer = session.createConsumer(session.createQueue(getClass().getName()));
-
-      broker.stop();
-      broker.waitUntilStopped();
-      broker = null;
-
-      final CountDownLatch done = new CountDownLatch(1);
-      final CountDownLatch started = new CountDownLatch(1);
-      ExecutorService executor = Executors.newSingleThreadExecutor();
-
-      executor.execute(new Runnable() {
-         @Override
-         public void run() {
-            try {
-               started.countDown();
-               LOG.info("Entering into a Sync receive call");
-               consumer.receive();
-            }
-            catch (JMSException e) {
-            }
-            done.countDown();
-         }
-      });
-
-      assertTrue(started.await(10, TimeUnit.SECONDS));
-      assertFalse(done.await(20, TimeUnit.SECONDS));
-   }
-
-   @Test
-   public void testHungReceiveNoWait() throws Exception {
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      final MessageConsumer consumer = session.createConsumer(session.createQueue(getClass().getName()));
-
-      broker.stop();
-      broker.waitUntilStopped();
-      broker = null;
-
-      final CountDownLatch done = new CountDownLatch(1);
-      final CountDownLatch started = new CountDownLatch(1);
-      ExecutorService executor = Executors.newSingleThreadExecutor();
-
-      executor.execute(new Runnable() {
-         @Override
-         public void run() {
-            try {
-               started.countDown();
-               LOG.info("Entering into a Sync receiveNoWait call");
-               consumer.receiveNoWait();
-            }
-            catch (JMSException e) {
-            }
-            done.countDown();
-         }
-      });
-
-      assertTrue(started.await(10, TimeUnit.SECONDS));
-      assertTrue(done.await(20, TimeUnit.SECONDS));
-   }
-
-   @Test
-   public void testHungReceiveTimed() throws Exception {
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      final MessageConsumer consumer = session.createConsumer(session.createQueue(getClass().getName()));
-
-      broker.stop();
-      broker.waitUntilStopped();
-      broker = null;
-
-      final CountDownLatch done = new CountDownLatch(1);
-      final CountDownLatch started = new CountDownLatch(1);
-      ExecutorService executor = Executors.newSingleThreadExecutor();
-
-      executor.execute(new Runnable() {
-         @Override
-         public void run() {
-            try {
-               started.countDown();
-               LOG.info("Entering into a timed Sync receive call");
-               consumer.receive(10);
-            }
-            catch (JMSException e) {
-            }
-            done.countDown();
-         }
-      });
-
-      assertTrue(started.await(10, TimeUnit.SECONDS));
-      assertTrue(done.await(20, TimeUnit.SECONDS));
-   }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3934Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3934Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3934Test.java
deleted file mode 100644
index 3287085..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3934Test.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- * 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;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.management.openmbean.CompositeData;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.QueueViewMBean;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-public class AMQ3934Test {
-
-   private static final transient Logger LOG = LoggerFactory.getLogger(AMQ3934Test.class);
-   private static BrokerService brokerService;
-   private static String TEST_QUEUE = "testQueue";
-   private static ActiveMQQueue queue = new ActiveMQQueue(TEST_QUEUE);
-   private static String BROKER_ADDRESS = "tcp://localhost:0";
-
-   private ActiveMQConnectionFactory connectionFactory;
-   private String connectionUri;
-   private String messageID;
-
-   @Before
-   public void setUp() throws Exception {
-      brokerService = new BrokerService();
-      brokerService.setPersistent(false);
-      brokerService.setUseJmx(true);
-      connectionUri = brokerService.addConnector(BROKER_ADDRESS).getPublishableConnectString();
-      brokerService.start();
-      brokerService.waitUntilStarted();
-
-      connectionFactory = new ActiveMQConnectionFactory(connectionUri);
-      sendMessage();
-   }
-
-   public void sendMessage() throws Exception {
-      final Connection conn = connectionFactory.createConnection();
-      try {
-         conn.start();
-         final Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         final Destination queue = session.createQueue(TEST_QUEUE);
-         final Message toSend = session.createMessage();
-         final MessageProducer producer = session.createProducer(queue);
-         producer.send(queue, toSend);
-      }
-      finally {
-         conn.close();
-      }
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      brokerService.stop();
-      brokerService.waitUntilStopped();
-   }
-
-   @Test
-   public void getMessage() throws Exception {
-      final QueueViewMBean queueView = getProxyToQueueViewMBean();
-      final CompositeData messages[] = queueView.browse();
-      messageID = (String) messages[0].get("JMSMessageID");
-      assertNotNull(messageID);
-      assertNotNull(queueView.getMessage(messageID));
-      LOG.debug("Attempting to remove message ID: " + messageID);
-      queueView.removeMessage(messageID);
-      assertNull(queueView.getMessage(messageID));
-   }
-
-   private QueueViewMBean getProxyToQueueViewMBean() throws MalformedObjectNameException, NullPointerException, JMSException {
-      final ObjectName queueViewMBeanName = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + queue.getQueueName());
-      final QueueViewMBean proxy = (QueueViewMBean) brokerService.getManagementContext().newProxyInstance(queueViewMBeanName, QueueViewMBean.class, true);
-      return proxy;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3961Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3961Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3961Test.java
deleted file mode 100644
index c39cabf..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3961Test.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.jms.ConnectionConsumer;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.ServerSession;
-import javax.jms.ServerSessionPool;
-import javax.jms.Session;
-import javax.jms.TopicConnection;
-import javax.jms.TopicPublisher;
-import javax.jms.TopicSession;
-import javax.jms.TopicSubscriber;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AMQ3961Test {
-
-   private static BrokerService brokerService;
-   private static String BROKER_ADDRESS = "tcp://localhost:0";
-
-   private ActiveMQConnectionFactory connectionFactory;
-   private String connectionUri;
-
-   @Before
-   public void setUp() throws Exception {
-      brokerService = new BrokerService();
-      brokerService.setPersistent(false);
-      brokerService.setUseJmx(true);
-      brokerService.setDeleteAllMessagesOnStartup(true);
-      connectionUri = brokerService.addConnector(BROKER_ADDRESS).getPublishableConnectString();
-      brokerService.start();
-      brokerService.waitUntilStarted();
-
-      connectionFactory = new ActiveMQConnectionFactory(connectionUri);
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      brokerService.stop();
-      brokerService.waitUntilStopped();
-   }
-
-   public class TestServerSessionPool implements ServerSessionPool {
-
-      private final TopicConnection connection;
-
-      public TestServerSessionPool(final TopicConnection connection) {
-         this.connection = connection;
-      }
-
-      @Override
-      public ServerSession getServerSession() throws JMSException {
-         final TopicSession topicSession = connection.createTopicSession(true, Session.AUTO_ACKNOWLEDGE);
-         return new TestServerSession(topicSession);
-      }
-   }
-
-   public class TestServerSession implements ServerSession, MessageListener {
-
-      private final TopicSession session;
-
-      public TestServerSession(final TopicSession session) throws JMSException {
-         this.session = session;
-         session.setMessageListener(this);
-      }
-
-      @Override
-      public Session getSession() throws JMSException {
-         return session;
-      }
-
-      @Override
-      public void start() throws JMSException {
-         session.run();
-      }
-
-      @Override
-      public void onMessage(final Message message) {
-         synchronized (processedSessions) {
-            processedSessions.add(this);
-         }
-      }
-   }
-
-   public static final int MESSAGE_COUNT = 16;
-   private final List<TestServerSession> processedSessions = new LinkedList<>();
-   private final List<TestServerSession> committedSessions = new LinkedList<>();
-
-   @Test
-   public void testPrefetchInDurableSubscription() throws Exception {
-      final ActiveMQTopic topic = new ActiveMQTopic("TestTopic");
-
-      final TopicConnection initialSubConnection = connectionFactory.createTopicConnection();
-      initialSubConnection.setClientID("TestClient");
-      initialSubConnection.start();
-      final TopicSession initialSubSession = initialSubConnection.createTopicSession(false, Session.CLIENT_ACKNOWLEDGE);
-      final TopicSubscriber initialSubscriber = initialSubSession.createDurableSubscriber(topic, "TestSubscriber");
-
-      initialSubscriber.close();
-      initialSubSession.close();
-      initialSubConnection.close();
-
-      final TopicConnection publisherConnection = connectionFactory.createTopicConnection();
-      publisherConnection.start();
-      final TopicSession publisherSession = publisherConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
-      final TopicPublisher publisher = publisherSession.createPublisher(topic);
-      for (int i = 1; i <= MESSAGE_COUNT; i++) {
-         final Message msg = publisherSession.createTextMessage("Message #" + i);
-         publisher.publish(msg);
-      }
-      publisher.close();
-      publisherSession.close();
-      publisherConnection.close();
-
-      final TopicConnection connection = connectionFactory.createTopicConnection();
-      connection.setClientID("TestClient");
-      connection.start();
-      final TestServerSessionPool pool = new TestServerSessionPool(connection);
-      final ConnectionConsumer connectionConsumer = connection.createDurableConnectionConsumer(topic, "TestSubscriber", null, pool, 1);
-      while (true) {
-         int lastMsgCount = 0;
-         int msgCount = 0;
-         do {
-            lastMsgCount = msgCount;
-            Thread.sleep(200L);
-            synchronized (processedSessions) {
-               msgCount = processedSessions.size();
-            }
-         } while (lastMsgCount < msgCount);
-
-         if (lastMsgCount == 0) {
-            break;
-         }
-
-         final LinkedList<TestServerSession> collected;
-         synchronized (processedSessions) {
-            collected = new LinkedList<>(processedSessions);
-            processedSessions.clear();
-         }
-
-         final Iterator<TestServerSession> sessions = collected.iterator();
-         while (sessions.hasNext()) {
-            final TestServerSession session = sessions.next();
-            committedSessions.add(session);
-            session.getSession().commit();
-            session.getSession().close();
-         }
-      }
-
-      connectionConsumer.close();
-      final TopicSession finalSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
-      finalSession.unsubscribe("TestSubscriber");
-      finalSession.close();
-      connection.close();
-      assertEquals(MESSAGE_COUNT, committedSessions.size());
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3992Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3992Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3992Test.java
deleted file mode 100644
index 4fe8ba1..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3992Test.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.management.ObjectName;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.BrokerView;
-import org.apache.activemq.broker.jmx.DurableSubscriptionViewMBean;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ3992Test {
-
-   private static final transient Logger LOG = LoggerFactory.getLogger(AMQ3992Test.class);
-   private static BrokerService brokerService;
-   private static String BROKER_ADDRESS = "tcp://localhost:0";
-
-   private String connectionUri;
-
-   @Before
-   public void setUp() throws Exception {
-      brokerService = new BrokerService();
-      brokerService.setPersistent(false);
-      brokerService.setUseJmx(true);
-      brokerService.setDeleteAllMessagesOnStartup(true);
-      connectionUri = brokerService.addConnector(BROKER_ADDRESS).getPublishableConnectString();
-      brokerService.start();
-      brokerService.waitUntilStarted();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      brokerService.stop();
-      brokerService.waitUntilStopped();
-   }
-
-   @Test
-   public void testDurableConsumerEnqueueCountWithZeroPrefetch() throws Exception {
-
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(connectionUri);
-      connectionFactory.getPrefetchPolicy().setAll(0);
-
-      Connection connection = connectionFactory.createConnection();
-      connection.setClientID(getClass().getName());
-      connection.start();
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Destination destination = session.createTopic("DurableTopic");
-
-      MessageConsumer consumer = session.createDurableSubscriber((Topic) destination, "EnqueueSub");
-
-      BrokerView view = brokerService.getAdminView();
-      view.getDurableTopicSubscribers();
-
-      ObjectName subName = view.getDurableTopicSubscribers()[0];
-
-      DurableSubscriptionViewMBean sub = (DurableSubscriptionViewMBean) brokerService.getManagementContext().newProxyInstance(subName, DurableSubscriptionViewMBean.class, true);
-
-      assertEquals(0, sub.getEnqueueCounter());
-
-      LOG.info("Enqueue counter for sub before pull requests: " + sub.getEnqueueCounter());
-
-      // Trigger some pull Timeouts.
-      consumer.receive(500);
-      consumer.receive(500);
-      consumer.receive(500);
-      consumer.receive(500);
-      consumer.receive(500);
-
-      // Let them all timeout.
-      Thread.sleep(600);
-
-      LOG.info("Enqueue counter for sub after pull requests: " + sub.getEnqueueCounter());
-      assertEquals(0, sub.getEnqueueCounter());
-
-      consumer.close();
-      session.close();
-      connection.close();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4062Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4062Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4062Test.java
deleted file mode 100644
index 8272aef..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4062Test.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.util.Iterator;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CountDownLatch;
-
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQSession;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.DurableTopicSubscription;
-import org.apache.activemq.broker.region.RegionBroker;
-import org.apache.activemq.broker.region.Subscription;
-import org.apache.activemq.broker.region.TopicRegion;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ConsumerInfo;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.util.SubscriptionKey;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AMQ4062Test {
-
-   private BrokerService service;
-   private PolicyEntry policy;
-   private ConcurrentMap<SubscriptionKey, DurableTopicSubscription> durableSubscriptions;
-
-   private static final int PREFETCH_SIZE_5 = 5;
-   private String connectionUri;
-
-   @Before
-   public void startBroker() throws IOException, Exception {
-      service = new BrokerService();
-      service.setPersistent(true);
-      service.setDeleteAllMessagesOnStartup(true);
-      service.setUseJmx(false);
-
-      KahaDBPersistenceAdapter pa = new KahaDBPersistenceAdapter();
-      File dataFile = new File("createData");
-      pa.setDirectory(dataFile);
-      pa.setJournalMaxFileLength(1024 * 1024 * 32);
-
-      service.setPersistenceAdapter(pa);
-
-      policy = new PolicyEntry();
-      policy.setTopic(">");
-      policy.setDurableTopicPrefetch(PREFETCH_SIZE_5);
-      PolicyMap pMap = new PolicyMap();
-      pMap.setDefaultEntry(policy);
-
-      service.setDestinationPolicy(pMap);
-
-      service.addConnector("tcp://localhost:0");
-
-      service.start();
-      service.waitUntilStarted();
-
-      connectionUri = service.getTransportConnectors().get(0).getPublishableConnectString();
-   }
-
-   public void restartBroker() throws IOException, Exception {
-      service = new BrokerService();
-      service.setPersistent(true);
-      service.setUseJmx(false);
-      service.setKeepDurableSubsActive(false);
-
-      KahaDBPersistenceAdapter pa = new KahaDBPersistenceAdapter();
-      File dataFile = new File("createData");
-      pa.setDirectory(dataFile);
-      pa.setJournalMaxFileLength(1024 * 1024 * 32);
-
-      service.setPersistenceAdapter(pa);
-
-      policy = new PolicyEntry();
-      policy.setTopic(">");
-      policy.setDurableTopicPrefetch(PREFETCH_SIZE_5);
-      PolicyMap pMap = new PolicyMap();
-      pMap.setDefaultEntry(policy);
-
-      service.setDestinationPolicy(pMap);
-      service.addConnector("tcp://localhost:0");
-      service.start();
-      service.waitUntilStarted();
-
-      connectionUri = service.getTransportConnectors().get(0).getPublishableConnectString();
-   }
-
-   @After
-   public void stopBroker() throws Exception {
-      service.stop();
-      service.waitUntilStopped();
-      service = null;
-   }
-
-   @Test
-   public void testDirableSubPrefetchRecovered() throws Exception {
-
-      PrefetchConsumer consumer = new PrefetchConsumer(true, connectionUri);
-      consumer.receive();
-      durableSubscriptions = getDurableSubscriptions();
-      ConsumerInfo info = getConsumerInfo(durableSubscriptions);
-
-      //check if the prefetchSize equals to the size we set in the PolicyEntry
-      assertEquals(PREFETCH_SIZE_5, info.getPrefetchSize());
-
-      consumer.a.countDown();
-      Producer p = new Producer(connectionUri);
-      p.send();
-      p = null;
-
-      service.stop();
-      service.waitUntilStopped();
-      durableSubscriptions = null;
-
-      consumer = null;
-      stopBroker();
-
-      restartBroker();
-
-      getDurableSubscriptions();
-      info = null;
-      info = getConsumerInfo(durableSubscriptions);
-
-      //check if the prefetchSize equals to 0 after persistent storage recovered
-      //assertEquals(0, info.getPrefetchSize());
-
-      consumer = new PrefetchConsumer(false, connectionUri);
-      consumer.receive();
-      consumer.a.countDown();
-
-      info = null;
-      info = getConsumerInfo(durableSubscriptions);
-
-      //check if the prefetchSize is the default size for durable consumer and the PolicyEntry
-      //we set earlier take no effect
-      //assertEquals(100, info.getPrefetchSize());
-      //info.getPrefetchSize() is 100,it should be 5,because I set the PolicyEntry as follows,
-      //policy.setDurableTopicPrefetch(PREFETCH_SIZE_5);
-      assertEquals(5, info.getPrefetchSize());
-   }
-
-   @SuppressWarnings("unchecked")
-   private ConcurrentMap<SubscriptionKey, DurableTopicSubscription> getDurableSubscriptions() throws NoSuchFieldException, IllegalAccessException {
-      if (durableSubscriptions != null)
-         return durableSubscriptions;
-      RegionBroker regionBroker = (RegionBroker) service.getRegionBroker();
-      TopicRegion region = (TopicRegion) regionBroker.getTopicRegion();
-      Field field = TopicRegion.class.getDeclaredField("durableSubscriptions");
-      field.setAccessible(true);
-      durableSubscriptions = (ConcurrentMap<SubscriptionKey, DurableTopicSubscription>) field.get(region);
-      return durableSubscriptions;
-   }
-
-   private ConsumerInfo getConsumerInfo(ConcurrentMap<SubscriptionKey, DurableTopicSubscription> durableSubscriptions) {
-      ConsumerInfo info = null;
-      for (Iterator<DurableTopicSubscription> it = durableSubscriptions.values().iterator(); it.hasNext(); ) {
-         Subscription sub = it.next();
-         info = sub.getConsumerInfo();
-         if (info.getSubscriptionName().equals(PrefetchConsumer.SUBSCRIPTION_NAME)) {
-            return info;
-         }
-      }
-      return null;
-   }
-
-   public class PrefetchConsumer implements MessageListener {
-
-      public static final String SUBSCRIPTION_NAME = "A_NAME_ABC_DEF";
-      private final String user = ActiveMQConnection.DEFAULT_USER;
-      private final String password = ActiveMQConnection.DEFAULT_PASSWORD;
-      private final String uri;
-      private boolean transacted;
-      ActiveMQConnection connection;
-      Session session;
-      MessageConsumer consumer;
-      private boolean needAck = false;
-      CountDownLatch a = new CountDownLatch(1);
-
-      public PrefetchConsumer(boolean needAck, String uri) {
-         this.needAck = needAck;
-         this.uri = uri;
-      }
-
-      public void receive() throws Exception {
-         ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(user, password, uri);
-         connection = (ActiveMQConnection) connectionFactory.createConnection();
-         connection.setClientID("3");
-         connection.start();
-
-         session = connection.createSession(transacted, Session.CLIENT_ACKNOWLEDGE);
-         Destination destination = session.createTopic("topic2");
-         consumer = session.createDurableSubscriber((Topic) destination, SUBSCRIPTION_NAME);
-         consumer.setMessageListener(this);
-      }
-
-      @Override
-      public void onMessage(Message message) {
-         try {
-            a.await();
-         }
-         catch (InterruptedException e1) {
-         }
-         if (needAck) {
-            try {
-               message.acknowledge();
-               consumer.close();
-               session.close();
-               connection.close();
-            }
-            catch (JMSException e) {
-            }
-         }
-      }
-   }
-
-   public class Producer {
-
-      protected final String user = ActiveMQConnection.DEFAULT_USER;
-
-      private final String password = ActiveMQConnection.DEFAULT_PASSWORD;
-      private final String uri;
-      private boolean transacted;
-
-      public Producer(String uri) {
-         this.uri = uri;
-      }
-
-      public void send() throws Exception {
-         ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(user, password, uri);
-         ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection();
-         connection.start();
-
-         ActiveMQSession session = (ActiveMQSession) connection.createSession(transacted, Session.AUTO_ACKNOWLEDGE);
-         Destination destination = session.createTopic("topic2");
-         MessageProducer producer = session.createProducer(destination);
-         producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-         for (int i = 0; i < 100; i++) {
-            TextMessage om = session.createTextMessage("hello from producer");
-            producer.send(om);
-         }
-         producer.close();
-         session.close();
-         connection.close();
-      }
-   }
-}


[45/60] [abbrv] activemq-artemis git commit: Refactor test to avoid port conflict.

Posted by cl...@apache.org.
Refactor test to avoid port conflict.


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/e6d51b7a
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/e6d51b7a
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/e6d51b7a

Branch: refs/heads/refactor-openwire
Commit: e6d51b7a492c7b78b791aa92e8d36650d1229390
Parents: e84edec
Author: Howard Gao <ho...@gmail.com>
Authored: Thu Feb 25 20:43:02 2016 +0800
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:44:58 2016 -0400

----------------------------------------------------------------------
 .../apache/activemq/broker/BrokerService.java   | 56 +++++++++++++++++---
 .../artemiswrapper/ArtemisBrokerWrapper.java    | 45 ++++++++--------
 2 files changed, 71 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e6d51b7a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
index 13d6b96..cbf41e1 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
@@ -100,8 +100,8 @@ public class BrokerService implements Service {
    private BrokerId brokerId;
    private Throwable startException = null;
    private boolean startAsync = false;
-   public Set<Integer> extraConnectors = new HashSet<>();
-   public Set<Integer> sslConnectors = new HashSet<>();
+   public Set<ConnectorInfo> extraConnectors = new HashSet<>();
+//   public Set<Integer> sslConnectors = new HashSet<>();
 
    private List<TransportConnector> transportConnectors = new ArrayList<>();
    private File dataDirectoryFile;
@@ -494,11 +494,22 @@ public class BrokerService implements Service {
       this.transportConnectors = transportConnectors;
       for (TransportConnector connector : transportConnectors) {
          if (connector.getUri().getScheme().equals("ssl")) {
-            this.sslConnectors.add(connector.getUri().getPort());
-            System.out.println(this + " added ssl connector: " + connector.getUri().getPort());
+            boolean added = this.extraConnectors.add(new ConnectorInfo(connector.getUri().getPort(), true));
+            if (added) {
+               System.out.println("added ssl connector " + connector);
+            }
+            else {
+               System.out.println("WARNing! failed to add ssl connector: " + connector);
+            }
          }
          else {
-            this.extraConnectors.add(connector.getUri().getPort());
+            boolean added = this.extraConnectors.add(new ConnectorInfo(connector.getUri().getPort()));
+            if (added) {
+               System.out.println("added connector " + connector);
+            }
+            else {
+               System.out.println("WARNing! failed to add connector: " + connector);
+            }
          }
       }
    }
@@ -567,7 +578,7 @@ public class BrokerService implements Service {
 
       connector = new FakeTransportConnector(bindAddress);
       this.transportConnectors.add(connector);
-      this.extraConnectors.add(port);
+      this.extraConnectors.add(new ConnectorInfo(port));
 
       return connector;
    }
@@ -752,8 +763,10 @@ public class BrokerService implements Service {
       URI uri = null;
       try {
          if (this.extraConnectors.size() > 0) {
-            Integer port = extraConnectors.iterator().next();
-            uri = new URI("tcp://localhost:" + port);
+            ConnectorInfo info = extraConnectors.iterator().next();
+            Integer port = info.port;
+            String schema = info.ssl ? "ssl" : "tcp";
+            uri = new URI(schema + "://localhost:" + port);
          } else {
             uri = new URI(this.getDefaultUri());
          }
@@ -763,6 +776,33 @@ public class BrokerService implements Service {
       return uri;
    }
 
+   public static class ConnectorInfo {
+
+      public int port;
+      public boolean ssl;
+
+      public ConnectorInfo(int port) {
+         this(port, false);
+      }
+
+      public ConnectorInfo(int port, boolean ssl) {
+         this.port = port;
+         this.ssl = ssl;
+      }
+
+      @Override
+      public int hashCode() {
+         return port;
+      }
+
+      @Override
+      public boolean equals(Object obj) {
+         if (obj instanceof ConnectorInfo) {
+            return this.port == ((ConnectorInfo)obj).port;
+         }
+         return false;
+      }
+   }
 }
 
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e6d51b7a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
index be1713b..83c12db 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
@@ -94,17 +94,13 @@ public class ArtemisBrokerWrapper extends ArtemisBrokerBase {
       if (bservice.extraConnectors.size() == 0) {
          serverConfig.addAcceptorConfiguration("home", "tcp://localhost:61616?protocols=OPENWIRE,CORE");
       }
-      if (this.bservice.enableSsl() && bservice.sslConnectors.size() == 0) {
+      if (this.bservice.enableSsl()) {
          //default
-         addSSLAcceptor(serverConfig, 61611);
+         addServerAcceptor(serverConfig, new BrokerService.ConnectorInfo(61611));
       }
 
-      for (Integer port : bservice.sslConnectors) {
-         addSSLAcceptor(serverConfig, port);
-      }
-
-      for (Integer port : bservice.extraConnectors) {
-         serverConfig.addAcceptorConfiguration("homePort" + port, "tcp://localhost:" + port + "?protocols=OPENWIRE,CORE");
+      for (BrokerService.ConnectorInfo info : bservice.extraConnectors) {
+         addServerAcceptor(serverConfig, info);
       }
 
       serverConfig.setSecurityEnabled(enableSecurity);
@@ -170,21 +166,26 @@ public class ArtemisBrokerWrapper extends ArtemisBrokerBase {
 
    }
 
-   private void addSSLAcceptor(Configuration serverConfig, Integer port) {
-      HashMap<String, Object> params = new HashMap<String, Object>();
-      params.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
-      params.put(TransportConstants.PORT_PROP_NAME, port);
-      params.put(TransportConstants.PROTOCOLS_PROP_NAME, "OPENWIRE");
-      params.put(TransportConstants.KEYSTORE_PATH_PROP_NAME, bservice.SERVER_SIDE_KEYSTORE);
-      params.put(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME, bservice.KEYSTORE_PASSWORD);
-      params.put(TransportConstants.KEYSTORE_PROVIDER_PROP_NAME, bservice.storeType);
-      if (bservice.SERVER_SIDE_TRUSTSTORE != null) {
-         params.put(TransportConstants.TRUSTSTORE_PATH_PROP_NAME, bservice.SERVER_SIDE_TRUSTSTORE);
-         params.put(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME, bservice.TRUSTSTORE_PASSWORD);
-         params.put(TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME, bservice.storeType);
+   private void addServerAcceptor(Configuration serverConfig, BrokerService.ConnectorInfo info) throws Exception {
+      if (info.ssl) {
+         HashMap<String, Object> params = new HashMap<String, Object>();
+         params.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
+         params.put(TransportConstants.PORT_PROP_NAME, info.port);
+         params.put(TransportConstants.PROTOCOLS_PROP_NAME, "OPENWIRE");
+         params.put(TransportConstants.KEYSTORE_PATH_PROP_NAME, bservice.SERVER_SIDE_KEYSTORE);
+         params.put(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME, bservice.KEYSTORE_PASSWORD);
+         params.put(TransportConstants.KEYSTORE_PROVIDER_PROP_NAME, bservice.storeType);
+         if (bservice.SERVER_SIDE_TRUSTSTORE != null) {
+            params.put(TransportConstants.TRUSTSTORE_PATH_PROP_NAME, bservice.SERVER_SIDE_TRUSTSTORE);
+            params.put(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME, bservice.TRUSTSTORE_PASSWORD);
+            params.put(TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME, bservice.storeType);
+         }
+         TransportConfiguration sslTransportConfig = new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, params);
+         serverConfig.getAcceptorConfigurations().add(sslTransportConfig);
+      }
+      else {
+         serverConfig.addAcceptorConfiguration("homePort" + info.port, "tcp://localhost:" + info.port + "?protocols=OPENWIRE,CORE");
       }
-      TransportConfiguration sslTransportConfig = new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, params);
-      serverConfig.getAcceptorConfigurations().add(sslTransportConfig);
    }
 
    private void translatePolicyMap(Configuration serverConfig, PolicyMap policyMap) {


[11/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/RedeliveryPluginHeaderTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/RedeliveryPluginHeaderTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/RedeliveryPluginHeaderTest.java
deleted file mode 100644
index b0e7bd3..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/RedeliveryPluginHeaderTest.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/**
- * 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;
-
-import java.io.File;
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.RedeliveryPolicy;
-import org.apache.activemq.broker.BrokerPlugin;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.TransportConnector;
-import org.apache.activemq.broker.region.policy.RedeliveryPolicyMap;
-import org.apache.activemq.broker.util.RedeliveryPlugin;
-import org.apache.activemq.util.IOHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Testing if the the broker "sends" the message as expected after the redeliveryPlugin has redelivered the
- * message previously.
- */
-
-public class RedeliveryPluginHeaderTest extends TestCase {
-
-   private static final String TEST_QUEUE_ONE = "TEST_QUEUE_ONE";
-   private static final String TEST_QUEUE_TWO = "TEST_QUEUE_TWO";
-   private static final Logger LOG = LoggerFactory.getLogger(RedeliveryPluginHeaderTest.class);
-   private String transportURL;
-   private BrokerService broker;
-
-   /**
-    * Test
-    * - consumes message from Queue1
-    * - rolls back message to Queue1 and message is scheduled for redelivery to Queue1 by brokers plugin
-    * - consumes message from Queue1 again
-    * - sends same message to Queue2
-    * - expects to consume message from Queue2 immediately
-    */
-
-   public void testSendAfterRedelivery() throws Exception {
-      broker = this.createBroker(false);
-      broker.start();
-      broker.waitUntilStarted();
-
-      LOG.info("***Broker started...");
-
-      //pushed message to broker
-
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(transportURL + "?trace=true&jms.redeliveryPolicy.maximumRedeliveries=0");
-
-      Connection connection = factory.createConnection();
-      connection.start();
-
-      try {
-
-         Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-
-         Destination destinationQ1 = session.createQueue(TEST_QUEUE_ONE);
-         Destination destinationQ2 = session.createQueue(TEST_QUEUE_TWO);
-
-         MessageProducer producerQ1 = session.createProducer(destinationQ1);
-         producerQ1.setDeliveryMode(DeliveryMode.PERSISTENT);
-
-         Message m = session.createTextMessage("testMessage");
-         LOG.info("*** send message to broker...");
-         producerQ1.send(m);
-         session.commit();
-
-         //consume message from Q1 and rollback to get it redelivered
-         MessageConsumer consumerQ1 = session.createConsumer(destinationQ1);
-
-         LOG.info("*** consume message from Q1 and rolled back..");
-
-         TextMessage textMessage = (TextMessage) consumerQ1.receive();
-         LOG.info("got redelivered: " + textMessage);
-         assertFalse("JMSRedelivered flag is not set", textMessage.getJMSRedelivered());
-         session.rollback();
-
-         LOG.info("*** consumed message from Q1 again and sending to Q2..");
-         TextMessage textMessage2 = (TextMessage) consumerQ1.receive();
-         LOG.info("got: " + textMessage2);
-         session.commit();
-         assertTrue("JMSRedelivered flag is set", textMessage2.getJMSRedelivered());
-
-         //send message to Q2 and consume from Q2
-         MessageConsumer consumerQ2 = session.createConsumer(destinationQ2);
-         MessageProducer producer_two = session.createProducer(destinationQ2);
-         producer_two.send(textMessage2);
-         session.commit();
-
-         //Message should be available straight away on the queue_two
-         Message textMessage3 = consumerQ2.receive(1000);
-         assertNotNull("should have consumed a message from TEST_QUEUE_TWO", textMessage3);
-         assertFalse("JMSRedelivered flag is not set", textMessage3.getJMSRedelivered());
-         session.commit();
-
-      }
-      finally {
-
-         connection.close();
-
-         if (broker != null) {
-            broker.stop();
-         }
-
-      }
-
-   }
-
-   protected BrokerService createBroker(boolean withJMX) throws Exception {
-      File schedulerDirectory = new File("target/scheduler");
-      IOHelper.mkdirs(schedulerDirectory);
-      IOHelper.deleteChildren(schedulerDirectory);
-
-      BrokerService answer = new BrokerService();
-      answer.setAdvisorySupport(false);
-      answer.setDataDirectory("target");
-      answer.setSchedulerDirectoryFile(schedulerDirectory);
-      answer.setSchedulerSupport(true);
-      answer.setPersistent(true);
-      answer.setDeleteAllMessagesOnStartup(true);
-      answer.setUseJmx(withJMX);
-
-      RedeliveryPlugin redeliveryPlugin = new RedeliveryPlugin();
-      RedeliveryPolicyMap redeliveryPolicyMap = new RedeliveryPolicyMap();
-      RedeliveryPolicy defaultEntry = new RedeliveryPolicy();
-      defaultEntry.setInitialRedeliveryDelay(5000);
-      defaultEntry.setMaximumRedeliveries(5);
-      redeliveryPolicyMap.setDefaultEntry(defaultEntry);
-      redeliveryPlugin.setRedeliveryPolicyMap(redeliveryPolicyMap);
-
-      answer.setPlugins(new BrokerPlugin[]{redeliveryPlugin});
-      TransportConnector transportConnector = answer.addConnector("tcp://localhost:0");
-
-      transportURL = transportConnector.getConnectUri().toASCIIString();
-
-      return answer;
-   }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/SlowConsumerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/SlowConsumerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/SlowConsumerTest.java
deleted file mode 100644
index b4858c1..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/SlowConsumerTest.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/**
- * 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;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.Socket;
-
-import javax.jms.Connection;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SlowConsumerTest extends TestCase {
-
-   private static final Logger LOG = LoggerFactory.getLogger(SlowConsumerTest.class);
-   private static final int MESSAGES_COUNT = 10000;
-
-   private final int messageLogFrequency = 2500;
-   private final long messageReceiveTimeout = 10000L;
-
-   private Socket stompSocket;
-   private ByteArrayOutputStream inputBuffer;
-   private int messagesCount;
-
-   /**
-    * @param args
-    * @throws Exception
-    */
-   public void testRemoveSubscriber() throws Exception {
-      final BrokerService broker = new BrokerService();
-      broker.setPersistent(true);
-      broker.setUseJmx(true);
-      broker.setDeleteAllMessagesOnStartup(true);
-
-      broker.addConnector("tcp://localhost:0").setName("Default");
-      broker.start();
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString());
-      final Connection connection = factory.createConnection();
-      connection.start();
-
-      Thread producingThread = new Thread("Producing thread") {
-         @Override
-         public void run() {
-            try {
-               Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-               MessageProducer producer = session.createProducer(new ActiveMQQueue(getDestinationName()));
-               for (int idx = 0; idx < MESSAGES_COUNT; ++idx) {
-                  Message message = session.createTextMessage("" + idx);
-                  producer.send(message);
-                  LOG.debug("Sending: " + idx);
-               }
-               producer.close();
-               session.close();
-            }
-            catch (Throwable ex) {
-               ex.printStackTrace();
-            }
-         }
-      };
-      producingThread.setPriority(Thread.MAX_PRIORITY);
-      producingThread.start();
-      Thread.sleep(1000);
-
-      Thread consumingThread = new Thread("Consuming thread") {
-
-         @Override
-         public void run() {
-            try {
-               Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-               MessageConsumer consumer = session.createConsumer(new ActiveMQQueue(getDestinationName()));
-               int diff = 0;
-               while (messagesCount != MESSAGES_COUNT) {
-                  Message msg = consumer.receive(messageReceiveTimeout);
-                  if (msg == null) {
-                     LOG.warn("Got null message at count: " + messagesCount + ". Continuing...");
-                     break;
-                  }
-                  String text = ((TextMessage) msg).getText();
-                  int currentMsgIdx = Integer.parseInt(text);
-                  LOG.debug("Received: " + text + " messageCount: " + messagesCount);
-                  msg.acknowledge();
-                  if ((messagesCount + diff) != currentMsgIdx) {
-                     LOG.debug("Message(s) skipped!! Should be message no.: " + messagesCount + " but got: " + currentMsgIdx);
-                     diff = currentMsgIdx - messagesCount;
-                  }
-                  ++messagesCount;
-                  if (messagesCount % messageLogFrequency == 0) {
-                     LOG.info("Received: " + messagesCount + " messages so far");
-                  }
-                  // Thread.sleep(70);
-               }
-            }
-            catch (Throwable ex) {
-               ex.printStackTrace();
-            }
-         }
-      };
-      consumingThread.start();
-      consumingThread.join();
-
-      assertEquals(MESSAGES_COUNT, messagesCount);
-
-   }
-
-   public void sendFrame(String data) throws Exception {
-      byte[] bytes = data.getBytes("UTF-8");
-      OutputStream outputStream = stompSocket.getOutputStream();
-      for (int i = 0; i < bytes.length; i++) {
-         outputStream.write(bytes[i]);
-      }
-      outputStream.flush();
-   }
-
-   public String receiveFrame(long timeOut) throws Exception {
-      stompSocket.setSoTimeout((int) timeOut);
-      InputStream is = stompSocket.getInputStream();
-      int c = 0;
-      for (;;) {
-         c = is.read();
-         if (c < 0) {
-            throw new IOException("socket closed.");
-         }
-         else if (c == 0) {
-            c = is.read();
-            byte[] ba = inputBuffer.toByteArray();
-            inputBuffer.reset();
-            return new String(ba, "UTF-8");
-         }
-         else {
-            inputBuffer.write(c);
-         }
-      }
-   }
-
-   protected String getDestinationName() {
-      return getClass().getName() + "." + getName();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/SparseAckReplayAfterStoreCleanupLevelDBStoreTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/SparseAckReplayAfterStoreCleanupLevelDBStoreTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/SparseAckReplayAfterStoreCleanupLevelDBStoreTest.java
deleted file mode 100644
index 3e22dc2..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/SparseAckReplayAfterStoreCleanupLevelDBStoreTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * 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;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.leveldb.LevelDBStore;
-
-public class SparseAckReplayAfterStoreCleanupLevelDBStoreTest extends AMQ2832Test {
-
-   @Override
-   protected void configurePersistence(BrokerService brokerService, boolean deleteAllOnStart) throws Exception {
-      LevelDBStore store = new LevelDBStore();
-      store.setFlushDelay(0);
-      brokerService.setPersistenceAdapter(store);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TempQueueDeleteOnCloseTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TempQueueDeleteOnCloseTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TempQueueDeleteOnCloseTest.java
deleted file mode 100644
index f521d40..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TempQueueDeleteOnCloseTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * 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;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.junit.Test;
-
-/**
- * Demonstrates how unmarshalled VM advisory messages for temporary queues prevent other connections from being closed.
- */
-public class TempQueueDeleteOnCloseTest {
-
-   @Test
-   public void test() throws Exception {
-      ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost");
-
-      // create a connection and session with a temporary queue
-      Connection connectionA = connectionFactory.createConnection();
-      connectionA.setClientID("ConnectionA");
-      Session sessionA = connectionA.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Destination tempQueueA = sessionA.createTemporaryQueue();
-      MessageConsumer consumer = sessionA.createConsumer(tempQueueA);
-      connectionA.start();
-
-      // start and stop another connection
-      Connection connectionB = connectionFactory.createConnection();
-      connectionB.setClientID("ConnectionB");
-      connectionB.start();
-      connectionB.close();
-
-      consumer.close();
-      connectionA.close();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TempStorageBlockedBrokerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TempStorageBlockedBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TempStorageBlockedBrokerTest.java
deleted file mode 100644
index dc15f87..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TempStorageBlockedBrokerTest.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/**
- * 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;
-
-import java.io.File;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.ResourceAllocationException;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQPrefetchPolicy;
-import org.apache.activemq.TestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.store.kahadb.plist.PListStoreImpl;
-import org.apache.activemq.usage.MemoryUsage;
-import org.apache.activemq.usage.StoreUsage;
-import org.apache.activemq.usage.SystemUsage;
-import org.apache.activemq.usage.TempUsage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class TempStorageBlockedBrokerTest extends TestSupport {
-
-   public int deliveryMode = DeliveryMode.PERSISTENT;
-
-   private static final Logger LOG = LoggerFactory.getLogger(TempStorageBlockedBrokerTest.class);
-   private static final int MESSAGES_COUNT = 1000;
-   private static byte[] buf = new byte[4 * 1024];
-   private BrokerService broker;
-   AtomicInteger messagesSent = new AtomicInteger(0);
-   AtomicInteger messagesConsumed = new AtomicInteger(0);
-
-   protected long messageReceiveTimeout = 10000L;
-
-   Destination destination = new ActiveMQTopic("FooTwo");
-
-   private String connectionUri;
-
-   public void testRunProducerWithHungConsumer() throws Exception {
-
-      final long origTempUsage = broker.getSystemUsage().getTempUsage().getUsage();
-
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri);
-      // ensure messages are spooled to disk for this consumer
-      ActiveMQPrefetchPolicy prefetch = new ActiveMQPrefetchPolicy();
-      prefetch.setTopicPrefetch(10);
-      factory.setPrefetchPolicy(prefetch);
-      Connection consumerConnection = factory.createConnection();
-      consumerConnection.start();
-
-      Session consumerSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer consumer = consumerSession.createConsumer(destination);
-
-      final Connection producerConnection = factory.createConnection();
-      producerConnection.start();
-
-      final CountDownLatch producerHasSentTenMessages = new CountDownLatch(10);
-      Thread producingThread = new Thread("Producing thread") {
-         @Override
-         public void run() {
-            try {
-               Session session = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-               MessageProducer producer = session.createProducer(destination);
-               producer.setDeliveryMode(deliveryMode);
-               for (int idx = 0; idx < MESSAGES_COUNT; ++idx) {
-                  Message message = session.createTextMessage(new String(buf) + idx);
-
-                  producer.send(message);
-                  messagesSent.incrementAndGet();
-                  producerHasSentTenMessages.countDown();
-                  Thread.sleep(10);
-                  if (idx != 0 && idx % 100 == 0) {
-                     LOG.info("Sent Message " + idx);
-                     LOG.info("Temp Store Usage " + broker.getSystemUsage().getTempUsage().getUsage());
-                  }
-               }
-               producer.close();
-               session.close();
-            }
-            catch (Throwable ex) {
-               ex.printStackTrace();
-            }
-         }
-      };
-      producingThread.start();
-
-      assertTrue("producer has sent 10 in a reasonable time", producerHasSentTenMessages.await(30, TimeUnit.SECONDS));
-
-      int count = 0;
-
-      Message m = null;
-      while ((m = consumer.receive(messageReceiveTimeout)) != null) {
-         count++;
-         if (count != 0 && count % 10 == 0) {
-            LOG.info("Received Message (" + count + "):" + m);
-         }
-         messagesConsumed.incrementAndGet();
-         try {
-            Thread.sleep(100);
-         }
-         catch (Exception e) {
-            LOG.info("error sleeping");
-         }
-      }
-
-      LOG.info("Connection Timeout: Retrying.. count: " + count);
-
-      while ((m = consumer.receive(messageReceiveTimeout)) != null) {
-         count++;
-         if (count != 0 && count % 100 == 0) {
-            LOG.info("Received Message (" + count + "):" + m);
-         }
-         messagesConsumed.incrementAndGet();
-         try {
-            Thread.sleep(100);
-         }
-         catch (Exception e) {
-            LOG.info("error sleeping");
-         }
-      }
-
-      LOG.info("consumer session closing: consumed count: " + count);
-
-      consumerSession.close();
-
-      producingThread.join();
-
-      final long tempUsageBySubscription = broker.getSystemUsage().getTempUsage().getUsage();
-      LOG.info("Orig Usage: " + origTempUsage + ", currentUsage: " + tempUsageBySubscription);
-
-      producerConnection.close();
-      consumerConnection.close();
-
-      LOG.info("Subscrition Usage: " + tempUsageBySubscription + ", endUsage: " + broker.getSystemUsage().getTempUsage().getUsage());
-
-      // do a cleanup
-      ((PListStoreImpl) broker.getTempDataStore()).run();
-      LOG.info("Subscrition Usage: " + tempUsageBySubscription + ", endUsage: " + broker.getSystemUsage().getTempUsage().getUsage());
-
-      assertEquals("Incorrect number of Messages Sent: " + messagesSent.get(), messagesSent.get(), MESSAGES_COUNT);
-      assertEquals("Incorrect number of Messages Consumed: " + messagesConsumed.get(), messagesConsumed.get(), MESSAGES_COUNT);
-   }
-
-   public void testFillTempAndConsume() throws Exception {
-
-      broker.getSystemUsage().setSendFailIfNoSpace(true);
-      destination = new ActiveMQQueue("Foo");
-
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri);
-      final ActiveMQConnection producerConnection = (ActiveMQConnection) factory.createConnection();
-      // so we can easily catch the ResourceAllocationException on send
-      producerConnection.setAlwaysSyncSend(true);
-      producerConnection.start();
-
-      Session session = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = session.createProducer(destination);
-      producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
-      try {
-         while (true) {
-            Message message = session.createTextMessage(new String(buf) + messagesSent.toString());
-            producer.send(message);
-            messagesSent.incrementAndGet();
-            if (messagesSent.get() % 100 == 0) {
-               LOG.info("Sent Message " + messagesSent.get());
-               LOG.info("Temp Store Usage " + broker.getSystemUsage().getTempUsage().getUsage());
-            }
-         }
-      }
-      catch (ResourceAllocationException ex) {
-         LOG.info("Got resource exception : " + ex + ", after sent: " + messagesSent.get());
-      }
-
-      // consume all sent
-      Connection consumerConnection = factory.createConnection();
-      consumerConnection.start();
-
-      Session consumerSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer consumer = consumerSession.createConsumer(destination);
-
-      while (consumer.receive(messageReceiveTimeout) != null) {
-         messagesConsumed.incrementAndGet();
-         if (messagesConsumed.get() % 1000 == 0) {
-            LOG.info("received Message " + messagesConsumed.get());
-            LOG.info("Temp Store Usage " + broker.getSystemUsage().getTempUsage().getUsage());
-         }
-      }
-
-      assertEquals("Incorrect number of Messages Consumed: " + messagesConsumed.get(), messagesConsumed.get(), messagesSent.get());
-   }
-
-   @Override
-   public void setUp() throws Exception {
-
-      broker = new BrokerService();
-      broker.setDataDirectory("target" + File.separator + "activemq-data");
-      broker.setPersistent(true);
-      broker.setUseJmx(true);
-      broker.setAdvisorySupport(false);
-      broker.setDeleteAllMessagesOnStartup(true);
-
-      setDefaultPersistenceAdapter(broker);
-      SystemUsage sysUsage = broker.getSystemUsage();
-      MemoryUsage memUsage = new MemoryUsage();
-      memUsage.setLimit((1024 * 1024));
-      StoreUsage storeUsage = new StoreUsage();
-      storeUsage.setLimit((1024 * 1024) * 38);
-      TempUsage tmpUsage = new TempUsage();
-      tmpUsage.setLimit((1024 * 1024) * 38);
-
-      PolicyEntry defaultPolicy = new PolicyEntry();
-      // defaultPolicy.setTopic("FooTwo");
-      defaultPolicy.setProducerFlowControl(false);
-      defaultPolicy.setMemoryLimit(10 * 1024);
-
-      PolicyMap policyMap = new PolicyMap();
-      policyMap.setDefaultEntry(defaultPolicy);
-
-      sysUsage.setMemoryUsage(memUsage);
-      sysUsage.setStoreUsage(storeUsage);
-      sysUsage.setTempUsage(tmpUsage);
-
-      broker.setDestinationPolicy(policyMap);
-      broker.setSystemUsage(sysUsage);
-
-      broker.addConnector("tcp://localhost:0").setName("Default");
-      broker.start();
-
-      connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
-   }
-
-   @Override
-   public void tearDown() throws Exception {
-      if (broker != null) {
-         broker.stop();
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TempStorageConfigBrokerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TempStorageConfigBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TempStorageConfigBrokerTest.java
deleted file mode 100644
index d04cc3f..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TempStorageConfigBrokerTest.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.ResourceAllocationException;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.store.kahadb.plist.PListStoreImpl;
-import org.junit.After;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Test that when configuring small temp store limits the journal size must also
- * be smaller than the configured limit, but will still send a ResourceAllocationException
- * if its not when sendFailIfNoSpace is enabled.
- */
-public class TempStorageConfigBrokerTest {
-
-   public int deliveryMode = DeliveryMode.PERSISTENT;
-
-   private static final Logger LOG = LoggerFactory.getLogger(TempStorageConfigBrokerTest.class);
-   private static byte[] buf = new byte[4 * 1024];
-   private BrokerService broker;
-   private AtomicInteger messagesSent = new AtomicInteger(0);
-   private AtomicInteger messagesConsumed = new AtomicInteger(0);
-
-   private String brokerUri;
-   private long messageReceiveTimeout = 10000L;
-   private Destination destination = new ActiveMQTopic("FooTwo");
-
-   @Test(timeout = 360000)
-   @Ignore("blocks in hudson, needs investigation")
-   public void testFillTempAndConsumeWithBadTempStoreConfig() throws Exception {
-
-      createBrokerWithInvalidTempStoreConfig();
-
-      broker.getSystemUsage().setSendFailIfNoSpace(true);
-      destination = new ActiveMQQueue("Foo");
-
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerUri);
-      final ActiveMQConnection producerConnection = (ActiveMQConnection) factory.createConnection();
-      // so we can easily catch the ResourceAllocationException on send
-      producerConnection.setAlwaysSyncSend(true);
-      producerConnection.start();
-
-      Session session = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = session.createProducer(destination);
-      producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
-      try {
-         while (true) {
-            Message message = session.createTextMessage(new String(buf) + messagesSent.toString());
-            producer.send(message);
-            messagesSent.incrementAndGet();
-            if (messagesSent.get() % 100 == 0) {
-               LOG.info("Sent Message " + messagesSent.get());
-               LOG.info("Temp Store Usage " + broker.getSystemUsage().getTempUsage().getUsage());
-            }
-         }
-      }
-      catch (ResourceAllocationException ex) {
-         assertTrue("Should not be able to send 100 messages: ", messagesSent.get() < 100);
-         LOG.info("Got resource exception : " + ex + ", after sent: " + messagesSent.get());
-      }
-   }
-
-   @Test(timeout = 360000)
-   @Ignore("blocks in hudson, needs investigation")
-   public void testFillTempAndConsumeWithGoodTempStoreConfig() throws Exception {
-
-      createBrokerWithValidTempStoreConfig();
-
-      broker.getSystemUsage().setSendFailIfNoSpace(true);
-      destination = new ActiveMQQueue("Foo");
-
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerUri);
-      final ActiveMQConnection producerConnection = (ActiveMQConnection) factory.createConnection();
-      // so we can easily catch the ResourceAllocationException on send
-      producerConnection.setAlwaysSyncSend(true);
-      producerConnection.start();
-
-      Session session = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = session.createProducer(destination);
-      producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
-      try {
-         while (true) {
-            Message message = session.createTextMessage(new String(buf) + messagesSent.toString());
-            producer.send(message);
-            messagesSent.incrementAndGet();
-            if (messagesSent.get() % 100 == 0) {
-               LOG.info("Sent Message " + messagesSent.get());
-               LOG.info("Temp Store Usage " + broker.getSystemUsage().getTempUsage().getUsage());
-            }
-         }
-      }
-      catch (ResourceAllocationException ex) {
-         assertTrue("Should be able to send at least 200 messages but was: " + messagesSent.get(), messagesSent.get() > 200);
-         LOG.info("Got resource exception : " + ex + ", after sent: " + messagesSent.get());
-      }
-
-      // consume all sent
-      Connection consumerConnection = factory.createConnection();
-      consumerConnection.start();
-
-      Session consumerSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer consumer = consumerSession.createConsumer(destination);
-
-      while (consumer.receive(messageReceiveTimeout) != null) {
-         messagesConsumed.incrementAndGet();
-         if (messagesConsumed.get() % 1000 == 0) {
-            LOG.info("received Message " + messagesConsumed.get());
-            LOG.info("Temp Store Usage " + broker.getSystemUsage().getTempUsage().getUsage());
-         }
-      }
-
-      assertEquals("Incorrect number of Messages Consumed: " + messagesConsumed.get(), messagesConsumed.get(), messagesSent.get());
-   }
-
-   private void createBrokerWithValidTempStoreConfig() throws Exception {
-      broker = new BrokerService();
-      broker.setDataDirectory("target" + File.separator + "activemq-data");
-      broker.setPersistent(true);
-      broker.setUseJmx(true);
-      broker.setAdvisorySupport(false);
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.setPersistenceAdapter(new KahaDBPersistenceAdapter());
-
-      broker.getSystemUsage().setSendFailIfNoSpace(true);
-      broker.getSystemUsage().getMemoryUsage().setLimit(1048576);
-      broker.getSystemUsage().getTempUsage().setLimit(2 * 1048576);
-      ((PListStoreImpl) broker.getSystemUsage().getTempUsage().getStore()).setJournalMaxFileLength(2 * 1048576);
-      broker.getSystemUsage().getStoreUsage().setLimit(20 * 1048576);
-
-      PolicyEntry defaultPolicy = new PolicyEntry();
-      defaultPolicy.setProducerFlowControl(false);
-      defaultPolicy.setMemoryLimit(10 * 1024);
-
-      PolicyMap policyMap = new PolicyMap();
-      policyMap.setDefaultEntry(defaultPolicy);
-
-      broker.setDestinationPolicy(policyMap);
-      broker.addConnector("tcp://localhost:0").setName("Default");
-      broker.start();
-
-      brokerUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
-   }
-
-   private void createBrokerWithInvalidTempStoreConfig() throws Exception {
-      broker = new BrokerService();
-      broker.setDataDirectory("target" + File.separator + "activemq-data");
-      broker.setPersistent(true);
-      broker.setUseJmx(true);
-      broker.setAdvisorySupport(false);
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.setPersistenceAdapter(new KahaDBPersistenceAdapter());
-
-      broker.getSystemUsage().setSendFailIfNoSpace(true);
-      broker.getSystemUsage().getMemoryUsage().setLimit(1048576);
-      broker.getSystemUsage().getTempUsage().setLimit(2 * 1048576);
-      broker.getSystemUsage().getStoreUsage().setLimit(2 * 1048576);
-
-      PolicyEntry defaultPolicy = new PolicyEntry();
-      defaultPolicy.setProducerFlowControl(false);
-      defaultPolicy.setMemoryLimit(10 * 1024);
-
-      PolicyMap policyMap = new PolicyMap();
-      policyMap.setDefaultEntry(defaultPolicy);
-
-      broker.setDestinationPolicy(policyMap);
-      broker.addConnector("tcp://localhost:0").setName("Default");
-      broker.start();
-
-      brokerUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      if (broker != null) {
-         broker.stop();
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TempStoreDataCleanupTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TempStoreDataCleanupTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TempStoreDataCleanupTest.java
deleted file mode 100644
index 8051a59..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TempStoreDataCleanupTest.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.util.Random;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.Broker;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.broker.region.policy.SharedDeadLetterStrategy;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.store.kahadb.plist.PListStoreImpl;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class TempStoreDataCleanupTest {
-
-   private static final Logger LOG = LoggerFactory.getLogger(TempStoreDataCleanupTest.class);
-   private static final String QUEUE_NAME = TempStoreDataCleanupTest.class.getName() + "Queue";
-
-   private final String str = new String("QAa0bcLdUK2eHfJgTP8XhiFj61DOklNm9nBoI5pGqYVrs3CtSuMZvwWx4yE7zR");
-
-   private BrokerService broker;
-   private String connectionUri;
-   private ExecutorService pool;
-   private String queueName;
-   private Random r = new Random();
-
-   @Before
-   public void setUp() throws Exception {
-
-      broker = new BrokerService();
-      broker.setDataDirectory("target" + File.separator + "activemq-data");
-      broker.setPersistent(true);
-      broker.setUseJmx(true);
-      broker.setDedicatedTaskRunner(false);
-      broker.setAdvisorySupport(false);
-      broker.setDeleteAllMessagesOnStartup(true);
-
-      SharedDeadLetterStrategy strategy = new SharedDeadLetterStrategy();
-      strategy.setProcessExpired(false);
-      strategy.setProcessNonPersistent(false);
-
-      PolicyEntry defaultPolicy = new PolicyEntry();
-      defaultPolicy.setQueue(">");
-      defaultPolicy.setOptimizedDispatch(true);
-      defaultPolicy.setDeadLetterStrategy(strategy);
-      defaultPolicy.setMemoryLimit(9000000);
-
-      PolicyMap policyMap = new PolicyMap();
-      policyMap.setDefaultEntry(defaultPolicy);
-
-      broker.setDestinationPolicy(policyMap);
-
-      broker.getSystemUsage().getMemoryUsage().setLimit(300000000L);
-
-      broker.addConnector("tcp://localhost:0").setName("Default");
-      broker.start();
-      broker.waitUntilStarted();
-
-      connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
-      pool = Executors.newFixedThreadPool(10);
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-      }
-
-      if (pool != null) {
-         pool.shutdown();
-      }
-   }
-
-   @Test
-   public void testIt() throws Exception {
-
-      int startPercentage = broker.getAdminView().getMemoryPercentUsage();
-      LOG.info("MemoryUsage at test start = " + startPercentage);
-
-      for (int i = 0; i < 2; i++) {
-         LOG.info("Started the test iteration: " + i + " using queueName = " + queueName);
-         queueName = QUEUE_NAME + i;
-         final CountDownLatch latch = new CountDownLatch(11);
-
-         pool.execute(new Runnable() {
-            @Override
-            public void run() {
-               receiveAndDiscard100messages(latch);
-            }
-         });
-
-         for (int j = 0; j < 10; j++) {
-            pool.execute(new Runnable() {
-               @Override
-               public void run() {
-                  send10000messages(latch);
-               }
-            });
-         }
-
-         LOG.info("Waiting on the send / receive latch");
-         latch.await(5, TimeUnit.MINUTES);
-         LOG.info("Resumed");
-
-         destroyQueue();
-         TimeUnit.SECONDS.sleep(2);
-      }
-
-      LOG.info("MemoryUsage before awaiting temp store cleanup = " + broker.getAdminView().getMemoryPercentUsage());
-
-      final PListStoreImpl pa = (PListStoreImpl) broker.getTempDataStore();
-      assertTrue("only one journal file should be left: " + pa.getJournal().getFileMap().size(), Wait.waitFor(new Wait.Condition() {
-
-                    @Override
-                    public boolean isSatisified() throws Exception {
-                       return pa.getJournal().getFileMap().size() == 1;
-                    }
-                 }, TimeUnit.MINUTES.toMillis(3)));
-
-      int endPercentage = broker.getAdminView().getMemoryPercentUsage();
-      LOG.info("MemoryUsage at test end = " + endPercentage);
-
-      assertEquals(startPercentage, endPercentage);
-   }
-
-   public void destroyQueue() {
-      try {
-         Broker broker = this.broker.getBroker();
-         if (!broker.isStopped()) {
-            LOG.info("Removing: " + queueName);
-            broker.removeDestination(this.broker.getAdminConnectionContext(), new ActiveMQQueue(queueName), 10);
-         }
-      }
-      catch (Exception e) {
-         LOG.warn("Got an error while removing the test queue", e);
-      }
-   }
-
-   private void send10000messages(CountDownLatch latch) {
-      ActiveMQConnection activeMQConnection = null;
-      try {
-         activeMQConnection = createConnection(null);
-         Session session = activeMQConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageProducer producer = session.createProducer(session.createQueue(queueName));
-         producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-         activeMQConnection.start();
-         for (int i = 0; i < 10000; i++) {
-            TextMessage textMessage = session.createTextMessage();
-            textMessage.setText(generateBody(1000));
-            textMessage.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
-            producer.send(textMessage);
-            try {
-               Thread.sleep(10);
-            }
-            catch (InterruptedException e) {
-            }
-         }
-         producer.close();
-      }
-      catch (JMSException e) {
-         LOG.warn("Got an error while sending the messages", e);
-      }
-      finally {
-         if (activeMQConnection != null) {
-            try {
-               activeMQConnection.close();
-            }
-            catch (JMSException e) {
-            }
-         }
-      }
-      latch.countDown();
-   }
-
-   private void receiveAndDiscard100messages(CountDownLatch latch) {
-      ActiveMQConnection activeMQConnection = null;
-      try {
-         activeMQConnection = createConnection(null);
-         Session session = activeMQConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageConsumer messageConsumer = session.createConsumer(session.createQueue(queueName));
-         activeMQConnection.start();
-         for (int i = 0; i < 100; i++) {
-            messageConsumer.receive();
-         }
-         messageConsumer.close();
-         LOG.info("Created and disconnected");
-      }
-      catch (JMSException e) {
-         LOG.warn("Got an error while receiving the messages", e);
-      }
-      finally {
-         if (activeMQConnection != null) {
-            try {
-               activeMQConnection.close();
-            }
-            catch (JMSException e) {
-            }
-         }
-      }
-      latch.countDown();
-   }
-
-   private ActiveMQConnection createConnection(String id) throws JMSException {
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri);
-      if (id != null) {
-         factory.setClientID(id);
-      }
-
-      ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
-      return connection;
-   }
-
-   private String generateBody(int length) {
-
-      StringBuilder sb = new StringBuilder();
-      int te = 0;
-      for (int i = 1; i <= length; i++) {
-         te = r.nextInt(62);
-         sb.append(str.charAt(te));
-      }
-      return sb.toString();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TransactedStoreUsageSuspendResumeTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TransactedStoreUsageSuspendResumeTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TransactedStoreUsageSuspendResumeTest.java
deleted file mode 100644
index db3888a..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TransactedStoreUsageSuspendResumeTest.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/**
- * 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;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.AutoFailTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.assertTrue;
-
-// https://issues.apache.org/jira/browse/AMQ-4262
-public class TransactedStoreUsageSuspendResumeTest {
-
-   private static final Logger LOG = LoggerFactory.getLogger(TransactedStoreUsageSuspendResumeTest.class);
-
-   private static final int MAX_MESSAGES = 10000;
-
-   private static final String QUEUE_NAME = "test.queue";
-
-   private BrokerService broker;
-
-   private final CountDownLatch messagesReceivedCountDown = new CountDownLatch(MAX_MESSAGES);
-   private final CountDownLatch messagesSentCountDown = new CountDownLatch(MAX_MESSAGES);
-   private final CountDownLatch consumerStartLatch = new CountDownLatch(1);
-
-   private class ConsumerThread extends Thread {
-
-      @Override
-      public void run() {
-         try {
-
-            consumerStartLatch.await(30, TimeUnit.SECONDS);
-
-            ConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
-            Connection connection = factory.createConnection();
-            connection.start();
-            Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-
-            // wait for producer to stop
-            long currentSendCount;
-            do {
-               currentSendCount = messagesSentCountDown.getCount();
-               TimeUnit.SECONDS.sleep(5);
-            } while (currentSendCount != messagesSentCountDown.getCount());
-
-            LOG.info("Starting consumer at: " + currentSendCount);
-
-            MessageConsumer consumer = session.createConsumer(session.createQueue(QUEUE_NAME));
-
-            do {
-               Message message = consumer.receive(5000);
-               if (message != null) {
-                  session.commit();
-                  messagesReceivedCountDown.countDown();
-               }
-               if (messagesReceivedCountDown.getCount() % 500 == 0) {
-                  LOG.info("remaining to receive: " + messagesReceivedCountDown.getCount());
-               }
-            } while (messagesReceivedCountDown.getCount() != 0);
-            consumer.close();
-            session.close();
-            connection.close();
-         }
-         catch (Exception e) {
-            Assert.fail(e.getMessage());
-         }
-      }
-   }
-
-   @Before
-   public void setup() throws Exception {
-
-      broker = new BrokerService();
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.setPersistent(true);
-
-      KahaDBPersistenceAdapter kahaDB = new KahaDBPersistenceAdapter();
-      kahaDB.setJournalMaxFileLength(500 * 1024);
-      kahaDB.setCleanupInterval(10 * 1000);
-      broker.setPersistenceAdapter(kahaDB);
-
-      broker.getSystemUsage().getStoreUsage().setLimit(7 * 1024 * 1024);
-
-      broker.start();
-      broker.waitUntilStarted();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      broker.stop();
-   }
-
-   @Test
-   public void testTransactedStoreUsageSuspendResume() throws Exception {
-
-      ConsumerThread thread = new ConsumerThread();
-      thread.start();
-      ExecutorService sendExecutor = Executors.newSingleThreadExecutor();
-      sendExecutor.execute(new Runnable() {
-         @Override
-         public void run() {
-            try {
-               sendMessages();
-            }
-            catch (Exception ignored) {
-            }
-         }
-      });
-      sendExecutor.shutdown();
-      sendExecutor.awaitTermination(5, TimeUnit.MINUTES);
-
-      boolean allMessagesReceived = messagesReceivedCountDown.await(10, TimeUnit.MINUTES);
-      if (!allMessagesReceived) {
-         AutoFailTestSupport.dumpAllThreads("StuckConsumer!");
-      }
-      assertTrue("Got all messages: " + messagesReceivedCountDown, allMessagesReceived);
-
-      // give consumers a chance to exit gracefully
-      TimeUnit.SECONDS.sleep(2);
-   }
-
-   private void sendMessages() throws Exception {
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
-      factory.setAlwaysSyncSend(true);
-      Connection connection = factory.createConnection();
-      connection.start();
-      Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-      Destination queue = session.createQueue(QUEUE_NAME);
-      Destination retainQueue = session.createQueue(QUEUE_NAME + "-retain");
-      MessageProducer producer = session.createProducer(null);
-
-      producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-      BytesMessage message = session.createBytesMessage();
-      message.writeBytes(new byte[10]);
-
-      for (int i = 0; i < 4240; i++) {
-         // mostly fill the store with retained messages
-         // so consumer only has a small bit of store usage to work with
-         producer.send(retainQueue, message);
-         session.commit();
-      }
-
-      consumerStartLatch.countDown();
-      for (int i = 0; i < MAX_MESSAGES; i++) {
-         producer.send(queue, message);
-         if (i > 0 && i % 20 == 0) {
-            session.commit();
-         }
-         messagesSentCountDown.countDown();
-         if (i > 0 && i % 500 == 0) {
-            LOG.info("Sent : " + i);
-         }
-
-      }
-      session.commit();
-      producer.close();
-      session.close();
-      connection.close();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TransactionNotStartedErrorTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TransactionNotStartedErrorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TransactionNotStartedErrorTest.java
deleted file mode 100644
index 2038279..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TransactionNotStartedErrorTest.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/**
- * 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;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.ObjectMessage;
-import javax.jms.Session;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/*
- * simulate message flow which cause the following exception in the broker
- * (exception logged by client) <br> 2007-07-24 13:51:23,624
- * com.easynet.halo.Halo ERROR (LoggingErrorHandler.java: 23) JMS failure
- * javax.jms.JMSException: Transaction 'TX:ID:dmt-53625-1185281414694-1:0:344'
- * has not been started. at
- * org.apache.activemq.broker.TransactionBroker.getTransaction(TransactionBroker.java:230)
- * This appears to be consistent in a MacBook. Haven't been able to replicate it
- * on Windows though
- */
-public class TransactionNotStartedErrorTest extends TestCase {
-
-   private static final Logger LOG = LoggerFactory.getLogger(TransactionNotStartedErrorTest.class);
-
-   private static final int counter = 500;
-
-   private static int hectorToHaloCtr;
-   private static int xenaToHaloCtr;
-   private static int troyToHaloCtr;
-
-   private static int haloToHectorCtr;
-   private static int haloToXenaCtr;
-   private static int haloToTroyCtr;
-
-   private final String hectorToHalo = "hectorToHalo";
-   private final String xenaToHalo = "xenaToHalo";
-   private final String troyToHalo = "troyToHalo";
-
-   private final String haloToHector = "haloToHector";
-   private final String haloToXena = "haloToXena";
-   private final String haloToTroy = "haloToTroy";
-
-   private BrokerService broker;
-
-   private Connection hectorConnection;
-   private Connection xenaConnection;
-   private Connection troyConnection;
-   private Connection haloConnection;
-
-   private final Object lock = new Object();
-
-   public Connection createConnection() throws Exception {
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString());
-      return factory.createConnection();
-   }
-
-   public Session createSession(Connection connection, boolean transacted) throws JMSException {
-      return connection.createSession(transacted, Session.AUTO_ACKNOWLEDGE);
-   }
-
-   public void startBroker() throws Exception {
-      broker = new BrokerService();
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.setPersistent(true);
-      broker.setUseJmx(true);
-      broker.addConnector("tcp://localhost:0").setName("Default");
-      broker.start();
-      LOG.info("Starting broker..");
-   }
-
-   @Override
-   public void tearDown() throws Exception {
-      hectorConnection.close();
-      xenaConnection.close();
-      troyConnection.close();
-      haloConnection.close();
-      broker.stop();
-   }
-
-   public void testTransactionNotStartedError() throws Exception {
-      startBroker();
-      hectorConnection = createConnection();
-      Thread hectorThread = buildProducer(hectorConnection, hectorToHalo);
-      Receiver hHectorReceiver = new Receiver() {
-         @Override
-         public void receive(String s) throws Exception {
-            haloToHectorCtr++;
-            if (haloToHectorCtr >= counter) {
-               synchronized (lock) {
-                  lock.notifyAll();
-               }
-            }
-         }
-      };
-      buildReceiver(hectorConnection, haloToHector, false, hHectorReceiver);
-
-      troyConnection = createConnection();
-      Thread troyThread = buildProducer(troyConnection, troyToHalo);
-      Receiver hTroyReceiver = new Receiver() {
-         @Override
-         public void receive(String s) throws Exception {
-            haloToTroyCtr++;
-            if (haloToTroyCtr >= counter) {
-               synchronized (lock) {
-                  lock.notifyAll();
-               }
-            }
-         }
-      };
-      buildReceiver(hectorConnection, haloToTroy, false, hTroyReceiver);
-
-      xenaConnection = createConnection();
-      Thread xenaThread = buildProducer(xenaConnection, xenaToHalo);
-      Receiver hXenaReceiver = new Receiver() {
-         @Override
-         public void receive(String s) throws Exception {
-            haloToXenaCtr++;
-            if (haloToXenaCtr >= counter) {
-               synchronized (lock) {
-                  lock.notifyAll();
-               }
-            }
-         }
-      };
-      buildReceiver(xenaConnection, haloToXena, false, hXenaReceiver);
-
-      haloConnection = createConnection();
-      final MessageSender hectorSender = buildTransactionalProducer(haloToHector, haloConnection);
-      final MessageSender troySender = buildTransactionalProducer(haloToTroy, haloConnection);
-      final MessageSender xenaSender = buildTransactionalProducer(haloToXena, haloConnection);
-      Receiver hectorReceiver = new Receiver() {
-         @Override
-         public void receive(String s) throws Exception {
-            hectorToHaloCtr++;
-            troySender.send("halo to troy because of hector");
-            if (hectorToHaloCtr >= counter) {
-               synchronized (lock) {
-                  lock.notifyAll();
-               }
-            }
-         }
-      };
-      Receiver xenaReceiver = new Receiver() {
-         @Override
-         public void receive(String s) throws Exception {
-            xenaToHaloCtr++;
-            hectorSender.send("halo to hector because of xena");
-            if (xenaToHaloCtr >= counter) {
-               synchronized (lock) {
-                  lock.notifyAll();
-               }
-            }
-         }
-      };
-      Receiver troyReceiver = new Receiver() {
-         @Override
-         public void receive(String s) throws Exception {
-            troyToHaloCtr++;
-            xenaSender.send("halo to xena because of troy");
-            if (troyToHaloCtr >= counter) {
-               synchronized (lock) {
-                  lock.notifyAll();
-               }
-            }
-         }
-      };
-      buildReceiver(haloConnection, hectorToHalo, true, hectorReceiver);
-      buildReceiver(haloConnection, xenaToHalo, true, xenaReceiver);
-      buildReceiver(haloConnection, troyToHalo, true, troyReceiver);
-
-      haloConnection.start();
-
-      troyConnection.start();
-      troyThread.start();
-
-      xenaConnection.start();
-      xenaThread.start();
-
-      hectorConnection.start();
-      hectorThread.start();
-      waitForMessagesToBeDelivered();
-      // number of messages received should match messages sent
-      assertEquals(hectorToHaloCtr, counter);
-      LOG.info("hectorToHalo received " + hectorToHaloCtr + " messages");
-      assertEquals(xenaToHaloCtr, counter);
-      LOG.info("xenaToHalo received " + xenaToHaloCtr + " messages");
-      assertEquals(troyToHaloCtr, counter);
-      LOG.info("troyToHalo received " + troyToHaloCtr + " messages");
-      assertEquals(haloToHectorCtr, counter);
-      LOG.info("haloToHector received " + haloToHectorCtr + " messages");
-      assertEquals(haloToXenaCtr, counter);
-      LOG.info("haloToXena received " + haloToXenaCtr + " messages");
-      assertEquals(haloToTroyCtr, counter);
-      LOG.info("haloToTroy received " + haloToTroyCtr + " messages");
-
-   }
-
-   protected void waitForMessagesToBeDelivered() {
-      // let's give the listeners enough time to read all messages
-      long maxWaitTime = counter * 3000;
-      long waitTime = maxWaitTime;
-      long start = (maxWaitTime <= 0) ? 0 : System.currentTimeMillis();
-
-      synchronized (lock) {
-         boolean hasMessages = true;
-         while (hasMessages && waitTime >= 0) {
-            try {
-               lock.wait(200);
-            }
-            catch (InterruptedException e) {
-               LOG.error(e.toString());
-            }
-            // check if all messages have been received
-            hasMessages = hectorToHaloCtr < counter || xenaToHaloCtr < counter || troyToHaloCtr < counter || haloToHectorCtr < counter || haloToXenaCtr < counter || haloToTroyCtr < counter;
-            waitTime = maxWaitTime - (System.currentTimeMillis() - start);
-         }
-      }
-   }
-
-   public MessageSender buildTransactionalProducer(String queueName, Connection connection) throws Exception {
-      return new MessageSender(queueName, connection, true, false);
-   }
-
-   public Thread buildProducer(Connection connection, final String queueName) throws Exception {
-      final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      final MessageSender producer = new MessageSender(queueName, connection, false, false);
-      Thread thread = new Thread() {
-
-         @Override
-         public synchronized void run() {
-            for (int i = 0; i < counter; i++) {
-               try {
-                  producer.send(queueName);
-                  if (session.getTransacted()) {
-                     session.commit();
-                  }
-
-               }
-               catch (Exception e) {
-                  throw new RuntimeException("on " + queueName + " send", e);
-               }
-            }
-         }
-      };
-      return thread;
-   }
-
-   public void buildReceiver(Connection connection,
-                             final String queueName,
-                             boolean transacted,
-                             final Receiver receiver) throws Exception {
-      final Session session = transacted ? connection.createSession(true, Session.SESSION_TRANSACTED) : connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer inputMessageConsumer = session.createConsumer(session.createQueue(queueName));
-      MessageListener messageListener = new MessageListener() {
-
-         @Override
-         public void onMessage(Message message) {
-            try {
-               ObjectMessage objectMessage = (ObjectMessage) message;
-               String s = (String) objectMessage.getObject();
-               receiver.receive(s);
-               if (session.getTransacted()) {
-                  session.commit();
-               }
-
-            }
-            catch (Exception e) {
-               e.printStackTrace();
-            }
-         }
-      };
-      inputMessageConsumer.setMessageListener(messageListener);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TrapMessageInJDBCStoreTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TrapMessageInJDBCStoreTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TrapMessageInJDBCStoreTest.java
deleted file mode 100644
index 67b284f..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/TrapMessageInJDBCStoreTest.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/**
- * 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;
-
-import java.io.IOException;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.store.jdbc.DataSourceServiceSupport;
-import org.apache.activemq.store.jdbc.JDBCPersistenceAdapter;
-import org.apache.activemq.store.jdbc.LeaseDatabaseLocker;
-import org.apache.activemq.store.jdbc.TransactionContext;
-import org.apache.activemq.util.IOHelper;
-import org.apache.activemq.util.LeaseLockerIOExceptionHandler;
-import org.apache.derby.jdbc.EmbeddedDataSource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Test to demostrate a message trapped in the JDBC store and not
- * delivered to consumer
- *
- * The test throws issues the commit to the DB but throws
- * an exception back to the broker. This scenario could happen when a network
- * cable is disconnected - message is committed to DB but broker does not know.
- */
-
-public class TrapMessageInJDBCStoreTest extends TestCase {
-
-   private static final String MY_TEST_Q = "MY_TEST_Q";
-   private static final Logger LOG = LoggerFactory.getLogger(TrapMessageInJDBCStoreTest.class);
-   private String transportUrl = "tcp://127.0.0.1:0";
-   private BrokerService broker;
-   private TestTransactionContext testTransactionContext;
-   private TestJDBCPersistenceAdapter jdbc;
-
-   protected BrokerService createBroker(boolean withJMX) throws Exception {
-      BrokerService broker = new BrokerService();
-
-      broker.setUseJmx(withJMX);
-
-      EmbeddedDataSource embeddedDataSource = (EmbeddedDataSource) DataSourceServiceSupport.createDataSource(IOHelper.getDefaultDataDirectory());
-      embeddedDataSource.setCreateDatabase("create");
-
-      //wire in a TestTransactionContext (wrapper to TransactionContext) that has an executeBatch()
-      // method that can be configured to throw a SQL exception on demand
-      jdbc = new TestJDBCPersistenceAdapter();
-      jdbc.setDataSource(embeddedDataSource);
-      jdbc.setCleanupPeriod(0);
-      testTransactionContext = new TestTransactionContext(jdbc);
-
-      jdbc.setLockKeepAlivePeriod(1000L);
-      LeaseDatabaseLocker leaseDatabaseLocker = new LeaseDatabaseLocker();
-      leaseDatabaseLocker.setLockAcquireSleepInterval(2000L);
-      jdbc.setLocker(leaseDatabaseLocker);
-
-      broker.setPersistenceAdapter(jdbc);
-
-      broker.setIoExceptionHandler(new LeaseLockerIOExceptionHandler());
-
-      transportUrl = broker.addConnector(transportUrl).getPublishableConnectString();
-      return broker;
-   }
-
-   /**
-    * sends 3 messages to the queue. When the second message is being committed to the JDBCStore, $
-    * it throws a dummy SQL exception - the message has been committed to the embedded DB before the exception
-    * is thrown
-    *
-    * Excepted correct outcome: receive 3 messages and the DB should contain no messages
-    *
-    * @throws Exception
-    */
-
-   public void testDBCommitException() throws Exception {
-
-      broker = this.createBroker(false);
-      broker.deleteAllMessages();
-      broker.start();
-      broker.waitUntilStarted();
-
-      LOG.info("***Broker started...");
-
-      // failover but timeout in 5 seconds so the test does not hang
-      String failoverTransportURL = "failover:(" + transportUrl + ")?timeout=5000";
-
-      sendMessage(MY_TEST_Q, failoverTransportURL);
-
-      //check db contents
-      ArrayList<Long> dbSeq = dbMessageCount();
-      LOG.info("*** after send: db contains message seq " + dbSeq);
-
-      List<TextMessage> consumedMessages = consumeMessages(MY_TEST_Q, failoverTransportURL);
-
-      assertEquals("number of consumed messages", 3, consumedMessages.size());
-
-      //check db contents
-      dbSeq = dbMessageCount();
-      LOG.info("*** after consume - db contains message seq " + dbSeq);
-
-      assertEquals("number of messages in DB after test", 0, dbSeq.size());
-
-      broker.stop();
-      broker.waitUntilStopped();
-   }
-
-   public List<TextMessage> consumeMessages(String queue, String transportURL) throws JMSException {
-      Connection connection = null;
-      LOG.debug("*** consumeMessages() called ...");
-
-      try {
-
-         ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(transportURL);
-
-         connection = factory.createConnection();
-         connection.start();
-         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         Destination destination = session.createQueue(queue);
-
-         ArrayList<TextMessage> consumedMessages = new ArrayList<>();
-
-         MessageConsumer messageConsumer = session.createConsumer(destination);
-
-         while (true) {
-            TextMessage textMessage = (TextMessage) messageConsumer.receive(4000);
-            LOG.debug("*** consumed Messages :" + textMessage);
-
-            if (textMessage == null) {
-               return consumedMessages;
-            }
-            consumedMessages.add(textMessage);
-         }
-
-      }
-      finally {
-         if (connection != null) {
-            connection.close();
-         }
-      }
-   }
-
-   public void sendMessage(String queue, String transportURL) throws Exception {
-      Connection connection = null;
-
-      try {
-
-         ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(transportURL);
-
-         connection = factory.createConnection();
-         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         Destination destination = session.createQueue(queue);
-         MessageProducer producer = session.createProducer(destination);
-         producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-
-         TextMessage m = session.createTextMessage("1");
-
-         LOG.debug("*** send message 1 to broker...");
-         producer.send(m);
-
-         // trigger SQL exception in transactionContext
-         LOG.debug("***  send message 2 to broker");
-         m.setText("2");
-         producer.send(m);
-
-         //check db contents
-         ArrayList<Long> dbSeq = dbMessageCount();
-         LOG.info("*** after send 2 - db contains message seq " + dbSeq);
-         assertEquals("number of messages in DB after send 2", 2, dbSeq.size());
-
-         LOG.debug("***  send  message 3 to broker");
-         m.setText("3");
-         producer.send(m);
-         LOG.debug("*** Finished sending messages to broker");
-
-      }
-      finally {
-         if (connection != null) {
-            connection.close();
-         }
-      }
-   }
-
-   /**
-    * query the DB to see what messages are left in the store
-    *
-    * @return
-    * @throws SQLException
-    * @throws IOException
-    */
-   private ArrayList<Long> dbMessageCount() throws SQLException, IOException {
-      java.sql.Connection conn = ((JDBCPersistenceAdapter) broker.getPersistenceAdapter()).getDataSource().getConnection();
-      PreparedStatement statement = conn.prepareStatement("SELECT MSGID_SEQ FROM ACTIVEMQ_MSGS");
-
-      try {
-
-         ResultSet result = statement.executeQuery();
-         ArrayList<Long> dbSeq = new ArrayList<>();
-
-         while (result.next()) {
-            dbSeq.add(result.getLong(1));
-         }
-
-         return dbSeq;
-
-      }
-      finally {
-         statement.close();
-         conn.close();
-
-      }
-
-   }
-
-	/*
-     * Mock classes used for testing
-	 */
-
-   public class TestJDBCPersistenceAdapter extends JDBCPersistenceAdapter {
-
-      @Override
-      public TransactionContext getTransactionContext() throws IOException {
-         return testTransactionContext;
-      }
-   }
-
-   public class TestTransactionContext extends TransactionContext {
-
-      private int count;
-
-      public TestTransactionContext(JDBCPersistenceAdapter jdbcPersistenceAdapter) throws IOException {
-         super(jdbcPersistenceAdapter);
-      }
-
-      @Override
-      public void executeBatch() throws SQLException {
-         super.executeBatch();
-         count++;
-         LOG.debug("ExecuteBatchOverride: count:" + count, new RuntimeException("executeBatch"));
-
-         // throw on second add message
-         if (count == 16) {
-            throw new SQLException("TEST SQL EXCEPTION from executeBatch after super.execution: count:" + count);
-         }
-      }
-
-   }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/VMTransportClosureTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/VMTransportClosureTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/VMTransportClosureTest.java
deleted file mode 100644
index 84c1765..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/VMTransportClosureTest.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
- * 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;
-
-import java.io.IOException;
-
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ShutdownInfo;
-import org.apache.activemq.transport.Transport;
-import org.apache.activemq.transport.TransportFactory;
-import org.apache.activemq.transport.TransportListener;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class VMTransportClosureTest extends EmbeddedBrokerTestSupport {
-
-   private static final Log LOG = LogFactory.getLog(VMTransportClosureTest.class);
-   private static final long MAX_TEST_TIME_MILLIS = 300000; // 5min
-   private static final int NUM_ATTEMPTS = 100000;
-
-   @Override
-   public void setUp() throws Exception {
-      setAutoFail(true);
-      setMaxTestTime(MAX_TEST_TIME_MILLIS);
-      super.setUp();
-   }
-
-   /**
-    * EmbeddedBrokerTestSupport.createBroker() binds the broker to a VM
-    * transport address, which results in a call to
-    * VMTransportFactory.doBind(location):
-    * <p>
-    * <code>
-    * public TransportServer doBind(URI location) throws IOException {
-    * return bind(location, false);
-    * }
-    * </code>
-    * </p>
-    * As a result, VMTransportServer.disposeOnDisconnect is <code>false</code>.
-    * To expose the bug, we need to have VMTransportServer.disposeOnDisconnect
-    * <code>true</code>, which is the case when the VMTransportServer is not
-    * already bound when the first connection is made.
-    */
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      BrokerService answer = new BrokerService();
-      answer.setPersistent(isPersistent());
-      // answer.addConnector(bindAddress);
-      return answer;
-   }
-
-   /**
-    * This test demonstrates how the "disposeOnDisonnect" feature of
-    * VMTransportServer can incorrectly close all VM connections to the local
-    * broker.
-    */
-   public void testPrematureClosure() throws Exception {
-
-      // Open a persistent connection to the local broker. The persistent
-      // connection is maintained through the test and should prevent the
-      // VMTransportServer from stopping itself when the local transport is
-      // closed.
-      ActiveMQConnection persistentConn = (ActiveMQConnection) createConnection();
-      persistentConn.start();
-      Session session = persistentConn.createSession(true, Session.SESSION_TRANSACTED);
-      MessageProducer producer = session.createProducer(destination);
-
-      for (int i = 0; i < NUM_ATTEMPTS; i++) {
-         LOG.info("Attempt: " + i);
-
-         // Open and close a local transport connection. As is done by by
-         // most users of the transport, ensure that the transport is stopped
-         // when closed by the peer (via ShutdownInfo). Closing the local
-         // transport should not affect the persistent connection.
-         final Transport localTransport = TransportFactory.connect(broker.getVmConnectorURI());
-         localTransport.setTransportListener(new TransportListener() {
-            @Override
-            public void onCommand(Object command) {
-               if (command instanceof ShutdownInfo) {
-                  try {
-                     localTransport.stop();
-                  }
-                  catch (Exception ex) {
-                     throw new RuntimeException(ex);
-                  }
-               }
-            }
-
-            @Override
-            public void onException(IOException error) {
-               // ignore
-            }
-
-            @Override
-            public void transportInterupted() {
-               // ignore
-            }
-
-            @Override
-            public void transportResumed() {
-               // ignore
-            }
-         });
-
-         localTransport.start();
-         localTransport.stop();
-
-         // Ensure that the persistent connection is still usable.
-         producer.send(session.createMessage());
-         session.rollback();
-      }
-
-      persistentConn.close();
-   }
-}


[02/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/TwoBrokerFailoverClusterTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/TwoBrokerFailoverClusterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/TwoBrokerFailoverClusterTest.java
index 5016e30..dc91873 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/TwoBrokerFailoverClusterTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/TwoBrokerFailoverClusterTest.java
@@ -16,22 +16,41 @@
  */
 package org.apache.activemq.transport.failover;
 
-public class TwoBrokerFailoverClusterTest extends FailoverClusterTestSupport {
+import org.apache.activemq.ActiveMQConnection;
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
-   private static final String BROKER_A_CLIENT_TC_ADDRESS = "tcp://127.0.0.1:61616";
-   private static final String BROKER_B_CLIENT_TC_ADDRESS = "tcp://127.0.0.1:61617";
-   private static final String BROKER_A_NOB_TC_ADDRESS = "tcp://127.0.0.1:61626";
-   private static final String BROKER_B_NOB_TC_ADDRESS = "tcp://127.0.0.1:61627";
-   private static final String BROKER_A_NAME = "BROKERA";
-   private static final String BROKER_B_NAME = "BROKERB";
+import javax.jms.Connection;
+import javax.jms.MessageConsumer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
 
+public class TwoBrokerFailoverClusterTest extends OpenwireArtemisBaseTest {
+
+   private static final int NUMBER_OF_CLIENTS = 30;
+   private final List<ActiveMQConnection> connections = new ArrayList<ActiveMQConnection>();
+   private EmbeddedJMS server0;
+   private EmbeddedJMS server1;
+   private String clientUrl;
+
+   @Test
    public void testTwoBrokersRestart() throws Exception {
-      createBrokerA(false, "", null, null);
-      createBrokerB(false, "", null, null);
-      getBroker(BROKER_B_NAME).waitUntilStarted();
 
       Thread.sleep(2000);
-      setClientUrl("failover://(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + ")");
       createClients();
 
       Thread.sleep(5000);
@@ -39,59 +58,106 @@ public class TwoBrokerFailoverClusterTest extends FailoverClusterTestSupport {
       assertClientsConnectedToTwoBrokers();
       assertClientsConnectionsEvenlyDistributed(.35);
 
-      getBroker(BROKER_A_NAME).stop();
-      getBroker(BROKER_A_NAME).waitUntilStopped();
-      removeBroker(BROKER_A_NAME);
+      server0.stop();
+      Assert.assertTrue(server1.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 1));
 
       Thread.sleep(1000);
 
-      assertAllConnectedTo(BROKER_B_CLIENT_TC_ADDRESS);
+      assertAllConnectedTo(newURI("127.0.0.1", 1));
 
       Thread.sleep(5000);
 
-      createBrokerA(false, "", null, null);
-      getBroker(BROKER_A_NAME).waitUntilStarted();
+      server0.start();
+      Assert.assertTrue(server0.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
+      Assert.assertTrue(server1.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
       Thread.sleep(5000);
 
+      //need update-cluster-clients, -on-remove and rebalance set to true.
       assertClientsConnectedToTwoBrokers();
       assertClientsConnectionsEvenlyDistributed(.35);
    }
 
-   private void createBrokerA(boolean multi,
-                              String params,
-                              String clusterFilter,
-                              String destinationFilter) throws Exception {
-      final String tcParams = (params == null) ? "" : params;
-      if (getBroker(BROKER_A_NAME) == null) {
-         addBroker(BROKER_A_NAME, createBroker(BROKER_A_NAME));
-         addTransportConnector(getBroker(BROKER_A_NAME), "openwire", BROKER_A_CLIENT_TC_ADDRESS + tcParams, true);
-         if (multi) {
-            addTransportConnector(getBroker(BROKER_A_NAME), "network", BROKER_A_NOB_TC_ADDRESS + tcParams, false);
-            addNetworkBridge(getBroker(BROKER_A_NAME), "A_2_B_Bridge", "static://(" + BROKER_B_NOB_TC_ADDRESS + ")?useExponentialBackOff=false", false, clusterFilter);
-         }
-         else {
-            addNetworkBridge(getBroker(BROKER_A_NAME), "A_2_B_Bridge", "static://(" + BROKER_B_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=false", false, clusterFilter);
-         }
-         getBroker(BROKER_A_NAME).start();
+
+   @Before
+   public void setUp() throws Exception {
+      Configuration config0 = createConfig("127.0.0.1", 0);
+      Configuration config1 = createConfig("127.0.0.1", 1);
+
+      deployClusterConfiguration(config0, 1);
+      deployClusterConfiguration(config1, 0);
+
+      server0 = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
+      server1 = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
+
+      clientUrl = "failover://(" + newURI("127.0.0.1", 0) + "," + newURI("127.0.0.1", 1) + ")";
+
+      server0.start();
+      server1.start();
+      Assert.assertTrue(server0.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
+      Assert.assertTrue(server1.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
+   }
+
+   @After
+   public void tearDown() throws Exception {
+      server0.stop();
+      server1.stop();
+   }
+
+   protected void createClients() throws Exception {
+      createClients(NUMBER_OF_CLIENTS);
+   }
+
+   protected void createClients(int numOfClients) throws Exception {
+      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(clientUrl);
+      for (int i = 0; i < numOfClients; i++) {
+         ActiveMQConnection c = (ActiveMQConnection) factory.createConnection();
+         c.start();
+         Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         Queue queue = s.createQueue(getClass().getName());
+         MessageConsumer consumer = s.createConsumer(queue);
+         connections.add(c);
       }
    }
 
-   private void createBrokerB(boolean multi,
-                              String params,
-                              String clusterFilter,
-                              String destinationFilter) throws Exception {
-      final String tcParams = (params == null) ? "" : params;
-      if (getBroker(BROKER_B_NAME) == null) {
-         addBroker(BROKER_B_NAME, createBroker(BROKER_B_NAME));
-         addTransportConnector(getBroker(BROKER_B_NAME), "openwire", BROKER_B_CLIENT_TC_ADDRESS + tcParams, true);
-         if (multi) {
-            addTransportConnector(getBroker(BROKER_B_NAME), "network", BROKER_B_NOB_TC_ADDRESS + tcParams, false);
-            addNetworkBridge(getBroker(BROKER_B_NAME), "B_2_A_Bridge", "static://(" + BROKER_A_NOB_TC_ADDRESS + ")?useExponentialBackOff=false", false, clusterFilter);
+   protected void assertClientsConnectedToTwoBrokers() {
+      Set<String> set = new HashSet<String>();
+      for (ActiveMQConnection c : connections) {
+         if (c.getTransportChannel().getRemoteAddress() != null) {
+            set.add(c.getTransportChannel().getRemoteAddress());
          }
-         else {
-            addNetworkBridge(getBroker(BROKER_B_NAME), "B_2_A_Bridge", "static://(" + BROKER_A_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=false", false, clusterFilter);
+      }
+      Assert.assertTrue("Only 2 connections should be found: " + set, set.size() == 2);
+   }
+
+   protected void assertClientsConnectionsEvenlyDistributed(double minimumPercentage) {
+      Map<String, Double> clientConnectionCounts = new HashMap<String, Double>();
+      int total = 0;
+      for (ActiveMQConnection c : connections) {
+         String key = c.getTransportChannel().getRemoteAddress();
+         if (key != null) {
+            total++;
+            if (clientConnectionCounts.containsKey(key)) {
+               double count = clientConnectionCounts.get(key);
+               count += 1.0;
+               clientConnectionCounts.put(key, count);
+            }
+            else {
+               clientConnectionCounts.put(key, 1.0);
+            }
          }
-         getBroker(BROKER_B_NAME).start();
+      }
+      Set<String> keys = clientConnectionCounts.keySet();
+      for (String key : keys) {
+         double count = clientConnectionCounts.get(key);
+         double percentage = count / total;
+         System.out.println(count + " of " + total + " connections for " + key + " = " + percentage);
+         Assert.assertTrue("Connections distribution expected to be >= than " + minimumPercentage + ".  Actuall distribution was " + percentage + " for connection " + key, percentage >= minimumPercentage);
+      }
+   }
+
+   protected void assertAllConnectedTo(String url) throws Exception {
+      for (ActiveMQConnection c : connections) {
+         Assert.assertEquals(url, c.getTransportChannel().getRemoteAddress());
       }
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/fanout/FanoutTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/fanout/FanoutTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/fanout/FanoutTest.java
index dc369be..a372b79 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/fanout/FanoutTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/fanout/FanoutTest.java
@@ -26,45 +26,42 @@ import javax.jms.Session;
 import junit.framework.TestCase;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
 import org.apache.activemq.broker.BrokerFactory;
 import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
 import org.apache.activemq.util.MessageIdList;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
-public class FanoutTest extends TestCase {
+public class FanoutTest extends OpenwireArtemisBaseTest {
 
-   BrokerService broker1;
-   BrokerService broker2;
+   EmbeddedJMS[] servers = new EmbeddedJMS[2];
 
    ActiveMQConnectionFactory producerFactory = new ActiveMQConnectionFactory("fanout:(static:(tcp://localhost:61616,tcp://localhost:61617))?fanOutQueues=true");
    Connection producerConnection;
    Session producerSession;
    int messageCount = 100;
 
-   @Override
+   @Before
    public void setUp() throws Exception {
-      broker1 = BrokerFactory.createBroker("broker:(tcp://localhost:61616)/brokerA?persistent=false&useJmx=false");
-      broker2 = BrokerFactory.createBroker("broker:(tcp://localhost:61617)/brokerB?persistent=false&useJmx=false");
-
-      broker1.start();
-      broker2.start();
-
-      broker1.waitUntilStarted();
-      broker2.waitUntilStarted();
+      setUpNonClusterServers(servers);
 
       producerConnection = producerFactory.createConnection();
       producerConnection.start();
       producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    }
 
-   @Override
+   @After
    public void tearDown() throws Exception {
       producerSession.close();
       producerConnection.close();
 
-      broker1.stop();
-      broker2.stop();
+      shutDownNonClusterServers(servers);
    }
 
+   @Test
    public void testSendReceive() throws Exception {
 
       MessageProducer prod = createProducer();
@@ -76,7 +73,6 @@ public class FanoutTest extends TestCase {
 
       assertMessagesReceived("tcp://localhost:61616");
       assertMessagesReceived("tcp://localhost:61617");
-
    }
 
    protected MessageProducer createProducer() throws Exception {
@@ -95,7 +91,7 @@ public class FanoutTest extends TestCase {
       listener.assertMessagesReceived(messageCount);
 
       consumer.close();
-      consumerConnection.close();
       consumerSession.close();
+      consumerConnection.close();
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/fanout/FanoutTransportBrokerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/fanout/FanoutTransportBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/fanout/FanoutTransportBrokerTest.java
index 7e52f13..2cfc136 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/fanout/FanoutTransportBrokerTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/fanout/FanoutTransportBrokerTest.java
@@ -18,51 +18,111 @@ package org.apache.activemq.transport.fanout;
 
 import java.io.IOException;
 import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
 import javax.jms.DeliveryMode;
+import javax.jms.MessageNotWriteableException;
 
-import junit.framework.Test;
-
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
 import org.apache.activemq.broker.StubConnection;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.command.ActiveMQTextMessage;
 import org.apache.activemq.command.ActiveMQTopic;
+import org.apache.activemq.command.ConnectionId;
 import org.apache.activemq.command.ConnectionInfo;
 import org.apache.activemq.command.ConsumerInfo;
+import org.apache.activemq.command.Message;
+import org.apache.activemq.command.MessageDispatch;
+import org.apache.activemq.command.MessageId;
 import org.apache.activemq.command.ProducerInfo;
 import org.apache.activemq.command.SessionInfo;
-import org.apache.activemq.network.NetworkTestSupport;
 import org.apache.activemq.transport.Transport;
 import org.apache.activemq.transport.TransportFactory;
 import org.apache.activemq.transport.TransportFilter;
 import org.apache.activemq.transport.mock.MockTransport;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class FanoutTransportBrokerTest extends NetworkTestSupport {
+@RunWith(Parameterized.class)
+public class FanoutTransportBrokerTest extends OpenwireArtemisBaseTest {
+   public static final boolean FAST_NO_MESSAGE_LEFT_ASSERT = System.getProperty("FAST_NO_MESSAGE_LEFT_ASSERT", "true").equals("true");
+
+   protected ArrayList<StubConnection> connections = new ArrayList<StubConnection>();
+   protected long idGenerator;
+   protected int msgIdGenerator;
+   protected int maxWait = 10000;
 
    private static final Logger LOG = LoggerFactory.getLogger(FanoutTransportBrokerTest.class);
 
-   public ActiveMQDestination destination;
-   public int deliveryMode;
+   private EmbeddedJMS server;
+   private EmbeddedJMS remoteServer;
+
+   private ActiveMQDestination destination;
+   private int deliveryMode;
 
-   public static Test suite() {
-      return suite(FanoutTransportBrokerTest.class);
+   @Parameterized.Parameters(name="test-{index}")
+   public static Collection<Object[]> getParams()
+   {
+      return Arrays.asList(new Object[][]{
+              {Integer.valueOf(DeliveryMode.NON_PERSISTENT), new ActiveMQQueue("TEST")},
+              {Integer.valueOf(DeliveryMode.NON_PERSISTENT), new ActiveMQTopic("TEST")},
+              {Integer.valueOf(DeliveryMode.PERSISTENT), new ActiveMQQueue("TEST")},
+              {Integer.valueOf(DeliveryMode.PERSISTENT), new ActiveMQTopic("TEST")}
+      });
    }
 
-   public static void main(String[] args) {
-      junit.textui.TestRunner.run(suite());
+   public FanoutTransportBrokerTest(int deliveryMode, ActiveMQDestination destination) {
+      this.deliveryMode = deliveryMode;
+      this.destination = destination;
    }
 
-   public void initCombosForTestPublisherFansout() {
-      addCombinationValues("deliveryMode", new Object[]{Integer.valueOf(DeliveryMode.NON_PERSISTENT), Integer.valueOf(DeliveryMode.PERSISTENT)});
-      addCombinationValues("destination", new Object[]{new ActiveMQTopic("TEST"), new ActiveMQQueue("TEST")});
+   @Before
+   public void setUp() throws Exception {
+      Configuration config0 = createConfig(0);
+      server = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
+      Configuration config1 = createConfig(1);
+      remoteServer = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
+      server.start();
+      remoteServer.start();
+
+   }
+   @After
+   public void tearDown() throws Exception {
+      for (StubConnection conn : connections) {
+         try {
+            conn.stop();
+         }
+         catch (Exception e) {
+         }
+      }
+      try {
+         remoteServer.stop();
+      }
+      catch (Exception e) {
+      }
+      try {
+         server.stop();
+      }
+      catch (Exception e) {
+      }
    }
 
+   @Test
    public void testPublisherFansout() throws Exception {
-
       // Start a normal consumer on the local broker
       StubConnection connection1 = createConnection();
       ConnectionInfo connectionInfo1 = createConnectionInfo();
@@ -94,21 +154,28 @@ public class FanoutTransportBrokerTest extends NetworkTestSupport {
       // Send the message using the fail over publisher.
       connection3.request(createMessage(producerInfo3, destination, deliveryMode));
 
-      assertNotNull(receiveMessage(connection1));
+      Assert.assertNotNull(receiveMessage(connection1));
       assertNoMessagesLeft(connection1);
 
-      assertNotNull(receiveMessage(connection2));
+      Assert.assertNotNull(receiveMessage(connection2));
       assertNoMessagesLeft(connection2);
 
    }
 
+   /*
    public void initCombosForTestPublisherWaitsForServerToBeUp() {
       addCombinationValues("deliveryMode", new Object[]{Integer.valueOf(DeliveryMode.NON_PERSISTENT), Integer.valueOf(DeliveryMode.PERSISTENT)});
       addCombinationValues("destination", new Object[]{new ActiveMQTopic("TEST")});
    }
+*/
 
+   @Test
    public void testPublisherWaitsForServerToBeUp() throws Exception {
 
+      if (name.getMethodName().contains("test-0") || name.getMethodName().contains("test-2")) {
+         System.out.println("Discarding invalid test: " + name.getMethodName());
+         return;
+      }
       // Start a normal consumer on the local broker
       StubConnection connection1 = createConnection();
       ConnectionInfo connectionInfo1 = createConnectionInfo();
@@ -140,19 +207,18 @@ public class FanoutTransportBrokerTest extends NetworkTestSupport {
       // Send the message using the fail over publisher.
       connection3.request(createMessage(producerInfo3, destination, deliveryMode));
 
-      assertNotNull(receiveMessage(connection1));
+      Assert.assertNotNull(receiveMessage(connection1));
       assertNoMessagesLeft(connection1);
 
-      assertNotNull(receiveMessage(connection2));
+      Assert.assertNotNull(receiveMessage(connection2));
       assertNoMessagesLeft(connection2);
 
       final CountDownLatch publishDone = new CountDownLatch(1);
 
       // The MockTransport is on the remote connection.
       // Slip in a new transport filter after the MockTransport
-      MockTransport mt = connection3.getTransport().narrow(MockTransport.class);
+      MockTransport mt = (MockTransport) connection3.getTransport().narrow(MockTransport.class);
       mt.install(new TransportFilter(mt.getNext()) {
-         @Override
          public void oneway(Object command) throws IOException {
             LOG.info("Dropping: " + command);
             // just eat it! to simulate a recent failure.
@@ -161,7 +227,6 @@ public class FanoutTransportBrokerTest extends NetworkTestSupport {
 
       // Send a message (async) as this will block
       new Thread() {
-         @Override
          public void run() {
             // Send the message using the fail over publisher.
             try {
@@ -175,7 +240,7 @@ public class FanoutTransportBrokerTest extends NetworkTestSupport {
       }.start();
 
       // Assert that we block:
-      assertFalse(publishDone.await(3, TimeUnit.SECONDS));
+      Assert.assertFalse(publishDone.await(3, TimeUnit.SECONDS));
 
       // Restart the remote server. State should be re-played and the publish
       // should continue.
@@ -184,26 +249,127 @@ public class FanoutTransportBrokerTest extends NetworkTestSupport {
       LOG.info("Broker Restarted");
 
       // This should reconnect, and resend
-      assertTrue(publishDone.await(20, TimeUnit.SECONDS));
+      Assert.assertTrue(publishDone.await(20, TimeUnit.SECONDS));
 
    }
 
-   @Override
    protected String getLocalURI() {
       return "tcp://localhost:61616";
    }
 
-   @Override
    protected String getRemoteURI() {
       return "tcp://localhost:61617";
    }
 
    protected StubConnection createFanoutConnection() throws Exception {
-      URI fanoutURI = new URI("fanout://(static://(" + connector.getServer().getConnectURI() + "," + "mock://" + remoteConnector.getServer().getConnectURI() + "))?fanOutQueues=true");
+      URI fanoutURI = new URI("fanout://(static://(" + newURI(0) + "," + "mock://" + newURI(1) + "))?fanOutQueues=true");
       Transport transport = TransportFactory.connect(fanoutURI);
       StubConnection connection = new StubConnection(transport);
       connections.add(connection);
       return connection;
    }
 
+
+   protected StubConnection createConnection() throws Exception {
+      Transport transport = TransportFactory.connect(new URI(newURI(0)));
+      StubConnection connection = new StubConnection(transport);
+      connections.add(connection);
+      return connection;
+   }
+
+   protected StubConnection createRemoteConnection() throws Exception {
+      Transport transport = TransportFactory.connect(new URI(newURI(1)));
+      StubConnection connection = new StubConnection(transport);
+      connections.add(connection);
+      return connection;
+   }
+
+   protected ConnectionInfo createConnectionInfo() throws Exception {
+      ConnectionInfo info = new ConnectionInfo();
+      info.setConnectionId(new ConnectionId("connection:" + (++idGenerator)));
+      info.setClientId(info.getConnectionId().getValue());
+      return info;
+   }
+
+   protected SessionInfo createSessionInfo(ConnectionInfo connectionInfo) throws Exception {
+      SessionInfo info = new SessionInfo(connectionInfo, ++idGenerator);
+      return info;
+   }
+
+   protected ConsumerInfo createConsumerInfo(SessionInfo sessionInfo,
+                                             ActiveMQDestination destination) throws Exception {
+      ConsumerInfo info = new ConsumerInfo(sessionInfo, ++idGenerator);
+      info.setBrowser(false);
+      info.setDestination(destination);
+      info.setPrefetchSize(1000);
+      info.setDispatchAsync(false);
+      return info;
+   }
+
+   protected ProducerInfo createProducerInfo(SessionInfo sessionInfo) throws Exception {
+      ProducerInfo info = new ProducerInfo(sessionInfo, ++idGenerator);
+      return info;
+   }
+
+   protected Message createMessage(ProducerInfo producerInfo, ActiveMQDestination destination, int deliveryMode) {
+      Message message = createMessage(producerInfo, destination);
+      message.setPersistent(deliveryMode == DeliveryMode.PERSISTENT);
+      return message;
+   }
+
+   protected Message createMessage(ProducerInfo producerInfo, ActiveMQDestination destination) {
+      ActiveMQTextMessage message = new ActiveMQTextMessage();
+      message.setMessageId(new MessageId(producerInfo, ++msgIdGenerator));
+      message.setDestination(destination);
+      message.setPersistent(false);
+      try {
+         message.setText("Test Message Payload.");
+      }
+      catch (MessageNotWriteableException e) {
+      }
+      return message;
+   }
+
+   public Message receiveMessage(StubConnection connection) throws InterruptedException {
+      return receiveMessage(connection, maxWait);
+   }
+
+   public Message receiveMessage(StubConnection connection, long timeout) throws InterruptedException {
+      while (true) {
+         Object o = connection.getDispatchQueue().poll(timeout, TimeUnit.MILLISECONDS);
+
+         if (o == null) {
+            return null;
+         }
+         if (o instanceof MessageDispatch) {
+
+            MessageDispatch dispatch = (MessageDispatch) o;
+            if (dispatch.getMessage() == null) {
+               return null;
+            }
+            dispatch.setMessage(dispatch.getMessage().copy());
+            dispatch.getMessage().setRedeliveryCounter(dispatch.getRedeliveryCounter());
+            return dispatch.getMessage();
+         }
+      }
+   }
+
+   protected void assertNoMessagesLeft(StubConnection connection) throws InterruptedException {
+      long wait = FAST_NO_MESSAGE_LEFT_ASSERT ? 0 : maxWait;
+      while (true) {
+         Object o = connection.getDispatchQueue().poll(wait, TimeUnit.MILLISECONDS);
+         if (o == null) {
+            return;
+         }
+         if (o instanceof MessageDispatch && ((MessageDispatch) o).getMessage() != null) {
+            Assert.fail("Received a message: " + ((MessageDispatch) o).getMessage().getMessageId());
+         }
+      }
+   }
+   protected void restartRemoteBroker() throws Exception {
+      remoteServer.stop();
+      Thread.sleep(2000);
+      remoteServer.start();
+   }
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/InactivityMonitorTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/InactivityMonitorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/InactivityMonitorTest.java
index 619190f..01f6963 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/InactivityMonitorTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/InactivityMonitorTest.java
@@ -173,11 +173,8 @@ public class InactivityMonitorTest extends CombinationTestSupport implements Tra
    }
 
    public void testClientHang() throws Exception {
-
-      //
       // Manually create a client transport so that it does not send KeepAlive
-      // packets.
-      // this should simulate a client hang.
+      // packets.  this should simulate a client hang.
       clientTransport = new TcpTransport(new OpenWireFormat(), SocketFactory.getDefault(), new URI("tcp://localhost:" + serverPort), null);
       clientTransport.setTransportListener(new TransportListener() {
          @Override
@@ -205,9 +202,10 @@ public class InactivityMonitorTest extends CombinationTestSupport implements Tra
          public void transportResumed() {
          }
       });
+
       clientTransport.start();
       WireFormatInfo info = new WireFormatInfo();
-      info.setVersion(OpenWireFormat.DEFAULT_VERSION);
+      info.setVersion(OpenWireFormat.DEFAULT_LEGACY_VERSION);
       info.setMaxInactivityDuration(1000);
       clientTransport.oneway(info);
 
@@ -242,19 +240,17 @@ public class InactivityMonitorTest extends CombinationTestSupport implements Tra
     * @throws URISyntaxException
     */
    public void initCombosForTestNoClientHangWithServerBlock() throws Exception {
-
       startClient();
 
-      addCombinationValues("clientInactivityLimit", new Object[]{Long.valueOf(1000)});
-      addCombinationValues("serverInactivityLimit", new Object[]{Long.valueOf(1000)});
-      addCombinationValues("serverRunOnCommand", new Object[]{new Runnable() {
+      addCombinationValues("clientInactivityLimit", new Object[] {Long.valueOf(1000)});
+      addCombinationValues("serverInactivityLimit", new Object[] {Long.valueOf(1000)});
+      addCombinationValues("serverRunOnCommand", new Object[] {new Runnable() {
          @Override
          public void run() {
             try {
                LOG.info("Sleeping");
                Thread.sleep(4000);
-            }
-            catch (InterruptedException e) {
+            } catch (InterruptedException e) {
             }
          }
       }});
@@ -272,5 +268,4 @@ public class InactivityMonitorTest extends CombinationTestSupport implements Tra
       assertEquals(0, clientErrorCount.get());
       assertEquals(0, serverErrorCount.get());
    }
-
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java
index 9ae82ac..9d3c347 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java
@@ -23,7 +23,6 @@ import junit.framework.Test;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.broker.BrokerService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -183,15 +182,6 @@ public class TransportUriTest extends EmbeddedBrokerTestSupport {
       super.tearDown();
    }
 
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      BrokerService answer = new BrokerService();
-      answer.setUseJmx(false);
-      answer.setPersistent(isPersistent());
-      answer.addConnector(bindAddress);
-      return answer;
-   }
-
    public static Test suite() {
       return suite(TransportUriTest.class);
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportBrokerNameTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportBrokerNameTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportBrokerNameTest.java
deleted file mode 100644
index 3791848..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportBrokerNameTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * 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.vm;
-
-import java.net.URI;
-
-import javax.jms.Connection;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerRegistry;
-
-public class VMTransportBrokerNameTest extends TestCase {
-
-   private static final String MY_BROKER = "myBroker";
-   final String vmUrl = "vm:(broker:(tcp://localhost:61616)/" + MY_BROKER + "?persistent=false)";
-
-   public void testBrokerName() throws Exception {
-      ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(new URI(vmUrl));
-      ActiveMQConnection c1 = (ActiveMQConnection) cf.createConnection();
-      assertTrue("Transport has name in it: " + c1.getTransport(), c1.getTransport().toString().contains(MY_BROKER));
-
-      // verify Broker is there with name
-      ActiveMQConnectionFactory cfbyName = new ActiveMQConnectionFactory(new URI("vm://" + MY_BROKER + "?create=false"));
-      Connection c2 = cfbyName.createConnection();
-
-      assertNotNull(BrokerRegistry.getInstance().lookup(MY_BROKER));
-      assertEquals(BrokerRegistry.getInstance().findFirst().getBrokerName(), MY_BROKER);
-      assertEquals(BrokerRegistry.getInstance().getBrokers().size(), 1);
-
-      c1.close();
-      c2.close();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportBrokerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportBrokerTest.java
deleted file mode 100644
index 52e4b88..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportBrokerTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 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.vm;
-
-import junit.framework.Test;
-
-import org.apache.activemq.transport.TransportBrokerTestSupport;
-
-public class VMTransportBrokerTest extends TransportBrokerTestSupport {
-
-   @Override
-   protected String getBindLocation() {
-      return "vm://localhost";
-   }
-
-   public static Test suite() {
-      return suite(VMTransportBrokerTest.class);
-   }
-
-   public static void main(String[] args) {
-      junit.textui.TestRunner.run(suite());
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportEmbeddedBrokerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportEmbeddedBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportEmbeddedBrokerTest.java
deleted file mode 100644
index dbc7f29..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportEmbeddedBrokerTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * 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.vm;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import javax.jms.DeliveryMode;
-
-import org.apache.activemq.broker.BrokerRegistry;
-import org.apache.activemq.broker.BrokerTestSupport;
-import org.apache.activemq.broker.StubConnection;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ConnectionInfo;
-import org.apache.activemq.command.ConsumerInfo;
-import org.apache.activemq.command.Message;
-import org.apache.activemq.command.ProducerInfo;
-import org.apache.activemq.command.SessionInfo;
-import org.apache.activemq.transport.Transport;
-import org.apache.activemq.transport.TransportFactory;
-import org.apache.activemq.util.IOExceptionSupport;
-
-/**
- * Used to see if the VM transport starts an embedded broker on demand.
- */
-public class VMTransportEmbeddedBrokerTest extends BrokerTestSupport {
-
-   public static void main(String[] args) {
-      junit.textui.TestRunner.run(VMTransportEmbeddedBrokerTest.class);
-   }
-
-   public void testConsumerPrefetchAtOne() throws Exception {
-
-      // Make sure the broker is created due to the connection being started.
-      assertNull(BrokerRegistry.getInstance().lookup("localhost"));
-      StubConnection connection = createConnection();
-      assertNotNull(BrokerRegistry.getInstance().lookup("localhost"));
-
-      // Start a producer and consumer
-      ConnectionInfo connectionInfo = createConnectionInfo();
-      SessionInfo sessionInfo = createSessionInfo(connectionInfo);
-      ProducerInfo producerInfo = createProducerInfo(sessionInfo);
-      connection.send(connectionInfo);
-      connection.send(sessionInfo);
-      connection.send(producerInfo);
-
-      ActiveMQQueue destination = new ActiveMQQueue("TEST");
-
-      ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, destination);
-      consumerInfo.setPrefetchSize(1);
-      connection.send(consumerInfo);
-
-      // Send 2 messages to the broker.
-      connection.send(createMessage(producerInfo, destination, DeliveryMode.NON_PERSISTENT));
-      connection.send(createMessage(producerInfo, destination, DeliveryMode.NON_PERSISTENT));
-
-      // Make sure only 1 message was delivered.
-      Message m = receiveMessage(connection);
-      assertNotNull(m);
-      assertNoMessagesLeft(connection);
-
-      // Make sure the broker is shutdown when the connection is stopped.
-      assertNotNull(BrokerRegistry.getInstance().lookup("localhost"));
-      connection.stop();
-      assertNull(BrokerRegistry.getInstance().lookup("localhost"));
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      // Don't call super since it manually starts up a broker.
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      // Don't call super since it manually tears down a broker.
-   }
-
-   @Override
-   protected StubConnection createConnection() throws Exception {
-      try {
-         Transport transport = TransportFactory.connect(new URI("vm://localhost?broker.persistent=false"));
-         StubConnection connection = new StubConnection(transport);
-         return connection;
-      }
-      catch (URISyntaxException e) {
-         throw IOExceptionSupport.create(e);
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportThreadSafeTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportThreadSafeTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportThreadSafeTest.java
deleted file mode 100644
index 2268048..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportThreadSafeTest.java
+++ /dev/null
@@ -1,937 +0,0 @@
-/**
- * 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.vm;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.Queue;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.activemq.command.BaseCommand;
-import org.apache.activemq.command.ExceptionResponse;
-import org.apache.activemq.command.Response;
-import org.apache.activemq.command.ShutdownInfo;
-import org.apache.activemq.state.CommandVisitor;
-import org.apache.activemq.transport.FutureResponse;
-import org.apache.activemq.transport.MutexTransport;
-import org.apache.activemq.transport.ResponseCallback;
-import org.apache.activemq.transport.ResponseCorrelator;
-import org.apache.activemq.transport.Transport;
-import org.apache.activemq.transport.TransportDisposedIOException;
-import org.apache.activemq.transport.TransportListener;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class VMTransportThreadSafeTest {
-
-   private static final Logger LOG = LoggerFactory.getLogger(VMTransportThreadSafeTest.class);
-
-   private final static String location1 = "vm://transport1";
-   private final static String location2 = "vm://transport2";
-
-   private final ConcurrentLinkedQueue<DummyCommand> localReceived = new ConcurrentLinkedQueue<>();
-   private final ConcurrentLinkedQueue<DummyCommand> remoteReceived = new ConcurrentLinkedQueue<>();
-
-   private class DummyCommand extends BaseCommand {
-
-      public final int sequenceId;
-
-      public DummyCommand() {
-         this.sequenceId = 0;
-      }
-
-      public DummyCommand(int id) {
-         this.sequenceId = id;
-      }
-
-      @Override
-      public Response visit(CommandVisitor visitor) throws Exception {
-         return null;
-      }
-
-      @Override
-      public byte getDataStructureType() {
-         return 42;
-      }
-   }
-
-   private class VMTestTransportListener implements TransportListener {
-
-      protected final Queue<DummyCommand> received;
-
-      public boolean shutdownReceived = false;
-
-      public VMTestTransportListener(Queue<DummyCommand> receiveQueue) {
-         this.received = receiveQueue;
-      }
-
-      @Override
-      public void onCommand(Object command) {
-
-         if (command instanceof ShutdownInfo) {
-            shutdownReceived = true;
-         }
-         else {
-            received.add((DummyCommand) command);
-         }
-      }
-
-      @Override
-      public void onException(IOException error) {
-      }
-
-      @Override
-      public void transportInterupted() {
-      }
-
-      @Override
-      public void transportResumed() {
-      }
-   }
-
-   private class VMResponderTransportListener implements TransportListener {
-
-      protected final Queue<DummyCommand> received;
-
-      private final Transport peer;
-
-      public VMResponderTransportListener(Queue<DummyCommand> receiveQueue, Transport peer) {
-         this.received = receiveQueue;
-         this.peer = peer;
-      }
-
-      @Override
-      public void onCommand(Object command) {
-
-         if (command instanceof ShutdownInfo) {
-            return;
-         }
-         else {
-            received.add((DummyCommand) command);
-
-            if (peer != null) {
-               try {
-                  peer.oneway(command);
-               }
-               catch (IOException e) {
-               }
-            }
-         }
-      }
-
-      @Override
-      public void onException(IOException error) {
-      }
-
-      @Override
-      public void transportInterupted() {
-      }
-
-      @Override
-      public void transportResumed() {
-      }
-   }
-
-   private class SlowVMTestTransportListener extends VMTestTransportListener {
-
-      private final TimeUnit delayUnit;
-      private final long delay;
-
-      public SlowVMTestTransportListener(Queue<DummyCommand> receiveQueue) {
-         this(receiveQueue, 10, TimeUnit.MILLISECONDS);
-      }
-
-      public SlowVMTestTransportListener(Queue<DummyCommand> receiveQueue, long delay, TimeUnit delayUnit) {
-         super(receiveQueue);
-
-         this.delay = delay;
-         this.delayUnit = delayUnit;
-      }
-
-      @Override
-      public void onCommand(Object command) {
-         super.onCommand(command);
-         try {
-            delayUnit.sleep(delay);
-         }
-         catch (InterruptedException e) {
-         }
-      }
-   }
-
-   private class GatedVMTestTransportListener extends VMTestTransportListener {
-
-      private final CountDownLatch gate;
-
-      public GatedVMTestTransportListener(Queue<DummyCommand> receiveQueue) {
-         this(receiveQueue, new CountDownLatch(1));
-      }
-
-      public GatedVMTestTransportListener(Queue<DummyCommand> receiveQueue, CountDownLatch gate) {
-         super(receiveQueue);
-
-         this.gate = gate;
-      }
-
-      @Override
-      public void onCommand(Object command) {
-         super.onCommand(command);
-         try {
-            gate.await();
-         }
-         catch (InterruptedException e) {
-         }
-      }
-   }
-
-   private void assertMessageAreOrdered(ConcurrentLinkedQueue<DummyCommand> queue) {
-      int lastSequenceId = 0;
-      for (DummyCommand command : queue) {
-         int id = command.sequenceId;
-         assertTrue("Last id: " + lastSequenceId + " should be less than current id: " + id, id > lastSequenceId);
-      }
-   }
-
-   @Before
-   public void setUp() throws Exception {
-      localReceived.clear();
-      remoteReceived.clear();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-   }
-
-   @Test(timeout = 60000)
-   public void testStartWthoutListenerIOE() throws Exception {
-
-      final VMTransport local = new VMTransport(new URI(location1));
-      final VMTransport remote = new VMTransport(new URI(location2));
-
-      local.setPeer(remote);
-      remote.setPeer(local);
-
-      remote.setTransportListener(new VMTestTransportListener(localReceived));
-
-      try {
-         local.start();
-         fail("Should have thrown an IOExcoption");
-      }
-      catch (IOException e) {
-      }
-   }
-
-   @Test(timeout = 60000)
-   public void testOnewayOnStoppedTransportTDE() throws Exception {
-
-      final VMTransport local = new VMTransport(new URI(location1));
-      final VMTransport remote = new VMTransport(new URI(location2));
-
-      local.setPeer(remote);
-      remote.setPeer(local);
-
-      local.setTransportListener(new VMTestTransportListener(localReceived));
-      remote.setTransportListener(new VMTestTransportListener(remoteReceived));
-
-      local.start();
-      local.stop();
-
-      try {
-         local.oneway(new DummyCommand());
-         fail("Should have thrown a TransportDisposedException");
-      }
-      catch (TransportDisposedIOException e) {
-      }
-   }
-
-   @Test(timeout = 60000)
-   public void testStopSendsShutdownToPeer() throws Exception {
-
-      final VMTransport local = new VMTransport(new URI(location1));
-      final VMTransport remote = new VMTransport(new URI(location2));
-
-      local.setPeer(remote);
-      remote.setPeer(local);
-
-      final VMTestTransportListener remoteListener = new VMTestTransportListener(remoteReceived);
-
-      local.setTransportListener(new VMTestTransportListener(localReceived));
-      remote.setTransportListener(remoteListener);
-
-      local.start();
-      local.stop();
-
-      assertTrue(Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return remoteListener.shutdownReceived;
-         }
-      }));
-   }
-
-   @Test(timeout = 60000)
-   public void testRemoteStopSendsExceptionToPendingRequests() throws Exception {
-
-      final VMTransport local = new VMTransport(new URI(location1));
-      final VMTransport remote = new VMTransport(new URI(location2));
-
-      local.setPeer(remote);
-      remote.setPeer(local);
-
-      final VMTestTransportListener remoteListener = new VMTestTransportListener(remoteReceived);
-      remote.setTransportListener(remoteListener);
-      remote.start();
-
-      final Response[] answer = new Response[1];
-      ResponseCorrelator responseCorrelator = new ResponseCorrelator(local);
-      responseCorrelator.setTransportListener(new VMTestTransportListener(localReceived));
-      responseCorrelator.start();
-      responseCorrelator.asyncRequest(new DummyCommand(), new ResponseCallback() {
-         @Override
-         public void onCompletion(FutureResponse resp) {
-            try {
-               answer[0] = resp.getResult();
-            }
-            catch (IOException e) {
-               e.printStackTrace();
-            }
-         }
-      });
-
-      // simulate broker stop
-      remote.stop();
-
-      assertTrue(Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            LOG.info("answer: " + answer[0]);
-            return answer[0] instanceof ExceptionResponse && ((ExceptionResponse) answer[0]).getException() instanceof TransportDisposedIOException;
-         }
-      }));
-
-      local.stop();
-   }
-
-   @Test(timeout = 60000)
-   public void testMultipleStartsAndStops() throws Exception {
-
-      final VMTransport local = new VMTransport(new URI(location1));
-      final VMTransport remote = new VMTransport(new URI(location2));
-
-      local.setPeer(remote);
-      remote.setPeer(local);
-
-      local.setTransportListener(new VMTestTransportListener(localReceived));
-      remote.setTransportListener(new VMTestTransportListener(remoteReceived));
-
-      local.start();
-      remote.start();
-
-      local.start();
-      remote.start();
-
-      for (int i = 0; i < 100; ++i) {
-         local.oneway(new DummyCommand());
-      }
-
-      for (int i = 0; i < 100; ++i) {
-         remote.oneway(new DummyCommand());
-      }
-
-      local.start();
-      remote.start();
-
-      assertTrue(Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return remoteReceived.size() == 100;
-         }
-      }));
-
-      assertTrue(Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return localReceived.size() == 100;
-         }
-      }));
-
-      local.stop();
-      local.stop();
-      remote.stop();
-      remote.stop();
-   }
-
-   @Test(timeout = 60000)
-   public void testStartWithPeerNotStartedEnqueusCommandsNonAsync() throws Exception {
-      doTestStartWithPeerNotStartedEnqueusCommands(false);
-   }
-
-   private void doTestStartWithPeerNotStartedEnqueusCommands(boolean async) throws Exception {
-
-      final VMTransport local = new VMTransport(new URI(location1));
-      final VMTransport remote = new VMTransport(new URI(location2));
-
-      remote.setAsync(async);
-
-      local.setPeer(remote);
-      remote.setPeer(local);
-
-      local.setTransportListener(new VMTestTransportListener(localReceived));
-      remote.setTransportListener(new VMTestTransportListener(remoteReceived));
-
-      local.start();
-
-      for (int i = 0; i < 100; ++i) {
-         local.oneway(new DummyCommand());
-      }
-
-      assertEquals(100, remote.getMessageQueue().size());
-
-      remote.start();
-
-      assertTrue(Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return remoteReceived.size() == 100;
-         }
-      }));
-
-      local.stop();
-      remote.stop();
-   }
-
-   @Test(timeout = 60000)
-   public void testBlockedOnewayEnqeueAandStopTransportAsync() throws Exception {
-      doTestBlockedOnewayEnqeueAandStopTransport(true);
-   }
-
-   @Test(timeout = 60000)
-   public void testBlockedOnewayEnqeueAandStopTransportNonAsync() throws Exception {
-      doTestBlockedOnewayEnqeueAandStopTransport(false);
-   }
-
-   private void doTestBlockedOnewayEnqeueAandStopTransport(boolean async) throws Exception {
-
-      final VMTransport local = new VMTransport(new URI(location1));
-      final VMTransport remote = new VMTransport(new URI(location2));
-
-      final AtomicInteger sequenceId = new AtomicInteger();
-
-      remote.setAsync(async);
-      remote.setAsyncQueueDepth(99);
-
-      local.setPeer(remote);
-      remote.setPeer(local);
-
-      local.setTransportListener(new VMTestTransportListener(localReceived));
-      remote.setTransportListener(new VMTestTransportListener(remoteReceived));
-
-      local.start();
-
-      Thread t = new Thread(new Runnable() {
-
-         @Override
-         public void run() {
-            for (int i = 0; i < 100; ++i) {
-               try {
-                  local.oneway(new DummyCommand(sequenceId.incrementAndGet()));
-               }
-               catch (Exception e) {
-               }
-            }
-
-         }
-      });
-      t.start();
-
-      LOG.debug("Started async delivery, wait for remote's queue to fill up");
-
-      assertTrue(Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return remote.getMessageQueue().remainingCapacity() == 0;
-         }
-      }));
-
-      LOG.debug("Remote messageQ is full, start it and stop all");
-
-      remote.start();
-      local.stop();
-      remote.stop();
-   }
-
-   @Test(timeout = 60000)
-   public void testBlockedOnewayEnqeueWhileStartedDetectsStop() throws Exception {
-      final VMTransport local = new VMTransport(new URI(location1));
-      final VMTransport remote = new VMTransport(new URI(location2));
-
-      final AtomicInteger sequenceId = new AtomicInteger();
-
-      remote.setAsync(true);
-      remote.setAsyncQueueDepth(2);
-
-      local.setPeer(remote);
-      remote.setPeer(local);
-
-      local.setTransportListener(new VMTestTransportListener(localReceived));
-      remote.setTransportListener(new GatedVMTestTransportListener(remoteReceived));
-
-      local.start();
-      remote.start();
-
-      Thread t = new Thread(new Runnable() {
-
-         @Override
-         public void run() {
-            for (int i = 0; i < 3; ++i) {
-               try {
-                  local.oneway(new DummyCommand(sequenceId.incrementAndGet()));
-               }
-               catch (Exception e) {
-               }
-            }
-
-         }
-      });
-      t.start();
-
-      LOG.debug("Started async delivery, wait for remote's queue to fill up");
-      assertTrue(Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return remote.getMessageQueue().remainingCapacity() == 0;
-         }
-      }));
-
-      LOG.debug("Starting async gate open.");
-      Thread gateman = new Thread(new Runnable() {
-         @Override
-         public void run() {
-            try {
-               Thread.sleep(100);
-            }
-            catch (InterruptedException e) {
-            }
-            ((GatedVMTestTransportListener) remote.getTransportListener()).gate.countDown();
-         }
-      });
-      gateman.start();
-
-      remote.stop();
-      local.stop();
-
-      assertEquals(1, remoteReceived.size());
-      assertMessageAreOrdered(remoteReceived);
-   }
-
-   @Test(timeout = 60000)
-   public void testStopWhileStartingAsyncWithNoAsyncLimit() throws Exception {
-      // In the async case the iterate method should see that we are stopping and
-      // drop out before we dispatch all the messages but it should get at least 49 since
-      // the stop thread waits 500 mills and the listener is waiting 10 mills on each receive.
-      doTestStopWhileStartingWithNoAsyncLimit(true, 49);
-   }
-
-   @Test(timeout = 60000)
-   public void testStopWhileStartingNonAsyncWithNoAsyncLimit() throws Exception {
-      // In the non-async case the start dispatches all messages up front and then continues on
-      doTestStopWhileStartingWithNoAsyncLimit(false, 100);
-   }
-
-   private void doTestStopWhileStartingWithNoAsyncLimit(boolean async, final int expect) throws Exception {
-
-      final VMTransport local = new VMTransport(new URI(location1));
-      final VMTransport remote = new VMTransport(new URI(location2));
-
-      remote.setAsync(async);
-
-      local.setPeer(remote);
-      remote.setPeer(local);
-
-      local.setTransportListener(new VMTestTransportListener(localReceived));
-      remote.setTransportListener(new SlowVMTestTransportListener(remoteReceived));
-
-      local.start();
-
-      for (int i = 0; i < 100; ++i) {
-         local.oneway(new DummyCommand(i));
-      }
-
-      Thread t = new Thread(new Runnable() {
-
-         @Override
-         public void run() {
-            try {
-               Thread.sleep(1000);
-               remote.stop();
-            }
-            catch (Exception e) {
-            }
-         }
-      });
-
-      remote.start();
-
-      t.start();
-
-      assertTrue("Remote should receive: " + expect + ", commands but got: " + remoteReceived.size(), Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return remoteReceived.size() >= expect;
-         }
-      }));
-
-      LOG.debug("Remote listener received " + remoteReceived.size() + " messages");
-
-      local.stop();
-
-      assertTrue("Remote transport never was disposed.", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return remote.isDisposed();
-         }
-      }));
-   }
-
-   @Test(timeout = 120000)
-   public void TestTwoWayMessageThroughPutSync() throws Exception {
-
-      long totalTimes = 0;
-      final long executions = 20;
-
-      for (int i = 0; i < 20; ++i) {
-         totalTimes += doTestTwoWayMessageThroughPut(false);
-      }
-
-      LOG.info("Total time of one way sync send throughput test: " + (totalTimes / executions) + "ms");
-   }
-
-   @Test(timeout = 120000)
-   public void TestTwoWayMessageThroughPutAsnyc() throws Exception {
-
-      long totalTimes = 0;
-      final long executions = 50;
-
-      for (int i = 0; i < executions; ++i) {
-         totalTimes += doTestTwoWayMessageThroughPut(false);
-      }
-
-      LOG.info("Total time of one way async send throughput test: " + (totalTimes / executions) + "ms");
-   }
-
-   private long doTestTwoWayMessageThroughPut(boolean async) throws Exception {
-
-      final VMTransport local = new VMTransport(new URI(location1));
-      final VMTransport remote = new VMTransport(new URI(location2));
-
-      final AtomicInteger sequenceId = new AtomicInteger();
-
-      remote.setAsync(async);
-
-      local.setPeer(remote);
-      remote.setPeer(local);
-
-      local.setTransportListener(new VMTestTransportListener(localReceived));
-      remote.setTransportListener(new VMTestTransportListener(remoteReceived));
-
-      final int messageCount = 200000;
-
-      local.start();
-      remote.start();
-
-      long startTime = System.currentTimeMillis();
-
-      Thread localSend = new Thread(new Runnable() {
-
-         @Override
-         public void run() {
-            for (int i = 0; i < messageCount; ++i) {
-               try {
-                  local.oneway(new DummyCommand(sequenceId.incrementAndGet()));
-               }
-               catch (Exception e) {
-               }
-            }
-
-         }
-      });
-
-      Thread remoteSend = new Thread(new Runnable() {
-
-         @Override
-         public void run() {
-            for (int i = 0; i < messageCount; ++i) {
-               try {
-                  remote.oneway(new DummyCommand(sequenceId.incrementAndGet()));
-               }
-               catch (Exception e) {
-               }
-            }
-
-         }
-      });
-
-      localSend.start();
-      remoteSend.start();
-
-      // Wait for both to finish and then check that each side go the correct amount
-      localSend.join();
-      remoteSend.join();
-
-      long endTime = System.currentTimeMillis();
-
-      assertTrue(Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return remoteReceived.size() == messageCount;
-         }
-      }));
-
-      assertTrue(Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return localReceived.size() == messageCount;
-         }
-      }));
-
-      LOG.debug("All messages sent,stop all");
-
-      local.stop();
-      remote.stop();
-
-      localReceived.clear();
-      remoteReceived.clear();
-
-      return endTime - startTime;
-   }
-
-   @Test(timeout = 120000)
-   public void TestOneWayMessageThroughPutSync() throws Exception {
-
-      long totalTimes = 0;
-      final long executions = 30;
-
-      for (int i = 0; i < executions; ++i) {
-         totalTimes += doTestOneWayMessageThroughPut(false);
-      }
-
-      LOG.info("Total time of one way sync send throughput test: " + (totalTimes / executions) + "ms");
-   }
-
-   @Test(timeout = 120000)
-   public void TestOneWayMessageThroughPutAsnyc() throws Exception {
-
-      long totalTimes = 0;
-      final long executions = 20;
-
-      for (int i = 0; i < 20; ++i) {
-         totalTimes += doTestOneWayMessageThroughPut(true);
-      }
-
-      LOG.info("Total time of one way async send throughput test: " + (totalTimes / executions) + "ms");
-   }
-
-   private long doTestOneWayMessageThroughPut(boolean async) throws Exception {
-
-      final VMTransport local = new VMTransport(new URI(location1));
-      final VMTransport remote = new VMTransport(new URI(location2));
-
-      final AtomicInteger sequenceId = new AtomicInteger();
-
-      remote.setAsync(async);
-
-      local.setPeer(remote);
-      remote.setPeer(local);
-
-      local.setTransportListener(new VMTestTransportListener(localReceived));
-      remote.setTransportListener(new VMTestTransportListener(remoteReceived));
-
-      final int messageCount = 100000;
-
-      local.start();
-      remote.start();
-
-      long startTime = System.currentTimeMillis();
-
-      Thread localSend = new Thread(new Runnable() {
-
-         @Override
-         public void run() {
-            for (int i = 0; i < messageCount; ++i) {
-               try {
-                  local.oneway(new DummyCommand(sequenceId.incrementAndGet()));
-               }
-               catch (Exception e) {
-               }
-            }
-
-         }
-      });
-
-      localSend.start();
-
-      // Wait for both to finish and then check that each side go the correct amount
-      localSend.join();
-
-      long endTime = System.currentTimeMillis();
-
-      assertTrue(Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return remoteReceived.size() == messageCount;
-         }
-      }));
-
-      LOG.debug("All messages sent,stop all");
-
-      local.stop();
-      remote.stop();
-
-      localReceived.clear();
-      remoteReceived.clear();
-
-      return endTime - startTime;
-   }
-
-   @Test(timeout = 120000)
-   public void testTwoWayTrafficWithMutexTransportSync1() throws Exception {
-
-      for (int i = 0; i < 20; ++i) {
-         doTestTwoWayTrafficWithMutexTransport(false, false);
-      }
-   }
-
-   @Test(timeout = 120000)
-   public void testTwoWayTrafficWithMutexTransportSync2() throws Exception {
-
-      for (int i = 0; i < 20; ++i) {
-         doTestTwoWayTrafficWithMutexTransport(true, false);
-      }
-   }
-
-   @Test(timeout = 120000)
-   public void testTwoWayTrafficWithMutexTransportSync3() throws Exception {
-
-      for (int i = 0; i < 20; ++i) {
-         doTestTwoWayTrafficWithMutexTransport(false, true);
-      }
-   }
-
-   @Test(timeout = 120000)
-   public void testTwoWayTrafficWithMutexTransportSync4() throws Exception {
-
-      for (int i = 0; i < 20; ++i) {
-         doTestTwoWayTrafficWithMutexTransport(false, false);
-      }
-   }
-
-   public void doTestTwoWayTrafficWithMutexTransport(boolean localAsync, boolean remoteAsync) throws Exception {
-
-      final VMTransport vmlocal = new VMTransport(new URI(location1));
-      final VMTransport vmremote = new VMTransport(new URI(location2));
-
-      final MutexTransport local = new MutexTransport(vmlocal);
-      final MutexTransport remote = new MutexTransport(vmremote);
-
-      final AtomicInteger sequenceId = new AtomicInteger();
-
-      vmlocal.setAsync(localAsync);
-      vmremote.setAsync(remoteAsync);
-
-      vmlocal.setPeer(vmremote);
-      vmremote.setPeer(vmlocal);
-
-      local.setTransportListener(new VMTestTransportListener(localReceived));
-      remote.setTransportListener(new VMResponderTransportListener(remoteReceived, remote));
-
-      final int messageCount = 200000;
-
-      Thread localSend = new Thread(new Runnable() {
-
-         @Override
-         public void run() {
-            for (int i = 0; i < messageCount; ++i) {
-               try {
-                  local.oneway(new DummyCommand(sequenceId.incrementAndGet()));
-               }
-               catch (Exception e) {
-               }
-            }
-         }
-      });
-
-      Thread remoteSend = new Thread(new Runnable() {
-
-         @Override
-         public void run() {
-            for (int i = 0; i < messageCount; ++i) {
-               try {
-                  remote.oneway(new DummyCommand(sequenceId.incrementAndGet()));
-               }
-               catch (Exception e) {
-               }
-            }
-         }
-      });
-
-      localSend.start();
-      remoteSend.start();
-
-      Thread.sleep(10);
-
-      local.start();
-      remote.start();
-
-      // Wait for both to finish and then check that each side go the correct amount
-      localSend.join();
-      remoteSend.join();
-
-      assertTrue("Remote should have received (" + messageCount + ") but got ()" + remoteReceived.size(), Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return remoteReceived.size() == messageCount;
-         }
-      }));
-
-      assertTrue("Local should have received (" + messageCount * 2 + ") but got ()" + localReceived.size(), Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return localReceived.size() == messageCount * 2;
-         }
-      }));
-
-      LOG.debug("All messages sent,stop all");
-
-      local.stop();
-      remote.stop();
-
-      localReceived.clear();
-      remoteReceived.clear();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportWaitForTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportWaitForTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportWaitForTest.java
deleted file mode 100644
index dd14d67..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VMTransportWaitForTest.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- * 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.vm;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.JMSException;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerRegistry;
-import org.apache.activemq.broker.BrokerService;
-import org.junit.After;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class VMTransportWaitForTest {
-
-   static final Logger LOG = LoggerFactory.getLogger(VMTransportWaitForTest.class);
-
-   private static final int WAIT_TIME = 20000;
-   private static final int SHORT_WAIT_TIME = 5000;
-
-   private static final String VM_BROKER_URI_NO_WAIT = "vm://localhost?broker.persistent=false&create=false";
-
-   private static final String VM_BROKER_URI_WAIT_FOR_START = VM_BROKER_URI_NO_WAIT + "&waitForStart=" + WAIT_TIME;
-
-   private static final String VM_BROKER_URI_SHORT_WAIT_FOR_START = VM_BROKER_URI_NO_WAIT + "&waitForStart=" + SHORT_WAIT_TIME;
-
-   CountDownLatch started = new CountDownLatch(1);
-   CountDownLatch gotConnection = new CountDownLatch(1);
-
-   @After
-   public void after() throws IOException {
-      BrokerRegistry.getInstance().unbind("localhost");
-   }
-
-   @Test(timeout = 90000)
-   public void testWaitFor() throws Exception {
-      try {
-         ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(new URI(VM_BROKER_URI_NO_WAIT));
-         cf.createConnection();
-         fail("expect broker not exist exception");
-      }
-      catch (JMSException expectedOnNoBrokerAndNoCreate) {
-      }
-
-      // spawn a thread that will wait for an embedded broker to start via
-      // vm://..
-      Thread t = new Thread("ClientConnectionThread") {
-         @Override
-         public void run() {
-            try {
-               started.countDown();
-               ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(new URI(VM_BROKER_URI_WAIT_FOR_START));
-               cf.createConnection();
-               gotConnection.countDown();
-            }
-            catch (Exception e) {
-               e.printStackTrace();
-               fail("unexpected exception: " + e);
-            }
-         }
-      };
-      t.start();
-      started.await(20, TimeUnit.SECONDS);
-      Thread.yield();
-      assertFalse("has not got connection", gotConnection.await(2, TimeUnit.SECONDS));
-
-      BrokerService broker = new BrokerService();
-      broker.setPersistent(false);
-      broker.start();
-      assertTrue("has got connection", gotConnection.await(5, TimeUnit.SECONDS));
-      broker.stop();
-   }
-
-   @Test(timeout = 90000)
-   public void testWaitForNoBrokerInRegistry() throws Exception {
-
-      long startTime = System.currentTimeMillis();
-
-      try {
-         ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(new URI(VM_BROKER_URI_SHORT_WAIT_FOR_START));
-         cf.createConnection();
-         fail("expect broker not exist exception");
-      }
-      catch (JMSException expectedOnNoBrokerAndNoCreate) {
-      }
-
-      long endTime = System.currentTimeMillis();
-
-      LOG.info("Total wait time was: {}", endTime - startTime);
-      assertTrue(endTime - startTime >= SHORT_WAIT_TIME - 100);
-   }
-
-   @Test(timeout = 90000)
-   public void testWaitForNotStartedButInRegistry() throws Exception {
-
-      BrokerService broker = new BrokerService();
-      broker.setPersistent(false);
-      BrokerRegistry.getInstance().bind("localhost", broker);
-
-      long startTime = System.currentTimeMillis();
-
-      try {
-         ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(new URI(VM_BROKER_URI_SHORT_WAIT_FOR_START));
-         cf.createConnection();
-         fail("expect broker not exist exception");
-      }
-      catch (JMSException expectedOnNoBrokerAndNoCreate) {
-      }
-
-      long endTime = System.currentTimeMillis();
-
-      LOG.info("Total wait time was: {}", endTime - startTime);
-      assertTrue(endTime - startTime >= SHORT_WAIT_TIME - 100);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java
deleted file mode 100644
index 2b97cff..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/vm/VmTransportNetworkBrokerTest.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/**
- * 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.vm;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.bugs.embedded.ThreadExplorer;
-import org.apache.activemq.network.NetworkConnector;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class VmTransportNetworkBrokerTest extends TestCase {
-
-   private static final Logger LOG = LoggerFactory.getLogger(VmTransportNetworkBrokerTest.class);
-
-   private static final String VM_BROKER_URI = "vm://localhost?create=false";
-
-   CountDownLatch started = new CountDownLatch(1);
-   CountDownLatch gotConnection = new CountDownLatch(1);
-
-   public void testNoThreadLeak() throws Exception {
-
-      // with VMConnection and simple discovery network connector
-      int originalThreadCount = Thread.activeCount();
-      LOG.debug(ThreadExplorer.show("threads at beginning"));
-
-      BrokerService broker = new BrokerService();
-      broker.setDedicatedTaskRunner(true);
-      broker.setPersistent(false);
-      broker.addConnector("tcp://localhost:61616");
-      NetworkConnector networkConnector = broker.addNetworkConnector("static:(tcp://wrongHostname1:61617,tcp://wrongHostname2:61618)?useExponentialBackOff=false");
-      networkConnector.setDuplex(true);
-      broker.start();
-
-      ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(new URI(VM_BROKER_URI));
-      Connection connection = cf.createConnection("system", "manager");
-      connection.start();
-
-      // let it settle
-      TimeUnit.SECONDS.sleep(5);
-
-      int threadCountAfterStart = Thread.activeCount();
-      TimeUnit.SECONDS.sleep(30);
-      int threadCountAfterSleep = Thread.activeCount();
-
-      assertTrue("Threads are leaking: " + ThreadExplorer.show("active sleep") + ", threadCount=" + threadCountAfterStart + " threadCountAfterSleep=" + threadCountAfterSleep, threadCountAfterSleep < threadCountAfterStart + 8);
-
-      connection.close();
-      broker.stop();
-      broker.waitUntilStopped();
-
-      // testNoDanglingThreadsAfterStop with tcp transport
-      broker = new BrokerService();
-      broker.setSchedulerSupport(true);
-      broker.setDedicatedTaskRunner(true);
-      broker.setPersistent(false);
-      broker.addConnector("tcp://localhost:61616?wireFormat.maxInactivityDuration=1000&wireFormat.maxInactivityDurationInitalDelay=1000");
-      broker.start();
-
-      cf = new ActiveMQConnectionFactory("tcp://localhost:61616?wireFormat.maxInactivityDuration=1000&wireFormat.maxInactivityDurationInitalDelay=1000");
-      connection = cf.createConnection("system", "manager");
-      connection.start();
-      connection.close();
-      broker.stop();
-      broker.waitUntilStopped();
-
-      // let it settle
-      TimeUnit.SECONDS.sleep(5);
-
-      // get final threads but filter out any daemon threads that the JVM may have created.
-      Thread[] threads = filterDaemonThreads(ThreadExplorer.listThreads());
-      int threadCountAfterStop = threads.length;
-
-      // lets see the thread counts at INFO level so they are always in the test log
-      LOG.info(ThreadExplorer.show("active after stop"));
-      LOG.info("originalThreadCount=" + originalThreadCount + " threadCountAfterStop=" + threadCountAfterStop);
-
-      assertTrue("Threads are leaking: " +
-                    ThreadExplorer.show("active after stop") +
-                    ". originalThreadCount=" +
-                    originalThreadCount +
-                    " threadCountAfterStop=" +
-                    threadCountAfterStop, threadCountAfterStop <= originalThreadCount);
-   }
-
-   /**
-    * Filters any daemon threads from the thread list.
-    *
-    * Thread counts before and after the test should ideally be equal.
-    * However there is no guarantee that the JVM does not create any
-    * additional threads itself.
-    * E.g. on Mac OSX there is a JVM internal thread called
-    * "Poller SunPKCS11-Darwin" created after the test go started and
-    * under the main thread group.
-    * When debugging tests in Eclipse another so called "Reader" thread
-    * is created by Eclipse.
-    * So we cannot assume that the JVM does not create additional threads
-    * during the test. However for the time being we assume that any such
-    * additionally created threads are daemon threads.
-    *
-    * @param threads - the array of threads to parse
-    * @return a new array with any daemon threads removed
-    */
-   public Thread[] filterDaemonThreads(Thread[] threads) throws Exception {
-
-      List<Thread> threadList = new ArrayList<>(Arrays.asList(threads));
-
-      // Can't use an Iterator as it would raise a
-      // ConcurrentModificationException when trying to remove an element
-      // from the list, so using standard walk through
-      for (int i = 0; i < threadList.size(); i++) {
-
-         Thread thread = threadList.get(i);
-         LOG.debug("Inspecting thread " + thread.getName());
-         if (thread.isDaemon()) {
-            LOG.debug("Removing deamon thread.");
-            threadList.remove(thread);
-            Thread.sleep(100);
-
-         }
-      }
-      LOG.debug("Converting list back to Array");
-      return threadList.toArray(new Thread[0]);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/LockFileTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/LockFileTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/LockFileTest.java
new file mode 100644
index 0000000..03e0d2e
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/util/LockFileTest.java
@@ -0,0 +1,70 @@
+/**
+ * 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.util;
+
+import java.io.File;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class LockFileTest {
+
+    @Test
+    public void testNoDeleteOnUnlockIfNotLocked() throws Exception {
+
+        File lockFile = new File(IOHelper.getDefaultDataDirectory(), "lockToTest1");
+        IOHelper.mkdirs(lockFile.getParentFile());
+        lockFile.createNewFile();
+
+        LockFile underTest = new LockFile(lockFile, true);
+
+        underTest.lock();
+
+        lockFile.delete();
+
+        assertFalse("no longer valid", underTest.keepAlive());
+
+        // a slave gets in
+        lockFile.createNewFile();
+
+        underTest.unlock();
+
+        assertTrue("file still exists after unlock when not locked", lockFile.exists());
+
+    }
+
+    @Test
+    public void testDeleteOnUnlockIfLocked() throws Exception {
+
+        File lockFile = new File(IOHelper.getDefaultDataDirectory(), "lockToTest2");
+        IOHelper.mkdirs(lockFile.getParentFile());
+        lockFile.createNewFile();
+
+        LockFile underTest = new LockFile(lockFile, true);
+
+        underTest.lock();
+
+        assertTrue("valid", underTest.keepAlive());
+
+        underTest.unlock();
+
+        assertFalse("file deleted on unlock", lockFile.exists());
+
+    }
+}


[53/60] [abbrv] activemq-artemis git commit: tests cleanup, added some more debug information

Posted by cl...@apache.org.
tests cleanup, added some more debug information


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/0ceb3648
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/0ceb3648
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/0ceb3648

Branch: refs/heads/refactor-openwire
Commit: 0ceb364875ce7f8b066da43b84245fb95ab92376
Parents: fe6111c
Author: Howard Gao <ho...@gmail.com>
Authored: Mon Feb 29 22:25:17 2016 +0800
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:45:29 2016 -0400

----------------------------------------------------------------------
 .../apache/activemq/broker/BrokerService.java   |  4 +--
 .../artemiswrapper/ArtemisBrokerWrapper.java    |  2 +-
 .../transport/tcp/TcpTransportFactory.java      | 30 ++++++++++++++------
 .../apache/activemq/CombinationTestSupport.java |  2 +-
 ...ExclusiveConsumerStartupDestinationTest.java |  1 +
 .../apache/activemq/ExclusiveConsumerTest.java  |  2 ++
 .../activemq/JmsTransactionTestSupport.java     |  1 +
 ...sTopicSendReceiveWithTwoConnectionsTest.java |  2 ++
 .../transport/tcp/SslBrokerServiceTest.java     |  1 +
 9 files changed, 33 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0ceb3648/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
index cbf41e1..b6acee4 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
@@ -101,7 +101,6 @@ public class BrokerService implements Service {
    private Throwable startException = null;
    private boolean startAsync = false;
    public Set<ConnectorInfo> extraConnectors = new HashSet<>();
-//   public Set<Integer> sslConnectors = new HashSet<>();
 
    private List<TransportConnector> transportConnectors = new ArrayList<>();
    private File dataDirectoryFile;
@@ -591,12 +590,13 @@ public class BrokerService implements Service {
       return port;
    }
 
-   private static boolean checkPort(final int port) {
+   public static boolean checkPort(final int port) {
       ServerSocket ssocket = null;
       try {
          ssocket = new ServerSocket(port);
       }
       catch (Exception e) {
+         LOG.info("port " + port + " is being used.");
          return false;
       }
       finally {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0ceb3648/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
index 83c12db..1a0e297 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
@@ -96,7 +96,7 @@ public class ArtemisBrokerWrapper extends ArtemisBrokerBase {
       }
       if (this.bservice.enableSsl()) {
          //default
-         addServerAcceptor(serverConfig, new BrokerService.ConnectorInfo(61611));
+         addServerAcceptor(serverConfig, new BrokerService.ConnectorInfo(61611, true));
       }
 
       for (BrokerService.ConnectorInfo info : bservice.extraConnectors) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0ceb3648/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
index 5b07f48..c44dd72 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
@@ -31,6 +31,7 @@ import org.apache.activemq.TransportLoggerSupport;
 import org.apache.activemq.artemiswrapper.ArtemisBrokerHelper;
 import org.apache.activemq.broker.BrokerRegistry;
 import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.artemiswrapper.ArtemisBrokerWrapper;
 import org.apache.activemq.openwire.OpenWireFormat;
 import org.apache.activemq.transport.*;
 import org.apache.activemq.util.IOExceptionSupport;
@@ -44,12 +45,7 @@ public class TcpTransportFactory extends TransportFactory {
 
    private static final Logger LOG = LoggerFactory.getLogger(TcpTransportFactory.class);
 
-   private static volatile String brokerService = null;
-
-   //if a broker is started or stopped it should set this.
-   public static void setBrokerName(String name) {
-      brokerService = name;
-   }
+   private static volatile InternalServiceInfo brokerService = null;
 
    @Override
    public Transport doConnect(URI location) throws Exception {
@@ -59,11 +55,11 @@ public class TcpTransportFactory extends TransportFactory {
       URI location1 = URISupport.createRemainingURI(location, Collections.EMPTY_MAP);
 
       LOG.info("deciding whether starting an internal broker: " + brokerService + " flag: " + BrokerService.disableWrapper);
-      if (brokerService == null && !BrokerService.disableWrapper) {
+      if (brokerService == null && !BrokerService.disableWrapper && BrokerService.checkPort(location1.getPort())) {
 
          LOG.info("starting internal broker: " + location1);
          ArtemisBrokerHelper.startArtemisBroker(location1);
-         brokerService = location.toString();
+         brokerService = new InternalServiceInfo(location.toString());
 
          if (brokerId != null) {
             BrokerRegistry.getInstance().bind(brokerId, ArtemisBrokerHelper.getBroker());
@@ -185,6 +181,7 @@ public class TcpTransportFactory extends TransportFactory {
 
    //remember call this if the test is using the internal broker.
    public static void clearService() {
+      LOG.info("#### clearing internal service " + brokerService);
       if (brokerService != null) {
          try {
             ArtemisBrokerHelper.stopArtemisBroker();
@@ -197,4 +194,21 @@ public class TcpTransportFactory extends TransportFactory {
          }
       }
    }
+
+   //added createTime for debugging
+   private static class InternalServiceInfo {
+      private String internalService;
+      private long createTime;
+
+      public InternalServiceInfo(String brokerService) {
+         this.internalService = brokerService;
+         this.createTime = System.currentTimeMillis();
+         LOG.info("just created " + this);
+      }
+
+      @Override
+      public String toString() {
+         return internalService + "@" + createTime;
+      }
+   }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0ceb3648/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/CombinationTestSupport.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/CombinationTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/CombinationTestSupport.java
index d7caafa..dc8f138 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/CombinationTestSupport.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/CombinationTestSupport.java
@@ -116,7 +116,7 @@ public abstract class CombinationTestSupport extends AutoFailTestSupport {
    public static void checkStopped() throws Exception {
       ArtemisBrokerHelper.stopArtemisBroker();
       boolean notStopped = BrokerService.checkStopped();
-      TcpTransportFactory.setBrokerName(null);
+      TcpTransportFactory.clearService();
       if (notStopped) {
          fail("brokers not stopped see exceptions above");
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0ceb3648/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerStartupDestinationTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerStartupDestinationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerStartupDestinationTest.java
index 06fbbbe..1e0555c 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerStartupDestinationTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerStartupDestinationTest.java
@@ -98,6 +98,7 @@ public class ExclusiveConsumerStartupDestinationTest extends EmbeddedBrokerTestS
       }
    }
 
+   //Exclusive consumer not implemented yet.
    public void testFailoverToAnotherExclusiveConsumerCreatedFirst() throws JMSException, InterruptedException {
       Connection conn = createConnection(true);
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0ceb3648/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerTest.java
index b2c1d8a..5bc647e 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerTest.java
@@ -28,6 +28,7 @@ import junit.framework.TestCase;
 
 import org.apache.activemq.artemiswrapper.ArtemisBrokerHelper;
 import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.transport.tcp.TcpTransportFactory;
 
 public class ExclusiveConsumerTest extends TestCase {
 
@@ -44,6 +45,7 @@ public class ExclusiveConsumerTest extends TestCase {
 
    @Override
    protected void tearDown() throws Exception {
+      TcpTransportFactory.clearService();
       super.tearDown();
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0ceb3648/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java
index dfcf302..abaf52d 100755
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java
@@ -36,6 +36,7 @@ import org.apache.activemq.broker.BrokerFactory;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.test.JmsResourceProvider;
 import org.apache.activemq.test.TestSupport;
+import org.apache.activemq.transport.tcp.TcpTransportFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0ceb3648/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsTest.java
index 00452d1..1f8d8da 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsTest.java
@@ -23,6 +23,7 @@ import javax.jms.MessageConsumer;
 import javax.jms.Session;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.transport.tcp.TcpTransportFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -103,6 +104,7 @@ public class JmsTopicSendReceiveWithTwoConnectionsTest extends JmsSendReceiveTes
       receiveSession.close();
       sendConnection.close();
       receiveConnection.close();
+      TcpTransportFactory.clearService();
    }
 
    /**

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0ceb3648/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslBrokerServiceTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslBrokerServiceTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslBrokerServiceTest.java
index 3a1c9a4..d380246 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslBrokerServiceTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslBrokerServiceTest.java
@@ -124,6 +124,7 @@ public class SslBrokerServiceTest extends TransportBrokerTestSupport {
    private void makeSSLConnection(SSLContext context,
                                   String enabledSuites[],
                                   TransportConnector connector) throws Exception, UnknownHostException, SocketException {
+      System.out.println("-----connector: " + connector);
       SSLSocket sslSocket = (SSLSocket) context.getSocketFactory().createSocket("localhost", connector.getUri().getPort());
 
       if (enabledSuites != null) {


[32/60] [abbrv] activemq-artemis git commit: Added openwire parameters as bean properties so that it can be passed via the new protocol manager bean util.

Posted by cl...@apache.org.
Added openwire parameters as bean properties so that it
can be passed via the new protocol manager bean util.


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/754c3b90
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/754c3b90
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/754c3b90

Branch: refs/heads/refactor-openwire
Commit: 754c3b905d2bd4fc0315d895cff65dbd73bd418a
Parents: 3328b2f
Author: Howard Gao <ho...@gmail.com>
Authored: Wed Feb 17 20:50:33 2016 +0800
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:44:21 2016 -0400

----------------------------------------------------------------------
 .../protocol/openwire/OpenWireConnection.java   | 25 ++-----------
 .../openwire/OpenWireProtocolManager.java       | 38 +++++++++++++++++---
 .../artemiswrapper/OpenwireArtemisBaseTest.java | 20 ++++++++---
 .../transport/failover/FailoverClusterTest.java | 11 ++++--
 .../failover/FailoverComplexClusterTest.java    | 16 ++++++---
 .../failover/FailoverPriorityTest.java          | 22 ++++++++----
 .../failover/FailoverUpdateURIsTest.java        |  6 +++-
 7 files changed, 94 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/754c3b90/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
index 61e93cb..a6f0f34 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
@@ -55,7 +55,6 @@ import org.apache.activemq.artemis.spi.core.remoting.Acceptor;
 import org.apache.activemq.artemis.spi.core.remoting.Connection;
 import org.apache.activemq.artemis.spi.core.remoting.ReadyListener;
 import org.apache.activemq.artemis.utils.ConcurrentHashSet;
-import org.apache.activemq.artemis.utils.ConfigurationHelper;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.BrokerInfo;
 import org.apache.activemq.command.Command;
@@ -153,10 +152,6 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
 
    private String defaultSocketURIString;
 
-   private boolean rebalance;
-   private boolean updateClusterClients;
-   private boolean updateClusterClientsOnRemove;
-
    public OpenWireConnection(Acceptor acceptorUsed,
                              Connection connection,
                              OpenWireProtocolManager openWireProtocolManager,
@@ -167,12 +162,6 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
       this.wireFormat = wf;
       this.creationTime = System.currentTimeMillis();
       this.defaultSocketURIString = connection.getLocalAddress();
-
-      //Clebert: These are parameters specific to openwire cluster with defaults as specified at
-      //http://activemq.apache.org/failover-transport-reference.html
-      rebalance = ConfigurationHelper.getBooleanProperty("rebalance-cluster-clients", true, acceptorUsed.getConfiguration());
-      updateClusterClients = ConfigurationHelper.getBooleanProperty("update-cluster-clients", true, acceptorUsed.getConfiguration());
-      updateClusterClientsOnRemove = ConfigurationHelper.getBooleanProperty("update-cluster-clients-on-remove", true, acceptorUsed.getConfiguration());
    }
 
    @Override
@@ -200,10 +189,6 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
       return info.getPassword();
    }
 
-   public boolean isRebalance() {
-      return rebalance;
-   }
-
    private ConnectionInfo getConnectionInfo() {
       if (state == null) {
          return null;
@@ -539,9 +524,9 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
          Response resp = new ExceptionResponse(e);
          return resp;
       }
-      if (info.isManageable() && this.isUpdateClusterClients()) {
+      if (info.isManageable() && protocolManager.isUpdateClusterClients()) {
          // send ConnectionCommand
-         ConnectionControl command = protocolManager.newConnectionControl(rebalance);
+         ConnectionControl command = protocolManager.newConnectionControl();
          command.setFaultTolerant(protocolManager.isFaultTolerantConfiguration());
          if (info.isFailoverReconnect()) {
             command.setRebalanceConnection(false);
@@ -1274,16 +1259,12 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
 
    public void updateClient(ConnectionControl control) {
       //      if (!destroyed && context.isFaultTolerant()) {
-      if (updateClusterClients) {
+      if (protocolManager.isUpdateClusterClients()) {
          dispatchAsync(control);
       }
       //      }
    }
 
-   public boolean isUpdateClusterClients() {
-      return updateClusterClients;
-   }
-
    public AMQConnectionContext initContext(ConnectionInfo info) {
       WireFormatInfo wireFormatInfo = wireFormat.getPreferedWireFormatInfo();
       // Older clients should have been defaulting this field to true.. but

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/754c3b90/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
index 525844c..bd26b07 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
@@ -148,6 +148,12 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
 
    private final ScheduledExecutorService scheduledPool;
 
+   //bean properties
+   //http://activemq.apache.org/failover-transport-reference.html
+   private boolean rebalanceClusterClients = false;
+   private boolean updateClusterClients = false;
+   private boolean updateClusterClientsOnRemove = false;
+
    public OpenWireProtocolManager(OpenWireProtocolManagerFactory factory, ActiveMQServer server) {
       this.factory = factory;
       this.server = server;
@@ -189,7 +195,7 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
       }
 
       for (OpenWireConnection c : this.connections) {
-         ConnectionControl control = newConnectionControl(c.isRebalance());
+         ConnectionControl control = newConnectionControl();
          c.updateClient(control);
       }
    }
@@ -422,13 +428,13 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
       return brokerName;
    }
 
-   protected ConnectionControl newConnectionControl(boolean rebalance) {
+   protected ConnectionControl newConnectionControl() {
       ConnectionControl control = new ConnectionControl();
 
-      String uri = generateMembersURI(rebalance);
+      String uri = generateMembersURI(rebalanceClusterClients);
       control.setConnectedBrokers(uri);
 
-      control.setRebalanceConnection(rebalance);
+      control.setRebalanceConnection(rebalanceClusterClients);
       return control;
    }
 
@@ -814,4 +820,28 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
       brokerInfo.setPeerBrokerInfos(null);
       connection.dispatchAsync(brokerInfo);
    }
+
+   public void setRebalanceClusterClients(boolean rebalance) {
+      this.rebalanceClusterClients = rebalance;
+   }
+
+   public boolean isRebalanceClusterClients() {
+      return this.rebalanceClusterClients;
+   }
+
+   public void setUpdateClusterClients(boolean updateClusterClients) {
+      this.updateClusterClients = updateClusterClients;
+   }
+
+   public boolean isUpdateClusterClients() {
+      return this.updateClusterClients;
+   }
+
+   public  void setUpdateClusterClientsOnRemove(boolean updateClusterClientsOnRemove) {
+      this.updateClusterClientsOnRemove = updateClusterClientsOnRemove;
+   }
+
+   public boolean isUpdateClusterClientsOnRemove() {
+      return this.updateClusterClientsOnRemove;
+   }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/754c3b90/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/OpenwireArtemisBaseTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/OpenwireArtemisBaseTest.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/OpenwireArtemisBaseTest.java
index be9cf06..5c8d3b6 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/OpenwireArtemisBaseTest.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/OpenwireArtemisBaseTest.java
@@ -19,7 +19,9 @@ package org.apache.activemq.broker.artemiswrapper;
 
 import java.io.File;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
@@ -31,6 +33,8 @@ import org.apache.activemq.artemis.core.server.JournalType;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
 import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.activemq.artemis.utils.uri.URISchema;
+import org.apache.activemq.artemis.utils.uri.URISupport;
 import org.apache.activemq.broker.BrokerService;
 import org.junit.Assert;
 import org.junit.Rule;
@@ -88,7 +92,7 @@ public class OpenwireArtemisBaseTest {
    public String CLUSTER_PASSWORD = "OPENWIRECLUSTER";
 
    protected Configuration createConfig(final int serverID) throws Exception {
-      return createConfig("localhost", serverID);
+      return createConfig("localhost", serverID, Collections.EMPTY_MAP);
    }
 
    protected Configuration createConfig(final String hostAddress, final int serverID, final int port) throws Exception {
@@ -111,6 +115,10 @@ public class OpenwireArtemisBaseTest {
    }
 
    protected Configuration createConfig(final String hostAddress, final int serverID) throws Exception {
+      return createConfig(hostAddress, serverID, Collections.EMPTY_MAP);
+   }
+
+   protected Configuration createConfig(final String hostAddress, final int serverID, Map<String, String> params) throws Exception {
       ConfigurationImpl configuration = new ConfigurationImpl().setJMXManagementEnabled(false).
               setSecurityEnabled(false).setJournalMinFiles(2).setJournalFileSize(1000 * 1024).setJournalType(JournalType.NIO).
               setJournalDirectory(getJournalDir(serverID, false)).
@@ -123,7 +131,7 @@ public class OpenwireArtemisBaseTest {
 
       configuration.addAddressesSetting("#", new AddressSettings().setAutoCreateJmsQueues(true).setAutoDeleteJmsQueues(true));
 
-      configuration.addAcceptorConfiguration("netty", newURI(hostAddress, serverID));
+      configuration.addAcceptorConfiguration("netty", newURI(hostAddress, serverID) + "?" + URISupport.createQueryString(params));
       configuration.addConnectorConfiguration("netty-connector", newURI(hostAddress, serverID));
 
       return configuration;
@@ -171,8 +179,12 @@ public class OpenwireArtemisBaseTest {
       return "tcp://" + localhostAddress + ":" + (61616 + serverID);
    }
 
-   protected static String newURIwithPort(String localhostAddress, int port) {
-      return "tcp://" + localhostAddress + ":" + port;
+   protected static String newURIwithPort(String localhostAddress, int port) throws Exception {
+      return newURIwithPort(localhostAddress, port, Collections.EMPTY_MAP);
+   }
+
+   protected static String newURIwithPort(String localhostAddress, int port, Map<String, String> params) throws Exception {
+      return "tcp://" + localhostAddress + ":" + port + "?" + URISupport.createQueryString(params);
    }
 
    public static JMSServerControl createJMSServerControl(final MBeanServer mbeanServer) throws Exception {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/754c3b90/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.java
index bf43caa..74fa6aa 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.java
@@ -22,8 +22,10 @@ import javax.jms.Queue;
 import javax.jms.Session;
 import java.net.URI;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
@@ -50,8 +52,13 @@ public class FailoverClusterTest extends OpenwireArtemisBaseTest {
 
    @Before
    public void setUp() throws Exception {
-      Configuration config1 = createConfig(1);
-      Configuration config2 = createConfig(2);
+      Map<String, String> params = new HashMap<String, String>();
+
+      params.put("rebalanceClusterClients", "true");
+      params.put("updateClusterClients", "true");
+
+      Configuration config1 = createConfig("localhost", 1, params);
+      Configuration config2 = createConfig("localhost", 2, params);
 
       deployClusterConfiguration(config1, 2);
       deployClusterConfiguration(config2, 1);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/754c3b90/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java
index 1d902e3..fd9ce1f 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java
@@ -65,9 +65,15 @@ public class FailoverComplexClusterTest extends OpenwireArtemisBaseTest {
 
    //default setup for most tests
    private void commonSetup() throws Exception {
-      Configuration config0 = createConfig(0);
-      Configuration config1 = createConfig(1);
-      Configuration config2 = createConfig(2);
+      Map<String, String> params = new HashMap<String, String>();
+
+      params.put("rebalanceClusterClients", "true");
+      params.put("updateClusterClients", "true");
+      params.put("updateClusterClientsOnRemove", "true");
+
+      Configuration config0 = createConfig("localhost", 0, params);
+      Configuration config1 = createConfig("localhost", 1, params);
+      Configuration config2 = createConfig("localhost", 2, params);
 
       deployClusterConfiguration(config0, 1, 2);
       deployClusterConfiguration(config1, 0, 2);
@@ -248,9 +254,9 @@ public class FailoverComplexClusterTest extends OpenwireArtemisBaseTest {
    @Test
    public void testFailOverWithUpdateClientsOnRemove() throws Exception {
       // Broker A
-      Configuration config0 = createConfig(0, "?rebalance-cluster-client=true&update-cluster-clients=true&update-cluster-clients-on-remove=true");
+      Configuration config0 = createConfig(0, "?rebalanceClusterClients=true&updateClusterClients=true&updateClusterClientsOnRemove=true");
       // Broker B
-      Configuration config1 = createConfig(1, "?rebalance-cluster-client=true&update-cluster-clients=true&update-cluster-clients-on-remove=true");
+      Configuration config1 = createConfig(1, "?rebalanceClusterClients=true&updateClusterClients=true&updateClusterClientsOnRemove=true");
 
       deployClusterConfiguration(config0, 1);
       deployClusterConfiguration(config1, 0);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/754c3b90/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPriorityTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPriorityTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPriorityTest.java
index 6e559e7..6f4b27e 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPriorityTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPriorityTest.java
@@ -19,6 +19,7 @@ package org.apache.activemq.transport.failover;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.activemq.ActiveMQConnection;
@@ -49,11 +50,16 @@ public class FailoverPriorityTest extends OpenwireArtemisBaseTest {
    private final List<ActiveMQConnection> connections = new ArrayList<ActiveMQConnection>();
    private EmbeddedJMS[] servers = new EmbeddedJMS[3];
    private String clientUrl;
+   private Map<String, String> params = new HashMap<String, String>();
 
    @Before
    public void setUp() throws Exception {
       urls.put(0, BROKER_A_CLIENT_TC_ADDRESS);
       urls.put(1, BROKER_B_CLIENT_TC_ADDRESS);
+      params.clear();
+      params.put("rebalanceClusterClients", "true");
+      params.put("updateClusterClients", "true");
+      params.put("updateClusterClientsOnRemove", "true");
    }
 
    @After
@@ -136,7 +142,7 @@ public class FailoverPriorityTest extends OpenwireArtemisBaseTest {
 
    @Test
    public void testThreeBrokers() throws Exception {
-      commonSetup();
+      setupThreeBrokers();
       Thread.sleep(1000);
 
       setClientUrl("failover:(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + "," + BROKER_C_CLIENT_TC_ADDRESS + ")?randomize=false&priorityBackup=true&initialReconnectDelay=1000&useExponentialBackOff=false");
@@ -262,11 +268,15 @@ public class FailoverPriorityTest extends OpenwireArtemisBaseTest {
       }
    }
 
-   //default setup for most tests
-   private void commonSetup() throws Exception {
-      Configuration config0 = createConfig("127.0.0.1", 0);
-      Configuration config1 = createConfig("127.0.0.1", 1);
-      Configuration config2 = createConfig("127.0.0.1", 2);
+   private void setupThreeBrokers() throws Exception {
+
+      params.put("rebalanceClusterClients", "false");
+      params.put("updateClusterClients", "false");
+      params.put("updateClusterClientsOnRemove", "false");
+
+      Configuration config0 = createConfig("127.0.0.1", 0, params);
+      Configuration config1 = createConfig("127.0.0.1", 1, params);
+      Configuration config2 = createConfig("127.0.0.1", 2, params);
 
       deployClusterConfiguration(config0, 1, 2);
       deployClusterConfiguration(config1, 0, 2);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/754c3b90/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUpdateURIsTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUpdateURIsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUpdateURIsTest.java
index 002a788..0a127dd 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUpdateURIsTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUpdateURIsTest.java
@@ -18,6 +18,8 @@ package org.apache.activemq.transport.failover;
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
 import javax.jms.Connection;
@@ -117,7 +119,9 @@ public class FailoverUpdateURIsTest extends OpenwireArtemisBaseTest {
 
    @Test
    public void testAutoUpdateURIs() throws Exception {
-      Configuration config0 = createConfig(0);
+      Map<String, String> params = new HashMap<String, String>();
+      params.put("updateClusterClients", "true");
+      Configuration config0 = createConfig("localhost", 0, params);
       deployClusterConfiguration(config0, 10);
       server0 = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
       server0.start();


[33/60] [abbrv] activemq-artemis git commit: avoiding NPE

Posted by cl...@apache.org.
avoiding NPE


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/573adbf1
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/573adbf1
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/573adbf1

Branch: refs/heads/refactor-openwire
Commit: 573adbf1b609d169c9beddb184eb159a4d478324
Parents: adeb22f
Author: Clebert Suconic <cl...@apache.org>
Authored: Fri Feb 19 15:37:12 2016 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:44:21 2016 -0400

----------------------------------------------------------------------
 .../artemis/core/protocol/openwire/OpenWireProtocolManager.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/573adbf1/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
index bd26b07..014181d 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
@@ -811,7 +811,7 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
    public void sendBrokerInfo(OpenWireConnection connection) {
       BrokerInfo brokerInfo = new BrokerInfo();
       brokerInfo.setBrokerName(server.getIdentity());
-      brokerInfo.setBrokerId(new BrokerId(server.getNodeID().toString()));
+      brokerInfo.setBrokerId(new BrokerId("" + server.getNodeID()));
       brokerInfo.setPeerBrokerInfos(null);
       brokerInfo.setFaultTolerantConfiguration(false);
       brokerInfo.setBrokerURL(connection.getLocalAddress());


[22/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2910Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2910Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2910Test.java
deleted file mode 100644
index 362fa5c..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2910Test.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/**
- * 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;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.JmsMultipleClientsTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.FilePendingQueueMessageStoragePolicy;
-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.junit.runner.RunWith;
-import org.junit.runners.BlockJUnit4ClassRunner;
-
-import java.util.Vector;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.Assert.assertTrue;
-
-@RunWith(BlockJUnit4ClassRunner.class)
-public class AMQ2910Test extends JmsMultipleClientsTestSupport {
-
-   final int maxConcurrency = 60;
-   final int msgCount = 200;
-   final Vector<Throwable> exceptions = new Vector<>();
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      //persistent = true;
-      BrokerService broker = new BrokerService();
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.addConnector("tcp://localhost:0");
-      PolicyMap policyMap = new PolicyMap();
-      PolicyEntry defaultEntry = new PolicyEntry();
-      defaultEntry.setPendingQueuePolicy(new FilePendingQueueMessageStoragePolicy());
-      defaultEntry.setCursorMemoryHighWaterMark(50);
-      defaultEntry.setMemoryLimit(500 * 1024);
-      defaultEntry.setProducerFlowControl(false);
-      policyMap.setDefaultEntry(defaultEntry);
-      broker.setDestinationPolicy(policyMap);
-
-      broker.getSystemUsage().getMemoryUsage().setLimit(1000 * 1024);
-
-      return broker;
-   }
-
-   @Test(timeout = 30 * 1000)
-   public void testConcurrentSendToPendingCursor() throws Exception {
-      final ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getConnectUri());
-      factory.setCloseTimeout(30000);
-      ExecutorService executor = Executors.newCachedThreadPool();
-      for (int i = 0; i < maxConcurrency; i++) {
-         final ActiveMQQueue dest = new ActiveMQQueue("Queue-" + i);
-         executor.execute(new Runnable() {
-            @Override
-            public void run() {
-               try {
-                  sendMessages(factory.createConnection(), dest, msgCount);
-               }
-               catch (Throwable t) {
-                  exceptions.add(t);
-               }
-            }
-         });
-      }
-
-      executor.shutdown();
-
-      assertTrue("send completed", executor.awaitTermination(60, TimeUnit.SECONDS));
-      assertNoExceptions();
-
-      executor = Executors.newCachedThreadPool();
-      for (int i = 0; i < maxConcurrency; i++) {
-         final ActiveMQQueue dest = new ActiveMQQueue("Queue-" + i);
-         executor.execute(new Runnable() {
-            @Override
-            public void run() {
-               try {
-                  startConsumers(factory, dest);
-               }
-               catch (Throwable t) {
-                  exceptions.add(t);
-               }
-            }
-         });
-      }
-
-      executor.shutdown();
-      assertTrue("consumers completed", executor.awaitTermination(60, TimeUnit.SECONDS));
-
-      allMessagesList.setMaximumDuration(120 * 1000);
-      final int numExpected = maxConcurrency * msgCount;
-      allMessagesList.waitForMessagesToArrive(numExpected);
-
-      if (allMessagesList.getMessageCount() != numExpected) {
-         dumpAllThreads(getName());
-
-      }
-      allMessagesList.assertMessagesReceivedNoWait(numExpected);
-
-      assertTrue("no exceptions: " + exceptions, exceptions.isEmpty());
-
-   }
-
-   private void assertNoExceptions() {
-      if (!exceptions.isEmpty()) {
-         for (Throwable t : exceptions) {
-            t.printStackTrace();
-         }
-      }
-      assertTrue("no exceptions: " + exceptions, exceptions.isEmpty());
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2982Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2982Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2982Test.java
deleted file mode 100644
index 573cdd3..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2982Test.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-
-import java.io.IOException;
-import java.util.concurrent.CountDownLatch;
-
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.RedeliveryPolicy;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.SharedDeadLetterStrategy;
-import org.apache.activemq.store.kahadb.KahaDBStore;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AMQ2982Test {
-
-   private static final int MAX_MESSAGES = 500;
-
-   private static final String QUEUE_NAME = "test.queue";
-
-   private BrokerService broker;
-
-   private final CountDownLatch messageCountDown = new CountDownLatch(MAX_MESSAGES);
-
-   private CleanableKahaDBStore kahaDB;
-
-   private static class CleanableKahaDBStore extends KahaDBStore {
-
-      // make checkpoint cleanup accessible
-      public void forceCleanup() throws IOException {
-         checkpointCleanup(true);
-      }
-
-      public int getFileMapSize() throws IOException {
-         // ensure save memory publishing, use the right lock
-         indexLock.readLock().lock();
-         try {
-            return getJournal().getFileMap().size();
-         }
-         finally {
-            indexLock.readLock().unlock();
-         }
-      }
-   }
-
-   @Before
-   public void setup() throws Exception {
-
-      broker = new BrokerService();
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.setPersistent(true);
-
-      kahaDB = new CleanableKahaDBStore();
-      kahaDB.setJournalMaxFileLength(256 * 1024);
-      broker.setPersistenceAdapter(kahaDB);
-
-      broker.start();
-      broker.waitUntilStarted();
-   }
-
-   private Connection registerDLQMessageListener() throws Exception {
-      ConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
-      Connection connection = factory.createConnection();
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer consumer = session.createConsumer(session.createQueue(SharedDeadLetterStrategy.DEFAULT_DEAD_LETTER_QUEUE_NAME));
-      consumer.setMessageListener(new MessageListener() {
-
-         @Override
-         public void onMessage(Message message) {
-            messageCountDown.countDown();
-         }
-      });
-
-      return connection;
-   }
-
-   class ConsumerThread extends Thread {
-
-      @Override
-      public void run() {
-         try {
-            ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
-
-            RedeliveryPolicy policy = new RedeliveryPolicy();
-            policy.setMaximumRedeliveries(0);
-            policy.setInitialRedeliveryDelay(100);
-            policy.setUseExponentialBackOff(false);
-
-            factory.setRedeliveryPolicy(policy);
-
-            Connection connection = factory.createConnection();
-            connection.start();
-            Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-            MessageConsumer consumer = session.createConsumer(session.createQueue(QUEUE_NAME));
-            do {
-               Message message = consumer.receive(300);
-               if (message != null) {
-                  session.rollback();
-               }
-            } while (messageCountDown.getCount() != 0);
-            consumer.close();
-            session.close();
-            connection.close();
-         }
-         catch (Exception e) {
-            Assert.fail(e.getMessage());
-         }
-      }
-   }
-
-   private void sendMessages() throws Exception {
-      ConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
-      Connection connection = factory.createConnection();
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = session.createProducer(session.createQueue(QUEUE_NAME));
-      producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-      for (int i = 0; i < MAX_MESSAGES; i++) {
-         BytesMessage message = session.createBytesMessage();
-         message.writeBytes(new byte[1000]);
-         producer.send(message);
-      }
-      producer.close();
-      session.close();
-      connection.close();
-   }
-
-   @Test
-   public void testNoStickyKahaDbLogFilesOnLocalTransactionRollback() throws Exception {
-
-      Connection dlqConnection = registerDLQMessageListener();
-
-      ConsumerThread thread = new ConsumerThread();
-      thread.start();
-
-      sendMessages();
-
-      thread.join(60 * 1000);
-      assertFalse(thread.isAlive());
-
-      dlqConnection.close();
-
-      kahaDB.forceCleanup();
-
-      assertEquals("only one active KahaDB log file after cleanup is expected", 1, kahaDB.getFileMapSize());
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      broker.stop();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2983Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2983Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2983Test.java
deleted file mode 100644
index 8714477..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2983Test.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.store.kahadb.KahaDBStore;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AMQ2983Test {
-
-   private static final int MAX_CONSUMER = 10;
-
-   private static final int MAX_MESSAGES = 2000;
-
-   private static final String QUEUE_NAME = "test.queue";
-
-   private BrokerService broker;
-
-   private final CountDownLatch messageCountDown = new CountDownLatch(MAX_MESSAGES);
-
-   private CleanableKahaDBStore kahaDB;
-
-   private static class CleanableKahaDBStore extends KahaDBStore {
-
-      // make checkpoint cleanup accessible
-      public void forceCleanup() throws IOException {
-         checkpointCleanup(true);
-      }
-
-      public int getFileMapSize() throws IOException {
-         // ensure save memory publishing, use the right lock
-         indexLock.readLock().lock();
-         try {
-            return getJournal().getFileMap().size();
-         }
-         finally {
-            indexLock.readLock().unlock();
-         }
-      }
-   }
-
-   private class ConsumerThread extends Thread {
-
-      @Override
-      public void run() {
-         try {
-            ConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
-            Connection connection = factory.createConnection();
-            connection.start();
-            Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-            MessageConsumer consumer = session.createConsumer(session.createQueue(QUEUE_NAME));
-            do {
-               Message message = consumer.receive(200);
-               if (message != null) {
-                  session.commit();
-                  messageCountDown.countDown();
-               }
-            } while (messageCountDown.getCount() != 0);
-            consumer.close();
-            session.close();
-            connection.close();
-         }
-         catch (Exception e) {
-            Assert.fail(e.getMessage());
-         }
-      }
-   }
-
-   @Before
-   public void setup() throws Exception {
-
-      broker = new BrokerService();
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.setPersistent(true);
-
-      kahaDB = new CleanableKahaDBStore();
-      kahaDB.setJournalMaxFileLength(256 * 1024);
-      broker.setPersistenceAdapter(kahaDB);
-
-      broker.start();
-      broker.waitUntilStarted();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      broker.stop();
-   }
-
-   @Test
-   public void testNoStickyKahaDbLogFilesOnConcurrentTransactionalConsumer() throws Exception {
-
-      List<Thread> consumerThreads = new ArrayList<>();
-      for (int i = 0; i < MAX_CONSUMER; i++) {
-         ConsumerThread thread = new ConsumerThread();
-         thread.start();
-         consumerThreads.add(thread);
-      }
-      sendMessages();
-
-      boolean allMessagesReceived = messageCountDown.await(60, TimeUnit.SECONDS);
-      assertTrue(allMessagesReceived);
-
-      for (Thread thread : consumerThreads) {
-         thread.join(TimeUnit.MILLISECONDS.convert(60, TimeUnit.SECONDS));
-         assertFalse(thread.isAlive());
-      }
-      kahaDB.forceCleanup();
-      assertEquals("Expect only one active KahaDB log file after cleanup", 1, kahaDB.getFileMapSize());
-   }
-
-   private void sendMessages() throws Exception {
-      ConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
-      Connection connection = factory.createConnection();
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = session.createProducer(session.createQueue(QUEUE_NAME));
-      producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-      for (int i = 0; i < MAX_MESSAGES; i++) {
-         BytesMessage message = session.createBytesMessage();
-         message.writeBytes(new byte[200]);
-         producer.send(message);
-      }
-      producer.close();
-      session.close();
-      connection.close();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3014Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3014Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3014Test.java
deleted file mode 100644
index 1e3c737..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3014Test.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/**
- * 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;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.Connection;
-import org.apache.activemq.broker.TransportConnector;
-import org.apache.activemq.command.BrokerInfo;
-import org.apache.activemq.network.DiscoveryNetworkConnector;
-import org.apache.activemq.thread.Task;
-import org.apache.activemq.thread.TaskRunner;
-import org.apache.activemq.thread.TaskRunnerFactory;
-import org.apache.activemq.transport.*;
-import org.apache.activemq.transport.discovery.simple.SimpleDiscoveryAgent;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * This test involves the creation of a local and remote broker, both of which
- * communicate over VM and TCP. The local broker establishes a bridge to the
- * remote broker for the purposes of verifying that broker info is only
- * transferred once the local broker's ID is known to the bridge support.
- */
-public class AMQ3014Test {
-
-   // Change this URL to be an unused port.
-   private static final String BROKER_URL = "tcp://localhost:0";
-
-   private List<BrokerInfo> remoteBrokerInfos = Collections.synchronizedList(new ArrayList<BrokerInfo>());
-
-   private BrokerService localBroker = new BrokerService();
-
-   // Override the "remote" broker so that it records all (remote) BrokerInfos
-   // that it receives.
-   private BrokerService remoteBroker = new BrokerService() {
-      @Override
-      protected TransportConnector createTransportConnector(URI brokerURI) throws Exception {
-         TransportServer transport = TransportFactorySupport.bind(this, brokerURI);
-         return new TransportConnector(transport) {
-            @Override
-            protected Connection createConnection(Transport transport) throws IOException {
-               Connection connection = super.createConnection(transport);
-               final TransportListener proxiedListener = transport.getTransportListener();
-               transport.setTransportListener(new TransportListener() {
-
-                  @Override
-                  public void onCommand(Object command) {
-                     if (command instanceof BrokerInfo) {
-                        remoteBrokerInfos.add((BrokerInfo) command);
-                     }
-                     proxiedListener.onCommand(command);
-                  }
-
-                  @Override
-                  public void onException(IOException error) {
-                     proxiedListener.onException(error);
-                  }
-
-                  @Override
-                  public void transportInterupted() {
-                     proxiedListener.transportInterupted();
-                  }
-
-                  @Override
-                  public void transportResumed() {
-                     proxiedListener.transportResumed();
-                  }
-               });
-               return connection;
-            }
-
-         };
-      }
-   };
-
-   @Before
-   public void init() throws Exception {
-      localBroker.setBrokerName("localBroker");
-      localBroker.setPersistent(false);
-      localBroker.setUseJmx(false);
-      localBroker.setSchedulerSupport(false);
-
-      remoteBroker.setBrokerName("remoteBroker");
-      remoteBroker.setPersistent(false);
-      remoteBroker.setUseJmx(false);
-      remoteBroker.addConnector(BROKER_URL);
-      remoteBroker.setSchedulerSupport(false);
-   }
-
-   @After
-   public void cleanup() throws Exception {
-      try {
-         localBroker.stop();
-      }
-      finally {
-         remoteBroker.stop();
-      }
-   }
-
-   /**
-    * This test verifies that the local broker's ID is typically known by the
-    * bridge support before the local broker's BrokerInfo is sent to the remote
-    * broker.
-    */
-   @Test
-   public void NormalCaseTest() throws Exception {
-      runTest(0, 3000);
-   }
-
-   /**
-    * This test verifies that timing can arise under which the local broker's
-    * ID is not known by the bridge support before the local broker's
-    * BrokerInfo is sent to the remote broker.
-    */
-   @Test
-   public void DelayedCaseTest() throws Exception {
-      runTest(500, 3000);
-   }
-
-   private void runTest(final long taskRunnerDelay, long timeout) throws Exception {
-      // Add a network connector to the local broker that will create a bridge
-      // to the remote broker.
-      DiscoveryNetworkConnector dnc = new DiscoveryNetworkConnector();
-      SimpleDiscoveryAgent da = new SimpleDiscoveryAgent();
-      da.setServices(remoteBroker.getTransportConnectors().get(0).getPublishableConnectString());
-      dnc.setDiscoveryAgent(da);
-      localBroker.addNetworkConnector(dnc);
-
-      // Before starting the local broker, intercept the task runner factory
-      // so that the
-      // local VMTransport dispatcher is artificially delayed.
-      final TaskRunnerFactory realTaskRunnerFactory = localBroker.getTaskRunnerFactory();
-      localBroker.setTaskRunnerFactory(new TaskRunnerFactory() {
-         @Override
-         public TaskRunner createTaskRunner(Task task, String name) {
-            final TaskRunner realTaskRunner = realTaskRunnerFactory.createTaskRunner(task, name);
-            if (name.startsWith("ActiveMQ Connection Dispatcher: ")) {
-               return new TaskRunner() {
-                  @Override
-                  public void shutdown() throws InterruptedException {
-                     realTaskRunner.shutdown();
-                  }
-
-                  @Override
-                  public void shutdown(long timeout) throws InterruptedException {
-                     realTaskRunner.shutdown(timeout);
-                  }
-
-                  @Override
-                  public void wakeup() throws InterruptedException {
-                     Thread.sleep(taskRunnerDelay);
-                     realTaskRunner.wakeup();
-                  }
-               };
-            }
-            else {
-               return realTaskRunnerFactory.createTaskRunner(task, name);
-            }
-         }
-      });
-
-      // Start the brokers and wait for the bridge to be created; the remote
-      // broker is started first to ensure it is available for the local
-      // broker to connect to.
-      remoteBroker.start();
-      localBroker.start();
-
-      // Wait for the remote broker to receive the local broker's BrokerInfo
-      // and then verify the local broker's ID is known.
-      long startTimeMillis = System.currentTimeMillis();
-      while (remoteBrokerInfos.isEmpty() && (System.currentTimeMillis() - startTimeMillis) < timeout) {
-         Thread.sleep(100);
-      }
-
-      Assert.assertFalse("Timed out waiting for bridge to form.", remoteBrokerInfos.isEmpty());
-      Assert.assertNotNull("Local broker ID is null.", remoteBrokerInfos.get(0).getBrokerId());
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3120Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3120Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3120Test.java
deleted file mode 100644
index 88a0db8..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3120Test.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/**
- * 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;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.util.ConsumerThread;
-import org.apache.activemq.util.ProducerThread;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.junit.Test;
-
-import javax.jms.*;
-
-import java.io.File;
-
-import static org.junit.Assert.assertEquals;
-
-public class AMQ3120Test {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ3120Test.class);
-
-   BrokerService broker = null;
-   File kahaDbDir = null;
-   private final Destination destination = new ActiveMQQueue("AMQ3120Test");
-   final String payload = new String(new byte[1024]);
-
-   protected void startBroker(boolean delete) throws Exception {
-      broker = new BrokerService();
-
-      //Start with a clean directory
-      kahaDbDir = new File(broker.getBrokerDataDirectory(), "KahaDB");
-      deleteDir(kahaDbDir);
-
-      broker.setSchedulerSupport(false);
-      broker.setDeleteAllMessagesOnStartup(delete);
-      broker.setPersistent(true);
-      broker.setUseJmx(false);
-      broker.addConnector("tcp://localhost:0");
-
-      PolicyMap map = new PolicyMap();
-      PolicyEntry entry = new PolicyEntry();
-      entry.setUseCache(false);
-      map.setDefaultEntry(entry);
-      broker.setDestinationPolicy(map);
-
-      configurePersistence(broker, delete);
-
-      broker.start();
-      LOG.info("Starting broker..");
-   }
-
-   protected void configurePersistence(BrokerService brokerService, boolean deleteAllOnStart) throws Exception {
-      KahaDBPersistenceAdapter adapter = (KahaDBPersistenceAdapter) brokerService.getPersistenceAdapter();
-
-      // ensure there are a bunch of data files but multiple entries in each
-      adapter.setJournalMaxFileLength(1024 * 20);
-
-      // speed up the test case, checkpoint and cleanup early and often
-      adapter.setCheckpointInterval(500);
-      adapter.setCleanupInterval(500);
-
-      if (!deleteAllOnStart) {
-         adapter.setForceRecoverIndex(true);
-      }
-
-   }
-
-   private boolean deleteDir(File dir) {
-      if (dir.isDirectory()) {
-         String[] children = dir.list();
-         for (int i = 0; i < children.length; i++) {
-            boolean success = deleteDir(new File(dir, children[i]));
-            if (!success) {
-               return false;
-            }
-         }
-      }
-
-      return dir.delete();
-   }
-
-   private int getFileCount(File dir) {
-      if (dir.isDirectory()) {
-         String[] children = dir.list();
-         return children.length;
-      }
-
-      return 0;
-   }
-
-   @Test
-   public void testCleanupOfFiles() throws Exception {
-      final int messageCount = 500;
-      startBroker(true);
-      int fileCount = getFileCount(kahaDbDir);
-      assertEquals(4, fileCount);
-
-      Connection connection = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getConnectUri()).createConnection();
-      connection.start();
-      Session producerSess = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Session consumerSess = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      ProducerThread producer = new ProducerThread(producerSess, destination) {
-         @Override
-         protected Message createMessage(int i) throws Exception {
-            return sess.createTextMessage(payload + "::" + i);
-         }
-      };
-      producer.setSleep(650);
-      producer.setMessageCount(messageCount);
-      ConsumerThread consumer = new ConsumerThread(consumerSess, destination);
-      consumer.setBreakOnNull(false);
-      consumer.setMessageCount(messageCount);
-
-      producer.start();
-      consumer.start();
-
-      producer.join();
-      consumer.join();
-
-      assertEquals("consumer got all produced messages", producer.getMessageCount(), consumer.getReceived());
-
-      broker.stop();
-      broker.waitUntilStopped();
-
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3140Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3140Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3140Test.java
deleted file mode 100644
index 621b421..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3140Test.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ScheduledMessage;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.util.IOHelper;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AMQ3140Test {
-
-   private static final int MESSAGES_PER_THREAD = 100;
-
-   private static final int THREAD_COUNT = 10;
-
-   private BrokerService broker;
-
-   private static final String QUEUE_NAME = "test";
-
-   private static class Sender extends Thread {
-
-      private static final int DELAY = 3000;
-
-      @Override
-      public void run() {
-         try {
-            ConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost");
-            Connection connection = cf.createConnection();
-            connection.start();
-            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-            MessageProducer producer = session.createProducer(session.createQueue(QUEUE_NAME));
-            Message message = session.createTextMessage("test");
-            for (int i = 0; i < MESSAGES_PER_THREAD; i++) {
-               message.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, DELAY);
-               producer.send(message);
-            }
-            session.close();
-            connection.close();
-         }
-         catch (JMSException e) {
-            fail(e.getMessage());
-         }
-      }
-   }
-
-   @Before
-   public void setup() throws Exception {
-      File schedulerDirectory = new File("target/test/ScheduledDB");
-
-      IOHelper.mkdirs(schedulerDirectory);
-      IOHelper.deleteChildren(schedulerDirectory);
-
-      broker = new BrokerService();
-      broker.setSchedulerSupport(true);
-      broker.setPersistent(true);
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.setDataDirectory("target");
-      broker.setSchedulerDirectoryFile(schedulerDirectory);
-      broker.setUseJmx(false);
-      broker.addConnector("vm://localhost");
-
-      broker.start();
-      broker.waitUntilStarted();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      broker.stop();
-   }
-
-   @Test
-   public void noMessageLostOnConcurrentScheduling() throws JMSException, InterruptedException {
-
-      final AtomicLong receiveCounter = new AtomicLong();
-
-      ConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost");
-      Connection connection = cf.createConnection();
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      MessageConsumer consumer = session.createConsumer(session.createQueue(QUEUE_NAME));
-      consumer.setMessageListener(new MessageListener() {
-
-         @Override
-         public void onMessage(Message message) {
-            receiveCounter.incrementAndGet();
-         }
-      });
-
-      List<Sender> senderThreads = new ArrayList<>();
-      for (int i = 0; i < THREAD_COUNT; i++) {
-         Sender sender = new Sender();
-         senderThreads.add(sender);
-      }
-      for (Sender sender : senderThreads) {
-         sender.start();
-      }
-      for (Sender sender : senderThreads) {
-         sender.join();
-      }
-
-      // wait until all scheduled messages has been received
-      TimeUnit.MINUTES.sleep(2);
-
-      session.close();
-      connection.close();
-
-      assertEquals(MESSAGES_PER_THREAD * THREAD_COUNT, receiveCounter.get());
-   }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3141Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3141Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3141Test.java
deleted file mode 100644
index 49db143..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3141Test.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ScheduledMessage;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.util.IOHelper;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AMQ3141Test {
-
-   private static final int MAX_MESSAGES = 100;
-
-   private static final long DELAY_IN_MS = 100;
-
-   private static final String QUEUE_NAME = "target.queue";
-
-   private BrokerService broker;
-
-   private final CountDownLatch messageCountDown = new CountDownLatch(MAX_MESSAGES);
-
-   private ConnectionFactory factory;
-
-   @Before
-   public void setup() throws Exception {
-
-      broker = new BrokerService();
-      broker.setPersistent(true);
-      broker.setSchedulerSupport(true);
-      broker.setDataDirectory("target");
-      broker.setUseJmx(false);
-      broker.addConnector("vm://localhost");
-
-      File schedulerDirectory = new File("target/test/ScheduledDB");
-      IOHelper.mkdirs(schedulerDirectory);
-      IOHelper.deleteChildren(schedulerDirectory);
-      broker.setSchedulerDirectoryFile(schedulerDirectory);
-
-      broker.start();
-      broker.waitUntilStarted();
-
-      factory = new ActiveMQConnectionFactory("vm://localhost");
-   }
-
-   private void sendMessages() throws Exception {
-      Connection connection = factory.createConnection();
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = session.createProducer(session.createQueue(QUEUE_NAME));
-      for (int i = 0; i < MAX_MESSAGES; i++) {
-         Message message = session.createTextMessage();
-         message.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, DELAY_IN_MS);
-         producer.send(message);
-      }
-      connection.close();
-   }
-
-   @Test
-   public void testNoMissingMessagesOnShortScheduleDelay() throws Exception {
-
-      Connection connection = factory.createConnection();
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer consumer = session.createConsumer(session.createQueue(QUEUE_NAME));
-
-      consumer.setMessageListener(new MessageListener() {
-         @Override
-         public void onMessage(Message message) {
-            messageCountDown.countDown();
-         }
-      });
-      sendMessages();
-
-      boolean receiveComplete = messageCountDown.await(5, TimeUnit.SECONDS);
-
-      connection.close();
-
-      assertTrue("expect all messages received but " + messageCountDown.getCount() + " are missing", receiveComplete);
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      broker.stop();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3145Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3145Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3145Test.java
deleted file mode 100644
index 7e7c959..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3145Test.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.QueueViewMBean;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ3145Test {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ3145Test.class);
-   private final String MESSAGE_TEXT = new String(new byte[1024]);
-   BrokerService broker;
-   ConnectionFactory factory;
-   Connection connection;
-   Session session;
-   Queue queue;
-   MessageConsumer consumer;
-
-   @Before
-   public void createBroker() throws Exception {
-      createBroker(true);
-   }
-
-   public void createBroker(boolean deleteAll) throws Exception {
-      broker = new BrokerService();
-      broker.setDeleteAllMessagesOnStartup(deleteAll);
-      broker.setDataDirectory("target/AMQ3145Test");
-      broker.setUseJmx(true);
-      broker.getManagementContext().setCreateConnector(false);
-      broker.addConnector("tcp://localhost:0");
-      broker.start();
-      broker.waitUntilStarted();
-      factory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getConnectUri().toString());
-      connection = factory.createConnection();
-      connection.start();
-      session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      if (consumer != null) {
-         consumer.close();
-      }
-      session.close();
-      connection.stop();
-      connection.close();
-      broker.stop();
-   }
-
-   @Test
-   public void testCacheDisableReEnable() throws Exception {
-      createProducerAndSendMessages(1);
-      QueueViewMBean proxy = getProxyToQueueViewMBean();
-      assertTrue("cache is enabled", proxy.isCacheEnabled());
-      tearDown();
-      createBroker(false);
-      proxy = getProxyToQueueViewMBean();
-      assertEquals("one pending message", 1, proxy.getQueueSize());
-      assertTrue("cache is disabled when there is a pending message", !proxy.isCacheEnabled());
-
-      createConsumer(1);
-      createProducerAndSendMessages(1);
-      assertTrue("cache is enabled again on next send when there are no messages", proxy.isCacheEnabled());
-   }
-
-   private QueueViewMBean getProxyToQueueViewMBean() throws MalformedObjectNameException, JMSException {
-      ObjectName queueViewMBeanName = new ObjectName("org.apache.activemq" + ":destinationType=Queue,destinationName=" + queue.getQueueName() + ",type=Broker,brokerName=localhost");
-      QueueViewMBean proxy = (QueueViewMBean) broker.getManagementContext().newProxyInstance(queueViewMBeanName, QueueViewMBean.class, true);
-      return proxy;
-   }
-
-   private void createProducerAndSendMessages(int numToSend) throws Exception {
-      queue = session.createQueue("test1");
-      MessageProducer producer = session.createProducer(queue);
-      for (int i = 0; i < numToSend; i++) {
-         TextMessage message = session.createTextMessage(MESSAGE_TEXT + i);
-         if (i != 0 && i % 50000 == 0) {
-            LOG.info("sent: " + i);
-         }
-         producer.send(message);
-      }
-      producer.close();
-   }
-
-   private void createConsumer(int numToConsume) throws Exception {
-      consumer = session.createConsumer(queue);
-      // wait for buffer fill out
-      for (int i = 0; i < numToConsume; ++i) {
-         Message message = consumer.receive(2000);
-         message.acknowledge();
-      }
-      consumer.close();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3157Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3157Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3157Test.java
deleted file mode 100644
index 34b1909..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3157Test.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/**
- * 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;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.management.ObjectName;
-
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.DestinationViewMBean;
-import org.apache.activemq.broker.region.DestinationInterceptor;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.broker.region.virtual.MirroredQueue;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.spring.ConsumerBean;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ3157Test extends EmbeddedBrokerTestSupport {
-
-   private static final transient Logger LOG = LoggerFactory.getLogger(AMQ3157Test.class);
-   private Connection connection;
-
-   public void testInactiveMirroredQueueIsCleanedUp() throws Exception {
-
-      if (connection == null) {
-         connection = createConnection();
-      }
-      connection.start();
-
-      ConsumerBean messageList = new ConsumerBean();
-      messageList.setVerbose(true);
-
-      ActiveMQDestination consumeDestination = createConsumeDestination();
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      LOG.info("Consuming from: " + consumeDestination);
-
-      MessageConsumer c1 = session.createConsumer(consumeDestination);
-      c1.setMessageListener(messageList);
-
-      // create topic producer
-      ActiveMQQueue sendDestination = new ActiveMQQueue(getQueueName());
-      LOG.info("Sending to: " + sendDestination);
-
-      MessageProducer producer = session.createProducer(sendDestination);
-      assertNotNull(producer);
-
-      final int total = 10;
-      for (int i = 0; i < total; i++) {
-         producer.send(session.createTextMessage("message: " + i));
-      }
-
-      messageList.assertMessagesArrived(total);
-      LOG.info("Received: " + messageList);
-      messageList.flushMessages();
-
-      MessageConsumer c2 = session.createConsumer(sendDestination);
-      c2.setMessageListener(messageList);
-      messageList.assertMessagesArrived(total);
-      LOG.info("Q Received: " + messageList);
-
-      connection.close();
-
-      List<ObjectName> topics = Arrays.asList(broker.getAdminView().getTopics());
-      assertTrue(topics.contains(createObjectName(consumeDestination)));
-      List<ObjectName> queues = Arrays.asList(broker.getAdminView().getQueues());
-      assertTrue(queues.contains(createObjectName(sendDestination)));
-
-      Thread.sleep(TimeUnit.SECONDS.toMillis(10));
-
-      topics = Arrays.asList(broker.getAdminView().getTopics());
-      if (topics != null) {
-         assertFalse("Virtual Topic Desination did not get cleaned up.", topics.contains(createObjectName(consumeDestination)));
-      }
-      queues = Arrays.asList(broker.getAdminView().getQueues());
-      if (queues != null) {
-         assertFalse("Mirrored Queue Desination did not get cleaned up.", queues.contains(createObjectName(sendDestination)));
-      }
-   }
-
-   protected ActiveMQDestination createConsumeDestination() {
-      return new ActiveMQTopic("VirtualTopic.Mirror." + getQueueName());
-   }
-
-   protected String getQueueName() {
-      return "My.Queue";
-   }
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      BrokerService answer = new BrokerService();
-      answer.setUseMirroredQueues(true);
-      answer.setPersistent(isPersistent());
-      answer.setSchedulePeriodForDestinationPurge(1000);
-
-      PolicyEntry entry = new PolicyEntry();
-      entry.setGcInactiveDestinations(true);
-      entry.setInactiveTimeoutBeforeGC(5000);
-      entry.setProducerFlowControl(true);
-      PolicyMap map = new PolicyMap();
-      map.setDefaultEntry(entry);
-
-      MirroredQueue mirrorQ = new MirroredQueue();
-      mirrorQ.setCopyMessage(true);
-      DestinationInterceptor[] destinationInterceptors = new DestinationInterceptor[]{mirrorQ};
-      answer.setDestinationInterceptors(destinationInterceptors);
-
-      answer.setDestinationPolicy(map);
-      answer.addConnector(bindAddress);
-
-      return answer;
-   }
-
-   protected DestinationViewMBean createView(ActiveMQDestination destination) throws Exception {
-      String domain = "org.apache.activemq";
-      ObjectName name;
-      if (destination.isQueue()) {
-         name = new ObjectName(domain + ":BrokerName=localhost,Type=Queue,Destination=" + destination.getPhysicalName());
-      }
-      else {
-         name = new ObjectName(domain + ":BrokerName=localhost,Type=Topic,Destination=" + destination.getPhysicalName());
-      }
-      return (DestinationViewMBean) broker.getManagementContext().newProxyInstance(name, DestinationViewMBean.class, true);
-   }
-
-   protected ObjectName createObjectName(ActiveMQDestination destination) throws Exception {
-      String domain = "org.apache.activemq";
-      ObjectName name;
-      if (destination.isQueue()) {
-         name = new ObjectName(domain + ":type=Broker,brokerName=localhost," +
-                                  "destinationType=Queue,destinationName=" + destination.getPhysicalName());
-      }
-      else {
-         name = new ObjectName(domain + ":type=Broker,brokerName=localhost," +
-                                  "destinationType=Topic,destinationName=" + destination.getPhysicalName());
-      }
-
-      return name;
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      if (connection != null) {
-         connection.close();
-      }
-      super.tearDown();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3167Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3167Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3167Test.java
deleted file mode 100644
index 6fd81b2..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3167Test.java
+++ /dev/null
@@ -1,471 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-
-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.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQMessage;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test the loss of messages detected during testing with ActiveMQ 5.4.1 and 5.4.2.
- * <br>
- * Symptoms: - 1 record is lost "early" in the stream. - no more records lost.
- * <br>
- * Test Configuration: - Broker Settings: - Destination Policy - Occurs with "Destination Policy" using Store Cursor and
- * a memory limit - Not reproduced without "Destination Policy" defined - Persistence Adapter - Memory: Does not occur.
- * - KahaDB: Occurs. - Messages - Occurs with TextMessage and BinaryMessage - Persistent messages.
- * <br>
- * Notes: - Lower memory limits increase the rate of occurrence. - Higher memory limits may prevent the problem
- * (probably because memory limits not reached). - Producers sending a number of messages before consumers come online
- * increases rate of occurrence.
- */
-
-public class AMQ3167Test {
-
-   protected BrokerService embeddedBroker;
-
-   protected static final int MEMORY_LIMIT = 16 * 1024;
-
-   protected static boolean Debug_f = false;
-
-   protected long Producer_stop_time = 0;
-   protected long Consumer_stop_time = 0;
-   protected long Consumer_startup_delay_ms = 2000;
-   protected boolean Stop_after_error = true;
-
-   protected Connection JMS_conn;
-   protected long Num_error = 0;
-
-   // // ////
-   // // UTILITIES ////
-   // // ////
-
-   /**
-    * Create a new, unsecured, client connection to the test broker using the given username and password. This
-    * connection bypasses all security.
-    * <br>
-    * Don't forget to start the connection or no messages will be received by consumers even though producers will work
-    * fine.
-    *
-    * @username name of the JMS user for the connection; may be null.
-    * @password Password for the JMS user; may be null.
-    */
-
-   protected Connection createUnsecuredConnection(String username, String password) throws javax.jms.JMSException {
-      ActiveMQConnectionFactory conn_fact;
-
-      conn_fact = new ActiveMQConnectionFactory(embeddedBroker.getVmConnectorURI());
-
-      return conn_fact.createConnection(username, password);
-   }
-
-   // // ////
-   // // TEST FUNCTIONALITY ////
-   // // ////
-
-   @Before
-   public void testPrep() throws Exception {
-      embeddedBroker = new BrokerService();
-      configureBroker(embeddedBroker);
-      embeddedBroker.start();
-      embeddedBroker.waitUntilStarted();
-
-      // Prepare the connection
-      JMS_conn = createUnsecuredConnection(null, null);
-      JMS_conn.start();
-   }
-
-   @After
-   public void testCleanup() throws java.lang.Exception {
-      JMS_conn.stop();
-      embeddedBroker.stop();
-   }
-
-   protected void configureBroker(BrokerService broker_svc) throws Exception {
-
-      broker_svc.setBrokerName("testbroker1");
-
-      broker_svc.setUseJmx(false);
-      broker_svc.setPersistent(true);
-      broker_svc.setDataDirectory("target/AMQ3167Test");
-      configureDestinationPolicy(broker_svc);
-   }
-
-   /**
-    * NOTE: overrides any prior policy map defined for the broker service.
-    */
-
-   protected void configureDestinationPolicy(BrokerService broker_svc) {
-      PolicyMap pol_map;
-      PolicyEntry pol_ent;
-      ArrayList<PolicyEntry> ent_list;
-
-      ent_list = new ArrayList<>();
-
-      //
-      // QUEUES
-      //
-
-      pol_ent = new PolicyEntry();
-      pol_ent.setQueue(">");
-      pol_ent.setMemoryLimit(MEMORY_LIMIT);
-      pol_ent.setProducerFlowControl(false);
-      ent_list.add(pol_ent);
-
-      //
-      // COMPLETE POLICY MAP
-      //
-
-      pol_map = new PolicyMap();
-      pol_map.setPolicyEntries(ent_list);
-
-      broker_svc.setDestinationPolicy(pol_map);
-   }
-
-   // // ////
-   // // TEST ////
-   // // ////
-
-   @Test
-   public void testQueueLostMessage() throws Exception {
-      Destination dest;
-
-      dest = ActiveMQDestination.createDestination("lostmsgtest.queue", ActiveMQDestination.QUEUE_TYPE);
-
-      // 10 seconds from now
-      Producer_stop_time = java.lang.System.nanoTime() + (10L * 1000000000L);
-
-      // 15 seconds from now
-      Consumer_stop_time = Producer_stop_time + (5L * 1000000000L);
-
-      runLostMsgTest(dest, 1000000, 1, 1, false);
-
-      // Make sure failures in the threads are thoroughly reported in the JUnit framework.
-      assertTrue(Num_error == 0);
-   }
-
-   /**
-    *
-    */
-
-   protected static void log(String msg) {
-      if (Debug_f)
-         java.lang.System.err.println(msg);
-   }
-
-   /**
-    * Main body of the lost-message test.
-    */
-
-   protected void runLostMsgTest(Destination dest,
-                                 int num_msg,
-                                 int num_send_per_sess,
-                                 int num_recv_per_sess,
-                                 boolean topic_f) throws Exception {
-      Thread prod_thread;
-      Thread cons_thread;
-      String tag;
-      Session sess;
-      MessageProducer prod;
-      MessageConsumer cons;
-      int ack_mode;
-
-      //
-      // Start the producer
-      //
-
-      tag = "prod";
-      log(">> Starting producer " + tag);
-
-      sess = JMS_conn.createSession((num_send_per_sess > 1), Session.AUTO_ACKNOWLEDGE);
-      prod = sess.createProducer(dest);
-
-      prod_thread = new producerThread(sess, prod, tag, num_msg, num_send_per_sess);
-      prod_thread.start();
-      log("Started producer " + tag);
-
-      //
-      // Delay before starting consumers
-      //
-
-      log("Waiting before starting consumers");
-      java.lang.Thread.sleep(Consumer_startup_delay_ms);
-
-      //
-      // Now create and start the consumer
-      //
-
-      tag = "cons";
-      log(">> Starting consumer");
-
-      if (num_recv_per_sess > 1)
-         ack_mode = Session.CLIENT_ACKNOWLEDGE;
-      else
-         ack_mode = Session.AUTO_ACKNOWLEDGE;
-
-      sess = JMS_conn.createSession(false, ack_mode);
-      cons = sess.createConsumer(dest);
-
-      cons_thread = new consumerThread(sess, cons, tag, num_msg, num_recv_per_sess);
-      cons_thread.start();
-      log("Started consumer " + tag);
-
-      //
-      // Wait for the producer and consumer to finish.
-      //
-
-      log("< waiting for producer.");
-      prod_thread.join();
-
-      log("< waiting for consumer.");
-      cons_thread.join();
-
-      log("Shutting down");
-   }
-
-   // // ////
-   // // INTERNAL CLASSES ////
-   // // ////
-
-   /**
-    * Producer thread - runs a single producer until the maximum number of messages is sent, the producer stop time is
-    * reached, or a test error is detected.
-    */
-
-   protected class producerThread extends Thread {
-
-      protected Session msgSess;
-      protected MessageProducer msgProd;
-      protected String producerTag;
-      protected int numMsg;
-      protected int numPerSess;
-      protected long producer_stop_time;
-
-      producerThread(Session sess, MessageProducer prod, String tag, int num_msg, int sess_size) {
-         super();
-
-         producer_stop_time = 0;
-         msgSess = sess;
-         msgProd = prod;
-         producerTag = tag;
-         numMsg = num_msg;
-         numPerSess = sess_size;
-      }
-
-      public void execTest() throws Exception {
-         Message msg;
-         int sess_start;
-         int cur;
-
-         sess_start = 0;
-         cur = 0;
-         while ((cur < numMsg) && (!didTimeOut()) && ((!Stop_after_error) || (Num_error == 0))) {
-            msg = msgSess.createTextMessage("test message from " + producerTag);
-            msg.setStringProperty("testprodtag", producerTag);
-            msg.setIntProperty("seq", cur);
-
-            if (msg instanceof ActiveMQMessage) {
-               ((ActiveMQMessage) msg).setResponseRequired(true);
-            }
-
-            //
-            // Send the message.
-            //
-
-            msgProd.send(msg);
-            cur++;
-
-            //
-            // Commit if the number of messages per session has been reached, and
-            // transactions are being used (only when > 1 msg per sess).
-            //
-
-            if ((numPerSess > 1) && ((cur - sess_start) >= numPerSess)) {
-               msgSess.commit();
-               sess_start = cur;
-            }
-         }
-
-         // Make sure to send the final commit, if there were sends since the last commit.
-         if ((numPerSess > 1) && ((cur - sess_start) > 0))
-            msgSess.commit();
-
-         if (cur < numMsg)
-            log("* Producer " + producerTag + " timed out at " + java.lang.System.nanoTime() + " (stop time " + producer_stop_time + ")");
-      }
-
-      /**
-       * Check whether it is time for the producer to terminate.
-       */
-
-      protected boolean didTimeOut() {
-         if ((Producer_stop_time > 0) && (java.lang.System.nanoTime() >= Producer_stop_time))
-            return true;
-
-         return false;
-      }
-
-      /**
-       * Run the producer.
-       */
-
-      @Override
-      public void run() {
-         try {
-            log("- running producer " + producerTag);
-            execTest();
-            log("- finished running producer " + producerTag);
-         }
-         catch (Throwable thrown) {
-            Num_error++;
-            fail("producer " + producerTag + " failed: " + thrown.getMessage());
-            throw new Error("producer " + producerTag + " failed", thrown);
-         }
-      }
-
-      @Override
-      public String toString() {
-         return producerTag;
-      }
-   }
-
-   /**
-    * Producer thread - runs a single consumer until the maximum number of messages is received, the consumer stop time
-    * is reached, or a test error is detected.
-    */
-
-   protected class consumerThread extends Thread {
-
-      protected Session msgSess;
-      protected MessageConsumer msgCons;
-      protected String consumerTag;
-      protected int numMsg;
-      protected int numPerSess;
-
-      consumerThread(Session sess, MessageConsumer cons, String tag, int num_msg, int sess_size) {
-         super();
-
-         msgSess = sess;
-         msgCons = cons;
-         consumerTag = tag;
-         numMsg = num_msg;
-         numPerSess = sess_size;
-      }
-
-      public void execTest() throws Exception {
-         Message msg;
-         int sess_start;
-         int cur;
-
-         msg = null;
-         sess_start = 0;
-         cur = 0;
-
-         while ((cur < numMsg) && (!didTimeOut()) && ((!Stop_after_error) || (Num_error == 0))) {
-            //
-            // Use a timeout of 1 second to periodically check the consumer timeout.
-            //
-            msg = msgCons.receive(1000);
-            if (msg != null) {
-               checkMessage(msg, cur);
-               cur++;
-
-               if ((numPerSess > 1) && ((cur - sess_start) >= numPerSess)) {
-                  msg.acknowledge();
-                  sess_start = cur;
-               }
-            }
-         }
-
-         // Acknowledge the last messages, if they were not yet acknowledged.
-         if ((numPerSess > 1) && ((cur - sess_start) > 0))
-            msg.acknowledge();
-
-         if (cur < numMsg)
-            log("* Consumer " + consumerTag + " timed out");
-      }
-
-      /**
-       * Check whether it is time for the consumer to terminate.
-       */
-
-      protected boolean didTimeOut() {
-         if ((Consumer_stop_time > 0) && (java.lang.System.nanoTime() >= Consumer_stop_time))
-            return true;
-
-         return false;
-      }
-
-      /**
-       * Verify the message received. Sequence numbers are checked and are expected to exactly match the message
-       * number (starting at 0).
-       */
-
-      protected void checkMessage(Message msg, int exp_seq) throws javax.jms.JMSException {
-         int seq;
-
-         seq = msg.getIntProperty("seq");
-
-         if (exp_seq != seq) {
-            Num_error++;
-            fail("*** Consumer " + consumerTag + " expected seq " + exp_seq + "; received " + seq);
-         }
-      }
-
-      /**
-       * Run the consumer.
-       */
-
-      @Override
-      public void run() {
-         try {
-            log("- running consumer " + consumerTag);
-            execTest();
-            log("- running consumer " + consumerTag);
-         }
-         catch (Throwable thrown) {
-            Num_error++;
-            fail("consumer " + consumerTag + " failed: " + thrown.getMessage());
-            throw new Error("consumer " + consumerTag + " failed", thrown);
-         }
-      }
-
-      @Override
-      public String toString() {
-         return consumerTag;
-      }
-   }
-}
\ No newline at end of file


[23/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2580Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2580Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2580Test.java
deleted file mode 100644
index 9d79a8e..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2580Test.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/**
- * 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;
-
-import junit.framework.Test;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQPrefetchPolicy;
-import org.apache.activemq.TestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.jms.TopicConnection;
-import javax.jms.TopicSession;
-
-public class AMQ2580Test extends TestSupport {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ2580Test.class);
-
-   private static final String TOPIC_NAME = "topicName";
-   private static final String CLIENT_ID = "client_id";
-   private static final String textOfSelectedMsg = "good_message";
-
-   protected TopicConnection connection;
-
-   private Topic topic;
-   private Session session;
-   private MessageProducer producer;
-   private ConnectionFactory connectionFactory;
-   private BrokerService service;
-
-   public static Test suite() {
-      return suite(AMQ2580Test.class);
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      super.setUp();
-      initDurableBroker();
-      initConnectionFactory();
-      initTopic();
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      shutdownClient();
-      service.stop();
-      super.tearDown();
-   }
-
-   private void initConnection() throws JMSException {
-      if (connection == null) {
-         LOG.info("Initializing connection");
-
-         connection = (TopicConnection) connectionFactory.createConnection();
-         connection.start();
-      }
-   }
-
-   public void initCombosForTestTopicIsDurableSmokeTest() throws Exception {
-      addCombinationValues("defaultPersistenceAdapter", PersistenceAdapterChoice.values());
-   }
-
-   public void testTopicIsDurableSmokeTest() throws Exception {
-
-      initClient();
-      MessageConsumer consumer = createMessageConsumer();
-      LOG.info("Consuming message");
-      assertNull(consumer.receive(1));
-      shutdownClient();
-      consumer.close();
-
-      sendMessages();
-      shutdownClient();
-
-      initClient();
-      consumer = createMessageConsumer();
-
-      LOG.info("Consuming message");
-      TextMessage answer1 = (TextMessage) consumer.receive(1000);
-      assertNotNull("we got our message", answer1);
-
-      consumer.close();
-   }
-
-   private MessageConsumer createMessageConsumer() throws JMSException {
-      LOG.info("creating durable subscriber");
-      return session.createDurableSubscriber(topic, TOPIC_NAME, "name='value'", false);
-   }
-
-   private void initClient() throws JMSException {
-      LOG.info("Initializing client");
-
-      initConnection();
-      initSession();
-   }
-
-   private void shutdownClient() throws JMSException {
-      LOG.info("Closing session and connection");
-      session.close();
-      connection.close();
-      session = null;
-      connection = null;
-   }
-
-   private void sendMessages() throws JMSException {
-      initConnection();
-
-      initSession();
-
-      LOG.info("Creating producer");
-      producer = session.createProducer(topic);
-
-      sendMessageThatFailsSelection();
-
-      sendMessage(textOfSelectedMsg, "value");
-   }
-
-   private void initSession() throws JMSException {
-      LOG.info("Initializing session");
-      session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
-   }
-
-   private void sendMessageThatFailsSelection() throws JMSException {
-      for (int i = 0; i < 5; i++) {
-         String textOfNotSelectedMsg = "Msg_" + i;
-         sendMessage(textOfNotSelectedMsg, "not_value");
-         LOG.info("#");
-      }
-   }
-
-   private void sendMessage(String msgText, String propertyValue) throws JMSException {
-      LOG.info("Creating message: " + msgText);
-      TextMessage messageToSelect = session.createTextMessage(msgText);
-      messageToSelect.setStringProperty("name", propertyValue);
-      LOG.info("Sending message");
-      producer.send(messageToSelect);
-   }
-
-   protected void initConnectionFactory() throws Exception {
-      ActiveMQConnectionFactory activeMqConnectionFactory = createActiveMqConnectionFactory();
-      connectionFactory = activeMqConnectionFactory;
-   }
-
-   private ActiveMQConnectionFactory createActiveMqConnectionFactory() throws Exception {
-      ActiveMQConnectionFactory activeMqConnectionFactory = new ActiveMQConnectionFactory("failover:" + service.getTransportConnectors().get(0).getConnectUri().toString());
-      activeMqConnectionFactory.setWatchTopicAdvisories(false);
-      ActiveMQPrefetchPolicy prefetchPolicy = new ActiveMQPrefetchPolicy();
-      prefetchPolicy.setDurableTopicPrefetch(2);
-      prefetchPolicy.setOptimizeDurableTopicPrefetch(2);
-      activeMqConnectionFactory.setPrefetchPolicy(prefetchPolicy);
-      activeMqConnectionFactory.setClientID(CLIENT_ID);
-      return activeMqConnectionFactory;
-   }
-
-   private void initDurableBroker() throws Exception {
-      service = new BrokerService();
-      setDefaultPersistenceAdapter(service);
-      service.setDeleteAllMessagesOnStartup(true);
-      service.setAdvisorySupport(false);
-      service.setTransportConnectorURIs(new String[]{"tcp://localhost:0"});
-      service.setPersistent(true);
-      service.setUseJmx(false);
-      service.start();
-
-   }
-
-   private void initTopic() throws JMSException {
-      initConnection();
-      TopicSession topicSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
-      topic = topicSession.createTopic(TOPIC_NAME);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2584ConcurrentDlqTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2584ConcurrentDlqTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2584ConcurrentDlqTest.java
deleted file mode 100644
index 3b7a11b..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2584ConcurrentDlqTest.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/**
- * 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;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.util.Arrays;
-import java.util.Properties;
-import java.util.Vector;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TopicSubscriber;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.BrokerView;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.store.PersistenceAdapter;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.util.IntrospectionSupport;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-// variation on AMQ2584 where the DLQ consumer works in parallel to producer so
-// that some dups are not suppressed as they are already acked by the consumer
-// the audit needs to be disabled to allow these dupes to be consumed
-public class AMQ2584ConcurrentDlqTest extends org.apache.activemq.TestSupport {
-
-   static final Logger LOG = LoggerFactory.getLogger(AMQ2584ConcurrentDlqTest.class);
-   BrokerService broker = null;
-   ActiveMQTopic topic;
-
-   ActiveMQConnection consumerConnection = null, producerConnection = null, dlqConnection = null;
-   Session consumerSession;
-   Session producerSession;
-   MessageProducer producer;
-   Vector<TopicSubscriber> duralbeSubs = new Vector<>();
-   final int numMessages = 1000;
-   final int numDurableSubs = 2;
-
-   String data;
-   private long dlqConsumerLastReceivedTimeStamp;
-   private AtomicLong dlqReceivedCount = new AtomicLong(0);
-
-   // 2 deliveries of each message, 3 producers
-   CountDownLatch redeliveryConsumerLatch = new CountDownLatch(((2 * numMessages) * numDurableSubs) - 1);
-   // should get at least numMessages, possibly more
-   CountDownLatch dlqConsumerLatch = new CountDownLatch((numMessages - 1));
-
-   public void testSize() throws Exception {
-      openConsumer(redeliveryConsumerLatch);
-      openDlqConsumer(dlqConsumerLatch);
-
-      assertEquals(0, broker.getAdminView().getStorePercentUsage());
-
-      for (int i = 0; i < numMessages; i++) {
-         sendMessage(false);
-      }
-
-      final BrokerView brokerView = broker.getAdminView();
-
-      broker.getSystemUsage().getStoreUsage().isFull();
-      LOG.info("store percent usage: " + brokerView.getStorePercentUsage());
-      assertTrue("redelivery consumer got all it needs, remaining: " + redeliveryConsumerLatch.getCount(), redeliveryConsumerLatch.await(60, TimeUnit.SECONDS));
-      assertTrue("dql  consumer got all it needs", dlqConsumerLatch.await(60, TimeUnit.SECONDS));
-      closeConsumer();
-
-      LOG.info("Giving dlq a chance to clear down once topic consumer is closed");
-
-      // consumer all of the duplicates that arrived after the first ack
-      closeDlqConsumer();
-
-      //get broker a chance to clean obsolete messages, wait 2*cleanupInterval
-      Thread.sleep(5000);
-
-      FilenameFilter justLogFiles = new FilenameFilter() {
-         @Override
-         public boolean accept(File file, String s) {
-            return s.endsWith(".log");
-         }
-      };
-      int numFiles = ((KahaDBPersistenceAdapter) broker.getPersistenceAdapter()).getDirectory().list(justLogFiles).length;
-      if (numFiles > 2) {
-         LOG.info(Arrays.toString(((KahaDBPersistenceAdapter) broker.getPersistenceAdapter()).getDirectory().list(justLogFiles)));
-      }
-      LOG.info("num files: " + numFiles);
-      assertEquals("kahaDB dir should contain 1 db file,is: " + numFiles, 1, numFiles);
-   }
-
-   private void openConsumer(final CountDownLatch latch) throws Exception {
-      consumerConnection = (ActiveMQConnection) createConnection();
-      consumerConnection.setClientID("cliID");
-      consumerConnection.start();
-      consumerSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      MessageListener listener = new MessageListener() {
-         @Override
-         public void onMessage(Message message) {
-            latch.countDown();
-            try {
-               consumerSession.recover();
-            }
-            catch (Exception ignored) {
-               ignored.printStackTrace();
-            }
-         }
-      };
-
-      for (int i = 1; i <= numDurableSubs; i++) {
-         TopicSubscriber sub = consumerSession.createDurableSubscriber(topic, "subName" + i);
-         sub.setMessageListener(listener);
-         duralbeSubs.add(sub);
-      }
-   }
-
-   private void openDlqConsumer(final CountDownLatch received) throws Exception {
-
-      dlqConnection = (ActiveMQConnection) createConnection();
-      Session dlqSession = dlqConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer dlqConsumer = dlqSession.createConsumer(new ActiveMQQueue("ActiveMQ.DLQ"));
-      dlqConsumer.setMessageListener(new MessageListener() {
-         @Override
-         public void onMessage(Message message) {
-            if (received.getCount() > 0 && received.getCount() % 200 == 0) {
-               LOG.info("remaining on DLQ: " + received.getCount());
-            }
-            received.countDown();
-            dlqConsumerLastReceivedTimeStamp = System.currentTimeMillis();
-            dlqReceivedCount.incrementAndGet();
-         }
-      });
-      dlqConnection.start();
-   }
-
-   private void closeConsumer() throws JMSException {
-      for (TopicSubscriber sub : duralbeSubs) {
-         sub.close();
-      }
-      if (consumerSession != null) {
-         for (int i = 1; i <= numDurableSubs; i++) {
-            consumerSession.unsubscribe("subName" + i);
-         }
-      }
-      if (consumerConnection != null) {
-         consumerConnection.close();
-         consumerConnection = null;
-      }
-   }
-
-   private void closeDlqConsumer() throws JMSException, InterruptedException {
-      final long limit = System.currentTimeMillis() + 30 * 1000;
-      if (dlqConsumerLastReceivedTimeStamp > 0) {
-         while (System.currentTimeMillis() < dlqConsumerLastReceivedTimeStamp + 5000 && System.currentTimeMillis() < limit) {
-            LOG.info("waiting for DLQ do drain, receivedCount: " + dlqReceivedCount);
-            TimeUnit.SECONDS.sleep(1);
-         }
-      }
-      if (dlqConnection != null) {
-         dlqConnection.close();
-         dlqConnection = null;
-      }
-   }
-
-   private void sendMessage(boolean filter) throws Exception {
-      if (producerConnection == null) {
-         producerConnection = (ActiveMQConnection) createConnection();
-         producerConnection.start();
-         producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         producer = producerSession.createProducer(topic);
-      }
-
-      Message message = producerSession.createMessage();
-      message.setStringProperty("data", data);
-      producer.send(message);
-   }
-
-   private void startBroker(boolean deleteMessages) throws Exception {
-      broker = new BrokerService();
-      broker.setAdvisorySupport(false);
-      broker.setBrokerName("testStoreSize");
-
-      PolicyMap map = new PolicyMap();
-      PolicyEntry entry = new PolicyEntry();
-      entry.setEnableAudit(false);
-      map.setDefaultEntry(entry);
-      broker.setDestinationPolicy(map);
-
-      if (deleteMessages) {
-         broker.setDeleteAllMessagesOnStartup(true);
-      }
-      configurePersistenceAdapter(broker.getPersistenceAdapter());
-      broker.getSystemUsage().getStoreUsage().setLimit(200 * 1000 * 1000);
-      broker.start();
-   }
-
-   private void configurePersistenceAdapter(PersistenceAdapter persistenceAdapter) {
-      Properties properties = new Properties();
-      String maxFileLengthVal = String.valueOf(2 * 1024 * 1024);
-      properties.put("journalMaxFileLength", maxFileLengthVal);
-      properties.put("maxFileLength", maxFileLengthVal);
-      properties.put("cleanupInterval", "2000");
-      properties.put("checkpointInterval", "2000");
-      // there are problems with duplicate dispatch in the cursor, which maintain
-      // a map of messages. A dup dispatch can be dropped.
-      // see: org.apache.activemq.broker.region.cursors.OrderedPendingList
-      // Adding duplicate detection to the default DLQ strategy removes the problem
-      // which means we can leave the default for concurrent store and dispatch q
-      //properties.put("concurrentStoreAndDispatchQueues", "false");
-
-      IntrospectionSupport.setProperties(persistenceAdapter, properties);
-   }
-
-   private void stopBroker() throws Exception {
-      if (broker != null)
-         broker.stop();
-      broker = null;
-   }
-
-   @Override
-   protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
-      return new ActiveMQConnectionFactory("vm://testStoreSize?jms.watchTopicAdvisories=false&jms.redeliveryPolicy.maximumRedeliveries=1&jms.redeliveryPolicy.initialRedeliveryDelay=0&waitForStart=5000&create=false");
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      super.setUp();
-
-      StringBuilder sb = new StringBuilder(5000);
-      for (int i = 0; i < 5000; i++) {
-         sb.append('a');
-      }
-      data = sb.toString();
-
-      startBroker(true);
-      topic = (ActiveMQTopic) createDestination();
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      stopBroker();
-      super.tearDown();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2584Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2584Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2584Test.java
deleted file mode 100644
index 14760d9..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2584Test.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/**
- * 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;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.TestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.BrokerView;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.store.PersistenceAdapter;
-import org.apache.activemq.util.IntrospectionSupport;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@RunWith(value = Parameterized.class)
-public class AMQ2584Test extends org.apache.activemq.TestSupport {
-
-   static final Logger LOG = LoggerFactory.getLogger(AMQ2584Test.class);
-   BrokerService broker = null;
-   ActiveMQTopic topic;
-
-   ActiveMQConnection consumerConnection = null, producerConnection = null;
-   Session producerSession;
-   MessageProducer producer;
-   final int minPercentUsageForStore = 3;
-   String data;
-
-   private final TestSupport.PersistenceAdapterChoice persistenceAdapterChoice;
-
-   @Parameterized.Parameters(name = "{0}")
-   public static Collection<TestSupport.PersistenceAdapterChoice[]> getTestParameters() {
-      TestSupport.PersistenceAdapterChoice[] kahaDb = {TestSupport.PersistenceAdapterChoice.KahaDB};
-      TestSupport.PersistenceAdapterChoice[] levelDb = {TestSupport.PersistenceAdapterChoice.LevelDB};
-      List<TestSupport.PersistenceAdapterChoice[]> choices = new ArrayList<>();
-      choices.add(kahaDb);
-      choices.add(levelDb);
-
-      return choices;
-   }
-
-   public AMQ2584Test(TestSupport.PersistenceAdapterChoice choice) {
-      this.persistenceAdapterChoice = choice;
-   }
-
-   @Test(timeout = 120000)
-   public void testSize() throws Exception {
-      int messages = 1000;
-      CountDownLatch redeliveryConsumerLatch = new CountDownLatch((messages * 3));
-      openConsumer(redeliveryConsumerLatch);
-
-      assertEquals(0, broker.getAdminView().getStorePercentUsage());
-
-      for (int i = 0; i < messages; i++) {
-         sendMessage(false);
-      }
-
-      final BrokerView brokerView = broker.getAdminView();
-
-      broker.getSystemUsage().getStoreUsage().isFull();
-      LOG.info("store percent usage: " + brokerView.getStorePercentUsage());
-      int storePercentUsage = broker.getAdminView().getStorePercentUsage();
-      assertTrue("some store in use", storePercentUsage > minPercentUsageForStore);
-
-      assertTrue("redelivery consumer got all it needs", redeliveryConsumerLatch.await(60, TimeUnit.SECONDS));
-      closeConsumer();
-
-      // consume from DLQ
-      final CountDownLatch received = new CountDownLatch(messages);
-      consumerConnection = (ActiveMQConnection) createConnection();
-      Session dlqSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer dlqConsumer = dlqSession.createConsumer(new ActiveMQQueue("ActiveMQ.DLQ"));
-      dlqConsumer.setMessageListener(new MessageListener() {
-         @Override
-         public void onMessage(Message message) {
-            if (received.getCount() % 500 == 0) {
-               LOG.info("remaining on DLQ: " + received.getCount());
-            }
-            received.countDown();
-         }
-      });
-      consumerConnection.start();
-
-      assertTrue("Not all messages reached the DLQ", received.await(60, TimeUnit.SECONDS));
-
-      assertTrue("Store usage exceeds expected usage", Wait.waitFor(new Wait.Condition() {
-                    @Override
-                    public boolean isSatisified() throws Exception {
-                       broker.getSystemUsage().getStoreUsage().isFull();
-                       LOG.info("store precent usage: " + brokerView.getStorePercentUsage());
-                       return broker.getAdminView().getStorePercentUsage() < minPercentUsageForStore;
-                    }
-                 }));
-
-      closeConsumer();
-
-   }
-
-   private void openConsumer(final CountDownLatch latch) throws Exception {
-      consumerConnection = (ActiveMQConnection) createConnection();
-      consumerConnection.setClientID("cliID");
-      consumerConnection.start();
-      final Session session = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      MessageListener listener = new MessageListener() {
-         @Override
-         public void onMessage(Message message) {
-            latch.countDown();
-            try {
-               session.recover();
-            }
-            catch (Exception ignored) {
-               ignored.printStackTrace();
-            }
-
-         }
-      };
-
-      session.createDurableSubscriber(topic, "subName1").setMessageListener(listener);
-      session.createDurableSubscriber(topic, "subName2").setMessageListener(listener);
-      session.createDurableSubscriber(topic, "subName3").setMessageListener(listener);
-   }
-
-   private void closeConsumer() throws JMSException {
-      if (consumerConnection != null)
-         consumerConnection.close();
-      consumerConnection = null;
-   }
-
-   private void sendMessage(boolean filter) throws Exception {
-      if (producerConnection == null) {
-         producerConnection = (ActiveMQConnection) createConnection();
-         producerConnection.start();
-         producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         producer = producerSession.createProducer(topic);
-      }
-
-      Message message = producerSession.createMessage();
-      message.setStringProperty("data", data);
-      producer.send(message);
-   }
-
-   private void startBroker(boolean deleteMessages) throws Exception {
-      broker = new BrokerService();
-      broker.setAdvisorySupport(false);
-      broker.setBrokerName("testStoreSize");
-
-      if (deleteMessages) {
-         broker.setDeleteAllMessagesOnStartup(true);
-      }
-      LOG.info("Starting broker with persistenceAdapterChoice " + persistenceAdapterChoice.toString());
-      setPersistenceAdapter(broker, persistenceAdapterChoice);
-      configurePersistenceAdapter(broker.getPersistenceAdapter());
-      broker.getSystemUsage().getStoreUsage().setLimit(200 * 1000 * 1000);
-      broker.start();
-   }
-
-   private void configurePersistenceAdapter(PersistenceAdapter persistenceAdapter) {
-      Properties properties = new Properties();
-      String maxFileLengthVal = String.valueOf(1 * 1024 * 1024);
-      properties.put("journalMaxFileLength", maxFileLengthVal);
-      properties.put("maxFileLength", maxFileLengthVal);
-      properties.put("cleanupInterval", "2000");
-      properties.put("checkpointInterval", "2000");
-
-      IntrospectionSupport.setProperties(persistenceAdapter, properties);
-   }
-
-   private void stopBroker() throws Exception {
-      if (broker != null)
-         broker.stop();
-      broker = null;
-   }
-
-   @Override
-   protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
-      return new ActiveMQConnectionFactory("vm://testStoreSize?jms.watchTopicAdvisories=false&jms.redeliveryPolicy.maximumRedeliveries=0&jms.closeTimeout=60000&waitForStart=5000&create=false");
-   }
-
-   @Override
-   @Before
-   public void setUp() throws Exception {
-      StringBuilder sb = new StringBuilder(5000);
-      for (int i = 0; i < 5000; i++) {
-         sb.append('a');
-      }
-      data = sb.toString();
-
-      startBroker(true);
-      topic = (ActiveMQTopic) createDestination();
-   }
-
-   @Override
-   @After
-   public void tearDown() throws Exception {
-      stopBroker();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2585Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2585Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2585Test.java
deleted file mode 100644
index 71cb2a8..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2585Test.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- *
- * 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;
-
-import javax.jms.Destination;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.EmbeddedBrokerAndConnectionTestSupport;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTextMessage;
-import org.apache.activemq.command.Message;
-import org.apache.activemq.spring.ConsumerBean;
-
-public class AMQ2585Test extends EmbeddedBrokerAndConnectionTestSupport {
-
-   private final Destination destination = new ActiveMQQueue("MyQueue");
-   final static String LENGTH10STRING = "1234567890";
-   private Session session;
-   private MessageProducer producer;
-   private ConsumerBean messageList;
-
-   public void testOneMessageWithProperties() throws Exception {
-      TextMessage message = session.createTextMessage(LENGTH10STRING);
-      message.setStringProperty(LENGTH10STRING, LENGTH10STRING);
-      producer.send(message);
-
-      messageList.assertMessagesArrived(1);
-
-      ActiveMQTextMessage received = ((ActiveMQTextMessage) messageList.flushMessages().get(0));
-
-      assertEquals(LENGTH10STRING, received.getText());
-      assertTrue(received.getProperties().size() > 0);
-      assertTrue(received.propertyExists(LENGTH10STRING));
-      assertEquals(LENGTH10STRING, received.getStringProperty(LENGTH10STRING));
-
-      /**
-       * As specified by getSize(), the size (memory usage) of the body should
-       * be length of text * 2. Unsure of how memory usage is calculated for
-       * properties, but should probably not be less than the sum of (string)
-       * lengths for the key name and value.
-       */
-
-      final int sizeShouldBeNoLessThan = LENGTH10STRING.length() * 4 + Message.DEFAULT_MINIMUM_MESSAGE_SIZE;
-      assertTrue("Message size was smaller than expected: " + received.getSize(), received.getSize() >= sizeShouldBeNoLessThan);
-      assertFalse(LENGTH10STRING.length() * 2 == received.getSize());
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      bindAddress = bindAddress + "?marshal=true";
-      super.setUp();
-      messageList = new ConsumerBean();
-      messageList.setVerbose(true);
-
-      session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      MessageConsumer messageConsumer = session.createConsumer(destination);
-
-      messageConsumer.setMessageListener(messageList);
-
-      producer = session.createProducer(destination);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2616Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2616Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2616Test.java
deleted file mode 100644
index f22ff48..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2616Test.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * 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;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.concurrent.atomic.AtomicBoolean;
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.FilePendingQueueMessageStoragePolicy;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.util.IOHelper;
-
-public class AMQ2616Test extends TestCase {
-
-   private static final int NUMBER = 2000;
-   private BrokerService brokerService;
-   private final ArrayList<Thread> threads = new ArrayList<>();
-   private final String ACTIVEMQ_BROKER_BIND = "tcp://0.0.0.0:0";
-   private final AtomicBoolean shutdown = new AtomicBoolean();
-
-   private String connectionUri;
-
-   public void testQueueResourcesReleased() throws Exception {
-      ActiveMQConnectionFactory fac = new ActiveMQConnectionFactory(connectionUri);
-      Connection tempConnection = fac.createConnection();
-      tempConnection.start();
-      Session tempSession = tempConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Queue tempQueue = tempSession.createTemporaryQueue();
-
-      Connection testConnection = fac.createConnection();
-      long startUsage = brokerService.getSystemUsage().getMemoryUsage().getUsage();
-      Session testSession = testConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer testProducer = testSession.createProducer(tempQueue);
-      byte[] payload = new byte[1024 * 4];
-      for (int i = 0; i < NUMBER; i++) {
-         BytesMessage msg = testSession.createBytesMessage();
-         msg.writeBytes(payload);
-         testProducer.send(msg);
-      }
-      long endUsage = brokerService.getSystemUsage().getMemoryUsage().getUsage();
-      assertFalse(startUsage == endUsage);
-      tempConnection.close();
-      Thread.sleep(1000);
-      endUsage = brokerService.getSystemUsage().getMemoryUsage().getUsage();
-      assertEquals(startUsage, endUsage);
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      // Start an embedded broker up.
-      brokerService = new BrokerService();
-
-      KahaDBPersistenceAdapter adaptor = new KahaDBPersistenceAdapter();
-      adaptor.setEnableJournalDiskSyncs(false);
-      File file = new File("target/AMQ2616Test");
-      IOHelper.mkdirs(file);
-      IOHelper.deleteChildren(file);
-      adaptor.setDirectory(file);
-      brokerService.setPersistenceAdapter(adaptor);
-
-      PolicyMap policyMap = new PolicyMap();
-      PolicyEntry pe = new PolicyEntry();
-      pe.setMemoryLimit(10 * 1024 * 1024);
-      pe.setOptimizedDispatch(true);
-      pe.setProducerFlowControl(false);
-      pe.setExpireMessagesPeriod(1000);
-      pe.setPendingQueuePolicy(new FilePendingQueueMessageStoragePolicy());
-      policyMap.put(new ActiveMQQueue(">"), pe);
-      brokerService.setDestinationPolicy(policyMap);
-      brokerService.getSystemUsage().getMemoryUsage().setLimit(20 * 1024 * 1024);
-      brokerService.getSystemUsage().getTempUsage().setLimit(200 * 1024 * 1024);
-      brokerService.addConnector(ACTIVEMQ_BROKER_BIND);
-      brokerService.start();
-      brokerService.waitUntilStarted();
-
-      connectionUri = brokerService.getTransportConnectors().get(0).getPublishableConnectString();
-
-      new ActiveMQQueue(getName());
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      // Stop any running threads.
-      shutdown.set(true);
-      for (Thread t : threads) {
-         t.interrupt();
-         t.join();
-      }
-      brokerService.stop();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2645Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2645Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2645Test.java
deleted file mode 100644
index 61a5d1e..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2645Test.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- * 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;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ2645Test extends EmbeddedBrokerTestSupport {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ2645Test.class);
-   private final static String QUEUE_NAME = "test.daroo.q";
-
-   public void testWaitForTransportInterruptionProcessingHang() throws Exception {
-      final ConnectionFactory fac = new ActiveMQConnectionFactory("failover:(" + this.bindAddress + ")");
-      final Connection connection = fac.createConnection();
-      try {
-         final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         final Queue queue = session.createQueue(QUEUE_NAME);
-         final MessageProducer producer = session.createProducer(queue);
-         producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-         connection.start();
-
-         producer.send(session.createTextMessage("test"));
-
-         final CountDownLatch afterRestart = new CountDownLatch(1);
-         final CountDownLatch twoNewMessages = new CountDownLatch(1);
-         final CountDownLatch thirdMessageReceived = new CountDownLatch(1);
-
-         final MessageConsumer consumer = session.createConsumer(session.createQueue(QUEUE_NAME));
-         consumer.setMessageListener(new MessageListener() {
-            @Override
-            public void onMessage(Message message) {
-               try {
-                  afterRestart.await();
-
-                  final TextMessage txtMsg = (TextMessage) message;
-                  if (txtMsg.getText().equals("test")) {
-                     producer.send(session.createTextMessage("test 1"));
-                     TimeUnit.SECONDS.sleep(5);
-                     // THIS SECOND send() WILL CAUSE CONSUMER DEADLOCK
-                     producer.send(session.createTextMessage("test 2"));
-                     LOG.info("Two new messages produced.");
-                     twoNewMessages.countDown();
-                  }
-                  else if (txtMsg.getText().equals("test 3")) {
-                     thirdMessageReceived.countDown();
-                  }
-               }
-               catch (Exception e) {
-                  LOG.error(e.toString());
-                  throw new RuntimeException(e);
-               }
-            }
-         });
-
-         LOG.info("Stopping broker....");
-         broker.stop();
-
-         LOG.info("Creating new broker...");
-         broker = createBroker();
-         startBroker();
-         broker.waitUntilStarted();
-
-         afterRestart.countDown();
-         assertTrue("Consumer is deadlocked!", twoNewMessages.await(60, TimeUnit.SECONDS));
-
-         producer.send(session.createTextMessage("test 3"));
-         assertTrue("Consumer got third message after block", thirdMessageReceived.await(60, TimeUnit.SECONDS));
-
-      }
-      finally {
-         broker.stop();
-      }
-
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      bindAddress = "tcp://0.0.0.0:61617";
-      super.setUp();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2736Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2736Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2736Test.java
deleted file mode 100644
index 533b827..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2736Test.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * 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;
-
-import javax.jms.Connection;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.store.kahadb.KahaDBStore;
-import org.apache.activemq.util.DefaultIOExceptionHandler;
-import org.junit.After;
-import org.junit.Test;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-public class AMQ2736Test {
-
-   BrokerService broker;
-
-   @Test
-   public void testRollbackOnRecover() throws Exception {
-      broker = createAndStartBroker(true);
-      DefaultIOExceptionHandler ignoreAllExceptionsIOExHandler = new DefaultIOExceptionHandler();
-      ignoreAllExceptionsIOExHandler.setIgnoreAllErrors(true);
-      broker.setIoExceptionHandler(ignoreAllExceptionsIOExHandler);
-
-      ActiveMQConnectionFactory f = new ActiveMQConnectionFactory("vm://localhost?async=false");
-      f.setAlwaysSyncSend(true);
-      Connection c = f.createConnection();
-      c.start();
-      Session s = c.createSession(true, Session.SESSION_TRANSACTED);
-      MessageProducer p = s.createProducer(new ActiveMQQueue("Tx"));
-      p.send(s.createTextMessage("aa"));
-
-      // kill journal without commit
-      KahaDBPersistenceAdapter pa = (KahaDBPersistenceAdapter) broker.getPersistenceAdapter();
-      KahaDBStore store = pa.getStore();
-
-      assertNotNull("last tx location is present " + store.getInProgressTxLocationRange()[1]);
-
-      // test hack, close the journal to ensure no further journal updates when broker stops
-      // mimic kill -9 in terms of no normal shutdown sequence
-      store.getJournal().close();
-      try {
-         store.close();
-      }
-      catch (Exception expectedLotsAsJournalBorked) {
-      }
-
-      broker.stop();
-      broker.waitUntilStopped();
-
-      // restart with recovery
-      broker = createAndStartBroker(false);
-
-      pa = (KahaDBPersistenceAdapter) broker.getPersistenceAdapter();
-      store = pa.getStore();
-
-      // inflight non xa tx should be rolledback on recovery
-      assertNull("in progress tx location is present ", store.getInProgressTxLocationRange()[0]);
-
-   }
-
-   @After
-   public void stopBroker() throws Exception {
-      if (broker != null) {
-         broker.stop();
-      }
-   }
-
-   private BrokerService createAndStartBroker(boolean deleteAll) throws Exception {
-      BrokerService broker = new BrokerService();
-      broker.setDeleteAllMessagesOnStartup(deleteAll);
-      broker.setUseJmx(false);
-      broker.getManagementContext().setCreateConnector(false);
-      broker.start();
-      return broker;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2751Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2751Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2751Test.java
deleted file mode 100644
index 539354c..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2751Test.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * 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;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ2751Test extends EmbeddedBrokerTestSupport {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ2751Test.class);
-
-   private static String clientIdPrefix = "consumer";
-   private static String queueName = "FOO";
-
-   public void testRecoverRedelivery() throws Exception {
-
-      final CountDownLatch redelivery = new CountDownLatch(6);
-      final ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("failover:(" + broker.getTransportConnectors().get(0).getConnectUri() + ")");
-      try {
-
-         Connection connection = factory.createConnection();
-         String clientId = clientIdPrefix;
-         connection.setClientID(clientId);
-
-         final Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
-         Queue queue = session.createQueue(queueName);
-
-         MessageConsumer consumer = session.createConsumer(queue);
-
-         consumer.setMessageListener(new MessageListener() {
-            @Override
-            public void onMessage(Message message) {
-               try {
-                  LOG.info("Got message: " + message.getJMSMessageID());
-                  if (message.getJMSRedelivered()) {
-                     LOG.info("It's a redelivery.");
-                     redelivery.countDown();
-                  }
-                  LOG.info("calling recover() on the session to force redelivery.");
-                  session.recover();
-               }
-               catch (JMSException e) {
-                  e.printStackTrace();
-               }
-            }
-         });
-
-         System.out.println("Created queue consumer with clientId " + clientId);
-         connection.start();
-
-         MessageProducer producer = session.createProducer(queue);
-         producer.send(session.createTextMessage("test"));
-
-         assertTrue("we got 6 redeliveries", redelivery.await(20, TimeUnit.SECONDS));
-
-      }
-      finally {
-         broker.stop();
-      }
-
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      bindAddress = "tcp://localhost:0";
-      super.setUp();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2801Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2801Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2801Test.java
deleted file mode 100644
index 43394dc..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2801Test.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.jms.TopicConnection;
-import javax.jms.TopicPublisher;
-import javax.jms.TopicSession;
-import javax.management.ObjectName;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.DurableSubscriptionViewMBean;
-import org.apache.activemq.broker.region.policy.FilePendingQueueMessageStoragePolicy;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.usage.SystemUsage;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ2801Test {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ2801Test.class);
-
-   private static final String TOPICNAME = "InvalidPendingQueueTest";
-   private static final String SELECTOR1 = "JMS_ID" + " = '" + "TEST" + "'";
-   private static final String SELECTOR2 = "JMS_ID" + " = '" + "TEST2" + "'";
-   private static final String SUBSCRIPTION1 = "InvalidPendingQueueTest_1";
-   private static final String SUBSCRIPTION2 = "InvalidPendingQueueTest_2";
-   private static final int MSG_COUNT = 2500;
-   private Session session1;
-   private Connection conn1;
-   private Topic topic1;
-   private MessageConsumer consumer1;
-   private Session session2;
-   private Connection conn2;
-   private Topic topic2;
-   private MessageConsumer consumer2;
-   private BrokerService broker;
-   private String connectionUri;
-
-   @Before
-   public void setUp() throws Exception {
-      broker = new BrokerService();
-      broker.setDataDirectory("target" + File.separator + "activemq-data");
-      broker.setPersistent(true);
-      broker.setUseJmx(true);
-      broker.setAdvisorySupport(false);
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.addConnector("tcp://localhost:0").setName("Default");
-      applyMemoryLimitPolicy(broker);
-      broker.start();
-
-      connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
-   }
-
-   private void applyMemoryLimitPolicy(BrokerService broker) {
-      final SystemUsage memoryManager = new SystemUsage();
-      memoryManager.getMemoryUsage().setLimit(5818230784L);
-      memoryManager.getStoreUsage().setLimit(6442450944L);
-      memoryManager.getTempUsage().setLimit(3221225472L);
-      broker.setSystemUsage(memoryManager);
-
-      final List<PolicyEntry> policyEntries = new ArrayList<>();
-      final PolicyEntry entry = new PolicyEntry();
-      entry.setQueue(">");
-      entry.setProducerFlowControl(false);
-      entry.setMemoryLimit(504857608);
-      entry.setPendingQueuePolicy(new FilePendingQueueMessageStoragePolicy());
-      policyEntries.add(entry);
-
-      final PolicyMap policyMap = new PolicyMap();
-      policyMap.setPolicyEntries(policyEntries);
-      broker.setDestinationPolicy(policyMap);
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      conn1.close();
-      conn2.close();
-      if (broker != null) {
-         broker.stop();
-      }
-   }
-
-   private void produceMessages() throws Exception {
-      TopicConnection connection = createConnection();
-      TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
-      Topic topic = session.createTopic(TOPICNAME);
-      TopicPublisher producer = session.createPublisher(topic);
-      connection.start();
-      producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-      long tStamp = System.currentTimeMillis();
-      BytesMessage message = session2.createBytesMessage();
-      for (int i = 1; i <= MSG_COUNT; i++) {
-         message.setStringProperty("JMS_ID", "TEST");
-         message.setIntProperty("Type", i);
-         producer.publish(message);
-         if (i % 100 == 0) {
-            LOG.info("sent: " + i + " @ " + ((System.currentTimeMillis() - tStamp) / 100) + "m/ms");
-            tStamp = System.currentTimeMillis();
-         }
-      }
-   }
-
-   private void activeateSubscribers() throws Exception {
-      // First consumer
-      conn1 = createConnection();
-      conn1.setClientID(SUBSCRIPTION1);
-      session1 = conn1.createSession(true, Session.SESSION_TRANSACTED);
-      topic1 = session1.createTopic(TOPICNAME);
-      consumer1 = session1.createDurableSubscriber(topic1, SUBSCRIPTION1, SELECTOR1, false);
-      conn1.start();
-
-      // Second consumer that just exists
-      conn2 = createConnection();
-      conn2.setClientID(SUBSCRIPTION2);
-      session2 = conn2.createSession(true, Session.SESSION_TRANSACTED);
-      topic2 = session2.createTopic(TOPICNAME);
-      consumer2 = session2.createDurableSubscriber(topic2, SUBSCRIPTION2, SELECTOR2, false);
-      conn2.start();
-   }
-
-   @Test
-   public void testInvalidPendingQueue() throws Exception {
-
-      activeateSubscribers();
-
-      assertNotNull(consumer1);
-      assertNotNull(consumer2);
-
-      produceMessages();
-      LOG.debug("Sent messages to a single subscriber");
-      Thread.sleep(2000);
-
-      LOG.debug("Closing durable subscriber connections");
-      conn1.close();
-      conn2.close();
-      LOG.debug("Closed durable subscriber connections");
-
-      Thread.sleep(2000);
-      LOG.debug("Re-starting durable subscriber connections");
-
-      activeateSubscribers();
-      LOG.debug("Started up durable subscriber connections - now view activemq console to see pending queue size on the other subscriber");
-
-      ObjectName[] subs = broker.getAdminView().getDurableTopicSubscribers();
-
-      for (int i = 0; i < subs.length; i++) {
-         ObjectName subName = subs[i];
-         DurableSubscriptionViewMBean sub = (DurableSubscriptionViewMBean) broker.getManagementContext().newProxyInstance(subName, DurableSubscriptionViewMBean.class, true);
-
-         LOG.info(sub.getSubscriptionName() + ": pending = " + sub.getPendingQueueSize() + ", dispatched: " + sub.getDispatchedQueueSize());
-         if (sub.getSubscriptionName().equals(SUBSCRIPTION1)) {
-            assertEquals("Incorrect number of pending messages", MSG_COUNT, sub.getPendingQueueSize() + sub.getDispatchedQueueSize());
-         }
-         else {
-            assertEquals("Incorrect number of pending messages", 0, sub.getPendingQueueSize());
-         }
-      }
-   }
-
-   private TopicConnection createConnection() throws Exception {
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
-      connectionFactory.setBrokerURL(connectionUri);
-      TopicConnection conn = connectionFactory.createTopicConnection();
-      return conn;
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2832Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2832Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2832Test.java
deleted file mode 100644
index f089941..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2832Test.java
+++ /dev/null
@@ -1,379 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.Topic;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQSession;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.leveldb.LevelDBStore;
-import org.apache.activemq.store.PersistenceAdapter;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.store.kahadb.disk.journal.DataFile;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ2832Test {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ2832Test.class);
-
-   BrokerService broker = null;
-   private ActiveMQConnectionFactory cf;
-   private final Destination destination = new ActiveMQQueue("AMQ2832Test");
-   private String connectionUri;
-
-   protected void startBroker() throws Exception {
-      doStartBroker(true, false);
-   }
-
-   protected void restartBroker() throws Exception {
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-      }
-      doStartBroker(false, false);
-   }
-
-   protected void recoverBroker() throws Exception {
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-      }
-      doStartBroker(false, true);
-   }
-
-   private void doStartBroker(boolean delete, boolean recover) throws Exception {
-      broker = new BrokerService();
-      broker.setDeleteAllMessagesOnStartup(delete);
-      broker.setPersistent(true);
-      broker.setUseJmx(true);
-      broker.addConnector("tcp://localhost:0");
-
-      configurePersistence(broker, recover);
-
-      connectionUri = "vm://localhost?create=false";
-      cf = new ActiveMQConnectionFactory(connectionUri);
-
-      broker.start();
-      LOG.info("Starting broker..");
-   }
-
-   protected void configurePersistence(BrokerService brokerService, boolean recover) throws Exception {
-      KahaDBPersistenceAdapter adapter = (KahaDBPersistenceAdapter) brokerService.getPersistenceAdapter();
-
-      // ensure there are a bunch of data files but multiple entries in each
-      adapter.setJournalMaxFileLength(1024 * 20);
-
-      // speed up the test case, checkpoint and cleanup early and often
-      adapter.setCheckpointInterval(5000);
-      adapter.setCleanupInterval(5000);
-
-      if (recover) {
-         adapter.setForceRecoverIndex(true);
-      }
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-      }
-   }
-
-   /**
-    * Scenario:
-    * db-1.log has an unacknowledged message,
-    * db-2.log contains acks for the messages from db-1.log,
-    * db-3.log contains acks for the messages from db-2.log
-    *
-    * Expected behavior: since db-1.log is blocked, db-2.log and db-3.log should not be removed during the cleanup.
-    * Current situation on 5.10.0, 5.10.1 is that db-3.log is removed causing all messages from db-2.log, whose acks were in db-3.log, to be replayed.
-    *
-    * @throws Exception
-    */
-   @Test
-   public void testAckChain() throws Exception {
-      startBroker();
-
-      StagedConsumer consumer = new StagedConsumer();
-      // file #1
-      produceMessagesToConsumeMultipleDataFiles(5);
-      // acknowledge first 2 messages and leave the 3rd one unacknowledged blocking db-1.log
-      consumer.receive(3);
-
-      // send messages by consuming and acknowledging every message right after sent in order to get KahadbAdd and Remove command to be saved together
-      // this is necessary in order to get KahaAddMessageCommand to be saved in one db file and the corresponding KahaRemoveMessageCommand in the next one
-      produceAndConsumeImmediately(20, consumer);
-      consumer.receive(2).acknowledge(); // consume and ack the last 2 unconsumed
-
-      // now we have 3 files written and started with #4
-      consumer.close();
-
-      broker.stop();
-      broker.waitUntilStopped();
-
-      recoverBroker();
-
-      consumer = new StagedConsumer();
-      Message message = consumer.receive(1);
-      assertNotNull("One message stays unacked from db-1.log", message);
-      message.acknowledge();
-      message = consumer.receive(1);
-      assertNull("There should not be any unconsumed messages any more", message);
-      consumer.close();
-   }
-
-   private void produceAndConsumeImmediately(int numOfMsgs, StagedConsumer consumer) throws Exception {
-      for (int i = 0; i < numOfMsgs; i++) {
-         produceMessagesToConsumeMultipleDataFiles(1);
-         consumer.receive(1).acknowledge();
-      }
-   }
-
-   @Test
-   public void testAckRemovedMessageReplayedAfterRecovery() throws Exception {
-
-      startBroker();
-
-      StagedConsumer consumer = new StagedConsumer();
-      int numMessagesAvailable = produceMessagesToConsumeMultipleDataFiles(20);
-      // this will block the reclaiming of one data file
-      Message firstUnacked = consumer.receive(10);
-      LOG.info("first unacked: " + firstUnacked.getJMSMessageID());
-      Message secondUnacked = consumer.receive(1);
-      LOG.info("second unacked: " + secondUnacked.getJMSMessageID());
-      numMessagesAvailable -= 11;
-
-      numMessagesAvailable += produceMessagesToConsumeMultipleDataFiles(10);
-      // ensure ack is another data file
-      LOG.info("Acking firstUnacked: " + firstUnacked.getJMSMessageID());
-      firstUnacked.acknowledge();
-
-      numMessagesAvailable += produceMessagesToConsumeMultipleDataFiles(10);
-
-      consumer.receive(numMessagesAvailable).acknowledge();
-
-      // second unacked should keep first data file available but journal with the first ack
-      // may get whacked
-      consumer.close();
-
-      broker.stop();
-      broker.waitUntilStopped();
-
-      recoverBroker();
-
-      consumer = new StagedConsumer();
-      // need to force recovery?
-
-      Message msg = consumer.receive(1, 5);
-      assertNotNull("One messages left after recovery", msg);
-      msg.acknowledge();
-
-      // should be no more messages
-      msg = consumer.receive(1, 5);
-      assertEquals("Only one messages left after recovery: " + msg, null, msg);
-      consumer.close();
-   }
-
-   @Test
-   public void testAlternateLossScenario() throws Exception {
-
-      startBroker();
-      PersistenceAdapter pa = broker.getPersistenceAdapter();
-      if (pa instanceof LevelDBStore) {
-         return;
-      }
-
-      ActiveMQQueue queue = new ActiveMQQueue("MyQueue");
-      ActiveMQQueue disposable = new ActiveMQQueue("MyDisposableQueue");
-      ActiveMQTopic topic = new ActiveMQTopic("MyDurableTopic");
-
-      // This ensure that data file 1 never goes away.
-      createInactiveDurableSub(topic);
-      assertEquals(1, getNumberOfJournalFiles());
-
-      // One Queue Message that will be acked in another data file.
-      produceMessages(queue, 1);
-      assertEquals(1, getNumberOfJournalFiles());
-
-      // Add some messages to consume space
-      produceMessages(disposable, 50);
-
-      int dataFilesCount = getNumberOfJournalFiles();
-      assertTrue(dataFilesCount > 1);
-
-      // Create an ack for the single message on this queue
-      drainQueue(queue);
-
-      // Add some more messages to consume space beyond tha data file with the ack
-      produceMessages(disposable, 50);
-
-      assertTrue(dataFilesCount < getNumberOfJournalFiles());
-      dataFilesCount = getNumberOfJournalFiles();
-
-      restartBroker();
-
-      // Clear out all queue data
-      broker.getAdminView().removeQueue(disposable.getQueueName());
-
-      // Once this becomes true our ack could be lost.
-      assertTrue("Less than three journal file expected, was " + getNumberOfJournalFiles(), Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return getNumberOfJournalFiles() <= 3;
-         }
-      }, TimeUnit.MINUTES.toMillis(3)));
-
-      // Recover and the Message should not be replayed but if the old MessageAck is lost
-      // then it could be.
-      recoverBroker();
-
-      assertTrue(drainQueue(queue) == 0);
-   }
-
-   private int getNumberOfJournalFiles() throws IOException {
-
-      Collection<DataFile> files = ((KahaDBPersistenceAdapter) broker.getPersistenceAdapter()).getStore().getJournal().getFileMap().values();
-      int reality = 0;
-      for (DataFile file : files) {
-         if (file != null) {
-            reality++;
-         }
-      }
-
-      return reality;
-   }
-
-   private void createInactiveDurableSub(Topic topic) throws Exception {
-      Connection connection = cf.createConnection();
-      connection.setClientID("Inactive");
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer consumer = session.createDurableSubscriber(topic, "Inactive");
-      consumer.close();
-      connection.close();
-      produceMessages(topic, 1);
-   }
-
-   private int drainQueue(Queue queue) throws Exception {
-      Connection connection = cf.createConnection();
-      connection.setClientID("Inactive");
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer consumer = session.createConsumer(queue);
-      int count = 0;
-      while (consumer.receive(5000) != null) {
-         count++;
-      }
-      consumer.close();
-      connection.close();
-      return count;
-   }
-
-   private int produceMessages(Destination destination, int numToSend) throws Exception {
-      int sent = 0;
-      Connection connection = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getConnectUri()).createConnection();
-      connection.start();
-      try {
-         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageProducer producer = session.createProducer(destination);
-         for (int i = 0; i < numToSend; i++) {
-            producer.send(createMessage(session, i));
-            sent++;
-         }
-      }
-      finally {
-         connection.close();
-      }
-
-      return sent;
-   }
-
-   private int produceMessagesToConsumeMultipleDataFiles(int numToSend) throws Exception {
-      return produceMessages(destination, numToSend);
-   }
-
-   final String payload = new String(new byte[1024]);
-
-   private Message createMessage(Session session, int i) throws Exception {
-      return session.createTextMessage(payload + "::" + i);
-   }
-
-   private class StagedConsumer {
-
-      Connection connection;
-      MessageConsumer consumer;
-
-      StagedConsumer() throws Exception {
-         connection = new ActiveMQConnectionFactory("failover://" + broker.getTransportConnectors().get(0).getConnectUri().toString()).createConnection();
-         connection.start();
-         consumer = connection.createSession(false, ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE).createConsumer(destination);
-      }
-
-      public Message receive(int numToReceive) throws Exception {
-         return receive(numToReceive, 2);
-      }
-
-      public Message receive(int numToReceive, int timeoutInSeconds) throws Exception {
-         Message msg = null;
-         for (; numToReceive > 0; numToReceive--) {
-
-            do {
-               msg = consumer.receive(1 * 1000);
-            } while (msg == null && --timeoutInSeconds > 0);
-
-            if (numToReceive > 1) {
-               msg.acknowledge();
-            }
-
-            if (msg != null) {
-               LOG.debug("received: " + msg.getJMSMessageID());
-            }
-         }
-         // last message, unacked
-         return msg;
-      }
-
-      void close() throws JMSException {
-         consumer.close();
-         connection.close();
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2870Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2870Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2870Test.java
deleted file mode 100644
index b4f0a33..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2870Test.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/**
- * 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;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Properties;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TopicSubscriber;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.BrokerView;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.store.PersistenceAdapter;
-import org.apache.activemq.util.IntrospectionSupport;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@RunWith(value = Parameterized.class)
-public class AMQ2870Test extends org.apache.activemq.TestSupport {
-
-   static final Logger LOG = LoggerFactory.getLogger(AMQ2870Test.class);
-   BrokerService broker = null;
-   ActiveMQTopic topic;
-
-   ActiveMQConnection consumerConnection = null, producerConnection = null;
-   Session producerSession;
-   MessageProducer producer;
-   final int minPercentUsageForStore = 10;
-   String data;
-
-   private final PersistenceAdapterChoice persistenceAdapterChoice;
-
-   @Parameterized.Parameters
-   public static Collection<PersistenceAdapterChoice[]> getTestParameters() {
-      String osName = System.getProperty("os.name");
-      LOG.info("Running on [" + osName + "]");
-      PersistenceAdapterChoice[] kahaDb = {PersistenceAdapterChoice.KahaDB};
-      PersistenceAdapterChoice[] levelDb = {PersistenceAdapterChoice.LevelDB};
-      List<PersistenceAdapterChoice[]> choices = new ArrayList<>();
-      choices.add(kahaDb);
-      if (!osName.equalsIgnoreCase("AIX") && !osName.equalsIgnoreCase("SunOS")) {
-         choices.add(levelDb);
-      }
-
-      return choices;
-   }
-
-   public AMQ2870Test(PersistenceAdapterChoice choice) {
-      this.persistenceAdapterChoice = choice;
-   }
-
-   @Test(timeout = 300000)
-   public void testSize() throws Exception {
-      openConsumer();
-
-      assertEquals(0, broker.getAdminView().getStorePercentUsage());
-
-      for (int i = 0; i < 5000; i++) {
-         sendMessage(false);
-      }
-
-      final BrokerView brokerView = broker.getAdminView();
-
-      // wait for reclaim
-      assertTrue("in range with consumer", Wait.waitFor(new Wait.Condition() {
-                    @Override
-                    public boolean isSatisified() throws Exception {
-                       // usage percent updated only on send check for isFull so once
-                       // sends complete it is no longer updated till next send via a call to isFull
-                       // this is optimal as it is only used to block producers
-                       broker.getSystemUsage().getStoreUsage().isFull();
-                       LOG.info("store percent usage: " + brokerView.getStorePercentUsage());
-                       return broker.getAdminView().getStorePercentUsage() < minPercentUsageForStore;
-                    }
-                 }));
-
-      closeConsumer();
-
-      assertTrue("in range with closed consumer", Wait.waitFor(new Wait.Condition() {
-                    @Override
-                    public boolean isSatisified() throws Exception {
-                       broker.getSystemUsage().getStoreUsage().isFull();
-                       LOG.info("store precent usage: " + brokerView.getStorePercentUsage());
-                       return broker.getAdminView().getStorePercentUsage() < minPercentUsageForStore;
-                    }
-                 }));
-
-      for (int i = 0; i < 5000; i++) {
-         sendMessage(false);
-      }
-
-      // What if i drop the subscription?
-      broker.getAdminView().destroyDurableSubscriber("cliID", "subName");
-
-      assertTrue("in range after send with consumer", Wait.waitFor(new Wait.Condition() {
-                    @Override
-                    public boolean isSatisified() throws Exception {
-                       broker.getSystemUsage().getStoreUsage().isFull();
-                       LOG.info("store precent usage: " + brokerView.getStorePercentUsage());
-                       return broker.getAdminView().getStorePercentUsage() < minPercentUsageForStore;
-                    }
-                 }));
-   }
-
-   private void openConsumer() throws Exception {
-      consumerConnection = (ActiveMQConnection) createConnection();
-      consumerConnection.setClientID("cliID");
-      consumerConnection.start();
-      Session session = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      TopicSubscriber subscriber = session.createDurableSubscriber(topic, "subName", "filter=true", false);
-
-      subscriber.setMessageListener(new MessageListener() {
-         @Override
-         public void onMessage(Message message) {
-            // received++;
-         }
-      });
-   }
-
-   private void closeConsumer() throws JMSException {
-      if (consumerConnection != null)
-         consumerConnection.close();
-      consumerConnection = null;
-   }
-
-   private void sendMessage(boolean filter) throws Exception {
-      if (producerConnection == null) {
-         producerConnection = (ActiveMQConnection) createConnection();
-         producerConnection.start();
-         producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         producer = producerSession.createProducer(topic);
-      }
-
-      Message message = producerSession.createMessage();
-      message.setBooleanProperty("filter", filter);
-      message.setStringProperty("data", data);
-      producer.send(message);
-   }
-
-   private void startBroker(boolean deleteMessages) throws Exception {
-      broker = new BrokerService();
-      broker.setAdvisorySupport(false);
-      broker.setBrokerName("testStoreSize");
-
-      if (deleteMessages) {
-         broker.setDeleteAllMessagesOnStartup(true);
-      }
-      LOG.info("Starting broker with persistenceAdapterChoice " + persistenceAdapterChoice.toString());
-      setPersistenceAdapter(broker, persistenceAdapterChoice);
-      configurePersistenceAdapter(broker.getPersistenceAdapter());
-      broker.getSystemUsage().getStoreUsage().setLimit(100 * 1000 * 1000);
-      broker.start();
-   }
-
-   private void configurePersistenceAdapter(PersistenceAdapter persistenceAdapter) {
-      Properties properties = new Properties();
-      String maxFileLengthVal = String.valueOf(2 * 1024 * 1024);
-      properties.put("journalMaxFileLength", maxFileLengthVal);
-      properties.put("maxFileLength", maxFileLengthVal);
-      properties.put("cleanupInterval", "2000");
-      properties.put("checkpointInterval", "2000");
-
-      // leveldb
-      properties.put("logSize", maxFileLengthVal);
-
-      IntrospectionSupport.setProperties(persistenceAdapter, properties);
-   }
-
-   private void stopBroker() throws Exception {
-      if (broker != null)
-         broker.stop();
-      broker = null;
-   }
-
-   @Override
-   protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
-      return new ActiveMQConnectionFactory("vm://testStoreSize?jms.watchTopicAdvisories=false&waitForStart=5000&create=false");
-   }
-
-   @Override
-   @Before
-   public void setUp() throws Exception {
-      StringBuilder sb = new StringBuilder(5000);
-      for (int i = 0; i < 5000; i++) {
-         sb.append('a');
-      }
-      data = sb.toString();
-
-      startBroker(true);
-      topic = (ActiveMQTopic) createDestination();
-   }
-
-   @Override
-   @After
-   public void tearDown() throws Exception {
-      stopBroker();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2902Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2902Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2902Test.java
deleted file mode 100644
index 798d32f..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2902Test.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * 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;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.TransportConnection;
-import org.apache.activemq.transport.TransportDisposedIOException;
-import org.apache.activemq.util.DefaultTestAppender;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.spi.LoggingEvent;
-import org.slf4j.LoggerFactory;
-
-public class AMQ2902Test extends TestCase {
-
-   private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(AMQ2580Test.class);
-
-   final AtomicBoolean gotExceptionInLog = new AtomicBoolean(Boolean.FALSE);
-   final AtomicBoolean failedToFindMDC = new AtomicBoolean(Boolean.FALSE);
-
-   Appender appender = new DefaultTestAppender() {
-      @Override
-      public void doAppend(LoggingEvent event) {
-         if (event.getThrowableInformation() != null && event.getThrowableInformation().getThrowable() instanceof TransportDisposedIOException) {
-
-            // Prevent StackOverflowException so we can see a sane stack trace.
-            if (gotExceptionInLog.get()) {
-               return;
-            }
-
-            gotExceptionInLog.set(Boolean.TRUE);
-            LOG.error("got event: " + event + ", ex:" + event.getThrowableInformation().getThrowable(), event.getThrowableInformation().getThrowable());
-            LOG.error("Event source: ", new Throwable("Here"));
-         }
-         if (!"Loaded the Bouncy Castle security provider.".equals(event.getMessage())) {
-            if (event.getMDC("activemq.broker") == null) {
-               failedToFindMDC.set(Boolean.TRUE);
-            }
-         }
-         return;
-      }
-   };
-
-   public void testNoExceptionOnClosewithStartStop() throws JMSException {
-      ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
-      Connection connection = connectionFactory.createConnection();
-      connection.start();
-      connection.stop();
-      connection.close();
-   }
-
-   public void testNoExceptionOnClose() throws JMSException {
-      ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
-      Connection connection = connectionFactory.createConnection();
-      connection.close();
-   }
-
-   @Override
-   public void setUp() throws Exception {
-      gotExceptionInLog.set(Boolean.FALSE);
-      failedToFindMDC.set(Boolean.FALSE);
-      Logger.getRootLogger().addAppender(appender);
-      Logger.getLogger(TransportConnection.class.getName() + ".Transport").setLevel(Level.DEBUG);
-      Logger.getLogger(TransportConnection.class.getName()).setLevel(Level.DEBUG);
-   }
-
-   @Override
-   public void tearDown() throws Exception {
-      Logger.getRootLogger().removeAppender(appender);
-      assertFalse("got unexpected ex in log on graceful close", gotExceptionInLog.get());
-      assertFalse("MDC is there", failedToFindMDC.get());
-   }
-}


[26/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicDLQTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicDLQTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicDLQTest.java
deleted file mode 100644
index d05a5c7..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicDLQTest.java
+++ /dev/null
@@ -1,433 +0,0 @@
-/**
- * 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.broker.virtual;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQMessageProducer;
-import org.apache.activemq.ActiveMQSession;
-import org.apache.activemq.RedeliveryPolicy;
-import org.apache.activemq.broker.BrokerFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.Queue;
-import org.apache.activemq.broker.region.RegionBroker;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Unit test for virtual topics and DLQ messaging. See individual test for more
- * detail
- */
-public class VirtualTopicDLQTest extends TestCase {
-
-   private static BrokerService broker;
-
-   private static final Logger LOG = LoggerFactory.getLogger(VirtualTopicDLQTest.class);
-
-   static final String jmsConnectionURI = "failover:(vm://localhost)";
-
-   // Virtual Topic that the test publishes 10 messages to
-   private static final String virtualTopicName = "VirtualTopic.Test";
-
-   // Queues that receive all the messages send to the virtual topic
-   private static final String consumer1Prefix = "Consumer.A.";
-   private static final String consumer2Prefix = "Consumer.B.";
-   private static final String consumer3Prefix = "Consumer.C.";
-
-   // Expected Individual Dead Letter Queue names that are tied to the
-   // Subscriber Queues
-   private static final String dlqPrefix = "ActiveMQ.DLQ.Topic.";
-
-   // Number of messages
-   private static final int numberMessages = 6;
-
-   @Override
-   @Before
-   public void setUp() throws Exception {
-      try {
-         broker = BrokerFactory.createBroker("xbean:org/apache/activemq/broker/virtual/virtual-individual-dlq.xml", true);
-         broker.start();
-         broker.waitUntilStarted();
-      }
-      catch (Exception e) {
-         e.printStackTrace();
-         throw e;
-      }
-   }
-
-   @Override
-   @After
-   public void tearDown() throws Exception {
-      try {
-         // Purge the DLQ's so counts are correct for next run
-         purgeDestination(dlqPrefix + consumer1Prefix + virtualTopicName);
-         purgeDestination(dlqPrefix + consumer2Prefix + virtualTopicName);
-         purgeDestination(dlqPrefix + consumer3Prefix + virtualTopicName);
-      }
-      catch (Exception e) {
-         e.printStackTrace();
-      }
-
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-         broker = null;
-      }
-   }
-
-   /*
-    * This test verifies that all undelivered messages sent to a consumers
-    * listening on a queue associated with a virtual topic with be forwarded to
-    * separate DLQ's.
-    *
-    * Note that the broker config, deadLetterStrategy need to have the enable
-    * audit set to false so that duplicate message sent from a topic to
-    * individual consumers are forwarded to the DLQ
-    *
-    * <deadLetterStrategy> <bean
-    * xmlns="http://www.springframework.org/schema/beans"
-    * class="org.apache.activemq.broker.region.policy.IndividualDeadLetterStrategy"
-    * > <property name="useQueueForQueueMessages" value="true"></property>
-    * <property name="processNonPersistent" value="true"></property> <property
-    * name="processExpired" value="false"></property> <property
-    * name="enableAudit" value="false"></property>
-    *
-    * </bean> </deadLetterStrategy>
-    */
-   @Test
-   public void testVirtualTopicSubscriberDeadLetterQueue() throws Exception {
-
-      TestConsumer consumer1 = null;
-      TestConsumer consumer2 = null;
-      TestConsumer consumer3 = null;
-      TestConsumer dlqConsumer1 = null;
-      TestConsumer dlqConsumer2 = null;
-      TestConsumer dlqConsumer3 = null;
-
-      try {
-
-         // The first 2 consumers will rollback, ultimately causing messages
-         // to land on the DLQ
-         consumer1 = new TestConsumer(consumer1Prefix + virtualTopicName, false, numberMessages, true);
-         thread(consumer1, false);
-
-         consumer2 = new TestConsumer(consumer2Prefix + virtualTopicName, false, numberMessages, true);
-         thread(consumer2, false);
-
-         // TestConsumer that does not throw exceptions, messages should not
-         // land on DLQ
-         consumer3 = new TestConsumer(consumer3Prefix + virtualTopicName, false, numberMessages, false);
-         thread(consumer3, false);
-
-         // TestConsumer to read the expected Dead Letter Queue
-         dlqConsumer1 = new TestConsumer(dlqPrefix + consumer1Prefix + virtualTopicName, false, numberMessages, false);
-         thread(dlqConsumer1, false);
-
-         dlqConsumer2 = new TestConsumer(dlqPrefix + consumer2Prefix + virtualTopicName, false, numberMessages, false);
-         thread(dlqConsumer2, false);
-
-         dlqConsumer3 = new TestConsumer(dlqPrefix + consumer3Prefix + virtualTopicName, false, numberMessages, false);
-         thread(dlqConsumer3, false);
-
-         // Give the consumers a second to start
-         Thread.sleep(1000);
-
-         // Start the producer
-         TestProducer producer = new TestProducer(virtualTopicName, true, numberMessages);
-         thread(producer, false);
-
-         assertTrue("sent all producer messages in time, count is: " + producer.getLatch().getCount(), producer.getLatch().await(10, TimeUnit.SECONDS));
-         LOG.info("producer successful, count = " + producer.getLatch().getCount());
-
-         assertTrue("remaining consumer1 count should be zero, is: " + consumer1.getLatch().getCount(), consumer1.getLatch().await(10, TimeUnit.SECONDS));
-         LOG.info("consumer1 successful, count = " + consumer1.getLatch().getCount());
-
-         assertTrue("remaining consumer2 count should be zero, is: " + consumer2.getLatch().getCount(), consumer2.getLatch().await(10, TimeUnit.SECONDS));
-         LOG.info("consumer2 successful, count = " + consumer2.getLatch().getCount());
-
-         assertTrue("remaining consumer3 count should be zero, is: " + consumer3.getLatch().getCount(), consumer3.getLatch().await(10, TimeUnit.SECONDS));
-         LOG.info("consumer3 successful, count = " + consumer3.getLatch().getCount());
-
-         assertTrue("remaining dlqConsumer1 count should be zero, is: " + dlqConsumer1.getLatch().getCount(), dlqConsumer1.getLatch().await(10, TimeUnit.SECONDS));
-         LOG.info("dlqConsumer1 successful, count = " + dlqConsumer1.getLatch().getCount());
-
-         assertTrue("remaining dlqConsumer2 count should be zero, is: " + dlqConsumer2.getLatch().getCount(), dlqConsumer2.getLatch().await(10, TimeUnit.SECONDS));
-         LOG.info("dlqConsumer2 successful, count = " + dlqConsumer2.getLatch().getCount());
-
-         assertTrue("remaining dlqConsumer3 count should be " + numberMessages + ", is: " + dlqConsumer3.getLatch().getCount(), dlqConsumer3.getLatch().getCount() == numberMessages);
-         LOG.info("dlqConsumer2 successful, count = " + dlqConsumer2.getLatch().getCount());
-
-      }
-      catch (Exception e) {
-         e.printStackTrace();
-         throw e;
-      }
-      finally {
-         // Tell consumers to stop (don't read any more messages after this)
-         if (consumer1 != null)
-            consumer1.setStop(true);
-         if (consumer2 != null)
-            consumer2.setStop(true);
-         if (consumer3 != null)
-            consumer3.setStop(true);
-         if (dlqConsumer1 != null)
-            dlqConsumer1.setStop(true);
-         if (dlqConsumer2 != null)
-            dlqConsumer2.setStop(true);
-         if (dlqConsumer3 != null)
-            dlqConsumer3.setStop(true);
-      }
-   }
-
-   private static Thread thread(Runnable runnable, boolean daemon) {
-      Thread brokerThread = new Thread(runnable);
-      brokerThread.setDaemon(daemon);
-      brokerThread.start();
-      return brokerThread;
-   }
-
-   private class TestProducer implements Runnable {
-
-      private String destinationName = null;
-      private boolean isTopic = true;
-      private int numberMessages = 0;
-      private CountDownLatch latch = null;
-
-      public TestProducer(String destinationName, boolean isTopic, int numberMessages) {
-         this.destinationName = destinationName;
-         this.isTopic = isTopic;
-         this.numberMessages = numberMessages;
-         latch = new CountDownLatch(numberMessages);
-      }
-
-      public CountDownLatch getLatch() {
-         return latch;
-      }
-
-      @Override
-      public void run() {
-         ActiveMQConnectionFactory connectionFactory = null;
-         ActiveMQConnection connection = null;
-         ActiveMQSession session = null;
-         Destination destination = null;
-
-         try {
-            LOG.info("Started TestProducer for destination (" + destinationName + ")");
-
-            connectionFactory = new ActiveMQConnectionFactory(jmsConnectionURI);
-            connection = (ActiveMQConnection) connectionFactory.createConnection();
-            connection.start();
-            session = (ActiveMQSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-            if (isTopic) {
-               destination = session.createTopic(this.destinationName);
-            }
-            else {
-               destination = session.createQueue(this.destinationName);
-            }
-
-            // Create a MessageProducer from the Session to the Topic or
-            // Queue
-            ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);
-            producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
-            for (int i = 0; i < numberMessages; i++) {
-               TextMessage message = session.createTextMessage("I am a message :: " + String.valueOf(i));
-               try {
-                  producer.send(message);
-
-               }
-               catch (Exception deeperException) {
-                  LOG.info("Producer for destination (" + destinationName + ") Caught: " + deeperException);
-               }
-
-               latch.countDown();
-               Thread.sleep(1000);
-            }
-
-            LOG.info("Finished TestProducer for destination (" + destinationName + ")");
-
-         }
-         catch (Exception e) {
-            LOG.error("Terminating TestProducer(" + destinationName + ")Caught: " + e);
-            e.printStackTrace();
-
-         }
-         finally {
-            try {
-               // Clean up
-               if (session != null)
-                  session.close();
-               if (connection != null)
-                  connection.close();
-
-            }
-            catch (Exception e) {
-               e.printStackTrace();
-               LOG.error("Closing connection/session (" + destinationName + ")Caught: " + e);
-            }
-         }
-      }
-   }
-
-   private class TestConsumer implements Runnable, ExceptionListener, MessageListener {
-
-      private String destinationName = null;
-      private boolean isTopic = true;
-      private CountDownLatch latch = null;
-      private int maxRedeliveries = 0;
-      private int receivedMessageCounter = 0;
-      private boolean bFakeFail = false;
-      private boolean bStop = false;
-
-      private ActiveMQConnectionFactory connectionFactory = null;
-      private ActiveMQConnection connection = null;
-      private Session session = null;
-      private MessageConsumer consumer = null;
-
-      public TestConsumer(String destinationName, boolean isTopic, int expectedNumberMessages, boolean bFakeFail) {
-         this.destinationName = destinationName;
-         this.isTopic = isTopic;
-         latch = new CountDownLatch(expectedNumberMessages * (this.bFakeFail ? (maxRedeliveries + 1) : 1));
-         this.bFakeFail = bFakeFail;
-      }
-
-      public CountDownLatch getLatch() {
-         return latch;
-      }
-
-      @Override
-      public void run() {
-
-         try {
-            LOG.info("Started TestConsumer for destination (" + destinationName + ")");
-
-            connectionFactory = new ActiveMQConnectionFactory(jmsConnectionURI);
-            connection = (ActiveMQConnection) connectionFactory.createConnection();
-            connection.start();
-            session = connection.createSession(true, Session.SESSION_TRANSACTED);
-
-            RedeliveryPolicy policy = connection.getRedeliveryPolicy();
-            policy.setInitialRedeliveryDelay(1);
-            policy.setUseExponentialBackOff(false);
-            policy.setMaximumRedeliveries(maxRedeliveries);
-
-            connection.setExceptionListener(this);
-
-            Destination destination = null;
-            if (isTopic) {
-               destination = session.createTopic(destinationName);
-            }
-            else {
-               destination = session.createQueue(destinationName);
-            }
-
-            consumer = session.createConsumer(destination);
-            consumer.setMessageListener(this);
-
-            while (!bStop) {
-               Thread.sleep(100);
-            }
-
-            LOG.info("Finished TestConsumer for destination name (" + destinationName + ") remaining " + this.latch.getCount() + " messages " + this.toString());
-
-         }
-         catch (Exception e) {
-            LOG.error("Consumer (" + destinationName + ") Caught: " + e);
-            e.printStackTrace();
-         }
-         finally {
-            try {
-               // Clean up
-               if (consumer != null)
-                  consumer.close();
-               if (session != null)
-                  session.close();
-               if (connection != null)
-                  connection.close();
-
-            }
-            catch (Exception e) {
-               e.printStackTrace();
-               LOG.error("Closing connection/session (" + destinationName + ")Caught: " + e);
-            }
-         }
-      }
-
-      @Override
-      public synchronized void onException(JMSException ex) {
-         ex.printStackTrace();
-         LOG.error("Consumer for destination, (" + destinationName + "), JMS Exception occurred.  Shutting down client.");
-      }
-
-      public synchronized void setStop(boolean bStop) {
-         this.bStop = bStop;
-      }
-
-      @Override
-      public synchronized void onMessage(Message message) {
-         receivedMessageCounter++;
-         latch.countDown();
-
-         LOG.info("Consumer for destination (" + destinationName + ") latch countdown: " + latch.getCount() + " :: Number messages received " + this.receivedMessageCounter);
-
-         try {
-            LOG.info("Consumer for destination (" + destinationName + ") Received message id :: " + message.getJMSMessageID());
-
-            if (!bFakeFail) {
-               LOG.info("Consumer on destination " + destinationName + " committing JMS Session for message: " + message.toString());
-               session.commit();
-            }
-            else {
-               LOG.info("Consumer on destination " + destinationName + " rolling back JMS Session for message: " + message.toString());
-               session.rollback(); // rolls back all the consumed messages
-               // on the session to
-            }
-
-         }
-         catch (JMSException ex) {
-            ex.printStackTrace();
-            LOG.error("Error reading JMS Message from destination " + destinationName + ".");
-         }
-      }
-   }
-
-   private static void purgeDestination(String destination) throws Exception {
-      final Queue dest = (Queue) ((RegionBroker) broker.getRegionBroker()).getQueueRegion().getDestinationMap().get(new ActiveMQQueue(destination));
-      dest.purge();
-      assertEquals(0, dest.getDestinationStatistics().getMessages().getCount());
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicDisconnectSelectorTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicDisconnectSelectorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicDisconnectSelectorTest.java
deleted file mode 100644
index 925b82c..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicDisconnectSelectorTest.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/**
- * 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.broker.virtual;
-
-import java.net.URI;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.spring.ConsumerBean;
-import org.apache.activemq.xbean.XBeanBrokerFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Test case for  https://issues.apache.org/jira/browse/AMQ-3004
- */
-
-public class VirtualTopicDisconnectSelectorTest extends EmbeddedBrokerTestSupport {
-
-   private static final Logger LOG = LoggerFactory.getLogger(VirtualTopicDisconnectSelectorTest.class);
-   protected Connection connection;
-
-   public void testVirtualTopicSelectorDisconnect() throws Exception {
-      testVirtualTopicDisconnect("odd = 'no'", 3000, 1500);
-   }
-
-   public void testVirtualTopicNoSelectorDisconnect() throws Exception {
-      testVirtualTopicDisconnect(null, 3000, 3000);
-   }
-
-   public void testVirtualTopicDisconnect(String messageSelector, int total, int expected) throws Exception {
-      if (connection == null) {
-         connection = createConnection();
-      }
-      connection.start();
-
-      final ConsumerBean messageList = new ConsumerBean();
-
-      Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
-      Destination producerDestination = getProducerDestination();
-      Destination destination = getConsumerDsetination();
-
-      LOG.info("Sending to: " + producerDestination);
-      LOG.info("Consuming from: " + destination);
-
-      MessageConsumer consumer = createConsumer(session, destination, messageSelector);
-
-      MessageListener listener = new MessageListener() {
-         @Override
-         public void onMessage(Message message) {
-            messageList.onMessage(message);
-            try {
-               message.acknowledge();
-            }
-            catch (JMSException e) {
-               e.printStackTrace();
-            }
-         }
-      };
-
-      consumer.setMessageListener(listener);
-
-      // create topic producer
-      MessageProducer producer = session.createProducer(producerDestination);
-      assertNotNull(producer);
-
-      int disconnectCount = total / 3;
-      int reconnectCount = (total * 2) / 3;
-
-      for (int i = 0; i < total; i++) {
-         producer.send(createMessage(session, i));
-
-         if (i == disconnectCount) {
-            consumer.close();
-         }
-         if (i == reconnectCount) {
-            consumer = createConsumer(session, destination, messageSelector);
-            consumer.setMessageListener(listener);
-         }
-      }
-
-      assertMessagesArrived(messageList, expected, 10000);
-   }
-
-   protected Destination getConsumerDsetination() {
-      return new ActiveMQQueue("Consumer.VirtualTopic.TEST");
-   }
-
-   protected Destination getProducerDestination() {
-      return new ActiveMQTopic("VirtualTopic.TEST");
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      super.setUp();
-   }
-
-   protected MessageConsumer createConsumer(Session session,
-                                            Destination destination,
-                                            String messageSelector) throws JMSException {
-      if (messageSelector != null) {
-         return session.createConsumer(destination, messageSelector);
-      }
-      else {
-         return session.createConsumer(destination);
-      }
-   }
-
-   protected TextMessage createMessage(Session session, int i) throws JMSException {
-      TextMessage textMessage = session.createTextMessage("message: " + i);
-      if (i % 2 != 0) {
-         textMessage.setStringProperty("odd", "yes");
-      }
-      else {
-         textMessage.setStringProperty("odd", "no");
-      }
-      textMessage.setIntProperty("i", i);
-      return textMessage;
-   }
-
-   protected void assertMessagesArrived(ConsumerBean messageList, int expected, long timeout) {
-      messageList.assertMessagesArrived(expected, timeout);
-
-      messageList.flushMessages();
-
-      LOG.info("validate no other messages on queues");
-      try {
-         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-         Destination destination1 = getConsumerDsetination();
-
-         MessageConsumer c1 = session.createConsumer(destination1, null);
-         c1.setMessageListener(messageList);
-
-         LOG.info("send one simple message that should go to both consumers");
-         MessageProducer producer = session.createProducer(getProducerDestination());
-         assertNotNull(producer);
-
-         producer.send(session.createTextMessage("Last Message"));
-
-         messageList.assertMessagesArrived(1);
-
-      }
-      catch (JMSException e) {
-         e.printStackTrace();
-         fail("unexpeced ex while waiting for last messages: " + e);
-      }
-   }
-
-   protected String getBrokerConfigUri() {
-      return "org/apache/activemq/broker/virtual/disconnected-selector.xml";
-   }
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      XBeanBrokerFactory factory = new XBeanBrokerFactory();
-      BrokerService answer = factory.createBroker(new URI(getBrokerConfigUri()));
-      return answer;
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicPubSubTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicPubSubTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicPubSubTest.java
deleted file mode 100644
index 0f2af0a..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicPubSubTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- * 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.broker.virtual;
-
-import java.util.Vector;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import junit.framework.Test;
-
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.spring.ConsumerBean;
-
-/**
- *
- *
- */
-public class VirtualTopicPubSubTest extends EmbeddedBrokerTestSupport {
-
-   private Vector<Connection> connections = new Vector<>();
-   public int ackMode = Session.AUTO_ACKNOWLEDGE;
-
-   public static Test suite() {
-      return suite(VirtualTopicPubSubTest.class);
-   }
-
-   public void initCombosForTestVirtualTopicCreation() {
-      addCombinationValues("ackMode", new Object[]{new Integer(Session.AUTO_ACKNOWLEDGE), new Integer(Session.CLIENT_ACKNOWLEDGE)});
-   }
-
-   private boolean doneTwice = false;
-
-   public void testVirtualTopicCreation() throws Exception {
-      doTestVirtualTopicCreation(10);
-   }
-
-   public void doTestVirtualTopicCreation(int total) throws Exception {
-
-      ConsumerBean messageList = new ConsumerBean() {
-         @Override
-         public synchronized void onMessage(Message message) {
-            super.onMessage(message);
-            if (ackMode == Session.CLIENT_ACKNOWLEDGE) {
-               try {
-                  message.acknowledge();
-               }
-               catch (JMSException e) {
-                  e.printStackTrace();
-               }
-            }
-
-         }
-      };
-      messageList.setVerbose(true);
-
-      String queueAName = getVirtualTopicConsumerName();
-      // create consumer 'cluster'
-      ActiveMQQueue queue1 = new ActiveMQQueue(queueAName);
-      ActiveMQQueue queue2 = new ActiveMQQueue(queueAName);
-
-      Session session = createStartAndTrackConnection().createSession(false, ackMode);
-      MessageConsumer c1 = session.createConsumer(queue1);
-
-      session = createStartAndTrackConnection().createSession(false, ackMode);
-      MessageConsumer c2 = session.createConsumer(queue2);
-
-      c1.setMessageListener(messageList);
-      c2.setMessageListener(messageList);
-
-      // create topic producer
-      Session producerSession = createStartAndTrackConnection().createSession(false, ackMode);
-      MessageProducer producer = producerSession.createProducer(new ActiveMQTopic(getVirtualTopicName()));
-      assertNotNull(producer);
-
-      for (int i = 0; i < total; i++) {
-         producer.send(producerSession.createTextMessage("message: " + i));
-      }
-
-      messageList.assertMessagesArrived(total);
-
-      // do twice so we confirm messages do not get redelivered after client acknowledgement
-      if (doneTwice == false) {
-         doneTwice = true;
-         doTestVirtualTopicCreation(0);
-      }
-   }
-
-   private Connection createStartAndTrackConnection() throws Exception {
-      Connection connection = createConnection();
-      connection.start();
-      connections.add(connection);
-      return connection;
-   }
-
-   protected String getVirtualTopicName() {
-      return "VirtualTopic.TEST";
-   }
-
-   protected String getVirtualTopicConsumerName() {
-      return "Consumer.A.VirtualTopic.TEST";
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      for (Connection connection : connections) {
-         connection.close();
-      }
-      super.tearDown();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicPubSubUsingXBeanTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicPubSubUsingXBeanTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicPubSubUsingXBeanTest.java
deleted file mode 100644
index 1d7ea71..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicPubSubUsingXBeanTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * 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.broker.virtual;
-
-import java.net.URI;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.xbean.XBeanBrokerFactory;
-
-/**
- *
- *
- */
-public class VirtualTopicPubSubUsingXBeanTest extends VirtualTopicPubSubTest {
-
-   @Override
-   protected String getVirtualTopicConsumerName() {
-      return "VirtualTopicConsumers.ConsumerNumberOne.FOO";
-   }
-
-   @Override
-   protected String getVirtualTopicName() {
-      return "FOO";
-   }
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      XBeanBrokerFactory factory = new XBeanBrokerFactory();
-      BrokerService answer = factory.createBroker(new URI(getBrokerConfigUri()));
-
-      // lets disable persistence as we are a test
-      answer.setPersistent(false);
-
-      return answer;
-   }
-
-   protected String getBrokerConfigUri() {
-      return "org/apache/activemq/broker/virtual/global-virtual-topics.xml";
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicSelectorTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicSelectorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicSelectorTest.java
deleted file mode 100644
index d94dd18..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicSelectorTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * 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.broker.virtual;
-
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.DestinationInterceptor;
-import org.apache.activemq.broker.region.virtual.VirtualDestination;
-import org.apache.activemq.broker.region.virtual.VirtualDestinationInterceptor;
-import org.apache.activemq.broker.region.virtual.VirtualTopic;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.spring.ConsumerBean;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class VirtualTopicSelectorTest extends CompositeTopicTest {
-
-   private static final Logger LOG = LoggerFactory.getLogger(VirtualTopicSelectorTest.class);
-
-   @Override
-   protected Destination getConsumer1Dsetination() {
-      return new ActiveMQQueue("Consumer.1.VirtualTopic.TEST");
-   }
-
-   @Override
-   protected Destination getConsumer2Dsetination() {
-      return new ActiveMQQueue("Consumer.2.VirtualTopic.TEST");
-   }
-
-   @Override
-   protected Destination getProducerDestination() {
-      return new ActiveMQTopic("VirtualTopic.TEST");
-   }
-
-   @Override
-   protected void assertMessagesArrived(ConsumerBean messageList1, ConsumerBean messageList2) {
-      messageList1.assertMessagesArrived(total / 2);
-      messageList2.assertMessagesArrived(total / 2);
-
-      messageList1.flushMessages();
-      messageList2.flushMessages();
-
-      LOG.info("validate no other messages on queues");
-      try {
-         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-         Destination destination1 = getConsumer1Dsetination();
-         Destination destination2 = getConsumer2Dsetination();
-         MessageConsumer c1 = session.createConsumer(destination1, null);
-         MessageConsumer c2 = session.createConsumer(destination2, null);
-         c1.setMessageListener(messageList1);
-         c2.setMessageListener(messageList2);
-
-         LOG.info("send one simple message that should go to both consumers");
-         MessageProducer producer = session.createProducer(getProducerDestination());
-         assertNotNull(producer);
-
-         producer.send(session.createTextMessage("Last Message"));
-
-         messageList1.assertMessagesArrived(1);
-         messageList2.assertMessagesArrived(1);
-
-      }
-      catch (JMSException e) {
-         e.printStackTrace();
-         fail("unexpeced ex while waiting for last messages: " + e);
-      }
-   }
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      // use message selectors on consumers that need to propagate up to the virtual
-      // topic dispatch so that un matched messages do not linger on subscription queues
-      messageSelector1 = "odd = 'yes'";
-      messageSelector2 = "odd = 'no'";
-
-      BrokerService broker = new BrokerService();
-      broker.setPersistent(false);
-
-      VirtualTopic virtualTopic = new VirtualTopic();
-      // the new config that enables selectors on the intercepter
-      virtualTopic.setSelectorAware(true);
-      VirtualDestinationInterceptor interceptor = new VirtualDestinationInterceptor();
-      interceptor.setVirtualDestinations(new VirtualDestination[]{virtualTopic});
-      broker.setDestinationInterceptors(new DestinationInterceptor[]{interceptor});
-      return broker;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicsAndDurableSubsTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicsAndDurableSubsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicsAndDurableSubsTest.java
deleted file mode 100644
index 4abf811..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualTopicsAndDurableSubsTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * 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.broker.virtual;
-
-import javax.jms.Connection;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.broker.jmx.MBeanTest;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.spring.ConsumerBean;
-
-public class VirtualTopicsAndDurableSubsTest extends MBeanTest {
-
-   private Connection connection;
-
-   public void testVirtualTopicCreationAndDurableSubs() throws Exception {
-      if (connection == null) {
-         connection = createConnection();
-      }
-      connection.setClientID(getAClientID());
-      connection.start();
-
-      ConsumerBean messageList = new ConsumerBean();
-      messageList.setVerbose(true);
-
-      String queueAName = getVirtualTopicConsumerName();
-      // create consumer 'cluster'
-      ActiveMQQueue queue1 = new ActiveMQQueue(queueAName);
-      ActiveMQQueue queue2 = new ActiveMQQueue(queueAName);
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer c1 = session.createConsumer(queue1);
-      MessageConsumer c2 = session.createConsumer(queue2);
-
-      c1.setMessageListener(messageList);
-      c2.setMessageListener(messageList);
-
-      // create topic producer
-      MessageProducer producer = session.createProducer(new ActiveMQTopic(getVirtualTopicName()));
-      assertNotNull(producer);
-
-      int total = 10;
-      for (int i = 0; i < total; i++) {
-         producer.send(session.createTextMessage("message: " + i));
-      }
-      messageList.assertMessagesArrived(total);
-
-      //Add and remove durable subscriber after using VirtualTopics
-      assertCreateAndDestroyDurableSubscriptions();
-   }
-
-   protected String getAClientID() {
-      return "VirtualTopicCreationAndDurableSubs";
-   }
-
-   protected String getVirtualTopicName() {
-      return "VirtualTopic.TEST";
-   }
-
-   protected String getVirtualTopicConsumerName() {
-      return "Consumer.A.VirtualTopic.TEST";
-   }
-
-   protected String getDurableSubscriberName() {
-      return "Sub1";
-   }
-
-   protected String getDurableSubscriberTopicName() {
-      return "simple.topic";
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      if (connection != null) {
-         connection.close();
-      }
-      super.tearDown();
-   }
-
-   //Overrides test cases from MBeanTest to avoid having them run.
-   @Override
-   public void testMBeans() throws Exception {
-   }
-
-   @Override
-   public void testMoveMessages() throws Exception {
-   }
-
-   @Override
-   public void testRetryMessages() throws Exception {
-   }
-
-   @Override
-   public void testMoveMessagesBySelector() throws Exception {
-   }
-
-   @Override
-   public void testCopyMessagesBySelector() throws Exception {
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/composite-queue.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/composite-queue.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/composite-queue.xml
deleted file mode 100644
index ed3bc73..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/composite-queue.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?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.
--->
-
-<!-- this file can only be parsed using the xbean-spring library -->
-<!-- START SNIPPET: xbean -->
-<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">
-
-  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />
-
-  <broker persistent="false" useJmx="false" xmlns="http://activemq.apache.org/schema/core">
-    <destinationInterceptors>
-      <virtualDestinationInterceptor>
-        <virtualDestinations>
-          <compositeQueue name="MY.QUEUE">
-            <forwardTo>
-              <queue physicalName="FOO" />
-              <topic physicalName="BAR" />
-            </forwardTo>
-          </compositeQueue>
-        </virtualDestinations>
-      </virtualDestinationInterceptor>
-    </destinationInterceptors>
-
-  </broker>
-
-</beans>
-<!-- END SNIPPET: xbean -->

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/composite-topic.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/composite-topic.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/composite-topic.xml
deleted file mode 100644
index ded6471..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/composite-topic.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?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.
--->
-
-<!-- this file can only be parsed using the xbean-spring library -->
-<!-- START SNIPPET: xbean -->
-<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">
-
-  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />
-
-  <broker xmlns="http://activemq.apache.org/schema/core">
-    <destinationInterceptors>
-      <virtualDestinationInterceptor>
-        <virtualDestinations>
-          <compositeTopic name="MY.TOPIC">
-            <forwardTo>
-              <queue physicalName="FOO" />
-              <topic physicalName="BAR" />
-            </forwardTo>
-          </compositeTopic>
-        </virtualDestinations>
-      </virtualDestinationInterceptor>
-    </destinationInterceptors>
-
-  </broker>
-
-</beans>
-<!-- END SNIPPET: xbean -->

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/disconnected-selector.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/disconnected-selector.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/disconnected-selector.xml
deleted file mode 100644
index 2772910..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/disconnected-selector.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?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.
--->
-
-<!-- this file can only be parsed using the xbean-spring library -->
-<!-- START SNIPPET: xbean -->
-<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">
-
-      <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />
-
-    <broker xmlns="http://activemq.apache.org/schema/core" persistent="false">
-        <destinationInterceptors>
-            <virtualDestinationInterceptor>
-                <virtualDestinations>
-                    <virtualTopic name="VirtualTopic.>" prefix="Consumer." selectorAware="true"/>
-                </virtualDestinations>
-            </virtualDestinationInterceptor>
-        </destinationInterceptors>
-        <plugins>
-            <virtualSelectorCacheBrokerPlugin persistFile = "target/selectorcache.data"/>
-        </plugins>
-    </broker>
-</beans>
-<!-- END SNIPPET: xbean -->

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/filtered-queue.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/filtered-queue.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/filtered-queue.xml
deleted file mode 100644
index d51f03c..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/filtered-queue.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?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.
--->
-
-<!-- this file can only be parsed using the xbean-spring library -->
-<!-- START SNIPPET: xbean -->
-<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">
-
-  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />
-
-  <broker xmlns="http://activemq.apache.org/schema/core">
-    <destinationInterceptors>
-      <virtualDestinationInterceptor>
-        <virtualDestinations>
-          <compositeQueue name="MY.QUEUE">
-            <forwardTo>
-              <filteredDestination selector="odd = 'yes'" queue="FOO"/>
-              <filteredDestination selector="i = 5" topic="BAR"/>
-            </forwardTo>
-          </compositeQueue>
-        </virtualDestinations>
-      </virtualDestinationInterceptor>
-    </destinationInterceptors>
-
-  </broker>
-
-</beans>
-<!-- END SNIPPET: xbean -->

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/global-virtual-topics.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/global-virtual-topics.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/global-virtual-topics.xml
deleted file mode 100644
index ddd0667..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/global-virtual-topics.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?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.
--->
-
-<!-- this file can only be parsed using the xbean-spring library -->
-<!-- START SNIPPET: xbean -->
-<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">
-
-  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />
-
-  <broker xmlns="http://activemq.apache.org/schema/core">
-    <destinationInterceptors>
-      <virtualDestinationInterceptor>
-        <virtualDestinations>
-          <virtualTopic name=">" prefix="VirtualTopicConsumers.*." selectorAware="false"/>
-        </virtualDestinations>
-      </virtualDestinationInterceptor>
-    </destinationInterceptors>
-
-  </broker>
-
-</beans>
-<!-- END SNIPPET: xbean -->

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/virtual-individual-dlq.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/virtual-individual-dlq.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/virtual-individual-dlq.xml
deleted file mode 100644
index d725436..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/virtual-individual-dlq.xml
+++ /dev/null
@@ -1,80 +0,0 @@
-<!--
-    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: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">
-
-    
-
-    <!-- 
-        The <broker> element is used to configure the ActiveMQ broker. 
-    -->
-    <broker xmlns="http://activemq.apache.org/schema/core" brokerName="bcBroker">
- 
-        <destinationInterceptors>
-      <virtualDestinationInterceptor>
-         <virtualDestinations>
-            <virtualTopic name="VirtualTopic.>" prefix="Consumer.*." />
-         </virtualDestinations>
-      </virtualDestinationInterceptor>
-   </destinationInterceptors>
-              
-   <destinationPolicy>
-      <policyMap>
-         <policyEntries>
-            <policyEntry queue=">" memoryLimit="128 mb" >
-               <deadLetterStrategy>
-                  <bean xmlns="http://www.springframework.org/schema/beans"
-                        class="org.apache.activemq.broker.region.policy.IndividualDeadLetterStrategy">
-                     <property name="useQueueForQueueMessages" value="true"></property>
-                     <property name="processNonPersistent" value="true"></property>
-                     <property name="processExpired" value="false"></property>
-                     <property name="enableAudit" value="false"></property>
-                     
-                  </bean>
-               </deadLetterStrategy>
-            </policyEntry>
-            <policyEntry topic=">" memoryLimit="128 mb" >
-               <deadLetterStrategy>
-                  <bean xmlns="http://www.springframework.org/schema/beans"
-                        class="org.apache.activemq.broker.region.policy.IndividualDeadLetterStrategy">
-                     <property name="useQueueForQueueMessages" value="true"></property>
-                     <property name="processNonPersistent" value="true"></property>
-                     <property name="processExpired" value="false"></property>
-                     <property name="enableAudit" value="false"></property>
-          
-                  </bean>
-               </deadLetterStrategy>
-             </policyEntry>
-         </policyEntries>
-      </policyMap>
-   </destinationPolicy>
-       
-        <managementContext>
-            <managementContext createConnector="false"/>
-        </managementContext>
-
-    </broker>
-
-    
-    
-</beans>
-<!-- END SNIPPET: example -->

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/virtual-topics-and-interceptor.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/virtual-topics-and-interceptor.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/virtual-topics-and-interceptor.xml
deleted file mode 100644
index fcce72e..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/virtual-topics-and-interceptor.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?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.
--->
-
-<!-- this file can only be parsed using the xbean-spring library -->
-<!-- START SNIPPET: xbean -->
-<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">
-
-  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />
-
-  <broker xmlns="http://activemq.apache.org/schema/core" persistent="false">
-
-
-    <destinationInterceptors>
-      <!--  custom destination interceptor -->
-      <bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.broker.virtual.DestinationInterceptorDurableSubTest$SimpleDestinationInterceptor" />
-
-      <virtualDestinationInterceptor>
-        <virtualDestinations>
-          <virtualTopic name=">" prefix="VirtualTopicConsumers.*." selectorAware="false"/>
-        </virtualDestinations>
-      </virtualDestinationInterceptor>
-    </destinationInterceptors>
-
-    <managementContext>
-      <managementContext createConnector="true" connectorPort="1299"/>
-    </managementContext>
-  </broker>
-
-</beans>
-<!-- END SNIPPET: xbean -->

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1282.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1282.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1282.java
deleted file mode 100644
index 0568757..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1282.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/**
- * 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;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.MapMessage;
-import javax.jms.Session;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-
-/**
- * An AMQ-1282 Test
- */
-public class AMQ1282 extends TestCase {
-
-   private ConnectionFactory factory;
-   private Connection connection;
-   private MapMessage message;
-
-   @Override
-   protected void setUp() throws Exception {
-      factory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
-      connection = factory.createConnection();
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      message = session.createMapMessage();
-      super.setUp();
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      connection.close();
-      super.tearDown();
-   }
-
-   public void testUnmappedBooleanMessage() throws JMSException {
-      Object expected;
-      try {
-         expected = Boolean.valueOf(null);
-      }
-      catch (Exception ex) {
-         expected = ex;
-      }
-      try {
-         Boolean actual = message.getBoolean("foo");
-         assertEquals(expected, actual);
-      }
-      catch (Exception ex) {
-         assertEquals(expected, ex);
-      }
-   }
-
-   public void testUnmappedIntegerMessage() throws JMSException {
-      Object expected;
-      try {
-         expected = Integer.valueOf(null);
-      }
-      catch (Exception ex) {
-         expected = ex;
-      }
-      try {
-         Integer actual = message.getInt("foo");
-         assertEquals(expected, actual);
-      }
-      catch (Exception ex) {
-         Class<?> aClass = expected.getClass();
-         assertTrue(aClass.isInstance(ex));
-      }
-   }
-
-   public void testUnmappedShortMessage() throws JMSException {
-      Object expected;
-      try {
-         expected = Short.valueOf(null);
-      }
-      catch (Exception ex) {
-         expected = ex;
-      }
-      try {
-         Short actual = message.getShort("foo");
-         assertEquals(expected, actual);
-      }
-      catch (Exception ex) {
-         Class<?> aClass = expected.getClass();
-         assertTrue(aClass.isInstance(ex));
-      }
-   }
-
-   public void testUnmappedLongMessage() throws JMSException {
-      Object expected;
-      try {
-         expected = Long.valueOf(null);
-      }
-      catch (Exception ex) {
-         expected = ex;
-      }
-      try {
-         Long actual = message.getLong("foo");
-         assertEquals(expected, actual);
-      }
-      catch (Exception ex) {
-         Class<?> aClass = expected.getClass();
-         assertTrue(aClass.isInstance(ex));
-      }
-   }
-
-   public void testUnmappedStringMessage() throws JMSException {
-      Object expected;
-      try {
-         expected = String.valueOf(null);
-      }
-      catch (Exception ex) {
-         expected = ex;
-      }
-      try {
-         String actual = message.getString("foo");
-         assertEquals(expected, actual);
-      }
-      catch (Exception ex) {
-         Class<?> aClass = expected.getClass();
-         assertTrue(aClass.isInstance(ex));
-      }
-   }
-
-   public void testUnmappedCharMessage() throws JMSException {
-      try {
-         message.getChar("foo");
-         fail("should have thrown NullPointerException");
-      }
-      catch (NullPointerException success) {
-         assertNotNull(success);
-      }
-   }
-
-   public void testUnmappedByteMessage() throws JMSException {
-      Object expected;
-      try {
-         expected = Byte.valueOf(null);
-      }
-      catch (Exception ex) {
-         expected = ex;
-      }
-      try {
-         Byte actual = message.getByte("foo");
-         assertEquals(expected, actual);
-      }
-      catch (Exception ex) {
-         Class<?> aClass = expected.getClass();
-         assertTrue(aClass.isInstance(ex));
-      }
-   }
-
-   public void testUnmappedDoubleMessage() throws JMSException {
-      Object expected;
-      try {
-         expected = Double.valueOf(null);
-      }
-      catch (Exception ex) {
-         expected = ex;
-      }
-      try {
-         Double actual = message.getDouble("foo");
-         assertEquals(expected, actual);
-      }
-      catch (Exception ex) {
-         Class<?> aClass = expected.getClass();
-         assertTrue(aClass.isInstance(ex));
-      }
-   }
-
-   public void testUnmappedFloatMessage() throws JMSException {
-      Object expected;
-      try {
-         expected = Float.valueOf(null);
-      }
-      catch (Exception ex) {
-         expected = ex;
-      }
-      try {
-         Float actual = message.getFloat("foo");
-         assertEquals(expected, actual);
-      }
-      catch (Exception ex) {
-         Class<?> aClass = expected.getClass();
-         assertTrue(aClass.isInstance(ex));
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1687Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1687Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1687Test.java
deleted file mode 100644
index 78a6088..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1687Test.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- * 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;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.spring.ConsumerBean;
-
-/**
- *
- *
- */
-public class AMQ1687Test extends EmbeddedBrokerTestSupport {
-
-   private Connection connection;
-
-   @Override
-   protected ConnectionFactory createConnectionFactory() throws Exception {
-      //prefetch change is not required, but test will not fail w/o it, only spew errors in the AMQ log.
-      return new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString() + "?jms.prefetchPolicy.all=5");
-   }
-
-   public void testVirtualTopicCreation() throws Exception {
-      if (connection == null) {
-         connection = createConnection();
-      }
-      connection.start();
-
-      ConsumerBean messageList = new ConsumerBean();
-      messageList.setVerbose(true);
-
-      String queueAName = getVirtualTopicConsumerName();
-      String queueBName = getVirtualTopicConsumerNameB();
-
-      // create consumer 'cluster'
-      ActiveMQQueue queue1 = new ActiveMQQueue(queueAName);
-      ActiveMQQueue queue2 = new ActiveMQQueue(queueBName);
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer c1 = session.createConsumer(queue1);
-      MessageConsumer c2 = session.createConsumer(queue2);
-
-      c1.setMessageListener(messageList);
-      c2.setMessageListener(messageList);
-
-      // create topic producer
-      ActiveMQTopic topic = new ActiveMQTopic(getVirtualTopicName());
-      MessageProducer producer = session.createProducer(topic);
-      assertNotNull(producer);
-
-      int total = 100;
-      for (int i = 0; i < total; i++) {
-         producer.send(session.createTextMessage("message: " + i));
-      }
-
-      messageList.assertMessagesArrived(total * 2);
-   }
-
-   protected String getVirtualTopicName() {
-      return "VirtualTopic.TEST";
-   }
-
-   protected String getVirtualTopicConsumerName() {
-      return "Consumer.A.VirtualTopic.TEST";
-   }
-
-   protected String getVirtualTopicConsumerNameB() {
-      return "Consumer.B.VirtualTopic.TEST";
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      this.bindAddress = "tcp://localhost:0";
-      super.setUp();
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      if (connection != null) {
-         connection.close();
-      }
-      super.tearDown();
-   }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1853Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1853Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1853Test.java
deleted file mode 100644
index 2f7b8fe..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1853Test.java
+++ /dev/null
@@ -1,378 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.*;
-
-import java.net.URI;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQMessageProducer;
-import org.apache.activemq.ActiveMQSession;
-import org.apache.activemq.RedeliveryPolicy;
-import org.apache.activemq.broker.BrokerFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.util.Wait;
-import org.apache.activemq.util.Wait.Condition;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Test validates that the AMQ consumer blocks on redelivery of a message,
- * through all redeliveries, until the message is either successfully consumed
- * or sent to the DLQ.
- */
-public class AMQ1853Test {
-
-   private static BrokerService broker;
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ1853Test.class);
-   static final String jmsConnectionURI = "failover:(vm://localhost)";
-
-   // Virtual Topic that the test publishes 10 messages to
-   private static final String queueFail = "Queue.BlockingConsumer.QueueFail";
-
-   // Number of messages
-
-   private final int producerMessages = 5;
-   private final int totalNumberMessages = producerMessages * 2;
-   private final int maxRedeliveries = 2;
-   private final int redeliveryDelay = 1000;
-
-   private Map<String, AtomicInteger> messageList = null;
-
-   @Before
-   public void setUp() throws Exception {
-      broker = BrokerFactory.createBroker(new URI("broker:()/localhost?persistent=false"));
-      broker.setUseJmx(false);
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.start();
-      broker.waitUntilStarted();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-         broker = null;
-      }
-   }
-
-   @Test
-   public void testConsumerMessagesAreNotOrdered() throws Exception {
-
-      TestConsumer consumerAllFail = null;
-      messageList = new Hashtable<>();
-
-      try {
-
-         // The first 2 consumers will rollback, ultimately causing messages to land on the DLQ
-
-         TestProducer producerAllFail = new TestProducer(queueFail);
-         thread(producerAllFail, false);
-
-         consumerAllFail = new TestConsumer(queueFail, true);
-         thread(consumerAllFail, false);
-
-         // Give the consumers a second to start
-         Thread.sleep(1000);
-
-         thread(producerAllFail, false);
-
-         // Give the consumers a second to start
-         Thread.sleep(1000);
-
-         producerAllFail.getLatch().await();
-
-         LOG.info("producer successful, count = " + producerAllFail.getLatch().getCount());
-         LOG.info("final message list size =  " + messageList.size());
-
-         assertTrue("message list size =  " + messageList.size() + " exptected:" + totalNumberMessages, Wait.waitFor(new Condition() {
-                       @Override
-                       public boolean isSatisified() throws Exception {
-                          return totalNumberMessages == messageList.size();
-                       }
-                    }));
-
-         consumerAllFail.getLatch().await();
-
-         LOG.info("consumerAllFail successful, count = " + consumerAllFail.getLatch().getCount());
-
-         Iterator<String> keys = messageList.keySet().iterator();
-         for (AtomicInteger counter : messageList.values()) {
-            String message = keys.next();
-            LOG.info("final count for message " + message + " counter =  " + counter.get());
-            assertTrue("for message " + message + " counter =  " + counter.get(), counter.get() == maxRedeliveries + 1);
-         }
-
-         assertFalse(consumerAllFail.messageReceiptIsOrdered());
-      }
-      finally {
-         if (consumerAllFail != null) {
-            consumerAllFail.setStop(true);
-         }
-      }
-   }
-
-   private static Thread thread(Runnable runnable, boolean daemon) {
-      Thread brokerThread = new Thread(runnable);
-      brokerThread.setDaemon(daemon);
-      brokerThread.start();
-      return brokerThread;
-   }
-
-   private class TestProducer implements Runnable {
-
-      private CountDownLatch latch = null;
-      private String destinationName = null;
-
-      public TestProducer(String destinationName) {
-         this.destinationName = destinationName;
-         // We run the producer 2 times
-         latch = new CountDownLatch(totalNumberMessages);
-      }
-
-      public CountDownLatch getLatch() {
-         return latch;
-      }
-
-      @Override
-      public void run() {
-
-         ActiveMQConnectionFactory connectionFactory = null;
-         ActiveMQConnection connection = null;
-         ActiveMQSession session = null;
-         Destination destination = null;
-
-         try {
-            LOG.info("Started TestProducer for destination (" + destinationName + ")");
-
-            connectionFactory = new ActiveMQConnectionFactory(jmsConnectionURI);
-            connection = (ActiveMQConnection) connectionFactory.createConnection();
-            connection.setCopyMessageOnSend(false);
-            connection.start();
-            session = (ActiveMQSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-            destination = session.createQueue(this.destinationName);
-
-            // Create a MessageProducer from the Session to the Topic or Queue
-            ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);
-            producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
-            for (int i = 0; i < (producerMessages); i++) {
-               TextMessage message = session.createTextMessage();
-               message.setLongProperty("TestTime", (System.currentTimeMillis()));
-               try {
-                  producer.send(message);
-                  LOG.info("Producer (" + destinationName + ")\n" + message.getJMSMessageID() + " = sent messageId\n");
-
-                  latch.countDown();
-                  LOG.info(" Latch count  " + latch.getCount());
-                  LOG.info("Producer message list size = " + messageList.keySet().size());
-                  messageList.put(message.getJMSMessageID(), new AtomicInteger(0));
-                  LOG.info("Producer message list size = " + messageList.keySet().size());
-
-               }
-               catch (Exception deeperException) {
-                  LOG.info("Producer for destination (" + destinationName + ") Caught: " + deeperException);
-               }
-
-               Thread.sleep(1000);
-            }
-
-            LOG.info("Finished TestProducer for destination (" + destinationName + ")");
-
-         }
-         catch (Exception e) {
-            LOG.error("Terminating TestProducer(" + destinationName + ")Caught: " + e);
-         }
-         finally {
-            try {
-               if (session != null) {
-                  session.close();
-               }
-               if (connection != null) {
-                  connection.close();
-               }
-            }
-            catch (Exception e) {
-               LOG.error("Closing connection/session (" + destinationName + ")Caught: " + e);
-            }
-         }
-      }
-   }
-
-   private class TestConsumer implements Runnable, ExceptionListener, MessageListener {
-
-      private CountDownLatch latch = null;
-      private int receivedMessageCounter = 0;
-      private boolean bFakeFail = false;
-      String destinationName = null;
-      boolean bMessageReceiptIsOrdered = true;
-      boolean bStop = false;
-      String previousMessageId = null;
-
-      private ActiveMQConnectionFactory connectionFactory = null;
-      private ActiveMQConnection connection = null;
-      private Session session = null;
-      private MessageConsumer consumer = null;
-
-      public TestConsumer(String destinationName, boolean bFakeFail) {
-         this.bFakeFail = bFakeFail;
-         latch = new CountDownLatch(totalNumberMessages * (this.bFakeFail ? (maxRedeliveries + 1) : 1));
-         this.destinationName = destinationName;
-      }
-
-      public CountDownLatch getLatch() {
-         return latch;
-      }
-
-      public boolean messageReceiptIsOrdered() {
-         return bMessageReceiptIsOrdered;
-      }
-
-      @Override
-      public void run() {
-
-         try {
-            LOG.info("Started TestConsumer for destination (" + destinationName + ")");
-
-            connectionFactory = new ActiveMQConnectionFactory(jmsConnectionURI);
-            connection = (ActiveMQConnection) connectionFactory.createConnection();
-            connection.setNonBlockingRedelivery(true);
-            session = connection.createSession(true, Session.SESSION_TRANSACTED);
-
-            RedeliveryPolicy policy = connection.getRedeliveryPolicy();
-            policy.setInitialRedeliveryDelay(redeliveryDelay);
-            policy.setBackOffMultiplier(-1);
-            policy.setRedeliveryDelay(redeliveryDelay);
-            policy.setMaximumRedeliveryDelay(-1);
-            policy.setUseExponentialBackOff(false);
-            policy.setMaximumRedeliveries(maxRedeliveries);
-
-            connection.setExceptionListener(this);
-            Destination destination = session.createQueue(destinationName);
-            consumer = session.createConsumer(destination);
-            consumer.setMessageListener(this);
-
-            connection.start();
-
-            while (!bStop) {
-               Thread.sleep(100);
-            }
-
-            LOG.info("Finished TestConsumer for destination name (" + destinationName + ") remaining " + this.latch.getCount() + " messages " + this.toString());
-
-         }
-         catch (Exception e) {
-            LOG.error("Consumer (" + destinationName + ") Caught: " + e);
-         }
-         finally {
-            try {
-               if (consumer != null) {
-                  consumer.close();
-               }
-               if (session != null) {
-                  session.close();
-               }
-               if (connection != null) {
-                  connection.close();
-               }
-            }
-            catch (Exception e) {
-               LOG.error("Closing connection/session (" + destinationName + ")Caught: " + e);
-            }
-         }
-      }
-
-      @Override
-      public synchronized void onException(JMSException ex) {
-         LOG.error("Consumer for destination, (" + destinationName + "), JMS Exception occurred.  Shutting down client.");
-      }
-
-      public synchronized void setStop(boolean bStop) {
-         this.bStop = bStop;
-      }
-
-      @Override
-      public synchronized void onMessage(Message message) {
-         receivedMessageCounter++;
-         latch.countDown();
-
-         LOG.info("Consumer for destination (" + destinationName + ") latch countdown: " + latch.getCount() +
-                     " :: Number messages received " + this.receivedMessageCounter);
-
-         try {
-
-            if (receivedMessageCounter % (maxRedeliveries + 1) == 1) {
-               previousMessageId = message.getJMSMessageID();
-            }
-
-            if (bMessageReceiptIsOrdered) {
-               bMessageReceiptIsOrdered = previousMessageId.trim().equals(message.getJMSMessageID());
-            }
-
-            final String jmsMessageId = message.getJMSMessageID();
-            assertTrue("Did not find expected ", Wait.waitFor(new Wait.Condition() {
-               @Override
-               public boolean isSatisified() throws Exception {
-                  return messageList.containsKey(jmsMessageId);
-               }
-            }));
-
-            AtomicInteger counter = messageList.get(jmsMessageId);
-            counter.incrementAndGet();
-
-            LOG.info("Consumer for destination (" + destinationName + ")\n" + message.getJMSMessageID() + " = currentMessageId\n" + previousMessageId + " = previousMessageId\n" + bMessageReceiptIsOrdered + "= bMessageReceiptIsOrdered\n" + ">>LATENCY " + (System.currentTimeMillis() - message.getLongProperty("TestTime")) + "\n" + "message counter = " + counter.get());
-
-            if (!bFakeFail) {
-               LOG.debug("Consumer on destination " + destinationName + " committing JMS Session for message: " + message.toString());
-               session.commit();
-            }
-            else {
-               LOG.debug("Consumer on destination " + destinationName + " rolling back JMS Session for message: " + message.toString());
-               session.rollback(); // rolls back all the consumed messages on the session to
-            }
-
-         }
-         catch (Exception ex) {
-            ex.printStackTrace();
-            LOG.error("Error reading JMS Message from destination " + destinationName + ".");
-         }
-      }
-   }
-}


[51/60] [abbrv] activemq-artemis git commit: looking for leaking server

Posted by cl...@apache.org.
looking for leaking server


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/2ad5c258
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/2ad5c258
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/2ad5c258

Branch: refs/heads/refactor-openwire
Commit: 2ad5c258c585516ba33429a8a9ffbcbd9196be39
Parents: 3bd1cde
Author: Clebert Suconic <cl...@apache.org>
Authored: Fri Mar 4 17:21:56 2016 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:45:29 2016 -0400

----------------------------------------------------------------------
 tests/activemq5-unit-tests/pom.xml              |  9 ++++
 .../artemiswrapper/CleanupThreadRule.java       | 52 ++++++++++++++++++++
 .../artemiswrapper/OpenwireArtemisBaseTest.java |  7 +++
 .../transport/failover/ClusterUtil.java         | 25 ----------
 4 files changed, 68 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2ad5c258/tests/activemq5-unit-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/pom.xml b/tests/activemq5-unit-tests/pom.xml
index a17847e..bbfbcd3 100644
--- a/tests/activemq5-unit-tests/pom.xml
+++ b/tests/activemq5-unit-tests/pom.xml
@@ -49,6 +49,14 @@
 
    <dependencies>
 
+      <!-- I imported this to get the ThreadLeakCheck -->
+      <dependency>
+         <groupId>org.apache.activemq</groupId>
+         <artifactId>artemis-server</artifactId>
+         <version>${project.version}</version>
+         <type>test-jar</type>
+      </dependency>
+
       <dependency>
          <groupId>org.apache.activemq</groupId>
          <artifactId>activemq-client</artifactId>
@@ -336,6 +344,7 @@
             </exclusion>
          </exclusions>
       </dependency>
+
        <!--
            JBoss Logging
        -->

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2ad5c258/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/CleanupThreadRule.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/CleanupThreadRule.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/CleanupThreadRule.java
new file mode 100644
index 0000000..2ddac3b
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/CleanupThreadRule.java
@@ -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.broker.artemiswrapper;
+
+import org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl;
+import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl;
+import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnector;
+import org.junit.rules.ExternalResource;
+
+public class CleanupThreadRule extends ExternalResource {
+
+   @Override
+   protected void before() throws Throwable {
+
+   }
+
+   @Override
+   protected void after() {
+      OperationContextImpl.clearContext();
+
+      // We shutdown the global pools to give a better isolation between tests
+      try {
+         ServerLocatorImpl.clearThreadPools();
+      }
+      catch (Throwable e) {
+         e.printStackTrace();
+      }
+
+      try {
+         NettyConnector.clearThreadPools();
+      }
+      catch (Exception e) {
+         e.printStackTrace();
+      }
+
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2ad5c258/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/OpenwireArtemisBaseTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/OpenwireArtemisBaseTest.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/OpenwireArtemisBaseTest.java
index 5c8d3b6..2f3a330 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/OpenwireArtemisBaseTest.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/OpenwireArtemisBaseTest.java
@@ -33,6 +33,7 @@ import org.apache.activemq.artemis.core.server.JournalType;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
 import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.activemq.artemis.tests.util.ThreadLeakCheckRule;
 import org.apache.activemq.artemis.utils.uri.URISchema;
 import org.apache.activemq.artemis.utils.uri.URISupport;
 import org.apache.activemq.broker.BrokerService;
@@ -48,6 +49,12 @@ import javax.management.ObjectName;
 public class OpenwireArtemisBaseTest {
 
    @Rule
+   public CleanupThreadRule cleanupRules = new CleanupThreadRule();
+
+   @Rule
+   public ThreadLeakCheckRule leakCheckRule = new ThreadLeakCheckRule();
+
+   @Rule
    public TemporaryFolder temporaryFolder;
    @Rule
    public TestName name = new TestName();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2ad5c258/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ClusterUtil.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ClusterUtil.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ClusterUtil.java
deleted file mode 100644
index 42f199f..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ClusterUtil.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.failover;
-
-/**
- * Utilities to create broker clusters
- */
-public class ClusterUtil {
-
-}


[25/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1866.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1866.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1866.java
deleted file mode 100644
index ad12f71..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1866.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/**
- * 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;
-
-import java.util.ArrayList;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicLong;
-
-import javax.jms.Connection;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.leveldb.LevelDBStore;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This is a test case for the issue reported at:
- * https://issues.apache.org/activemq/browse/AMQ-1866
- *
- * If you have a JMS producer sending messages to multiple fast consumers and
- * one slow consumer, eventually all consumers will run as slow as
- * the slowest consumer.
- */
-public class AMQ1866 extends TestCase {
-
-   private static final Logger log = LoggerFactory.getLogger(ConsumerThread.class);
-   private BrokerService brokerService;
-   private ArrayList<Thread> threads = new ArrayList<>();
-
-   private final String ACTIVEMQ_BROKER_BIND = "tcp://localhost:0";
-   private String ACTIVEMQ_BROKER_URI;
-
-   AtomicBoolean shutdown = new AtomicBoolean();
-   private ActiveMQQueue destination;
-
-   @Override
-   protected void setUp() throws Exception {
-      // Start an embedded broker up.
-      brokerService = new BrokerService();
-      LevelDBStore adaptor = new LevelDBStore();
-      brokerService.setPersistenceAdapter(adaptor);
-      brokerService.deleteAllMessages();
-
-      // A small max page size makes this issue occur faster.
-      PolicyMap policyMap = new PolicyMap();
-      PolicyEntry pe = new PolicyEntry();
-      pe.setMaxPageSize(1);
-      policyMap.put(new ActiveMQQueue(">"), pe);
-      brokerService.setDestinationPolicy(policyMap);
-
-      brokerService.addConnector(ACTIVEMQ_BROKER_BIND);
-      brokerService.start();
-
-      ACTIVEMQ_BROKER_URI = brokerService.getTransportConnectors().get(0).getPublishableConnectString();
-      destination = new ActiveMQQueue(getName());
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      // Stop any running threads.
-      shutdown.set(true);
-      for (Thread t : threads) {
-         t.interrupt();
-         t.join();
-      }
-      brokerService.stop();
-   }
-
-   public void testConsumerSlowDownPrefetch0() throws Exception {
-      ACTIVEMQ_BROKER_URI = ACTIVEMQ_BROKER_URI + "?jms.prefetchPolicy.queuePrefetch=0";
-      doTestConsumerSlowDown();
-   }
-
-   public void testConsumerSlowDownPrefetch10() throws Exception {
-      ACTIVEMQ_BROKER_URI = ACTIVEMQ_BROKER_URI + "?jms.prefetchPolicy.queuePrefetch=10";
-      doTestConsumerSlowDown();
-   }
-
-   public void testConsumerSlowDownDefaultPrefetch() throws Exception {
-      doTestConsumerSlowDown();
-   }
-
-   public void doTestConsumerSlowDown() throws Exception {
-
-      // Preload the queue.
-      produce(20000);
-
-      Thread producer = new Thread() {
-         @Override
-         public void run() {
-            try {
-               while (!shutdown.get()) {
-                  produce(1000);
-               }
-            }
-            catch (Exception e) {
-            }
-         }
-      };
-      threads.add(producer);
-      producer.start();
-
-      // This is the slow consumer.
-      ConsumerThread c1 = new ConsumerThread("Consumer-1");
-      threads.add(c1);
-      c1.start();
-
-      // Wait a bit so that the slow consumer gets assigned most of the messages.
-      Thread.sleep(500);
-      ConsumerThread c2 = new ConsumerThread("Consumer-2");
-      threads.add(c2);
-      c2.start();
-
-      int totalReceived = 0;
-      for (int i = 0; i < 30; i++) {
-         Thread.sleep(1000);
-         long c1Counter = c1.counter.getAndSet(0);
-         long c2Counter = c2.counter.getAndSet(0);
-         log.debug("c1: " + c1Counter + ", c2: " + c2Counter);
-         totalReceived += c1Counter;
-         totalReceived += c2Counter;
-
-         // Once message have been flowing for a few seconds, start asserting that c2 always gets messages.  It should be receiving about 100 / sec
-         if (i > 10) {
-            assertTrue("Total received=" + totalReceived + ", Consumer 2 should be receiving new messages every second.", c2Counter > 0);
-         }
-      }
-   }
-
-   public void produce(int count) throws Exception {
-      Connection connection = null;
-      try {
-         ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(ACTIVEMQ_BROKER_URI);
-         factory.setDispatchAsync(true);
-
-         connection = factory.createConnection();
-
-         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageProducer producer = session.createProducer(destination);
-         connection.start();
-
-         for (int i = 0; i < count; i++) {
-            producer.send(session.createTextMessage(getName() + " Message " + (++i)));
-         }
-
-      }
-      finally {
-         try {
-            connection.close();
-         }
-         catch (Throwable e) {
-         }
-      }
-   }
-
-   public class ConsumerThread extends Thread {
-
-      final AtomicLong counter = new AtomicLong();
-
-      public ConsumerThread(String threadId) {
-         super(threadId);
-      }
-
-      @Override
-      public void run() {
-         Connection connection = null;
-         try {
-            log.debug(getName() + ": is running");
-
-            ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(ACTIVEMQ_BROKER_URI);
-            factory.setDispatchAsync(true);
-
-            connection = factory.createConnection();
-
-            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-            MessageConsumer consumer = session.createConsumer(destination);
-            connection.start();
-
-            while (!shutdown.get()) {
-               TextMessage msg = (TextMessage) consumer.receive(1000);
-               if (msg != null) {
-                  int sleepingTime;
-                  if (getName().equals("Consumer-1")) {
-                     sleepingTime = 1000 * 1000;
-                  }
-                  else {
-                     sleepingTime = 1;
-                  }
-                  counter.incrementAndGet();
-                  Thread.sleep(sleepingTime);
-               }
-            }
-
-         }
-         catch (Exception e) {
-         }
-         finally {
-            log.debug(getName() + ": is stopping");
-            try {
-               connection.close();
-            }
-            catch (Throwable e) {
-            }
-         }
-      }
-
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1893Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1893Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1893Test.java
deleted file mode 100644
index b9cb919..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1893Test.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/**
- * 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;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class AMQ1893Test extends TestCase {
-
-   private static final Logger log = LoggerFactory.getLogger(AMQ1893Test.class);
-
-   static final String QUEUE_NAME = "TEST";
-
-   static final int MESSAGE_COUNT_OF_ONE_GROUP = 10000;
-
-   static final int[] PRIORITIES = new int[]{0, 5, 10};
-
-   static final boolean debug = false;
-
-   private BrokerService brokerService;
-
-   private ActiveMQQueue destination;
-
-   @Override
-   protected void setUp() throws Exception {
-      brokerService = new BrokerService();
-      brokerService.setDeleteAllMessagesOnStartup(true);
-      brokerService.addConnector("tcp://localhost:0");
-      brokerService.start();
-      destination = new ActiveMQQueue(QUEUE_NAME);
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      // Stop any running threads.
-      brokerService.stop();
-   }
-
-   public void testProduceConsumeWithSelector() throws Exception {
-      new TestProducer().produceMessages();
-      new TestConsumer().consume();
-   }
-
-   class TestProducer {
-
-      public void produceMessages() throws Exception {
-         ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerService.getTransportConnectors().get(0).getConnectUri().toString());
-         Connection connection = connectionFactory.createConnection();
-         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         Destination destination = session.createQueue(QUEUE_NAME);
-         MessageProducer producer = session.createProducer(destination);
-         producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-
-         long start = System.currentTimeMillis();
-
-         for (int priority : PRIORITIES) {
-
-            String name = null;
-            if (priority == 10) {
-               name = "high";
-            }
-            else if (priority == 5) {
-               name = "mid";
-            }
-            else {
-               name = "low";
-            }
-
-            for (int i = 1; i <= MESSAGE_COUNT_OF_ONE_GROUP; i++) {
-
-               TextMessage message = session.createTextMessage(name + "_" + i);
-               message.setIntProperty("priority", priority);
-
-               producer.send(message);
-            }
-         }
-
-         long end = System.currentTimeMillis();
-
-         log.info("sent " + (MESSAGE_COUNT_OF_ONE_GROUP * 3) + " messages in " + (end - start) + " ms");
-
-         producer.close();
-         session.close();
-         connection.close();
-      }
-   }
-
-   class TestConsumer {
-
-      private CountDownLatch finishLatch = new CountDownLatch(1);
-
-      public void consume() throws Exception {
-         ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerService.getTransportConnectors().get(0).getConnectUri().toString());
-
-         final int totalMessageCount = MESSAGE_COUNT_OF_ONE_GROUP * PRIORITIES.length;
-         final AtomicInteger counter = new AtomicInteger();
-         final MessageListener listener = new MessageListener() {
-            @Override
-            public void onMessage(Message message) {
-
-               if (debug) {
-                  try {
-                     log.info(((TextMessage) message).getText());
-                  }
-                  catch (JMSException e) {
-                     e.printStackTrace();
-                  }
-               }
-
-               if (counter.incrementAndGet() == totalMessageCount) {
-
-                  finishLatch.countDown();
-
-               }
-            }
-         };
-
-         int consumerCount = PRIORITIES.length;
-         Connection[] connections = new Connection[consumerCount];
-         Session[] sessions = new Session[consumerCount];
-         MessageConsumer[] consumers = new MessageConsumer[consumerCount];
-
-         for (int i = 0; i < consumerCount; i++) {
-            String selector = "priority = " + PRIORITIES[i];
-
-            connections[i] = connectionFactory.createConnection();
-            sessions[i] = connections[i].createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-            consumers[i] = sessions[i].createConsumer(destination, selector);
-            consumers[i].setMessageListener(listener);
-         }
-
-         for (Connection connection : connections) {
-            connection.start();
-         }
-
-         log.info("received " + counter.get() + " messages");
-
-         assertTrue("got all messages in time", finishLatch.await(60, TimeUnit.SECONDS));
-
-         log.info("received " + counter.get() + " messages");
-
-         for (MessageConsumer consumer : consumers) {
-            consumer.close();
-         }
-
-         for (Session session : sessions) {
-            session.close();
-         }
-
-         for (Connection connection : connections) {
-            connection.close();
-         }
-      }
-
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1917Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1917Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1917Test.java
deleted file mode 100644
index a7eb699..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1917Test.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/**
- * 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;
-
-import junit.framework.TestCase;
-
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQDestination;
-
-public class AMQ1917Test extends TestCase {
-
-   private static final int NUM_MESSAGES = 4000;
-   private static final int NUM_THREADS = 10;
-   private static final String REQUEST_QUEUE = "mock.in.queue";
-   private static final String REPLY_QUEUE = "mock.out.queue";
-
-   private Destination requestDestination = ActiveMQDestination.createDestination(REQUEST_QUEUE, ActiveMQDestination.QUEUE_TYPE);
-   private Destination replyDestination = ActiveMQDestination.createDestination(REPLY_QUEUE, ActiveMQDestination.QUEUE_TYPE);
-
-   private CountDownLatch roundTripLatch = new CountDownLatch(NUM_MESSAGES);
-   private CountDownLatch errorLatch = new CountDownLatch(1);
-   private ThreadPoolExecutor tpe;
-   private final String BROKER_URL = "tcp://localhost:0";
-   private String connectionUri;
-   private BrokerService broker = null;
-   private boolean working = true;
-
-   // trival session/producer pool
-   final Session[] sessions = new Session[NUM_THREADS];
-   final MessageProducer[] producers = new MessageProducer[NUM_THREADS];
-
-   @Override
-   public void setUp() throws Exception {
-      broker = new BrokerService();
-      broker.setPersistent(false);
-      broker.addConnector(BROKER_URL);
-      broker.start();
-
-      connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
-
-      BlockingQueue<Runnable> queue = new ArrayBlockingQueue<>(10000);
-      tpe = new ThreadPoolExecutor(NUM_THREADS, NUM_THREADS, 60000, TimeUnit.MILLISECONDS, queue);
-      ThreadFactory limitedthreadFactory = new LimitedThreadFactory(tpe.getThreadFactory());
-      tpe.setThreadFactory(limitedthreadFactory);
-   }
-
-   @Override
-   public void tearDown() throws Exception {
-      broker.stop();
-      tpe.shutdown();
-   }
-
-   public void testLoadedSendReceiveWithCorrelationId() throws Exception {
-
-      ActiveMQConnectionFactory connectionFactory = new org.apache.activemq.ActiveMQConnectionFactory();
-      connectionFactory.setBrokerURL(connectionUri);
-      Connection connection = connectionFactory.createConnection();
-      setupReceiver(connection);
-
-      connection = connectionFactory.createConnection();
-      connection.start();
-
-      // trival session/producer pool
-      for (int i = 0; i < NUM_THREADS; i++) {
-         sessions[i] = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         producers[i] = sessions[i].createProducer(requestDestination);
-      }
-
-      for (int i = 0; i < NUM_MESSAGES; i++) {
-         MessageSenderReceiver msr = new MessageSenderReceiver(requestDestination, replyDestination, "Test Message : " + i);
-         tpe.execute(msr);
-      }
-
-      while (!roundTripLatch.await(4000, TimeUnit.MILLISECONDS)) {
-         if (errorLatch.await(1000, TimeUnit.MILLISECONDS)) {
-            fail("there was an error, check the console for thread or thread allocation failure");
-            break;
-         }
-      }
-      working = false;
-   }
-
-   private void setupReceiver(final Connection connection) throws Exception {
-
-      final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      final MessageConsumer consumer = session.createConsumer(requestDestination);
-      final MessageProducer sender = session.createProducer(replyDestination);
-      connection.start();
-
-      new Thread() {
-         @Override
-         public void run() {
-            while (working) {
-               // wait for messages in infinitive loop
-               // time out is set to show the client is awaiting
-               try {
-                  TextMessage msg = (TextMessage) consumer.receive(20000);
-                  if (msg == null) {
-                     errorLatch.countDown();
-                     fail("Response timed out." + " latchCount=" + roundTripLatch.getCount());
-                  }
-                  else {
-                     String result = msg.getText();
-                     //System.out.println("Request:" + (i++)
-                     //        + ", msg=" + result + ", ID" + msg.getJMSMessageID());
-                     TextMessage response = session.createTextMessage();
-                     response.setJMSCorrelationID(msg.getJMSMessageID());
-                     response.setText(result);
-                     sender.send(response);
-                  }
-               }
-               catch (JMSException e) {
-                  if (working) {
-                     errorLatch.countDown();
-                     fail("Unexpected exception:" + e);
-                  }
-               }
-            }
-         }
-      }.start();
-   }
-
-   class MessageSenderReceiver implements Runnable {
-
-      Destination reqDest;
-      Destination replyDest;
-      String origMsg;
-
-      public MessageSenderReceiver(Destination reqDest, Destination replyDest, String msg) throws Exception {
-         this.replyDest = replyDest;
-         this.reqDest = reqDest;
-         this.origMsg = msg;
-      }
-
-      private int getIndexFromCurrentThread() {
-         String name = Thread.currentThread().getName();
-         String num = name.substring(name.lastIndexOf('-') + 1);
-         int idx = Integer.parseInt(num) - 1;
-         assertTrue("idx is in range: idx=" + idx, idx < NUM_THREADS);
-         return idx;
-      }
-
-      @Override
-      public void run() {
-         try {
-            // get thread session and producer from pool
-            int threadIndex = getIndexFromCurrentThread();
-            Session session = sessions[threadIndex];
-            MessageProducer producer = producers[threadIndex];
-
-            final Message sendJmsMsg = session.createTextMessage(origMsg);
-            producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-            producer.send(sendJmsMsg);
-
-            String jmsId = sendJmsMsg.getJMSMessageID();
-            String selector = "JMSCorrelationID='" + jmsId + "'";
-
-            MessageConsumer consumer = session.createConsumer(replyDest, selector);
-            Message receiveJmsMsg = consumer.receive(2000);
-            consumer.close();
-            if (receiveJmsMsg == null) {
-               errorLatch.countDown();
-               fail("Unable to receive response for:" + origMsg + ", with selector=" + selector);
-            }
-            else {
-               //System.out.println("received response message :"
-               //        + ((TextMessage) receiveJmsMsg).getText()
-               //        + " with selector : " + selector);
-               roundTripLatch.countDown();
-            }
-         }
-         catch (JMSException e) {
-            fail("unexpected exception:" + e);
-         }
-      }
-   }
-
-   public class LimitedThreadFactory implements ThreadFactory {
-
-      int threadCount;
-      private ThreadFactory factory;
-
-      public LimitedThreadFactory(ThreadFactory threadFactory) {
-         this.factory = threadFactory;
-      }
-
-      @Override
-      public Thread newThread(Runnable arg0) {
-         if (++threadCount > NUM_THREADS) {
-            errorLatch.countDown();
-            fail("too many threads requested");
-         }
-         return factory.newThread(arg0);
-      }
-   }
-}
-

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1936Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1936Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1936Test.java
deleted file mode 100644
index 6e49550..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ1936Test.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/**
- * 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;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.QueueReceiver;
-import javax.jms.QueueSender;
-import javax.jms.QueueSession;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.naming.NamingException;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.AutoFailTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.util.Wait;
-import org.apache.log4j.Logger;
-
-/**
- * AMQ1936Test
- */
-public class AMQ1936Test extends TestCase {
-
-   private final static Logger logger = Logger.getLogger(AMQ1936Test.class);
-   private final static String TEST_QUEUE_NAME = "dynamicQueues/duplicate.message.test.queue";
-   // //--
-   //
-   private final static long TEST_MESSAGE_COUNT = 6000; // The number of test messages to use
-   //
-   // //--
-   private final static int CONSUMER_COUNT = 2; // The number of message receiver instances
-   private final static boolean TRANSACTED_RECEIVE = true; // Flag used by receiver which indicates messages should be
-   // processed within a JMS transaction
-
-   private final ThreadPoolExecutor threadPool = new ThreadPoolExecutor(CONSUMER_COUNT, CONSUMER_COUNT, Long.MAX_VALUE, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
-   private final ThreadedMessageReceiver[] receivers = new ThreadedMessageReceiver[CONSUMER_COUNT];
-   private BrokerService broker = null;
-   static QueueConnectionFactory connectionFactory = null;
-
-   @Override
-   protected void setUp() throws Exception {
-      super.setUp();
-
-      broker = new BrokerService();
-      broker.getSystemUsage().getMemoryUsage().setLimit(5 * 1024 * 1024);
-      broker.setBrokerName("test");
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.start();
-      connectionFactory = new ActiveMQConnectionFactory("vm://test");
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      super.tearDown();
-
-      if (threadPool != null) {
-         // signal receivers to stop
-         for (ThreadedMessageReceiver receiver : receivers) {
-            receiver.setShouldStop(true);
-         }
-
-         logger.info("Waiting for receivers to shutdown..");
-         if (!threadPool.awaitTermination(10, TimeUnit.SECONDS)) {
-            logger.warn("Not all receivers completed shutdown.");
-         }
-         else {
-            logger.info("All receivers shutdown successfully..");
-         }
-      }
-
-      logger.debug("Stoping the broker.");
-
-      if (broker != null) {
-         broker.stop();
-      }
-   }
-
-   private void sendTextMessage(String queueName, int i) throws JMSException, NamingException {
-      QueueConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://test");
-      QueueConnection queueConnection = null;
-      QueueSession session = null;
-      QueueSender sender = null;
-      Queue queue = null;
-      TextMessage message = null;
-
-      try {
-
-         // Create the queue connection
-         queueConnection = connectionFactory.createQueueConnection();
-
-         session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
-         queue = session.createQueue(TEST_QUEUE_NAME);
-         sender = session.createSender(queue);
-         sender.setDeliveryMode(DeliveryMode.PERSISTENT);
-
-         message = session.createTextMessage(String.valueOf(i));
-
-         // send the message
-         sender.send(message);
-
-         if (session.getTransacted()) {
-            session.commit();
-         }
-         if (i % 1000 == 0) {
-            logger.info("Message successfully sent to : " + queue.getQueueName() + " messageid: " + message.getJMSMessageID() + " content:" + message.getText());
-         }
-      }
-      finally {
-         if (sender != null) {
-            sender.close();
-         }
-         if (session != null) {
-            session.close();
-         }
-         if (queueConnection != null) {
-            queueConnection.close();
-         }
-      }
-   }
-
-   public void testForDuplicateMessages() throws Exception {
-      final ConcurrentHashMap<String, String> messages = new ConcurrentHashMap<>();
-      final Object lock = new Object();
-      final CountDownLatch duplicateSignal = new CountDownLatch(1);
-      final AtomicInteger messageCount = new AtomicInteger(0);
-
-      // add 1/2 the number of our total messages
-      for (int i = 0; i < TEST_MESSAGE_COUNT / 2; i++) {
-         if (duplicateSignal.getCount() == 0) {
-            fail("Duplicate message id detected");
-         }
-         sendTextMessage(TEST_QUEUE_NAME, i);
-      }
-
-      // create a number of consumers to read of the messages and start them with a handler which simply stores the
-      // message ids
-      // in a Map and checks for a duplicate
-      for (int i = 0; i < CONSUMER_COUNT; i++) {
-         receivers[i] = new ThreadedMessageReceiver(TEST_QUEUE_NAME, new IMessageHandler() {
-
-            @Override
-            public void onMessage(Message message) throws Exception {
-               synchronized (lock) {
-                  int current = messageCount.incrementAndGet();
-                  if (current % 1000 == 0) {
-                     logger.info("Received message:" + message.getJMSMessageID() + " with content: " + ((TextMessage) message).getText());
-                  }
-                  if (messages.containsKey(message.getJMSMessageID())) {
-                     duplicateSignal.countDown();
-                     logger.fatal("duplicate message id detected:" + message.getJMSMessageID());
-                     fail("Duplicate message id detected:" + message.getJMSMessageID());
-                  }
-                  else {
-                     messages.put(message.getJMSMessageID(), message.getJMSMessageID());
-                  }
-               }
-            }
-         });
-         threadPool.submit(receivers[i]);
-      }
-
-      // starting adding the remaining messages
-      for (int i = 0; i < TEST_MESSAGE_COUNT / 2; i++) {
-         if (duplicateSignal.getCount() == 0) {
-            fail("Duplicate message id detected");
-         }
-         sendTextMessage(TEST_QUEUE_NAME, i);
-      }
-
-      logger.info("sent all " + TEST_MESSAGE_COUNT + " messages");
-
-      // allow some time for messages to be delivered to receivers.
-      boolean ok = Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return TEST_MESSAGE_COUNT == messages.size();
-         }
-      }, TimeUnit.MINUTES.toMillis(7));
-      if (!ok) {
-         AutoFailTestSupport.dumpAllThreads("--STUCK?--");
-      }
-      assertEquals("Number of messages received does not match the number sent", TEST_MESSAGE_COUNT, messages.size());
-      assertEquals(TEST_MESSAGE_COUNT, messageCount.get());
-   }
-
-   private final static class ThreadedMessageReceiver implements Runnable {
-
-      private IMessageHandler handler = null;
-      private final AtomicBoolean shouldStop = new AtomicBoolean(false);
-
-      public ThreadedMessageReceiver(String queueName, IMessageHandler handler) {
-         this.handler = handler;
-      }
-
-      @Override
-      public void run() {
-
-         QueueConnection queueConnection = null;
-         QueueSession session = null;
-         QueueReceiver receiver = null;
-         Queue queue = null;
-         Message message = null;
-         try {
-            try {
-
-               queueConnection = connectionFactory.createQueueConnection();
-               // create a transacted session
-               session = queueConnection.createQueueSession(TRANSACTED_RECEIVE, Session.AUTO_ACKNOWLEDGE);
-               queue = session.createQueue(TEST_QUEUE_NAME);
-               receiver = session.createReceiver(queue);
-
-               // start the connection
-               queueConnection.start();
-
-               logger.info("Receiver " + Thread.currentThread().getName() + " connected.");
-
-               // start receive loop
-               while (!(shouldStop.get() || Thread.currentThread().isInterrupted())) {
-                  try {
-                     message = receiver.receive(200);
-                  }
-                  catch (Exception e) {
-                     //
-                     // ignore interrupted exceptions
-                     //
-                     if (e instanceof InterruptedException || e.getCause() instanceof InterruptedException) {
-                                /* ignore */
-                     }
-                     else {
-                        throw e;
-                     }
-                  }
-
-                  if (message != null && this.handler != null) {
-                     this.handler.onMessage(message);
-                  }
-
-                  // commit session on successful handling of message
-                  if (session.getTransacted()) {
-                     session.commit();
-                  }
-               }
-
-               logger.info("Receiver " + Thread.currentThread().getName() + " shutting down.");
-
-            }
-            finally {
-               if (receiver != null) {
-                  try {
-                     receiver.close();
-                  }
-                  catch (JMSException e) {
-                     logger.warn(e);
-                  }
-               }
-               if (session != null) {
-                  try {
-                     session.close();
-                  }
-                  catch (JMSException e) {
-                     logger.warn(e);
-                  }
-               }
-               if (queueConnection != null) {
-                  queueConnection.close();
-               }
-            }
-         }
-         catch (JMSException e) {
-            logger.error(e);
-            e.printStackTrace();
-         }
-         catch (NamingException e) {
-            logger.error(e);
-         }
-         catch (Exception e) {
-            logger.error(e);
-            e.printStackTrace();
-         }
-      }
-
-      public void setShouldStop(Boolean shouldStop) {
-         this.shouldStop.set(shouldStop);
-      }
-   }
-
-   public interface IMessageHandler {
-
-      void onMessage(Message message) throws Exception;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2021Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2021Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2021Test.java
deleted file mode 100644
index 7236581..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2021Test.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.lang.Thread.UncaughtExceptionHandler;
-import java.util.ArrayList;
-import java.util.Vector;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This is a test case for the issue reported at: https://issues.apache.org/activemq/browse/AMQ-2021 Bug is modification
- * of inflight message properties so the failure can manifest itself in a bunch or ways, from message receipt with null
- * properties to marshall errors
- */
-public class AMQ2021Test implements ExceptionListener, UncaughtExceptionHandler {
-
-   private static final Logger log = LoggerFactory.getLogger(AMQ2021Test.class);
-   BrokerService brokerService;
-   ArrayList<Thread> threads = new ArrayList<>();
-   Vector<Throwable> exceptions;
-
-   @Rule
-   public TestName name = new TestName();
-
-   AMQ2021Test testCase;
-
-   private final String ACTIVEMQ_BROKER_BIND = "tcp://localhost:0";
-   private String CONSUMER_BROKER_URL = "?jms.redeliveryPolicy.maximumRedeliveries=1&jms.redeliveryPolicy.initialRedeliveryDelay=0";
-   private String PRODUCER_BROKER_URL;
-
-   private final int numMessages = 1000;
-   private final int numConsumers = 2;
-   private final int dlqMessages = numMessages / 2;
-
-   private CountDownLatch receivedLatch;
-   private ActiveMQTopic destination;
-   private CountDownLatch started;
-
-   @Before
-   public void setUp() throws Exception {
-      Thread.setDefaultUncaughtExceptionHandler(this);
-      testCase = this;
-
-      // Start an embedded broker up.
-      brokerService = new BrokerService();
-      brokerService.setDeleteAllMessagesOnStartup(true);
-      brokerService.addConnector(ACTIVEMQ_BROKER_BIND);
-      brokerService.start();
-      destination = new ActiveMQTopic(name.getMethodName());
-      exceptions = new Vector<>();
-
-      CONSUMER_BROKER_URL = brokerService.getTransportConnectors().get(0).getPublishableConnectString() + CONSUMER_BROKER_URL;
-      PRODUCER_BROKER_URL = brokerService.getTransportConnectors().get(0).getPublishableConnectString();
-
-      receivedLatch = new CountDownLatch(numConsumers * (numMessages + dlqMessages));
-      started = new CountDownLatch(1);
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      for (Thread t : threads) {
-         t.interrupt();
-         t.join();
-      }
-      brokerService.stop();
-   }
-
-   @Test(timeout = 240000)
-   public void testConcurrentTopicResendToDLQ() throws Exception {
-
-      for (int i = 0; i < numConsumers; i++) {
-         ConsumerThread c1 = new ConsumerThread("Consumer-" + i);
-         threads.add(c1);
-         c1.start();
-      }
-
-      assertTrue(started.await(10, TimeUnit.SECONDS));
-
-      Thread producer = new Thread() {
-         @Override
-         public void run() {
-            try {
-               produce(numMessages);
-            }
-            catch (Exception e) {
-            }
-         }
-      };
-      threads.add(producer);
-      producer.start();
-
-      boolean allGood = receivedLatch.await(90, TimeUnit.SECONDS);
-      for (Throwable t : exceptions) {
-         log.error("failing test with first exception", t);
-         fail("exception during test : " + t);
-      }
-      assertTrue("excepted messages received within time limit", allGood);
-
-      assertEquals(0, exceptions.size());
-
-      for (int i = 0; i < numConsumers; i++) {
-         // last recovery sends message to deq so is not received again
-         assertEquals(dlqMessages * 2, ((ConsumerThread) threads.get(i)).recoveries);
-         assertEquals(numMessages + dlqMessages, ((ConsumerThread) threads.get(i)).counter);
-      }
-
-      // half of the messages for each consumer should go to the dlq but duplicates will
-      // be suppressed
-      consumeFromDLQ(dlqMessages);
-
-   }
-
-   private void consumeFromDLQ(int messageCount) throws Exception {
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(CONSUMER_BROKER_URL);
-      Connection connection = connectionFactory.createConnection();
-      connection.start();
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer dlqConsumer = session.createConsumer(new ActiveMQQueue("ActiveMQ.DLQ"));
-      int count = 0;
-      for (int i = 0; i < messageCount; i++) {
-         if (dlqConsumer.receive(1000) == null) {
-            break;
-         }
-         count++;
-      }
-      assertEquals(messageCount, count);
-   }
-
-   public void produce(int count) throws Exception {
-      Connection connection = null;
-      try {
-         ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(PRODUCER_BROKER_URL);
-         connection = factory.createConnection();
-         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageProducer producer = session.createProducer(destination);
-         producer.setTimeToLive(0);
-         connection.start();
-
-         for (int i = 0; i < count; i++) {
-            int id = i + 1;
-            TextMessage message = session.createTextMessage(name.getMethodName() + " Message " + id);
-            message.setIntProperty("MsgNumber", id);
-            producer.send(message);
-
-            if (id % 500 == 0) {
-               log.info("sent " + id + ", ith " + message);
-            }
-         }
-      }
-      catch (JMSException e) {
-         log.error("unexpected ex on produce", e);
-         exceptions.add(e);
-      }
-      finally {
-         try {
-            if (connection != null) {
-               connection.close();
-            }
-         }
-         catch (Throwable e) {
-         }
-      }
-   }
-
-   public class ConsumerThread extends Thread implements MessageListener {
-
-      public long counter = 0;
-      public long recoveries = 0;
-      private Session session;
-
-      public ConsumerThread(String threadId) {
-         super(threadId);
-      }
-
-      @Override
-      public void run() {
-         try {
-            ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(CONSUMER_BROKER_URL);
-            Connection connection = connectionFactory.createConnection();
-            connection.setExceptionListener(testCase);
-            connection.setClientID(getName());
-            session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-            MessageConsumer consumer = session.createDurableSubscriber(destination, getName());
-            consumer.setMessageListener(this);
-            connection.start();
-
-            started.countDown();
-
-         }
-         catch (JMSException exception) {
-            log.error("unexpected ex in consumer run", exception);
-            exceptions.add(exception);
-         }
-      }
-
-      @Override
-      public void onMessage(Message message) {
-         try {
-            counter++;
-            int messageNumber = message.getIntProperty("MsgNumber");
-            if (messageNumber % 2 == 0) {
-               session.recover();
-               recoveries++;
-            }
-            else {
-               message.acknowledge();
-            }
-
-            if (counter % 200 == 0) {
-               log.info("recoveries:" + recoveries + ", Received " + counter + ", counter'th " + message);
-            }
-            receivedLatch.countDown();
-         }
-         catch (Exception e) {
-            log.error("unexpected ex on onMessage", e);
-            exceptions.add(e);
-         }
-      }
-
-   }
-
-   @Override
-   public void onException(JMSException exception) {
-      log.info("Unexpected JMSException", exception);
-      exceptions.add(exception);
-   }
-
-   @Override
-   public void uncaughtException(Thread thread, Throwable exception) {
-      log.info("Unexpected exception from thread " + thread + ", ex: " + exception);
-      exceptions.add(exception);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2084Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2084Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2084Test.java
deleted file mode 100644
index de9f2b5..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2084Test.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Properties;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.QueueReceiver;
-import javax.jms.QueueSession;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.jms.TopicConnection;
-import javax.jms.TopicConnectionFactory;
-import javax.jms.TopicPublisher;
-import javax.jms.TopicSession;
-import javax.jms.TopicSubscriber;
-import javax.naming.InitialContext;
-
-import org.apache.activemq.broker.BrokerService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ2084Test {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ2084Test.class);
-   BrokerService broker;
-   CountDownLatch qreceived;
-   String connectionUri;
-
-   @Before
-   public void startBroker() throws Exception {
-      broker = new BrokerService();
-      broker.setPersistent(false);
-      connectionUri = broker.addConnector("tcp://localhost:0").getPublishableConnectString();
-      broker.start();
-
-      qreceived = new CountDownLatch(1);
-   }
-
-   @After
-   public void stopBroker() throws Exception {
-      if (broker != null) {
-         broker.stop();
-      }
-   }
-
-   public void listenQueue(final String queueName, final String selectors) {
-      try {
-         Properties props = new Properties();
-         props.put("java.naming.factory.initial", "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
-         props.put("java.naming.provider.url", connectionUri);
-         props.put("queue.queueName", queueName);
-
-         javax.naming.Context ctx = new InitialContext(props);
-         QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
-         QueueConnection conn = factory.createQueueConnection();
-         final Queue queue = (Queue) ctx.lookup("queueName");
-         QueueSession session = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
-         QueueReceiver receiver = session.createReceiver(queue, selectors);
-         System.out.println("Message Selector: " + receiver.getMessageSelector());
-         receiver.setMessageListener(new MessageListener() {
-            @Override
-            public void onMessage(Message message) {
-               try {
-                  if (message instanceof TextMessage) {
-                     TextMessage txtMsg = (TextMessage) message;
-                     String msg = txtMsg.getText();
-                     LOG.info("Queue Message Received: " + queueName + " - " + msg);
-                     qreceived.countDown();
-
-                  }
-                  message.acknowledge();
-               }
-               catch (Throwable e) {
-                  e.printStackTrace();
-               }
-            }
-         });
-         conn.start();
-      }
-      catch (Exception e) {
-         e.printStackTrace();
-      }
-   }
-
-   public void listenTopic(final String topicName, final String selectors) {
-      try {
-         Properties props = new Properties();
-         props.put("java.naming.factory.initial", "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
-         props.put("java.naming.provider.url", connectionUri);
-         props.put("topic.topicName", topicName);
-
-         javax.naming.Context ctx = new InitialContext(props);
-         TopicConnectionFactory factory = (TopicConnectionFactory) ctx.lookup("ConnectionFactory");
-         TopicConnection conn = factory.createTopicConnection();
-         final Topic topic = (Topic) ctx.lookup("topicName");
-         TopicSession session = conn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
-         TopicSubscriber receiver = session.createSubscriber(topic, selectors, false);
-
-         receiver.setMessageListener(new MessageListener() {
-            @Override
-            public void onMessage(Message message) {
-               try {
-                  if (message instanceof TextMessage) {
-                     TextMessage txtMsg = (TextMessage) message;
-                     String msg = txtMsg.getText();
-                     LOG.info("Topic Message Received: " + topicName + " - " + msg);
-                  }
-                  message.acknowledge();
-               }
-               catch (Exception e) {
-                  e.printStackTrace();
-               }
-            }
-         });
-         conn.start();
-      }
-      catch (Exception e) {
-         e.printStackTrace();
-      }
-   }
-
-   public void publish(String topicName, String message) {
-      try {
-         Properties props = new Properties();
-         props.put("java.naming.factory.initial", "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
-         props.put("java.naming.provider.url", connectionUri);
-         props.put("topic.topicName", topicName);
-         javax.naming.Context ctx = new InitialContext(props);
-         TopicConnectionFactory factory = (TopicConnectionFactory) ctx.lookup("ConnectionFactory");
-         TopicConnection conn = factory.createTopicConnection();
-         Topic topic = (Topic) ctx.lookup("topicName");
-         TopicSession session = conn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
-         TopicPublisher publisher = session.createPublisher(topic);
-         if (message != null) {
-            Message msg = session.createTextMessage(message);
-            publisher.send(msg);
-         }
-      }
-      catch (Exception e) {
-         e.printStackTrace();
-      }
-   }
-
-   @Test
-   public void tryXpathSelectorMatch() throws Exception {
-      String xPath = "XPATH '//books//book[@lang=''en'']'";
-      listenQueue("Consumer.Sample.VirtualTopic.TestXpath", xPath);
-      publish("VirtualTopic.TestXpath", "<?xml version=\"1.0\" encoding=\"UTF-8\"?><books><book lang=\"en\">ABC</book></books>");
-      assertTrue("topic received: ", qreceived.await(20, TimeUnit.SECONDS));
-   }
-
-   @Test
-   public void tryXpathSelectorNoMatch() throws Exception {
-      String xPath = "XPATH '//books//book[@lang=''es'']'";
-      listenQueue("Consumer.Sample.VirtualTopic.TestXpath", xPath);
-      publish("VirtualTopic.TestXpath", "<?xml version=\"1.0\" encoding=\"UTF-8\"?><books><book lang=\"en\">ABC</book></books>");
-      assertFalse("topic did not receive unmatched", qreceived.await(5, TimeUnit.SECONDS));
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2103Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2103Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2103Test.java
deleted file mode 100644
index 8067305..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2103Test.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/**
- * 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;
-
-import javax.jms.Connection;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import junit.framework.Test;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerTestSupport;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQMapMessage;
-import org.apache.activemq.command.ActiveMQObjectMessage;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTextMessage;
-import org.apache.activemq.usecases.MyObject;
-
-public class AMQ2103Test extends BrokerTestSupport {
-
-   static PolicyEntry reduceMemoryFootprint = new PolicyEntry();
-
-   static {
-      reduceMemoryFootprint.setReduceMemoryFootprint(true);
-   }
-
-   public PolicyEntry defaultPolicy = reduceMemoryFootprint;
-
-   @Override
-   protected PolicyEntry getDefaultPolicy() {
-      return defaultPolicy;
-   }
-
-   public void initCombosForTestVerifyMarshalledStateIsCleared() throws Exception {
-      addCombinationValues("defaultPolicy", new Object[]{defaultPolicy, null});
-   }
-
-   public static Test suite() {
-      return suite(AMQ2103Test.class);
-   }
-
-   /**
-    * use mem persistence so no marshaling,
-    * reduceMemoryFootprint on/off that will reduce memory by whacking the marshaled state
-    * With vm transport and deferred serialisation and no persistence (mem persistence),
-    * we see the message as sent by the client so we can validate the contents against
-    * the policy
-    *
-    * @throws Exception
-    */
-   public void testVerifyMarshalledStateIsCleared() throws Exception {
-
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
-      factory.setOptimizedMessageDispatch(true);
-      factory.setObjectMessageSerializationDefered(true);
-      factory.setCopyMessageOnSend(false);
-
-      Connection connection = factory.createConnection();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      ActiveMQDestination destination = new ActiveMQQueue("testQ");
-      MessageConsumer consumer = session.createConsumer(destination);
-      connection.start();
-
-      MessageProducer producer = session.createProducer(destination);
-      final MyObject obj = new MyObject("A message");
-      ActiveMQObjectMessage m1 = (ActiveMQObjectMessage) session.createObjectMessage();
-      m1.setObject(obj);
-      producer.send(m1);
-
-      ActiveMQTextMessage m2 = new ActiveMQTextMessage();
-      m2.setText("Test Message Payload.");
-      producer.send(m2);
-
-      ActiveMQMapMessage m3 = new ActiveMQMapMessage();
-      m3.setString("text", "my message");
-      producer.send(m3);
-
-      Message m = consumer.receive(maxWait);
-      assertNotNull(m);
-      assertEquals(m1.getMessageId().toString(), m.getJMSMessageID());
-      assertTrue(m instanceof ActiveMQObjectMessage);
-
-      if (getDefaultPolicy() != null) {
-         assertNull("object data cleared by reduceMemoryFootprint (and never marshalled as using mem persistence)", ((ActiveMQObjectMessage) m).getObject());
-      }
-
-      // verify no serialisation via vm transport
-      assertEquals("writeObject called", 0, obj.getWriteObjectCalled());
-      assertEquals("readObject called", 0, obj.getReadObjectCalled());
-      assertEquals("readObjectNoData called", 0, obj.getReadObjectNoDataCalled());
-
-      m = consumer.receive(maxWait);
-      assertNotNull(m);
-      assertEquals(m2.getMessageId().toString(), m.getJMSMessageID());
-      assertTrue(m instanceof ActiveMQTextMessage);
-
-      if (getDefaultPolicy() != null) {
-         assertNull("text cleared by reduceMemoryFootprint (and never marshalled as using mem persistence)", ((ActiveMQTextMessage) m).getText());
-      }
-
-      m = consumer.receive(maxWait);
-      assertNotNull(m);
-      assertEquals(m3.getMessageId().toString(), m.getJMSMessageID());
-      assertTrue(m instanceof ActiveMQMapMessage);
-
-      if (getDefaultPolicy() != null) {
-         assertNull("text cleared by reduceMemoryFootprint (and never marshalled as using mem persistence)", ((ActiveMQMapMessage) m).getStringProperty("text"));
-      }
-
-      connection.close();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2149LevelDBTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2149LevelDBTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2149LevelDBTest.java
deleted file mode 100644
index 8cda3ef..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2149LevelDBTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * 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;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.leveldb.LevelDBStore;
-
-public class AMQ2149LevelDBTest extends AMQ2149Test {
-
-   @Override
-   protected void configurePersistenceAdapter(BrokerService brokerService) throws Exception {
-      LevelDBStore persistenceFactory = new LevelDBStore();
-      persistenceFactory.setDirectory(dataDirFile);
-      brokerService.setPersistenceAdapter(persistenceFactory);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2149Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2149Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2149Test.java
deleted file mode 100644
index 19dbf0e..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2149Test.java
+++ /dev/null
@@ -1,614 +0,0 @@
-/**
- * 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;
-
-import java.io.File;
-import java.lang.IllegalStateException;
-import java.util.HashSet;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.Vector;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicLong;
-
-import javax.jms.*;
-
-import org.apache.activemq.AutoFailTestSupport;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.Destination;
-import org.apache.activemq.broker.region.DestinationStatistics;
-import org.apache.activemq.broker.region.RegionBroker;
-import org.apache.activemq.broker.util.LoggingBrokerPlugin;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.junit.rules.TestName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.*;
-
-interface Configurer {
-
-   public void configure(BrokerService broker) throws Exception;
-}
-
-public class AMQ2149Test {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ2149Test.class);
-   @Rule
-   public TestName testName = new TestName();
-
-   private static final String BROKER_CONNECTOR = "tcp://localhost:61617";
-   private static final String DEFAULT_BROKER_URL = "failover:(" + BROKER_CONNECTOR + ")?maxReconnectDelay=1000&useExponentialBackOff=false";
-
-   private final String SEQ_NUM_PROPERTY = "seqNum";
-
-   final int MESSAGE_LENGTH_BYTES = 75 * 1024;
-   final long SLEEP_BETWEEN_SEND_MS = 25;
-   final int NUM_SENDERS_AND_RECEIVERS = 10;
-   final Object brokerLock = new Object();
-
-   private static final long DEFAULT_BROKER_STOP_PERIOD = 10 * 1000;
-   private static final long DEFAULT_NUM_TO_SEND = 1400;
-
-   long brokerStopPeriod = DEFAULT_BROKER_STOP_PERIOD;
-   long numtoSend = DEFAULT_NUM_TO_SEND;
-   long sleepBetweenSend = SLEEP_BETWEEN_SEND_MS;
-   String brokerURL = DEFAULT_BROKER_URL;
-
-   int numBrokerRestarts = 0;
-   final static int MAX_BROKER_RESTARTS = 4;
-   BrokerService broker;
-   Vector<Throwable> exceptions = new Vector<>();
-
-   protected File dataDirFile;
-   final LoggingBrokerPlugin[] plugins = new LoggingBrokerPlugin[]{new LoggingBrokerPlugin()};
-
-   public void createBroker(Configurer configurer) throws Exception {
-      broker = new BrokerService();
-      configurePersistenceAdapter(broker);
-
-      broker.getSystemUsage().getMemoryUsage().setLimit(MESSAGE_LENGTH_BYTES * 200 * NUM_SENDERS_AND_RECEIVERS);
-
-      broker.addConnector(BROKER_CONNECTOR);
-      broker.setBrokerName(testName.getMethodName());
-      broker.setDataDirectoryFile(dataDirFile);
-      if (configurer != null) {
-         configurer.configure(broker);
-      }
-      broker.start();
-   }
-
-   protected void configurePersistenceAdapter(BrokerService brokerService) throws Exception {
-   }
-
-   @Before
-   public void setUp() throws Exception {
-      LOG.debug("Starting test {}", testName.getMethodName());
-      dataDirFile = new File("target/" + testName.getMethodName());
-      numtoSend = DEFAULT_NUM_TO_SEND;
-      brokerStopPeriod = DEFAULT_BROKER_STOP_PERIOD;
-      sleepBetweenSend = SLEEP_BETWEEN_SEND_MS;
-      brokerURL = DEFAULT_BROKER_URL;
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      ExecutorService executor = Executors.newSingleThreadExecutor();
-      Future<Boolean> future = executor.submit(new TeardownTask(brokerLock, broker));
-      try {
-         LOG.debug("Teardown started.");
-         long start = System.currentTimeMillis();
-         Boolean result = future.get(30, TimeUnit.SECONDS);
-         long finish = System.currentTimeMillis();
-         LOG.debug("Result of teardown: {} after {} ms ", result, (finish - start));
-      }
-      catch (TimeoutException e) {
-         fail("Teardown timed out");
-         AutoFailTestSupport.dumpAllThreads(testName.getMethodName());
-      }
-      executor.shutdownNow();
-      exceptions.clear();
-   }
-
-   private String buildLongString() {
-      final StringBuilder stringBuilder = new StringBuilder(MESSAGE_LENGTH_BYTES);
-      for (int i = 0; i < MESSAGE_LENGTH_BYTES; ++i) {
-         stringBuilder.append((int) (Math.random() * 10));
-      }
-      return stringBuilder.toString();
-   }
-
-   HashSet<Connection> connections = new HashSet<>();
-
-   private class Receiver implements MessageListener {
-
-      private final javax.jms.Destination dest;
-
-      private final Connection connection;
-
-      private final Session session;
-
-      private final MessageConsumer messageConsumer;
-
-      private AtomicLong nextExpectedSeqNum = new AtomicLong();
-
-      private final boolean transactional;
-
-      private String lastId = null;
-
-      public Receiver(javax.jms.Destination dest, boolean transactional) throws JMSException {
-         this.dest = dest;
-         this.transactional = transactional;
-         connection = new ActiveMQConnectionFactory(brokerURL).createConnection();
-         connection.setClientID(dest.toString());
-         session = connection.createSession(transactional, transactional ? Session.SESSION_TRANSACTED : Session.AUTO_ACKNOWLEDGE);
-         if (ActiveMQDestination.transform(dest).isTopic()) {
-            messageConsumer = session.createDurableSubscriber((Topic) dest, dest.toString());
-         }
-         else {
-            messageConsumer = session.createConsumer(dest);
-         }
-         messageConsumer.setMessageListener(this);
-         connection.start();
-         connections.add(connection);
-      }
-
-      public void close() throws JMSException {
-         connection.close();
-      }
-
-      public long getNextExpectedSeqNo() {
-         return nextExpectedSeqNum.get();
-      }
-
-      final int TRANSACITON_BATCH = 500;
-      boolean resumeOnNextOrPreviousIsOk = false;
-
-      @Override
-      public void onMessage(Message message) {
-         try {
-            final long seqNum = message.getLongProperty(SEQ_NUM_PROPERTY);
-            if ((seqNum % TRANSACITON_BATCH) == 0) {
-               LOG.info(dest + " received " + seqNum);
-
-               if (transactional) {
-                  LOG.info("committing..");
-                  session.commit();
-               }
-            }
-            if (resumeOnNextOrPreviousIsOk) {
-               // after an indoubt commit we need to accept what we get (within reason)
-               if (seqNum != nextExpectedSeqNum.get()) {
-                  final long l = nextExpectedSeqNum.get();
-                  if (seqNum == l - (TRANSACITON_BATCH - 1)) {
-                     nextExpectedSeqNum.compareAndSet(l, l - (TRANSACITON_BATCH - 1));
-                     LOG.info("In doubt commit failed, getting replay at:" + nextExpectedSeqNum);
-                  }
-               }
-               resumeOnNextOrPreviousIsOk = false;
-            }
-            if (seqNum != nextExpectedSeqNum.get()) {
-               LOG.warn(dest + " received " + seqNum + " in msg: " + message.getJMSMessageID() + " expected " + nextExpectedSeqNum + ", lastId: " + lastId + ", message:" + message);
-               fail(dest + " received " + seqNum + " expected " + nextExpectedSeqNum);
-            }
-            nextExpectedSeqNum.incrementAndGet();
-            lastId = message.getJMSMessageID();
-         }
-         catch (TransactionRolledBackException expectedSometimesOnFailoverRecovery) {
-            LOG.info("got rollback: " + expectedSometimesOnFailoverRecovery);
-            if (expectedSometimesOnFailoverRecovery.getMessage().contains("completion in doubt")) {
-               // in doubt - either commit command or reply missing
-               // don't know if we will get a replay
-               resumeOnNextOrPreviousIsOk = true;
-               nextExpectedSeqNum.incrementAndGet();
-               LOG.info("in doubt transaction completion: ok to get next or previous batch. next:" + nextExpectedSeqNum);
-            }
-            else {
-               resumeOnNextOrPreviousIsOk = false;
-               // batch will be replayed
-               nextExpectedSeqNum.addAndGet(-(TRANSACITON_BATCH - 1));
-            }
-
-         }
-         catch (Throwable e) {
-            LOG.error(dest + " onMessage error", e);
-            exceptions.add(e);
-         }
-      }
-
-   }
-
-   private class Sender implements Runnable {
-
-      private final javax.jms.Destination dest;
-
-      private final Connection connection;
-
-      private final Session session;
-
-      private final MessageProducer messageProducer;
-
-      private volatile long nextSequenceNumber = 0;
-      private final Object guard = new Object();
-
-      public Sender(javax.jms.Destination dest) throws JMSException {
-         this.dest = dest;
-         connection = new ActiveMQConnectionFactory(brokerURL).createConnection();
-         session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         messageProducer = session.createProducer(dest);
-         messageProducer.setDeliveryMode(DeliveryMode.PERSISTENT);
-         connection.start();
-         connections.add(connection);
-      }
-
-      @Override
-      public void run() {
-         final String longString = buildLongString();
-         long nextSequenceNumber = this.nextSequenceNumber;
-         while (nextSequenceNumber < numtoSend) {
-            try {
-               final Message message = session.createTextMessage(longString);
-               message.setLongProperty(SEQ_NUM_PROPERTY, nextSequenceNumber);
-               synchronized (guard) {
-                  if (nextSequenceNumber == this.nextSequenceNumber) {
-                     this.nextSequenceNumber = nextSequenceNumber + 1;
-                     messageProducer.send(message);
-                  }
-                  else {
-                     continue;
-                  }
-               }
-
-               if ((nextSequenceNumber % 500) == 0) {
-                  LOG.info(dest + " sent " + nextSequenceNumber);
-               }
-
-            }
-            catch (javax.jms.IllegalStateException e) {
-               LOG.error(dest + " bailing on send error", e);
-               exceptions.add(e);
-               break;
-            }
-            catch (Exception e) {
-               LOG.error(dest + " send error", e);
-               exceptions.add(e);
-            }
-            if (sleepBetweenSend > 0) {
-               try {
-                  Thread.sleep(sleepBetweenSend);
-               }
-               catch (InterruptedException e) {
-                  LOG.warn(dest + " sleep interrupted", e);
-               }
-            }
-         }
-         try {
-            connection.close();
-         }
-         catch (JMSException ignored) {
-         }
-      }
-   }
-
-   // attempt to simply replicate leveldb failure. no joy yet
-   public void x_testRestartReReceive() throws Exception {
-      createBroker(new Configurer() {
-         @Override
-         public void configure(BrokerService broker) throws Exception {
-            broker.deleteAllMessages();
-         }
-      });
-
-      final javax.jms.Destination destination = ActiveMQDestination.createDestination("test.dest.X", ActiveMQDestination.QUEUE_TYPE);
-      Thread thread = new Thread(new Sender(destination));
-      thread.start();
-      thread.join();
-
-      Connection connection = new ActiveMQConnectionFactory(brokerURL).createConnection();
-      connection.setClientID(destination.toString());
-      Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-      MessageConsumer messageConsumer = session.createConsumer(destination);
-      connection.start();
-
-      int batch = 200;
-      long expectedSeq;
-
-      final TimerTask restartTask = scheduleRestartTask(null, new Configurer() {
-         @Override
-         public void configure(BrokerService broker) throws Exception {
-         }
-      });
-
-      expectedSeq = 0;
-      for (int s = 0; s < 4; s++) {
-         for (int i = 0; i < batch; i++) {
-            Message message = messageConsumer.receive(20000);
-            assertNotNull("s:" + s + ", i:" + i, message);
-            final long seqNum = message.getLongProperty(SEQ_NUM_PROPERTY);
-            assertEquals("expected order s:" + s, expectedSeq++, seqNum);
-
-            if (i > 0 && i % 600 == 0) {
-               LOG.info("Commit on %5");
-               //    session.commit();
-            }
-         }
-         restartTask.run();
-      }
-
-   }
-
-   // no need to run this unless there are some issues with the others
-   public void vanilaVerify_testOrder() throws Exception {
-
-      createBroker(new Configurer() {
-         @Override
-         public void configure(BrokerService broker) throws Exception {
-            broker.deleteAllMessages();
-         }
-      });
-
-      verifyOrderedMessageReceipt();
-      verifyStats(false);
-   }
-
-   @Test(timeout = 5 * 60 * 1000)
-   public void testOrderWithRestart() throws Exception {
-      createBroker(new Configurer() {
-         @Override
-         public void configure(BrokerService broker) throws Exception {
-            broker.deleteAllMessages();
-         }
-      });
-
-      final Timer timer = new Timer();
-      scheduleRestartTask(timer, new Configurer() {
-         @Override
-         public void configure(BrokerService broker) throws Exception {
-         }
-      });
-
-      try {
-         verifyOrderedMessageReceipt();
-      }
-      finally {
-         timer.cancel();
-      }
-
-      verifyStats(true);
-   }
-
-   @Test(timeout = 5 * 60 * 1000)
-   public void testTopicOrderWithRestart() throws Exception {
-      createBroker(new Configurer() {
-         @Override
-         public void configure(BrokerService broker) throws Exception {
-            broker.deleteAllMessages();
-         }
-      });
-
-      final Timer timer = new Timer();
-      scheduleRestartTask(timer, null);
-
-      try {
-         verifyOrderedMessageReceipt(ActiveMQDestination.TOPIC_TYPE);
-      }
-      finally {
-         timer.cancel();
-      }
-
-      verifyStats(true);
-   }
-
-   @Test(timeout = 5 * 60 * 1000)
-   public void testQueueTransactionalOrderWithRestart() throws Exception {
-      doTestTransactionalOrderWithRestart(ActiveMQDestination.QUEUE_TYPE);
-   }
-
-   @Test(timeout = 5 * 60 * 1000)
-   public void testTopicTransactionalOrderWithRestart() throws Exception {
-      doTestTransactionalOrderWithRestart(ActiveMQDestination.TOPIC_TYPE);
-   }
-
-   public void doTestTransactionalOrderWithRestart(byte destinationType) throws Exception {
-      numtoSend = 10000;
-      sleepBetweenSend = 3;
-      brokerStopPeriod = 10 * 1000;
-
-      createBroker(new Configurer() {
-         @Override
-         public void configure(BrokerService broker) throws Exception {
-            broker.deleteAllMessages();
-         }
-      });
-
-      final Timer timer = new Timer();
-      scheduleRestartTask(timer, null);
-
-      try {
-         verifyOrderedMessageReceipt(destinationType, 1, true);
-      }
-      finally {
-         timer.cancel();
-      }
-
-      verifyStats(true);
-   }
-
-   private void verifyStats(boolean brokerRestarts) throws Exception {
-      RegionBroker regionBroker = (RegionBroker) broker.getRegionBroker();
-
-      for (Destination dest : regionBroker.getQueueRegion().getDestinationMap().values()) {
-         DestinationStatistics stats = dest.getDestinationStatistics();
-         if (brokerRestarts) {
-            // all bets are off w.r.t stats as there may be duplicate sends and duplicate
-            // dispatches, all of which will be suppressed - either by the reference store
-            // not allowing duplicate references or consumers acking duplicates
-            LOG.info("with restart: not asserting qneue/dequeue stat match for: " + dest.getName() + " " + stats.getEnqueues().getCount() + " <= " + stats.getDequeues().getCount());
-         }
-         else {
-            assertEquals("qneue/dequeue match for: " + dest.getName(), stats.getEnqueues().getCount(), stats.getDequeues().getCount());
-         }
-      }
-   }
-
-   private TimerTask scheduleRestartTask(final Timer timer, final Configurer configurer) {
-      class RestartTask extends TimerTask {
-
-         @Override
-         public void run() {
-            synchronized (brokerLock) {
-               LOG.info("stopping broker..");
-               try {
-                  broker.stop();
-                  broker.waitUntilStopped();
-               }
-               catch (Exception e) {
-                  LOG.error("ex on broker stop", e);
-                  exceptions.add(e);
-               }
-               LOG.info("restarting broker");
-               try {
-                  createBroker(configurer);
-                  broker.waitUntilStarted();
-               }
-               catch (Exception e) {
-                  LOG.error("ex on broker restart", e);
-                  exceptions.add(e);
-               }
-            }
-            if (++numBrokerRestarts < MAX_BROKER_RESTARTS && timer != null) {
-               // do it again
-               try {
-                  timer.schedule(new RestartTask(), brokerStopPeriod);
-               }
-               catch (IllegalStateException ignore_alreadyCancelled) {
-               }
-            }
-            else {
-               LOG.info("no longer stopping broker on reaching Max restarts: " + MAX_BROKER_RESTARTS);
-            }
-         }
-      }
-      RestartTask task = new RestartTask();
-      if (timer != null) {
-         timer.schedule(task, brokerStopPeriod);
-      }
-      return task;
-   }
-
-   private void verifyOrderedMessageReceipt(byte destinationType) throws Exception {
-      verifyOrderedMessageReceipt(destinationType, NUM_SENDERS_AND_RECEIVERS, false);
-   }
-
-   private void verifyOrderedMessageReceipt() throws Exception {
-      verifyOrderedMessageReceipt(ActiveMQDestination.QUEUE_TYPE, NUM_SENDERS_AND_RECEIVERS, false);
-   }
-
-   private void verifyOrderedMessageReceipt(byte destinationType,
-                                            int concurrentPairs,
-                                            boolean transactional) throws Exception {
-
-      Vector<Thread> threads = new Vector<>();
-      Vector<Receiver> receivers = new Vector<>();
-
-      for (int i = 0; i < concurrentPairs; ++i) {
-         final javax.jms.Destination destination = ActiveMQDestination.createDestination("test.dest." + i, destinationType);
-         receivers.add(new Receiver(destination, transactional));
-         Thread thread = new Thread(new Sender(destination));
-         thread.start();
-         threads.add(thread);
-      }
-
-      final long expiry = System.currentTimeMillis() + 1000 * 60 * 4;
-      while (!threads.isEmpty() && exceptions.isEmpty() && System.currentTimeMillis() < expiry) {
-         Thread sendThread = threads.firstElement();
-         sendThread.join(1000 * 30);
-         if (!sendThread.isAlive()) {
-            threads.remove(sendThread);
-         }
-         else {
-            AutoFailTestSupport.dumpAllThreads("Send blocked");
-         }
-      }
-      LOG.info("senders done..." + threads);
-
-      while (!receivers.isEmpty() && System.currentTimeMillis() < expiry) {
-         Receiver receiver = receivers.firstElement();
-         if (receiver.getNextExpectedSeqNo() >= numtoSend || !exceptions.isEmpty()) {
-            receiver.close();
-            receivers.remove(receiver);
-         }
-      }
-
-      for (Connection connection : connections) {
-         try {
-            connection.close();
-         }
-         catch (Exception ignored) {
-         }
-      }
-      connections.clear();
-
-      assertTrue("No timeout waiting for senders/receivers to complete", System.currentTimeMillis() < expiry);
-      if (!exceptions.isEmpty()) {
-         exceptions.get(0).printStackTrace();
-      }
-
-      LOG.info("Dangling threads: " + threads);
-      for (Thread dangling : threads) {
-         dangling.interrupt();
-         dangling.join(10 * 1000);
-      }
-
-      assertTrue("No exceptions", exceptions.isEmpty());
-   }
-
-}
-
-class TeardownTask implements Callable<Boolean> {
-
-   private final Object brokerLock;
-   private BrokerService broker;
-
-   public TeardownTask(Object brokerLock, BrokerService broker) {
-      this.brokerLock = brokerLock;
-      this.broker = broker;
-   }
-
-   @Override
-   public Boolean call() throws Exception {
-      synchronized (brokerLock) {
-         if (broker != null) {
-            broker.stop();
-            broker.waitUntilStopped();
-         }
-      }
-      return Boolean.TRUE;
-   }
-}


[09/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/MessagePriorityTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/MessagePriorityTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/MessagePriorityTest.java
deleted file mode 100644
index a70ef67..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/MessagePriorityTest.java
+++ /dev/null
@@ -1,584 +0,0 @@
-/**
- * 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.store;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.jms.TopicSubscriber;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQPrefetchPolicy;
-import org.apache.activemq.CombinationTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.broker.region.policy.SharedDeadLetterStrategy;
-import org.apache.activemq.broker.region.policy.StorePendingDurableSubscriberMessageStoragePolicy;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.util.Wait;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-abstract public class MessagePriorityTest extends CombinationTestSupport {
-
-   private static final Logger LOG = LoggerFactory.getLogger(MessagePriorityTest.class);
-
-   BrokerService broker;
-   PersistenceAdapter adapter;
-
-   protected ActiveMQConnectionFactory factory;
-   protected Connection conn;
-   protected Session sess;
-
-   public boolean useCache = true;
-   public int deliveryMode = Message.DEFAULT_DELIVERY_MODE;
-   public boolean dispatchAsync = true;
-   public boolean prioritizeMessages = true;
-   public boolean immediatePriorityDispatch = true;
-   public int prefetchVal = 500;
-   public int expireMessagePeriod = 30000;
-
-   public int MSG_NUM = 600;
-   public int HIGH_PRI = 7;
-   public int LOW_PRI = 3;
-
-   abstract protected PersistenceAdapter createPersistenceAdapter(boolean delete) throws Exception;
-
-   @Override
-   protected void setUp() throws Exception {
-      broker = new BrokerService();
-      broker.setBrokerName("priorityTest");
-      broker.setAdvisorySupport(false);
-      adapter = createPersistenceAdapter(true);
-      broker.setPersistenceAdapter(adapter);
-      PolicyEntry policy = new PolicyEntry();
-      policy.setPrioritizedMessages(prioritizeMessages);
-      policy.setUseCache(useCache);
-      policy.setExpireMessagesPeriod(expireMessagePeriod);
-      StorePendingDurableSubscriberMessageStoragePolicy durableSubPending = new StorePendingDurableSubscriberMessageStoragePolicy();
-      durableSubPending.setImmediatePriorityDispatch(immediatePriorityDispatch);
-      durableSubPending.setUseCache(useCache);
-      policy.setPendingDurableSubscriberPolicy(durableSubPending);
-      PolicyMap policyMap = new PolicyMap();
-      policyMap.put(new ActiveMQQueue("TEST"), policy);
-      policyMap.put(new ActiveMQTopic("TEST"), policy);
-
-      // do not process expired for one test
-      PolicyEntry ignoreExpired = new PolicyEntry();
-      SharedDeadLetterStrategy ignoreExpiredStrategy = new SharedDeadLetterStrategy();
-      ignoreExpiredStrategy.setProcessExpired(false);
-      ignoreExpired.setDeadLetterStrategy(ignoreExpiredStrategy);
-      policyMap.put(new ActiveMQTopic("TEST_CLEANUP_NO_PRIORITY"), ignoreExpired);
-
-      broker.setDestinationPolicy(policyMap);
-      broker.start();
-      broker.waitUntilStarted();
-
-      factory = new ActiveMQConnectionFactory("vm://priorityTest");
-      ActiveMQPrefetchPolicy prefetch = new ActiveMQPrefetchPolicy();
-      prefetch.setAll(prefetchVal);
-      factory.setPrefetchPolicy(prefetch);
-      factory.setWatchTopicAdvisories(false);
-      factory.setDispatchAsync(dispatchAsync);
-      conn = factory.createConnection();
-      conn.setClientID("priority");
-      conn.start();
-      sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      try {
-         sess.close();
-         conn.close();
-      }
-      catch (Exception ignored) {
-      }
-      finally {
-         broker.stop();
-         broker.waitUntilStopped();
-      }
-   }
-
-   public void testStoreConfigured() throws Exception {
-      final Queue queue = sess.createQueue("TEST");
-      final Topic topic = sess.createTopic("TEST");
-
-      MessageProducer queueProducer = sess.createProducer(queue);
-      MessageProducer topicProducer = sess.createProducer(topic);
-
-      Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return broker.getRegionBroker().getDestinationMap().get(queue) != null;
-         }
-      });
-      assertTrue(broker.getRegionBroker().getDestinationMap().get(queue).getMessageStore().isPrioritizedMessages());
-
-      Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return broker.getRegionBroker().getDestinationMap().get(topic) != null;
-         }
-      });
-      assertTrue(broker.getRegionBroker().getDestinationMap().get(topic).getMessageStore().isPrioritizedMessages());
-
-      queueProducer.close();
-      topicProducer.close();
-
-   }
-
-   protected class ProducerThread extends Thread {
-
-      int priority;
-      int messageCount;
-      ActiveMQDestination dest;
-
-      public ProducerThread(ActiveMQDestination dest, int messageCount, int priority) {
-         this.messageCount = messageCount;
-         this.priority = priority;
-         this.dest = dest;
-      }
-
-      @Override
-      public void run() {
-         try {
-            MessageProducer producer = sess.createProducer(dest);
-            producer.setPriority(priority);
-            producer.setDeliveryMode(deliveryMode);
-            for (int i = 0; i < messageCount; i++) {
-               producer.send(sess.createTextMessage("message priority: " + priority));
-            }
-         }
-         catch (Exception e) {
-            e.printStackTrace();
-         }
-      }
-
-      public void setMessagePriority(int priority) {
-         this.priority = priority;
-      }
-
-      public void setMessageCount(int messageCount) {
-         this.messageCount = messageCount;
-      }
-
-   }
-
-   public void initCombosForTestQueues() {
-      addCombinationValues("useCache", new Object[]{new Boolean(true), new Boolean(false)});
-      addCombinationValues("deliveryMode", new Object[]{new Integer(DeliveryMode.NON_PERSISTENT), new Integer(DeliveryMode.PERSISTENT)});
-   }
-
-   public void testQueues() throws Exception {
-      ActiveMQQueue queue = (ActiveMQQueue) sess.createQueue("TEST");
-
-      ProducerThread lowPri = new ProducerThread(queue, MSG_NUM, LOW_PRI);
-      ProducerThread highPri = new ProducerThread(queue, MSG_NUM, HIGH_PRI);
-
-      lowPri.start();
-      highPri.start();
-
-      lowPri.join();
-      highPri.join();
-
-      MessageConsumer queueConsumer = sess.createConsumer(queue);
-      for (int i = 0; i < MSG_NUM * 2; i++) {
-         Message msg = queueConsumer.receive(5000);
-         LOG.debug("received i=" + i + ", " + (msg != null ? msg.getJMSMessageID() : null));
-         assertNotNull("Message " + i + " was null", msg);
-         assertEquals("Message " + i + " has wrong priority", i < MSG_NUM ? HIGH_PRI : LOW_PRI, msg.getJMSPriority());
-      }
-   }
-
-   protected Message createMessage(int priority) throws Exception {
-      final String text = "priority " + priority;
-      Message msg = sess.createTextMessage(text);
-      LOG.info("Sending  " + text);
-      return msg;
-   }
-
-   public void initCombosForTestDurableSubs() {
-      addCombinationValues("prefetchVal", new Object[]{new Integer(1000), new Integer(MSG_NUM / 4)});
-   }
-
-   public void testDurableSubs() throws Exception {
-      ActiveMQTopic topic = (ActiveMQTopic) sess.createTopic("TEST");
-      TopicSubscriber sub = sess.createDurableSubscriber(topic, "priority");
-      sub.close();
-
-      ProducerThread lowPri = new ProducerThread(topic, MSG_NUM, LOW_PRI);
-      ProducerThread highPri = new ProducerThread(topic, MSG_NUM, HIGH_PRI);
-
-      lowPri.start();
-      highPri.start();
-
-      lowPri.join();
-      highPri.join();
-
-      sub = sess.createDurableSubscriber(topic, "priority");
-      for (int i = 0; i < MSG_NUM * 2; i++) {
-         Message msg = sub.receive(5000);
-         assertNotNull("Message " + i + " was null", msg);
-         assertEquals("Message " + i + " has wrong priority", i < MSG_NUM ? HIGH_PRI : LOW_PRI, msg.getJMSPriority());
-      }
-
-      // verify that same broker/store can deal with non priority dest also
-      topic = (ActiveMQTopic) sess.createTopic("HAS_NO_PRIORITY");
-      sub = sess.createDurableSubscriber(topic, "no_priority");
-      sub.close();
-
-      lowPri = new ProducerThread(topic, MSG_NUM, LOW_PRI);
-      highPri = new ProducerThread(topic, MSG_NUM, HIGH_PRI);
-
-      lowPri.start();
-      highPri.start();
-
-      lowPri.join();
-      highPri.join();
-
-      sub = sess.createDurableSubscriber(topic, "no_priority");
-      // verify we got them all
-      for (int i = 0; i < MSG_NUM * 2; i++) {
-         Message msg = sub.receive(5000);
-         assertNotNull("Message " + i + " was null", msg);
-      }
-
-   }
-
-   public void initCombosForTestDurableSubsReconnect() {
-      addCombinationValues("prefetchVal", new Object[]{new Integer(1000), new Integer(MSG_NUM / 2)});
-      // REVISIT = is dispatchAsync = true a problem or is it just the test?
-      addCombinationValues("dispatchAsync", new Object[]{Boolean.FALSE});
-      addCombinationValues("useCache", new Object[]{Boolean.TRUE, Boolean.FALSE});
-   }
-
-   public void testDurableSubsReconnect() throws Exception {
-      ActiveMQTopic topic = (ActiveMQTopic) sess.createTopic("TEST");
-      final String subName = "priorityDisconnect";
-      TopicSubscriber sub = sess.createDurableSubscriber(topic, subName);
-      sub.close();
-
-      ProducerThread lowPri = new ProducerThread(topic, MSG_NUM, LOW_PRI);
-      ProducerThread highPri = new ProducerThread(topic, MSG_NUM, HIGH_PRI);
-
-      lowPri.start();
-      highPri.start();
-
-      lowPri.join();
-      highPri.join();
-
-      final int closeFrequency = MSG_NUM / 4;
-      sub = sess.createDurableSubscriber(topic, subName);
-      for (int i = 0; i < MSG_NUM * 2; i++) {
-         Message msg = sub.receive(15000);
-         LOG.debug("received i=" + i + ", " + (msg != null ? msg.getJMSMessageID() : null));
-         assertNotNull("Message " + i + " was null", msg);
-         assertEquals("Message " + i + " has wrong priority", i < MSG_NUM ? HIGH_PRI : LOW_PRI, msg.getJMSPriority());
-         if (i > 0 && i % closeFrequency == 0) {
-            LOG.info("Closing durable sub.. on: " + i);
-            sub.close();
-            sub = sess.createDurableSubscriber(topic, subName);
-         }
-      }
-   }
-
-   public void testHighPriorityDelivery() throws Exception {
-
-      // get zero prefetch
-      ActiveMQPrefetchPolicy prefetch = new ActiveMQPrefetchPolicy();
-      prefetch.setAll(0);
-      factory.setPrefetchPolicy(prefetch);
-      conn.close();
-      conn = factory.createConnection();
-      conn.setClientID("priority");
-      conn.start();
-      sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      ActiveMQTopic topic = (ActiveMQTopic) sess.createTopic("TEST");
-      final String subName = "priorityDisconnect";
-      TopicSubscriber sub = sess.createDurableSubscriber(topic, subName);
-      sub.close();
-
-      final int numToProduce = 2000;
-      final int[] dups = new int[numToProduce * 2];
-      ProducerThread producerThread = new ProducerThread(topic, numToProduce, LOW_PRI + 1);
-      producerThread.run();
-      LOG.info("Low priority messages sent");
-
-      sub = sess.createDurableSubscriber(topic, subName);
-      final int batchSize = 250;
-      int lowLowCount = 0;
-      for (int i = 0; i < numToProduce; i++) {
-         Message msg = sub.receive(15000);
-         LOG.info("received i=" + i + ", " + (msg != null ? msg.getJMSMessageID() + ", priority:" + msg.getJMSPriority() : null));
-         assertNotNull("Message " + i + " was null", msg);
-         assertEquals("Message " + i + " has wrong priority", LOW_PRI + 1, msg.getJMSPriority());
-         assertTrue("not duplicate ", dups[i] == 0);
-         dups[i] = 1;
-
-         if (i % batchSize == 0) {
-            producerThread.setMessagePriority(HIGH_PRI);
-            producerThread.setMessageCount(1);
-            producerThread.run();
-            LOG.info("High priority message sent, should be able to receive immediately");
-
-            if (i % batchSize * 2 == 0) {
-               producerThread.setMessagePriority(HIGH_PRI - 1);
-               producerThread.setMessageCount(1);
-               producerThread.run();
-               LOG.info("High -1 priority message sent, should be able to receive immediately");
-            }
-
-            if (i % batchSize * 4 == 0) {
-               producerThread.setMessagePriority(LOW_PRI);
-               producerThread.setMessageCount(1);
-               producerThread.run();
-               lowLowCount++;
-               LOG.info("Low low priority message sent, should not be able to receive immediately");
-            }
-
-            msg = sub.receive(15000);
-            assertNotNull("Message was null", msg);
-            LOG.info("received hi? : " + msg);
-            assertEquals("high priority", HIGH_PRI, msg.getJMSPriority());
-
-            if (i % batchSize * 2 == 0) {
-               msg = sub.receive(15000);
-               assertNotNull("Message was null", msg);
-               LOG.info("received hi -1 ? i=" + i + ", " + msg);
-               assertEquals("high priority", HIGH_PRI - 1, msg.getJMSPriority());
-            }
-         }
-      }
-      for (int i = 0; i < lowLowCount; i++) {
-         Message msg = sub.receive(15000);
-         LOG.debug("received i=" + i + ", " + (msg != null ? msg.getJMSMessageID() : null));
-         assertNotNull("Message " + i + " was null", msg);
-         assertEquals("Message " + i + " has wrong priority", LOW_PRI, msg.getJMSPriority());
-      }
-   }
-
-   public void initCombosForTestHighPriorityDeliveryInterleaved() {
-      addCombinationValues("useCache", new Object[]{Boolean.TRUE, Boolean.FALSE});
-   }
-
-   public void testHighPriorityDeliveryInterleaved() throws Exception {
-
-      // get zero prefetch
-      ActiveMQPrefetchPolicy prefetch = new ActiveMQPrefetchPolicy();
-      prefetch.setAll(0);
-      factory.setPrefetchPolicy(prefetch);
-      conn.close();
-      conn = factory.createConnection();
-      conn.setClientID("priority");
-      conn.start();
-      sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      ActiveMQTopic topic = (ActiveMQTopic) sess.createTopic("TEST");
-      final String subName = "priorityDisconnect";
-      TopicSubscriber sub = sess.createDurableSubscriber(topic, subName);
-      sub.close();
-
-      ProducerThread producerThread = new ProducerThread(topic, 1, HIGH_PRI);
-      producerThread.run();
-
-      producerThread.setMessagePriority(HIGH_PRI - 1);
-      producerThread.setMessageCount(1);
-      producerThread.run();
-
-      producerThread.setMessagePriority(LOW_PRI);
-      producerThread.setMessageCount(1);
-      producerThread.run();
-      LOG.info("Ordered priority messages sent");
-
-      sub = sess.createDurableSubscriber(topic, subName);
-
-      Message msg = sub.receive(15000);
-      assertNotNull("Message was null", msg);
-      LOG.info("received " + msg.getJMSMessageID() + ", priority:" + msg.getJMSPriority());
-      assertEquals("Message has wrong priority", HIGH_PRI, msg.getJMSPriority());
-
-      producerThread.setMessagePriority(LOW_PRI + 1);
-      producerThread.setMessageCount(1);
-      producerThread.run();
-
-      msg = sub.receive(15000);
-      assertNotNull("Message was null", msg);
-      LOG.info("received " + msg.getJMSMessageID() + ", priority:" + msg.getJMSPriority());
-      assertEquals("high priority", HIGH_PRI - 1, msg.getJMSPriority());
-
-      msg = sub.receive(15000);
-      assertNotNull("Message was null", msg);
-      LOG.info("received hi? : " + msg);
-      assertEquals("high priority", LOW_PRI + 1, msg.getJMSPriority());
-
-      msg = sub.receive(15000);
-      assertNotNull("Message was null", msg);
-      LOG.info("received hi? : " + msg);
-      assertEquals("high priority", LOW_PRI, msg.getJMSPriority());
-
-      msg = sub.receive(4000);
-      assertNull("Message was null", msg);
-   }
-
-   // immediatePriorityDispatch is only relevant when cache is exhausted
-   public void initCombosForTestHighPriorityDeliveryThroughBackLog() {
-      addCombinationValues("useCache", new Object[]{Boolean.FALSE});
-      addCombinationValues("immediatePriorityDispatch", new Object[]{Boolean.TRUE});
-   }
-
-   public void testHighPriorityDeliveryThroughBackLog() throws Exception {
-
-      // get zero prefetch
-      ActiveMQPrefetchPolicy prefetch = new ActiveMQPrefetchPolicy();
-      prefetch.setAll(0);
-      factory.setPrefetchPolicy(prefetch);
-      conn.close();
-      conn = factory.createConnection();
-      conn.setClientID("priority");
-      conn.start();
-      sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      ActiveMQTopic topic = (ActiveMQTopic) sess.createTopic("TEST");
-      final String subName = "priorityDisconnect";
-      TopicSubscriber sub = sess.createDurableSubscriber(topic, subName);
-      sub.close();
-
-      ProducerThread producerThread = new ProducerThread(topic, 600, LOW_PRI);
-      producerThread.run();
-
-      sub = sess.createDurableSubscriber(topic, subName);
-      int count = 0;
-
-      for (; count < 300; count++) {
-         Message msg = sub.receive(15000);
-         assertNotNull("Message was null", msg);
-         assertEquals("high priority", LOW_PRI, msg.getJMSPriority());
-      }
-
-      producerThread.setMessagePriority(HIGH_PRI);
-      producerThread.setMessageCount(1);
-      producerThread.run();
-
-      Message msg = sub.receive(15000);
-      assertNotNull("Message was null", msg);
-      assertEquals("high priority", HIGH_PRI, msg.getJMSPriority());
-
-      for (; count < 600; count++) {
-         msg = sub.receive(15000);
-         assertNotNull("Message was null", msg);
-         assertEquals("high priority", LOW_PRI, msg.getJMSPriority());
-      }
-   }
-
-   public void initCombosForTestHighPriorityNonDeliveryThroughBackLog() {
-      addCombinationValues("useCache", new Object[]{Boolean.FALSE});
-      addCombinationValues("immediatePriorityDispatch", new Object[]{Boolean.FALSE});
-   }
-
-   public void testHighPriorityNonDeliveryThroughBackLog() throws Exception {
-
-      // get zero prefetch
-      ActiveMQPrefetchPolicy prefetch = new ActiveMQPrefetchPolicy();
-      prefetch.setAll(0);
-      factory.setPrefetchPolicy(prefetch);
-      conn.close();
-      conn = factory.createConnection();
-      conn.setClientID("priority");
-      conn.start();
-      sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      ActiveMQTopic topic = (ActiveMQTopic) sess.createTopic("TEST");
-      final String subName = "priorityDisconnect";
-      TopicSubscriber sub = sess.createDurableSubscriber(topic, subName);
-      sub.close();
-
-      ProducerThread producerThread = new ProducerThread(topic, 600, LOW_PRI);
-      producerThread.run();
-
-      sub = sess.createDurableSubscriber(topic, subName);
-      int count = 0;
-
-      for (; count < 300; count++) {
-         Message msg = sub.receive(15000);
-         assertNotNull("Message was null", msg);
-         assertEquals("high priority", LOW_PRI, msg.getJMSPriority());
-      }
-
-      producerThread.setMessagePriority(HIGH_PRI);
-      producerThread.setMessageCount(1);
-      producerThread.run();
-
-      for (; count < 400; count++) {
-         Message msg = sub.receive(15000);
-         assertNotNull("Message was null", msg);
-         assertEquals("high priority", LOW_PRI, msg.getJMSPriority());
-      }
-
-      Message msg = sub.receive(15000);
-      assertNotNull("Message was null", msg);
-      assertEquals("high priority", HIGH_PRI, msg.getJMSPriority());
-
-      for (; count < 600; count++) {
-         msg = sub.receive(15000);
-         assertNotNull("Message was null", msg);
-         assertEquals("high priority", LOW_PRI, msg.getJMSPriority());
-      }
-   }
-
-   public void initCombosForTestQueueBacklog() {
-      // the cache limits the priority ordering to available memory
-      addCombinationValues("useCache", new Object[]{new Boolean(false)});
-      // expiry processing can fill the cursor with a snapshot of the producer
-      // priority, before producers are complete
-      addCombinationValues("expireMessagePeriod", new Object[]{new Integer(0)});
-   }
-
-   public void testQueueBacklog() throws Exception {
-      final int backlog = 180000;
-      ActiveMQQueue queue = (ActiveMQQueue) sess.createQueue("TEST");
-
-      ProducerThread lowPri = new ProducerThread(queue, backlog, LOW_PRI);
-      ProducerThread highPri = new ProducerThread(queue, 10, HIGH_PRI);
-
-      lowPri.start();
-      lowPri.join();
-      highPri.start();
-      highPri.join();
-
-      LOG.info("Starting consumer...");
-      MessageConsumer queueConsumer = sess.createConsumer(queue);
-      for (int i = 0; i < 500; i++) {
-         Message msg = queueConsumer.receive(20000);
-         LOG.debug("received i=" + i + ", " + (msg != null ? msg.getJMSMessageID() : null));
-         if (msg == null)
-            dumpAllThreads("backlog");
-         assertNotNull("Message " + i + " was null", msg);
-         assertEquals("Message " + i + " has wrong priority", i < 10 ? HIGH_PRI : LOW_PRI, msg.getJMSPriority());
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/StoreOrderTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/StoreOrderTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/StoreOrderTest.java
deleted file mode 100644
index f7ab98d..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/StoreOrderTest.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/**
- * 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.store;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-//  https://issues.apache.org/activemq/browse/AMQ-2594
-public abstract class StoreOrderTest {
-
-   private static final Logger LOG = LoggerFactory.getLogger(StoreOrderTest.class);
-
-   protected BrokerService broker;
-   private ActiveMQConnection connection;
-   public Destination destination = new ActiveMQQueue("StoreOrderTest?consumer.prefetchSize=0");
-
-   protected abstract void setPersistentAdapter(BrokerService brokerService) throws Exception;
-
-   protected void dumpMessages() throws Exception {
-   }
-
-   public class TransactedSend implements Runnable {
-
-      private CountDownLatch readyForCommit;
-      private CountDownLatch firstDone;
-      private boolean first;
-      private Session session;
-      private MessageProducer producer;
-
-      public TransactedSend(CountDownLatch readyForCommit, CountDownLatch firstDone, boolean b) throws Exception {
-         this.readyForCommit = readyForCommit;
-         this.firstDone = firstDone;
-         this.first = b;
-         session = connection.createSession(true, Session.SESSION_TRANSACTED);
-         producer = session.createProducer(destination);
-      }
-
-      @Override
-      public void run() {
-         try {
-            if (!first) {
-               firstDone.await(30, TimeUnit.SECONDS);
-            }
-            producer.send(session.createTextMessage(first ? "first" : "second"));
-            if (first) {
-               firstDone.countDown();
-            }
-            readyForCommit.countDown();
-
-         }
-         catch (Exception e) {
-            e.printStackTrace();
-            fail("unexpected ex on run " + e);
-         }
-      }
-
-      public void commit() throws Exception {
-         session.commit();
-         session.close();
-      }
-   }
-
-   @Before
-   public void setup() throws Exception {
-      broker = createBroker();
-      initConnection();
-   }
-
-   public void initConnection() throws Exception {
-      ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?create=false");
-      connection = (ActiveMQConnection) connectionFactory.createConnection();
-      connection.setWatchTopicAdvisories(false);
-      connection.start();
-   }
-
-   @After
-   public void stopBroker() throws Exception {
-      if (connection != null) {
-         connection.close();
-      }
-      if (broker != null) {
-         broker.stop();
-      }
-   }
-
-   @Test
-   public void testCompositeSendReceiveAfterRestart() throws Exception {
-      destination = new ActiveMQQueue("StoreOrderTest,SecondStoreOrderTest");
-      enqueueOneMessage();
-
-      LOG.info("restart broker");
-      stopBroker();
-      broker = createRestartedBroker();
-      dumpMessages();
-      initConnection();
-      destination = new ActiveMQQueue("StoreOrderTest");
-      assertNotNull("got one message from first dest", receiveOne());
-      dumpMessages();
-      destination = new ActiveMQQueue("SecondStoreOrderTest");
-      assertNotNull("got one message from second dest", receiveOne());
-   }
-
-   @Test
-   public void validateUnorderedTxCommit() throws Exception {
-
-      Executor executor = Executors.newCachedThreadPool();
-      CountDownLatch readyForCommit = new CountDownLatch(2);
-      CountDownLatch firstDone = new CountDownLatch(1);
-
-      TransactedSend first = new TransactedSend(readyForCommit, firstDone, true);
-      TransactedSend second = new TransactedSend(readyForCommit, firstDone, false);
-      executor.execute(first);
-      executor.execute(second);
-
-      assertTrue("both started", readyForCommit.await(20, TimeUnit.SECONDS));
-
-      LOG.info("commit out of order");
-      // send interleaved so sequence id at time of commit could be reversed
-      second.commit();
-
-      // force usage over the limit before second commit to flush cache
-      enqueueOneMessage();
-
-      // can get lost in the cursor as it is behind the last sequenceId that was cached
-      first.commit();
-
-      LOG.info("send/commit done..");
-
-      dumpMessages();
-
-      String received1, received2, received3 = null;
-      if (true) {
-         LOG.info("receive and rollback...");
-         Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-         received1 = receive(session);
-         received2 = receive(session);
-         received3 = receive(session);
-
-         assertEquals("second", received1);
-         assertEquals("middle", received2);
-         assertEquals("first", received3);
-
-         session.rollback();
-         session.close();
-      }
-
-      LOG.info("restart broker");
-      stopBroker();
-      broker = createRestartedBroker();
-      initConnection();
-
-      if (true) {
-         LOG.info("receive and rollback after restart...");
-         Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-         received1 = receive(session);
-         received2 = receive(session);
-         received3 = receive(session);
-         assertEquals("second", received1);
-         assertEquals("middle", received2);
-         assertEquals("first", received3);
-         session.rollback();
-         session.close();
-      }
-
-      LOG.info("receive and ack each message");
-      received1 = receiveOne();
-      received2 = receiveOne();
-      received3 = receiveOne();
-
-      assertEquals("second", received1);
-      assertEquals("middle", received2);
-      assertEquals("first", received3);
-   }
-
-   private void enqueueOneMessage() throws Exception {
-      Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-      MessageProducer producer = session.createProducer(destination);
-      producer.send(session.createTextMessage("middle"));
-      session.commit();
-      session.close();
-   }
-
-   private String receiveOne() throws Exception {
-      Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-      String received = receive(session);
-      session.commit();
-      session.close();
-      return received;
-   }
-
-   private String receive(Session session) throws Exception {
-      MessageConsumer consumer = session.createConsumer(destination);
-      String result = null;
-      TextMessage message = (TextMessage) consumer.receive(5000);
-      if (message != null) {
-         LOG.info("got message: " + message);
-         result = message.getText();
-      }
-      consumer.close();
-      return result;
-   }
-
-   protected BrokerService createBroker() throws Exception {
-      boolean deleteMessagesOnStartup = true;
-      return startBroker(deleteMessagesOnStartup);
-   }
-
-   protected BrokerService createRestartedBroker() throws Exception {
-      boolean deleteMessagesOnStartup = false;
-      return startBroker(deleteMessagesOnStartup);
-   }
-
-   protected BrokerService startBroker(boolean deleteMessagesOnStartup) throws Exception {
-      BrokerService newBroker = new BrokerService();
-      configureBroker(newBroker);
-      newBroker.setDeleteAllMessagesOnStartup(deleteMessagesOnStartup);
-      newBroker.start();
-      return newBroker;
-   }
-
-   protected void configureBroker(BrokerService brokerService) throws Exception {
-      setPersistentAdapter(brokerService);
-      brokerService.setAdvisorySupport(false);
-
-      PolicyMap map = new PolicyMap();
-      PolicyEntry defaultEntry = new PolicyEntry();
-      defaultEntry.setMemoryLimit(1024 * 3);
-      defaultEntry.setCursorMemoryHighWaterMark(68);
-      defaultEntry.setExpireMessagesPeriod(0);
-      map.setDefaultEntry(defaultEntry);
-      brokerService.setDestinationPolicy(map);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/StorePerDestinationTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/StorePerDestinationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/StorePerDestinationTest.java
deleted file mode 100644
index cc144d0..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/StorePerDestinationTest.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/**
- * 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.store;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Vector;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.TransactionId;
-import org.apache.activemq.store.kahadb.FilteredKahaDBPersistenceAdapter;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.store.kahadb.MultiKahaDBPersistenceAdapter;
-import org.apache.activemq.store.kahadb.MultiKahaDBTransactionStore;
-import org.apache.activemq.usage.SystemUsage;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class StorePerDestinationTest {
-
-   static final Logger LOG = LoggerFactory.getLogger(StorePerDestinationTest.class);
-   final static int maxFileLength = 1024 * 100;
-   final static int numToSend = 5000;
-   final Vector<Throwable> exceptions = new Vector<>();
-   BrokerService brokerService;
-
-   protected BrokerService createBroker(PersistenceAdapter kaha) throws Exception {
-
-      BrokerService broker = new BrokerService();
-      broker.setUseJmx(false);
-      broker.setPersistenceAdapter(kaha);
-      return broker;
-   }
-
-   protected PersistenceAdapter createStore(boolean delete) throws IOException {
-      KahaDBPersistenceAdapter kaha = new KahaDBPersistenceAdapter();
-      kaha.setJournalMaxFileLength(maxFileLength);
-      kaha.setCleanupInterval(5000);
-      if (delete) {
-         kaha.deleteAllMessages();
-      }
-      return kaha;
-   }
-
-   @Before
-   public void prepareCleanBrokerWithMultiStore() throws Exception {
-      prepareBrokerWithMultiStore(true);
-   }
-
-   public void prepareBrokerWithMultiStore(boolean deleteAllMessages) throws Exception {
-
-      MultiKahaDBPersistenceAdapter multiKahaDBPersistenceAdapter = new MultiKahaDBPersistenceAdapter();
-      if (deleteAllMessages) {
-         multiKahaDBPersistenceAdapter.deleteAllMessages();
-      }
-      ArrayList<FilteredKahaDBPersistenceAdapter> adapters = new ArrayList<>();
-
-      FilteredKahaDBPersistenceAdapter theRest = new FilteredKahaDBPersistenceAdapter();
-      theRest.setPersistenceAdapter(createStore(deleteAllMessages));
-      // default destination when not set is a match for all
-      adapters.add(theRest);
-
-      // separate store for FastQ
-      FilteredKahaDBPersistenceAdapter fastQStore = new FilteredKahaDBPersistenceAdapter();
-      fastQStore.setPersistenceAdapter(createStore(deleteAllMessages));
-      fastQStore.setDestination(new ActiveMQQueue("FastQ"));
-      adapters.add(fastQStore);
-
-      multiKahaDBPersistenceAdapter.setFilteredPersistenceAdapters(adapters);
-      brokerService = createBroker(multiKahaDBPersistenceAdapter);
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      brokerService.stop();
-   }
-
-   @Test
-   public void testTransactedSendReceive() throws Exception {
-      brokerService.start();
-      sendMessages(true, "SlowQ", 1, 0);
-      assertEquals("got one", 1, receiveMessages(true, "SlowQ", 1));
-   }
-
-   @Test
-   public void testTransactedSendReceiveAcrossStores() throws Exception {
-      brokerService.start();
-      sendMessages(true, "SlowQ,FastQ", 1, 0);
-      assertEquals("got one", 2, receiveMessages(true, "SlowQ,FastQ", 2));
-   }
-
-   @Test
-   public void testCommitRecovery() throws Exception {
-      doTestRecovery(true);
-   }
-
-   @Test
-   public void testRollbackRecovery() throws Exception {
-      doTestRecovery(false);
-   }
-
-   public void doTestRecovery(final boolean haveOutcome) throws Exception {
-      final MultiKahaDBPersistenceAdapter persistenceAdapter = (MultiKahaDBPersistenceAdapter) brokerService.getPersistenceAdapter();
-      MultiKahaDBTransactionStore transactionStore = new MultiKahaDBTransactionStore(persistenceAdapter) {
-         @Override
-         public void persistOutcome(Tx tx, TransactionId txid) throws IOException {
-            if (haveOutcome) {
-               super.persistOutcome(tx, txid);
-            }
-            try {
-               // IOExceptions will stop the broker
-               persistenceAdapter.stop();
-            }
-            catch (Exception e) {
-               LOG.error("ex on stop ", e);
-               exceptions.add(e);
-            }
-         }
-      };
-      persistenceAdapter.setTransactionStore(transactionStore);
-      brokerService.start();
-
-      ExecutorService executorService = Executors.newCachedThreadPool();
-      executorService.execute(new Runnable() {
-         @Override
-         public void run() {
-            try {
-               // commit will block
-               sendMessages(true, "SlowQ,FastQ", 1, 0);
-            }
-            catch (Exception expected) {
-               LOG.info("expected", expected);
-            }
-         }
-      });
-
-      brokerService.waitUntilStopped();
-      // interrupt the send thread
-      executorService.shutdownNow();
-
-      // verify auto recovery
-      prepareBrokerWithMultiStore(false);
-      brokerService.start();
-
-      assertEquals("expect to get the recovered message", haveOutcome ? 2 : 0, receiveMessages(false, "SlowQ,FastQ", 2));
-      assertEquals("all transactions are complete", 0, brokerService.getBroker().getPreparedTransactions(null).length);
-   }
-
-   @Test
-   public void testDirectoryDefault() throws Exception {
-      MultiKahaDBPersistenceAdapter multiKahaDBPersistenceAdapter = new MultiKahaDBPersistenceAdapter();
-      ArrayList<FilteredKahaDBPersistenceAdapter> adapters = new ArrayList<>();
-
-      FilteredKahaDBPersistenceAdapter otherFilteredKahaDBPersistenceAdapter = new FilteredKahaDBPersistenceAdapter();
-      PersistenceAdapter otherStore = createStore(false);
-      File someOtherDisk = new File("target" + File.separator + "someOtherDisk");
-      otherStore.setDirectory(someOtherDisk);
-      otherFilteredKahaDBPersistenceAdapter.setPersistenceAdapter(otherStore);
-      otherFilteredKahaDBPersistenceAdapter.setDestination(new ActiveMQQueue("Other"));
-      adapters.add(otherFilteredKahaDBPersistenceAdapter);
-
-      FilteredKahaDBPersistenceAdapter filteredKahaDBPersistenceAdapterDefault = new FilteredKahaDBPersistenceAdapter();
-      PersistenceAdapter storeDefault = createStore(false);
-      filteredKahaDBPersistenceAdapterDefault.setPersistenceAdapter(storeDefault);
-      adapters.add(filteredKahaDBPersistenceAdapterDefault);
-
-      multiKahaDBPersistenceAdapter.setFilteredPersistenceAdapters(adapters);
-
-      assertEquals(multiKahaDBPersistenceAdapter.getDirectory(), storeDefault.getDirectory().getParentFile());
-      assertEquals(someOtherDisk, otherStore.getDirectory().getParentFile());
-   }
-
-   @Test
-   public void testSlowFastDestinationsStoreUsage() throws Exception {
-      brokerService.start();
-      ExecutorService executorService = Executors.newCachedThreadPool();
-      executorService.execute(new Runnable() {
-         @Override
-         public void run() {
-            try {
-               sendMessages(false, "SlowQ", 50, 500);
-            }
-            catch (Exception e) {
-               exceptions.add(e);
-            }
-         }
-      });
-
-      executorService.execute(new Runnable() {
-         @Override
-         public void run() {
-            try {
-               sendMessages(false, "FastQ", numToSend, 0);
-            }
-            catch (Exception e) {
-               exceptions.add(e);
-            }
-         }
-      });
-
-      executorService.execute(new Runnable() {
-         @Override
-         public void run() {
-            try {
-               assertEquals("Got all sent", numToSend, receiveMessages(false, "FastQ", numToSend));
-            }
-            catch (Exception e) {
-               exceptions.add(e);
-            }
-         }
-      });
-
-      executorService.shutdown();
-      assertTrue("consumers executor finished on time", executorService.awaitTermination(5 * 60, TimeUnit.SECONDS));
-      final SystemUsage usage = brokerService.getSystemUsage();
-      assertTrue("Store is not hogged", Wait.waitFor(new Wait.Condition() {
-
-         @Override
-         public boolean isSatisified() throws Exception {
-            long storeUsage = usage.getStoreUsage().getUsage();
-            LOG.info("Store Usage: " + storeUsage);
-            return storeUsage < 5 * maxFileLength;
-         }
-      }));
-      assertTrue("no exceptions", exceptions.isEmpty());
-   }
-
-   private void sendMessages(boolean transacted, String destName, int count, long sleep) throws Exception {
-      ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost");
-      Connection connection = cf.createConnection();
-      try {
-         Session session = transacted ? connection.createSession(true, Session.SESSION_TRANSACTED) : connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageProducer producer = session.createProducer(new ActiveMQQueue(destName));
-         for (int i = 0; i < count; i++) {
-            if (sleep > 0) {
-               TimeUnit.MILLISECONDS.sleep(sleep);
-            }
-            producer.send(session.createTextMessage(createContent(i)));
-         }
-         if (transacted) {
-            session.commit();
-         }
-      }
-      finally {
-         connection.close();
-      }
-   }
-
-   private int receiveMessages(boolean transacted, String destName, int max) throws JMSException {
-      int rc = 0;
-      ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost");
-      Connection connection = cf.createConnection();
-      try {
-         connection.start();
-         Session session = transacted ? connection.createSession(true, Session.SESSION_TRANSACTED) : connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageConsumer messageConsumer = session.createConsumer(new ActiveMQQueue(destName));
-         while (rc < max && messageConsumer.receive(4000) != null) {
-            rc++;
-
-            if (transacted && rc % 200 == 0) {
-               session.commit();
-            }
-         }
-         if (transacted) {
-            session.commit();
-         }
-         return rc;
-      }
-      finally {
-         connection.close();
-      }
-   }
-
-   private String createContent(int i) {
-      StringBuilder sb = new StringBuilder(i + ":");
-      while (sb.length() < 1024) {
-         sb.append("*");
-      }
-      return sb.toString();
-   }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/BrokenPersistenceAdapter.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/BrokenPersistenceAdapter.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/BrokenPersistenceAdapter.java
deleted file mode 100644
index a484c64..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/BrokenPersistenceAdapter.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * 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.store.jdbc;
-
-import java.io.IOException;
-
-import org.apache.activemq.broker.ConnectionContext;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-class BrokenPersistenceAdapter extends JDBCPersistenceAdapter {
-
-   private final Logger LOG = LoggerFactory.getLogger(BrokenPersistenceAdapter.class);
-
-   private boolean shouldBreak = false;
-
-   @Override
-   public void commitTransaction(ConnectionContext context) throws IOException {
-      if (shouldBreak) {
-         LOG.warn("Throwing exception on purpose");
-         throw new IOException("Breaking on purpose");
-      }
-      LOG.debug("in commitTransaction");
-      super.commitTransaction(context);
-   }
-
-   public void setShouldBreak(boolean shouldBreak) {
-      this.shouldBreak = shouldBreak;
-   }
-}
-

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/DatabaseLockerConfigTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/DatabaseLockerConfigTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/DatabaseLockerConfigTest.java
deleted file mode 100644
index 5a4aae8..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/DatabaseLockerConfigTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * 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.store.jdbc;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.activemq.broker.AbstractLocker;
-import org.junit.Test;
-
-public class DatabaseLockerConfigTest {
-
-   @Test
-   public void testSleepConfig() throws Exception {
-      LeaseDatabaseLocker underTest = new LeaseDatabaseLocker();
-      underTest.setLockAcquireSleepInterval(50);
-      underTest.configure(null);
-      assertEquals("configured sleep value retained", 50, underTest.getLockAcquireSleepInterval());
-   }
-
-   @Test
-   public void testDefaultSleepConfig() throws Exception {
-      LeaseDatabaseLocker underTest = new LeaseDatabaseLocker();
-      underTest.configure(null);
-      assertEquals("configured sleep value retained", AbstractLocker.DEFAULT_LOCK_ACQUIRE_SLEEP_INTERVAL, underTest.getLockAcquireSleepInterval());
-   }
-
-   @Test
-   public void testSleepConfigOrig() throws Exception {
-      DefaultDatabaseLocker underTest = new DefaultDatabaseLocker();
-      underTest.setLockAcquireSleepInterval(50);
-      underTest.configure(null);
-      assertEquals("configured sleep value retained", 50, underTest.getLockAcquireSleepInterval());
-   }
-
-   @Test
-   public void testDefaultSleepConfigOrig() throws Exception {
-      DefaultDatabaseLocker underTest = new DefaultDatabaseLocker();
-      underTest.configure(null);
-      assertEquals("configured sleep value retained", AbstractLocker.DEFAULT_LOCK_ACQUIRE_SLEEP_INTERVAL, underTest.getLockAcquireSleepInterval());
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCCommitExceptionTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCCommitExceptionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCCommitExceptionTest.java
deleted file mode 100644
index 00c501f..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCCommitExceptionTest.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/**
- * 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.store.jdbc;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.openwire.OpenWireFormat;
-import org.apache.activemq.util.ByteSequence;
-import org.apache.activemq.wireformat.WireFormat;
-import org.apache.derby.jdbc.EmbeddedDataSource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-// https://issues.apache.org/activemq/browse/AMQ-2880
-public class JDBCCommitExceptionTest extends TestCase {
-
-   private static final Logger LOG = LoggerFactory.getLogger(JDBCCommitExceptionTest.class);
-
-   protected static final int messagesExpected = 10;
-   protected ActiveMQConnectionFactory factory;
-   protected BrokerService broker;
-   protected String connectionUri;
-   protected EmbeddedDataSource dataSource;
-   protected java.sql.Connection dbConnection;
-   protected BrokenPersistenceAdapter jdbc;
-
-   @Override
-   public void setUp() throws Exception {
-      broker = createBroker();
-      broker.start();
-
-      factory = new ActiveMQConnectionFactory(connectionUri + "?jms.prefetchPolicy.all=0&jms.redeliveryPolicy.maximumRedeliveries=" + messagesExpected);
-   }
-
-   @Override
-   public void tearDown() throws Exception {
-      broker.stop();
-   }
-
-   public void testSqlException() throws Exception {
-      doTestSqlException();
-   }
-
-   public void doTestSqlException() throws Exception {
-      sendMessages(messagesExpected);
-      int messagesReceived = receiveMessages(messagesExpected);
-
-      dumpMessages();
-      assertEquals("Messages expected doesn't equal messages received", messagesExpected, messagesReceived);
-      broker.stop();
-   }
-
-   protected void dumpMessages() throws Exception {
-      WireFormat wireFormat = new OpenWireFormat();
-      java.sql.Connection conn = ((JDBCPersistenceAdapter) broker.getPersistenceAdapter()).getDataSource().getConnection();
-      PreparedStatement statement = conn.prepareStatement("SELECT ID, MSG FROM ACTIVEMQ_MSGS");
-      ResultSet result = statement.executeQuery();
-      LOG.info("Messages left in broker after test");
-      while (result.next()) {
-         long id = result.getLong(1);
-         org.apache.activemq.command.Message message = (org.apache.activemq.command.Message) wireFormat.unmarshal(new ByteSequence(result.getBytes(2)));
-         LOG.info("id: " + id + ", message SeqId: " + message.getMessageId().getBrokerSequenceId() + ", MSG: " + message);
-      }
-      statement.close();
-      conn.close();
-   }
-
-   protected int receiveMessages(int messagesExpected) throws Exception {
-      javax.jms.Connection connection = factory.createConnection();
-      connection.start();
-      Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-
-      jdbc.setShouldBreak(true);
-
-      // first try and receive these messages, they'll continually fail
-      receiveMessages(messagesExpected, session);
-
-      jdbc.setShouldBreak(false);
-
-      // now that the store is sane, try and get all the messages sent
-      return receiveMessages(messagesExpected, session);
-   }
-
-   protected int receiveMessages(int messagesExpected, Session session) throws Exception {
-      int messagesReceived = 0;
-
-      for (int i = 0; i < messagesExpected; i++) {
-         Destination destination = session.createQueue("TEST");
-         MessageConsumer consumer = session.createConsumer(destination);
-         Message message = null;
-         try {
-            LOG.debug("Receiving message " + (messagesReceived + 1) + " of " + messagesExpected);
-            message = consumer.receive(2000);
-            LOG.info("Received : " + message);
-            if (message != null) {
-               session.commit();
-               messagesReceived++;
-            }
-         }
-         catch (Exception e) {
-            LOG.debug("Caught exception " + e);
-            session.rollback();
-         }
-         finally {
-            if (consumer != null) {
-               consumer.close();
-            }
-         }
-      }
-      return messagesReceived;
-   }
-
-   protected void sendMessages(int messagesExpected) throws Exception {
-      javax.jms.Connection connection = factory.createConnection();
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Destination destination = session.createQueue("TEST");
-      MessageProducer producer = session.createProducer(destination);
-      producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-
-      for (int i = 0; i < messagesExpected; i++) {
-         LOG.debug("Sending message " + (i + 1) + " of " + messagesExpected);
-         producer.send(session.createTextMessage("test message " + (i + 1)));
-      }
-   }
-
-   protected BrokerService createBroker() throws Exception {
-
-      BrokerService broker = new BrokerService();
-      jdbc = new BrokenPersistenceAdapter();
-
-      dataSource = new EmbeddedDataSource();
-      dataSource.setDatabaseName("target/derbyDb");
-      dataSource.setCreateDatabase("create");
-
-      jdbc.setDataSource(dataSource);
-      jdbc.setUseLock(false);
-      jdbc.deleteAllMessages();
-
-      broker.setPersistenceAdapter(jdbc);
-      broker.setPersistent(true);
-      connectionUri = broker.addConnector("tcp://localhost:0").getPublishableConnectString();
-
-      return broker;
-   }
-}
-
-
-

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCIOExceptionHandlerMockeryTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCIOExceptionHandlerMockeryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCIOExceptionHandlerMockeryTest.java
deleted file mode 100644
index fa7b848..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCIOExceptionHandlerMockeryTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * 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.store.jdbc;
-
-import java.io.IOException;
-import java.util.HashMap;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.Locker;
-import org.apache.activemq.broker.SuppressReplyException;
-import org.apache.activemq.util.LeaseLockerIOExceptionHandler;
-import org.apache.activemq.util.ServiceStopper;
-import org.apache.activemq.util.Wait;
-import org.jmock.Expectations;
-import org.jmock.Mockery;
-import org.jmock.States;
-import org.jmock.lib.legacy.ClassImposteriser;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-public class JDBCIOExceptionHandlerMockeryTest {
-
-   private static final Logger LOG = LoggerFactory.getLogger(JDBCIOExceptionHandlerMockeryTest.class);
-   private HashMap<Thread, Throwable> exceptions = new HashMap<>();
-
-   @Test
-   public void testShutdownWithoutTransportRestart() throws Exception {
-
-      Mockery context = new Mockery() {{
-         setImposteriser(ClassImposteriser.INSTANCE);
-      }};
-
-      Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
-         @Override
-         public void uncaughtException(Thread t, Throwable e) {
-            LOG.error("unexpected exception {} on thread {}", e, t);
-            exceptions.put(t, e);
-         }
-      });
-
-      final BrokerService brokerService = context.mock(BrokerService.class);
-      final JDBCPersistenceAdapter jdbcPersistenceAdapter = context.mock(JDBCPersistenceAdapter.class);
-      final Locker locker = context.mock(Locker.class);
-
-      final States jdbcConn = context.states("jdbc").startsAs("down");
-      final States broker = context.states("broker").startsAs("started");
-
-      // simulate jdbc up between hasLock and checkpoint, so hasLock fails to verify
-      context.checking(new Expectations() {{
-         allowing(brokerService).isRestartAllowed();
-         will(returnValue(false));
-         allowing(brokerService).stopAllConnectors(with(any(ServiceStopper.class)));
-         allowing(brokerService).getPersistenceAdapter();
-         will(returnValue(jdbcPersistenceAdapter));
-         allowing(jdbcPersistenceAdapter).getLocker();
-         will(returnValue(locker));
-         allowing(locker).keepAlive();
-         when(jdbcConn.is("down"));
-         will(returnValue(true));
-         allowing(locker).keepAlive();
-         when(jdbcConn.is("up"));
-         will(returnValue(false));
-
-         allowing(jdbcPersistenceAdapter).checkpoint(with(true));
-         then(jdbcConn.is("up"));
-         allowing(brokerService).stop();
-         then(broker.is("stopped"));
-
-      }});
-
-      LeaseLockerIOExceptionHandler underTest = new LeaseLockerIOExceptionHandler();
-      underTest.setBrokerService(brokerService);
-
-      try {
-         underTest.handle(new IOException());
-         fail("except suppress reply ex");
-      }
-      catch (SuppressReplyException expected) {
-      }
-
-      assertTrue("broker stopped state triggered", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            LOG.info("broker state {}", broker);
-            return broker.is("stopped").isActive();
-         }
-      }));
-      context.assertIsSatisfied();
-
-      assertTrue("no exceptions: " + exceptions, exceptions.isEmpty());
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCIOExceptionHandlerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCIOExceptionHandlerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCIOExceptionHandlerTest.java
deleted file mode 100644
index 6c43646..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCIOExceptionHandlerTest.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/**
- * 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.store.jdbc;
-
-import java.io.PrintWriter;
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
-
-import javax.jms.Connection;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.util.LeaseLockerIOExceptionHandler;
-import org.apache.activemq.util.Wait;
-import org.apache.derby.jdbc.EmbeddedDataSource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Test to see if the JDBCExceptionIOHandler will restart the transport connectors correctly after
- * the underlying DB has been stopped and restarted
- *
- * see AMQ-4575
- */
-public class JDBCIOExceptionHandlerTest extends TestCase {
-
-   private static final Logger LOG = LoggerFactory.getLogger(JDBCIOExceptionHandlerTest.class);
-   private static final String TRANSPORT_URL = "tcp://0.0.0.0:0";
-
-   private static final String DATABASE_NAME = "DERBY_OVERRIDE";
-   private ActiveMQConnectionFactory factory;
-   private ReconnectingEmbeddedDataSource dataSource;
-   private BrokerService broker;
-
-   protected BrokerService createBroker(boolean withJMX) throws Exception {
-      return createBroker("localhost", withJMX, true, true);
-   }
-
-   protected BrokerService createBroker(String name,
-                                        boolean withJMX,
-                                        boolean leaseLocker,
-                                        boolean startStopConnectors) throws Exception {
-      BrokerService broker = new BrokerService();
-      broker.setBrokerName(name);
-
-      broker.setUseJmx(withJMX);
-
-      EmbeddedDataSource embeddedDataSource = new EmbeddedDataSource();
-      embeddedDataSource.setDatabaseName(DATABASE_NAME);
-      embeddedDataSource.setCreateDatabase("create");
-
-      // create a wrapper to EmbeddedDataSource to allow the connection be
-      // reestablished to derby db
-      dataSource = new ReconnectingEmbeddedDataSource(embeddedDataSource);
-
-      JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter();
-      jdbc.setDataSource(dataSource);
-
-      jdbc.setLockKeepAlivePeriod(1000L);
-      if (leaseLocker) {
-         LeaseDatabaseLocker leaseDatabaseLocker = new LeaseDatabaseLocker();
-         leaseDatabaseLocker.setHandleStartException(true);
-         leaseDatabaseLocker.setLockAcquireSleepInterval(2000L);
-         jdbc.setLocker(leaseDatabaseLocker);
-      }
-
-      broker.setPersistenceAdapter(jdbc);
-      LeaseLockerIOExceptionHandler ioExceptionHandler = new LeaseLockerIOExceptionHandler();
-      ioExceptionHandler.setResumeCheckSleepPeriod(1000L);
-      ioExceptionHandler.setStopStartConnectors(startStopConnectors);
-      broker.setIoExceptionHandler(ioExceptionHandler);
-      String connectionUri = broker.addConnector(TRANSPORT_URL).getPublishableConnectString();
-
-      factory = new ActiveMQConnectionFactory(connectionUri);
-
-      return broker;
-   }
-
-   /*
-    * run test without JMX enabled
-    */
-   public void testRecoverWithOutJMX() throws Exception {
-      recoverFromDisconnectDB(false);
-   }
-
-   /*
-    * run test with JMX enabled
-    */
-   public void testRecoverWithJMX() throws Exception {
-      recoverFromDisconnectDB(true);
-   }
-
-   public void testSlaveStoppedLease() throws Exception {
-      testSlaveStopped(true);
-   }
-
-   public void testSlaveStoppedDefault() throws Exception {
-      testSlaveStopped(false);
-   }
-
-   public void testSlaveStopped(final boolean lease) throws Exception {
-      final BrokerService master = createBroker("master", true, lease, false);
-      master.start();
-      master.waitUntilStarted();
-
-      final AtomicReference<BrokerService> slave = new AtomicReference<>();
-
-      Thread slaveThread = new Thread() {
-         @Override
-         public void run() {
-            try {
-               BrokerService broker = new BrokerService();
-               broker.setBrokerName("slave");
-
-               JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter();
-               jdbc.setDataSource(dataSource);
-
-               jdbc.setLockKeepAlivePeriod(1000L);
-
-               if (lease) {
-                  LeaseDatabaseLocker leaseDatabaseLocker = new LeaseDatabaseLocker();
-                  leaseDatabaseLocker.setHandleStartException(true);
-                  leaseDatabaseLocker.setLockAcquireSleepInterval(2000L);
-                  jdbc.setLocker(leaseDatabaseLocker);
-               }
-
-               broker.setPersistenceAdapter(jdbc);
-               LeaseLockerIOExceptionHandler ioExceptionHandler = new LeaseLockerIOExceptionHandler();
-               ioExceptionHandler.setResumeCheckSleepPeriod(1000L);
-               ioExceptionHandler.setStopStartConnectors(false);
-               broker.setIoExceptionHandler(ioExceptionHandler);
-               slave.set(broker);
-               broker.start();
-            }
-            catch (Exception e) {
-               e.printStackTrace();
-            }
-         }
-      };
-
-      slaveThread.start();
-
-      Thread.sleep(5000);
-
-      dataSource.stopDB();
-
-      assertTrue("Master hasn't been stopped", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return master.isStopped();
-         }
-      }));
-
-      assertTrue("Slave hasn't been stopped", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return slave.get().isStopped();
-         }
-      }));
-
-   }
-
-   public void recoverFromDisconnectDB(boolean withJMX) throws Exception {
-      try {
-         broker = createBroker(withJMX);
-         broker.start();
-         broker.waitUntilStarted();
-
-         // broker started - stop db underneath it
-         dataSource.stopDB();
-
-         // wait - allow the leaselocker to kick the JDBCIOExceptionHandler
-         TimeUnit.SECONDS.sleep(3);
-
-         // check connector has shutdown
-         checkTransportConnectorStopped();
-
-         // restart db underneath
-         dataSource.restartDB();
-
-         Wait.waitFor(new Wait.Condition() {
-            @Override
-            public boolean isSatisified() throws Exception {
-               LOG.debug("*** checking connector to start...");
-               try {
-                  checkTransportConnectorStarted();
-                  return true;
-               }
-               catch (Throwable t) {
-                  LOG.debug(t.toString());
-               }
-               return false;
-            }
-         });
-
-      }
-      finally {
-         LOG.debug("*** broker is stopping...");
-         broker.stop();
-      }
-   }
-
-   private void checkTransportConnectorStopped() {
-      // connection is expected to fail
-      try {
-         factory.createConnection();
-         fail("Transport connector should be stopped");
-      }
-      catch (Exception ex) {
-         // expected an exception
-         LOG.debug(" checkTransportConnectorStopped() threw", ex);
-      }
-   }
-
-   private void checkTransportConnectorStarted() {
-      // connection is expected to succeed
-      try {
-         Connection conn = factory.createConnection();
-         conn.close();
-      }
-      catch (Exception ex) {
-         LOG.debug("checkTransportConnectorStarted() threw", ex);
-         fail("Transport connector should have been started");
-      }
-   }
-
-   /*
-    * Wrapped the derby datasource object to get DB reconnect functionality as I not
-    * manage to get that working directly on the EmbeddedDataSource
-    *
-    * NOTE: Not a thread Safe but for this unit test it should be fine
-    */
-   public class ReconnectingEmbeddedDataSource implements javax.sql.DataSource {
-
-      private EmbeddedDataSource realDatasource;
-
-      public ReconnectingEmbeddedDataSource(EmbeddedDataSource datasource) {
-         this.realDatasource = datasource;
-      }
-
-      @Override
-      public PrintWriter getLogWriter() throws SQLException {
-         return this.realDatasource.getLogWriter();
-      }
-
-      @Override
-      public void setLogWriter(PrintWriter out) throws SQLException {
-         this.realDatasource.setLogWriter(out);
-
-      }
-
-      @Override
-      public void setLoginTimeout(int seconds) throws SQLException {
-         this.realDatasource.setLoginTimeout(seconds);
-      }
-
-      @Override
-      public int getLoginTimeout() throws SQLException {
-         return this.realDatasource.getLoginTimeout();
-      }
-
-      @Override
-      public <T> T unwrap(Class<T> iface) throws SQLException {
-         return this.unwrap(iface);
-      }
-
-      @Override
-      public boolean isWrapperFor(Class<?> iface) throws SQLException {
-         return this.isWrapperFor(iface);
-      }
-
-      @Override
-      public java.sql.Connection getConnection() throws SQLException {
-         return this.realDatasource.getConnection();
-      }
-
-      @Override
-      public java.sql.Connection getConnection(String username, String password) throws SQLException {
-         return this.getConnection(username, password);
-      }
-
-      /**
-       * To simulate a db reconnect I just create a new EmbeddedDataSource .
-       *
-       * @throws SQLException
-       */
-      public void restartDB() throws SQLException {
-         EmbeddedDataSource newDatasource = new EmbeddedDataSource();
-         newDatasource.setDatabaseName(DATABASE_NAME);
-         newDatasource.getConnection();
-         LOG.info("*** DB restarted now...");
-         this.realDatasource = newDatasource;
-      }
-
-      public void stopDB() {
-         try {
-            realDatasource.setShutdownDatabase("shutdown");
-            LOG.info("***DB is being shutdown...");
-            dataSource.getConnection();
-            fail("should have thrown a db closed exception");
-         }
-         catch (Exception ex) {
-            ex.printStackTrace(System.out);
-         }
-      }
-
-      @Override
-      public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException {
-         return null;
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCLockTablePrefix.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCLockTablePrefix.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCLockTablePrefix.xml
deleted file mode 100644
index ac70fa7..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCLockTablePrefix.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<?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">
-
-    <!-- normal ActiveMQ XML config which is less verbose & can be validated -->
-    <amq:broker brokerName="brokerConfigTest" populateJMSXUserID="false"
-                useLoggingForShutdownErrors="true" useJmx="false"
-                persistent="true" vmConnectorURI="vm://javacoola"
-                useShutdownHook="false" deleteAllMessagesOnStartup="true">
-
-      <amq:persistenceAdapter>
-        <amq:jdbcPersistenceAdapter dataDirectory="target/activemq-data" dataSource="#derby-ds" lockKeepAlivePeriod="5000" createTablesOnStartup="true">
-          <!-- test that we can define the locker before th statements,
-          but the locker will still pickup the statements -->
-          <amq:locker>
-            <amq:lease-database-locker lockAcquireSleepInterval="10000"/>
-          </amq:locker>
-          <amq:statements>
-            <amq:statements tablePrefix="TTT_" messageTableName="AMQ_MSGS2" durableSubAcksTableName="AMQ_ACKS2" lockTableName="AMQ_LOCK2"/>
-          </amq:statements>
-          <amq:adapter>
-            <amq:defaultJDBCAdapter/>
-          </amq:adapter>
-        </amq:jdbcPersistenceAdapter>
-      </amq:persistenceAdapter>
-
-        <amq:transportConnectors>
-            <amq:transportConnector uri="vm://brokerConfigTest"/>
-        </amq:transportConnectors>
-
-    </amq:broker>
-
-  <bean id="derby-ds" class="org.apache.derby.jdbc.EmbeddedDataSource">
-    <property name="databaseName" value="target/derbyDb"/>
-    <property name="connectionAttributes" value=";create=true"/>
-  </bean>
-
-</beans>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCLockTablePrefixTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCLockTablePrefixTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCLockTablePrefixTest.java
deleted file mode 100644
index 854dd7a..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCLockTablePrefixTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * 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.store.jdbc;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.broker.BrokerFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.store.PersistenceAdapter;
-
-public class JDBCLockTablePrefixTest extends TestCase {
-
-   public void testLockTable() throws Exception {
-      BrokerService broker = BrokerFactory.createBroker("xbean:org/apache/activemq/store/jdbc/JDBCLockTablePrefix.xml");
-      broker.waitUntilStarted();
-
-      PersistenceAdapter pa = broker.getPersistenceAdapter();
-      assertNotNull(pa);
-
-      JDBCPersistenceAdapter jpa = (JDBCPersistenceAdapter) pa;
-      assertEquals("TTT_", jpa.getStatements().getTablePrefix());
-      assertEquals("AMQ_MSGS2", jpa.getStatements().getMessageTableName());
-      assertEquals("AMQ_LOCK2", jpa.getStatements().getLockTableName());
-
-      broker.stop();
-      broker.waitUntilStopped();
-   }
-
-}


[38/60] [abbrv] activemq-artemis git commit: fixing byteman tests

Posted by cl...@apache.org.
fixing byteman tests


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/bc25518b
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/bc25518b
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/bc25518b

Branch: refs/heads/refactor-openwire
Commit: bc25518b9264924a013081aeb740264212a5a1a3
Parents: e306e53
Author: Clebert Suconic <cl...@apache.org>
Authored: Tue Feb 23 22:04:16 2016 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:44:21 2016 -0400

----------------------------------------------------------------------
 .../protocol/openwire/OpenWireConnection.java   |  7 +-
 .../FailoverConsumerOutstandingCommitTest.java  | 88 +++++++++-----------
 .../FailoverConsumerUnconsumedTest.java         | 24 +++---
 .../failover/FailoverDuplicateTest.java         | 12 +--
 .../failover/FailoverPrefetchZeroTest.java      | 11 +--
 .../failover/FailoverTransactionTest.java       | 33 ++++----
 6 files changed, 85 insertions(+), 90 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bc25518b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
index dbbb59f..7c1c094 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
@@ -690,7 +690,12 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
    }
 
    // This will listen for commands throught the protocolmanager
-   class CommandProcessor implements CommandVisitor {
+   public class CommandProcessor implements CommandVisitor {
+
+
+      public AMQConnectionContext getContext() {
+         return OpenWireConnection.this.getContext();
+      }
 
       @Override
       public Response processAddConnection(ConnectionInfo info) throws Exception {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bc25518b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java
index 78a8a0b..705c033 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java
@@ -6,7 +6,7 @@
  * (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
+ * 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,
@@ -40,6 +40,7 @@ import javax.jms.TextMessage;
 import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection;
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext;
 import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
 import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
@@ -55,6 +56,7 @@ import org.junit.Test;
 
 @RunWith(BMUnitRunner.class)
 public class FailoverConsumerOutstandingCommitTest extends OpenwireArtemisBaseTest {
+
    private static final Logger LOG = LoggerFactory.getLogger(FailoverConsumerOutstandingCommitTest.class);
    private static final String QUEUE_NAME = "FailoverWithOutstandingCommit";
    private static final String MESSAGE_TEXT = "Test message ";
@@ -78,22 +80,17 @@ public class FailoverConsumerOutstandingCommitTest extends OpenwireArtemisBaseTe
 
    @Test
    @BMRules(
-      rules = {
-              @BMRule(
-                      name = "set no return response",
-                      targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
-                      targetMethod = "processCommitTransactionOnePhase",
-                      targetLocation = "ENTRY",
-                      binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
-                      action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.holdResponse(context)"),
-              @BMRule(
-                      name = "stop broker before commit",
-                      targetClass = "org.apache.activemq.artemis.core.server.impl.ServerSessionImpl",
-                      targetMethod = "commit",
-                      targetLocation = "ENTRY",
-                      action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.stopServerInTransaction()"),
-      }
-   )
+      rules = {@BMRule(
+         name = "set no return response",
+         targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor",
+         targetMethod = "processCommitTransactionOnePhase",
+         targetLocation = "ENTRY",
+         action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.holdResponse($0)"), @BMRule(
+         name = "stop broker before commit",
+         targetClass = "org.apache.activemq.artemis.core.server.impl.ServerSessionImpl",
+         targetMethod = "commit",
+         targetLocation = "ENTRY",
+         action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.stopServerInTransaction()"),})
    public void testFailoverConsumerDups() throws Exception {
       doTestFailoverConsumerDups(true);
    }
@@ -173,40 +170,37 @@ public class FailoverConsumerOutstandingCommitTest extends OpenwireArtemisBaseTe
 
    @Test
    @BMRules(
-      rules = {
-              @BMRule(
-                      name = "set no return response",
-                      targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
-                      targetMethod = "processCommitTransactionOnePhase",
-                      targetLocation = "ENTRY",
-                      binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
-                      action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.holdResponse(context)"),
-              @BMRule(
-                      name = "stop broker before commit",
-                      targetClass = "org.apache.activemq.artemis.core.server.impl.ServerSessionImpl",
-                      targetMethod = "commit",
-                      targetLocation = "ENTRY",
-                      action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.stopServerInTransaction();return")})
+      rules = {@BMRule(
+         name = "set no return response",
+         targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor",
+         targetMethod = "processCommitTransactionOnePhase",
+         targetLocation = "ENTRY",
+         binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
+         action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.holdResponse($0)"),
+
+         @BMRule(
+         name = "stop broker before commit",
+         targetClass = "org.apache.activemq.artemis.core.server.impl.ServerSessionImpl",
+         targetMethod = "commit",
+         targetLocation = "ENTRY",
+         action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.stopServerInTransaction();return")})
    public void TestFailoverConsumerOutstandingSendTxIncomplete() throws Exception {
       doTestFailoverConsumerOutstandingSendTx(false);
    }
 
    @Test
    @BMRules(
-      rules = {
-              @BMRule(
-                      name = "set no return response",
-                      targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
-                      targetMethod = "processCommitTransactionOnePhase",
-                      targetLocation = "ENTRY",
-                      binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
-                      action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.holdResponse(context)"),
-              @BMRule(
-                      name = "stop broker after commit",
-                      targetClass = "org.apache.activemq.artemis.core.server.impl.ServerSessionImpl",
-                      targetMethod = "commit",
-                      targetLocation = "AT EXIT",
-                      action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.stopServerInTransaction()")})
+      rules = {@BMRule(
+         name = "set no return response",
+         targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor",
+         targetMethod = "processCommitTransactionOnePhase",
+         targetLocation = "ENTRY",
+         action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.holdResponse($0)"), @BMRule(
+         name = "stop broker after commit",
+         targetClass = "org.apache.activemq.artemis.core.server.impl.ServerSessionImpl",
+         targetMethod = "commit",
+         targetLocation = "AT EXIT",
+         action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.stopServerInTransaction()")})
    public void TestFailoverConsumerOutstandingSendTxComplete() throws Exception {
       doTestFailoverConsumerOutstandingSendTx(true);
    }
@@ -362,9 +356,9 @@ public class FailoverConsumerOutstandingCommitTest extends OpenwireArtemisBaseTe
       producer.close();
    }
 
-   public static void holdResponse(AMQConnectionContext context) {
+   public static void holdResponse(OpenWireConnection.CommandProcessor context) {
       if (doByteman.get()) {
-         context.setDontSendReponse(true);
+         context.getContext().setDontSendReponse(true);
       }
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bc25518b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerUnconsumedTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerUnconsumedTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerUnconsumedTest.java
index 75c27d7..10927f2 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerUnconsumedTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerUnconsumedTest.java
@@ -40,6 +40,7 @@ import org.apache.activemq.ActiveMQMessageConsumer;
 import org.apache.activemq.ActiveMQMessageTransformation;
 import org.apache.activemq.ActiveMQSession;
 import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection;
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext;
 import org.apache.activemq.artemis.core.server.impl.QueueImpl;
 import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
@@ -92,11 +93,10 @@ public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest {
            rules = {
                    @BMRule(
                            name = "set no return response and stop the broker",
-                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor",
                            targetMethod = "processAddConsumer",
                            targetLocation = "ENTRY",
-                           binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
-                           action = "org.apache.activemq.transport.failover.FailoverConsumerUnconsumedTest.holdResponseAndStopBroker2(context)")
+                           action = "org.apache.activemq.transport.failover.FailoverConsumerUnconsumedTest.holdResponseAndStopBroker2($0)")
            }
    )
    public void testFailoverConsumerDups() throws Exception {
@@ -109,11 +109,10 @@ public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest {
            rules = {
                    @BMRule(
                            name = "set no return response and stop the broker",
-                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor",
                            targetMethod = "processAddConsumer",
                            targetLocation = "ENTRY",
-                           binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
-                           action = "org.apache.activemq.transport.failover.FailoverConsumerUnconsumedTest.holdResponseAndStopBroker2(context)")
+                           action = "org.apache.activemq.transport.failover.FailoverConsumerUnconsumedTest.holdResponseAndStopBroker2($0)")
            }
    )
    public void testFailoverConsumerDupsNoAdvisoryWatch() throws Exception {
@@ -127,11 +126,10 @@ public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest {
            rules = {
                    @BMRule(
                            name = "set no return response and stop the broker",
-                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor",
                            targetMethod = "processAddConsumer",
                            targetLocation = "ENTRY",
-                           binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
-                           action = "org.apache.activemq.transport.failover.FailoverConsumerUnconsumedTest.holdResponseAndStopBroker(context)")
+                           action = "org.apache.activemq.transport.failover.FailoverConsumerUnconsumedTest.holdResponseAndStopBroker($0)")
            }
    )
    public void testFailoverClientAckMissingRedelivery() throws Exception {
@@ -362,10 +360,10 @@ public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest {
       return idGen;
    }
 
-   public static void holdResponseAndStopBroker(AMQConnectionContext context) {
+   public static void holdResponseAndStopBroker(OpenWireConnection.CommandProcessor context) {
       if (doByteman.get()) {
          if (consumerCount.incrementAndGet() == maxConsumers) {
-            context.setDontSendReponse(true);
+            context.getContext().setDontSendReponse(true);
             Executors.newSingleThreadExecutor().execute(new Runnable() {
                public void run() {
                   try {
@@ -381,10 +379,10 @@ public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest {
       }
    }
 
-   public static void holdResponseAndStopBroker2(AMQConnectionContext context) {
+   public static void holdResponseAndStopBroker2(OpenWireConnection.CommandProcessor context) {
       if (doByteman.get()) {
          if (consumerCount.incrementAndGet() == maxConsumers + (watchTopicAdvisories.get() ? 1 : 0)) {
-            context.setDontSendReponse(true);
+            context.getContext().setDontSendReponse(true);
             Executors.newSingleThreadExecutor().execute(new Runnable() {
                public void run() {
                   try {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bc25518b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverDuplicateTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverDuplicateTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverDuplicateTest.java
index e801b3c..89d006a 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverDuplicateTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverDuplicateTest.java
@@ -33,6 +33,7 @@ import javax.jms.Session;
 import javax.jms.TextMessage;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection;
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext;
 import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
 import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
@@ -93,11 +94,10 @@ public class FailoverDuplicateTest extends OpenwireArtemisBaseTest {
            rules = {
                    @BMRule(
                            name = "set no return response and stop the broker",
-                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor",
                            targetMethod = "processMessage",
                            targetLocation = "EXIT",
-                           binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
-                           action = "org.apache.activemq.transport.failover.FailoverDuplicateTest.holdResponseAndStopConn(context)")
+                           action = "org.apache.activemq.transport.failover.FailoverDuplicateTest.holdResponseAndStopConn($0)")
            }
    )
    public void testFailoverSendReplyLost() throws Exception {
@@ -211,10 +211,10 @@ public class FailoverDuplicateTest extends OpenwireArtemisBaseTest {
       producer.close();
    }
 
-   public static void holdResponseAndStopConn(final AMQConnectionContext context) {
+   public static void holdResponseAndStopConn(final OpenWireConnection.CommandProcessor context) {
       if (doByteman.get()) {
          if (first.compareAndSet(false, true)) {
-            context.setDontSendReponse(true);
+            context.getContext().setDontSendReponse(true);
             Executors.newSingleThreadExecutor().execute(new Runnable() {
                @Override
                public void run() {
@@ -223,7 +223,7 @@ public class FailoverDuplicateTest extends OpenwireArtemisBaseTest {
                      Assert.assertTrue("message received on time", gotMessageLatch.await(60, TimeUnit.SECONDS));
                      Assert.assertTrue("new producers done on time", producersDone.await(120, TimeUnit.SECONDS));
                      LOG.info("Stopping connection post send and receive and multiple producers");
-                     context.getConnection().fail(null, "test Failoverduplicatetest");
+                     context.getContext().getConnection().fail(null, "test Failoverduplicatetest");
                   }
                   catch (Exception e) {
                      e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bc25518b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPrefetchZeroTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPrefetchZeroTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPrefetchZeroTest.java
index fcb60e5..5981845 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPrefetchZeroTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPrefetchZeroTest.java
@@ -31,6 +31,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection;
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext;
 import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
 import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
@@ -77,11 +78,10 @@ public class FailoverPrefetchZeroTest extends OpenwireArtemisBaseTest {
    @BMRules(
       rules = {@BMRule(
          name = "set no return response and stop the broker",
-         targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+         targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor",
          targetMethod = "processMessagePull",
          targetLocation = "ENTRY",
-         binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
-         action = "org.apache.activemq.transport.failover.FailoverPrefetchZeroTest.holdResponseAndStopBroker(context)")})
+         action = "org.apache.activemq.transport.failover.FailoverPrefetchZeroTest.holdResponseAndStopBroker($0)")})
    public void testPrefetchZeroConsumerThroughRestart() throws Exception {
       broker = createBroker();
       broker.start();
@@ -141,9 +141,10 @@ public class FailoverPrefetchZeroTest extends OpenwireArtemisBaseTest {
       producer.close();
    }
 
-   public static void holdResponseAndStopBroker(final AMQConnectionContext context) {
+   public static void holdResponseAndStopBroker(final OpenWireConnection.CommandProcessor context) {
+      new Exception("trace").printStackTrace();
       if (doByteman.get()) {
-         context.setDontSendReponse(true);
+         context.getContext().setDontSendReponse(true);
          pullDone.countDown();
          Executors.newSingleThreadExecutor().execute(new Runnable() {
             public void run() {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bc25518b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
index c129791..a3e023a 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
@@ -20,6 +20,7 @@ import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.ActiveMQMessageConsumer;
 import org.apache.activemq.AutoFailTestSupport;
+import org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection;
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext;
 import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
 import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
@@ -137,11 +138,10 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
            rules = {
                    @BMRule(
                            name = "set no return response and stop the broker",
-                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor",
                            targetMethod = "processCommitTransactionOnePhase",
                            targetLocation = "EXIT",
-                           binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
-                           action = "org.apache.activemq.transport.failover.FailoverTransactionTest.holdResponseAndStopBroker(context)")
+                           action = "org.apache.activemq.transport.failover.FailoverTransactionTest.holdResponseAndStopBroker($0)")
            }
    )
    public void testFailoverCommitReplyLost() throws Exception {
@@ -233,11 +233,11 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
            rules = {
                    @BMRule(
                            name = "set no return response and stop the broker",
-                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor",
                            targetMethod = "processMessage",
                            targetLocation = "EXIT",
                            binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
-                           action = "org.apache.activemq.transport.failover.FailoverTransactionTest.holdResponseAndStopBroker(context)")
+                           action = "org.apache.activemq.transport.failover.FailoverTransactionTest.holdResponseAndStopBroker($0)")
            }
    )
    public void testFailoverSendReplyLost() throws Exception {
@@ -318,11 +318,10 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
            rules = {
                    @BMRule(
                            name = "set no return response and stop the broker",
-                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor",
                            targetMethod = "processMessage",
                            targetLocation = "EXIT",
-                           binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
-                           action = "org.apache.activemq.transport.failover.FailoverTransactionTest.holdResponseAndStopProxyOnFirstSend(context)")
+                           action = "org.apache.activemq.transport.failover.FailoverTransactionTest.holdResponseAndStopProxyOnFirstSend($0)")
            }
    )
    public void testFailoverConnectionSendReplyLost() throws Exception {
@@ -515,11 +514,10 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
            rules = {
                    @BMRule(
                            name = "set no return response and stop the broker",
-                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor",
                            targetMethod = "processMessageAck",
                            targetLocation = "ENTRY",
-                           binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
-                           action = "org.apache.activemq.transport.failover.FailoverTransactionTest.holdResponseAndStopBroker(context)")
+                           action = "org.apache.activemq.transport.failover.FailoverTransactionTest.holdResponseAndStopBroker($0)")
            }
    )
    public void testFailoverConsumerAckLost() throws Exception {
@@ -683,11 +681,10 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
            rules = {
                    @BMRule(
                            name = "set no return response and stop the broker",
-                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor",
                            targetMethod = "processRemoveConsumer",
                            targetLocation = "ENTRY",
-                           binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
-                           action = "org.apache.activemq.transport.failover.FailoverTransactionTest.stopBrokerOnCounter(context)")
+                           action = "org.apache.activemq.transport.failover.FailoverTransactionTest.stopBrokerOnCounter($0)")
            }
    )
    public void testPoolingNConsumesAfterReconnect() throws Exception {
@@ -975,9 +972,9 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
       producer.close();
    }
 
-   public static void holdResponseAndStopBroker(final AMQConnectionContext context) {
+   public static void holdResponseAndStopBroker(final OpenWireConnection.CommandProcessor context) {
       if (doByteman.get()) {
-         context.setDontSendReponse(true);
+         context.getContext().setDontSendReponse(true);
          Executors.newSingleThreadExecutor().execute(new Runnable() {
             public void run() {
                LOG.info("Stopping broker post commit...");
@@ -995,11 +992,11 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
       }
    }
 
-   public static void holdResponseAndStopProxyOnFirstSend(final AMQConnectionContext context) {
+   public static void holdResponseAndStopProxyOnFirstSend(final OpenWireConnection.CommandProcessor context) {
       if (doByteman.get()) {
          if (firstSend) {
             firstSend = false;
-            context.setDontSendReponse(true);
+            context.getContext().setDontSendReponse(true);
             Executors.newSingleThreadExecutor().execute(new Runnable() {
                public void run() {
                   LOG.info("Stopping connection post send...");


[05/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/AMQ1925Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/AMQ1925Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/AMQ1925Test.java
index f80b09a..3d75905 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/AMQ1925Test.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/AMQ1925Test.java
@@ -20,7 +20,6 @@ import java.io.IOException;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicBoolean;
 
@@ -34,22 +33,26 @@ import javax.jms.MessageProducer;
 import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.jms.TransactionRolledBackException;
-
-import junit.framework.TestCase;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.TransportConnector;
-import org.apache.activemq.broker.region.Destination;
-import org.apache.activemq.broker.region.Queue;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.util.ServiceStopper;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.server.impl.QueueImpl;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
 import org.apache.log4j.Logger;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * TestCase showing the message-destroying described in AMQ-1925
  */
-public class AMQ1925Test extends TestCase implements ExceptionListener {
+public class AMQ1925Test extends OpenwireArtemisBaseTest implements ExceptionListener {
 
    private static final Logger log = Logger.getLogger(AMQ1925Test.class);
 
@@ -57,7 +60,7 @@ public class AMQ1925Test extends TestCase implements ExceptionListener {
    private static final String PROPERTY_MSG_NUMBER = "NUMBER";
    private static final int MESSAGE_COUNT = 10000;
 
-   private BrokerService bs;
+   private EmbeddedJMS bs;
    private URI tcpUri;
    private ActiveMQConnectionFactory cf;
 
@@ -74,17 +77,13 @@ public class AMQ1925Test extends TestCase implements ExceptionListener {
       final CountDownLatch starter = new CountDownLatch(1);
       final AtomicBoolean restarted = new AtomicBoolean();
       new Thread(new Runnable() {
-         @Override
          public void run() {
             try {
                starter.await();
 
                // Simulate broker failure & restart
                bs.stop();
-               bs = new BrokerService();
-               bs.setPersistent(true);
-               bs.setUseJmx(true);
-               bs.addConnector(tcpUri);
+               bs = createNewServer();
                bs.start();
 
                restarted.set(true);
@@ -97,21 +96,21 @@ public class AMQ1925Test extends TestCase implements ExceptionListener {
 
       for (int i = 0; i < MESSAGE_COUNT; i++) {
          Message message = consumer.receive(500);
-         assertNotNull("No Message " + i + " found", message);
+         Assert.assertNotNull("No Message " + i + " found", message);
 
          if (i < 10)
-            assertFalse("Timing problem, restarted too soon", restarted.get());
+            Assert.assertFalse("Timing problem, restarted too soon", restarted.get());
          if (i == 10) {
             starter.countDown();
          }
          if (i > MESSAGE_COUNT - 100) {
-            assertTrue("Timing problem, restarted too late", restarted.get());
+            Assert.assertTrue("Timing problem, restarted too late", restarted.get());
          }
 
-         assertEquals(i, message.getIntProperty(PROPERTY_MSG_NUMBER));
+         Assert.assertEquals(i, message.getIntProperty(PROPERTY_MSG_NUMBER));
          session.commit();
       }
-      assertNull(consumer.receive(500));
+      Assert.assertNull(consumer.receive(500));
 
       consumer.close();
       session.close();
@@ -133,17 +132,13 @@ public class AMQ1925Test extends TestCase implements ExceptionListener {
       final CountDownLatch starter = new CountDownLatch(1);
       final AtomicBoolean restarted = new AtomicBoolean();
       new Thread(new Runnable() {
-         @Override
          public void run() {
             try {
                starter.await();
 
                // Simulate broker failure & restart
                bs.stop();
-               bs = new BrokerService();
-               bs.setPersistent(true);
-               bs.setUseJmx(true);
-               bs.addConnector(tcpUri);
+               bs = createNewServer();
                bs.start();
 
                restarted.set(true);
@@ -172,12 +167,12 @@ public class AMQ1925Test extends TestCase implements ExceptionListener {
          }
 
          if (i < 10)
-            assertFalse("Timing problem, restarted too soon", restarted.get());
+            Assert.assertFalse("Timing problem, restarted too soon", restarted.get());
          if (i == 10) {
             starter.countDown();
          }
          if (i > MESSAGE_COUNT - 50) {
-            assertTrue("Timing problem, restarted too late", restarted.get());
+            Assert.assertTrue("Timing problem, restarted too late", restarted.get());
          }
 
          if (message1 != null) {
@@ -189,8 +184,8 @@ public class AMQ1925Test extends TestCase implements ExceptionListener {
             session2.commit();
          }
       }
-      assertNull(consumer1.receive(500));
-      assertNull(consumer2.receive(500));
+      Assert.assertNull(consumer1.receive(500));
+      Assert.assertNull(consumer2.receive(500));
 
       consumer1.close();
       session1.close();
@@ -203,7 +198,7 @@ public class AMQ1925Test extends TestCase implements ExceptionListener {
          foundMissingMessages = tryToFetchMissingMessages();
       }
       for (int i = 0; i < MESSAGE_COUNT; i++) {
-         assertTrue("Message-Nr " + i + " not found (" + results.size() + " total, " + foundMissingMessages + " have been found 'lingering' in the queue)", results.contains(i));
+         Assert.assertTrue("Message-Nr " + i + " not found (" + results.size() + " total, " + foundMissingMessages + " have been found 'lingering' in the queue)", results.contains(i));
       }
       assertQueueEmpty();
    }
@@ -231,6 +226,7 @@ public class AMQ1925Test extends TestCase implements ExceptionListener {
       return count;
    }
 
+   @Test
    public void testAMQ1925_TXBegin() throws Exception {
       Connection connection = cf.createConnection();
       connection.start();
@@ -241,20 +237,17 @@ public class AMQ1925Test extends TestCase implements ExceptionListener {
       boolean restartDone = false;
       for (int i = 0; i < MESSAGE_COUNT; i++) {
          Message message = consumer.receive(5000);
-         assertNotNull(message);
+         Assert.assertNotNull(message);
 
          if (i == 222 && !restartDone) {
             // Simulate broker failure & restart
             bs.stop();
-            bs = new BrokerService();
-            bs.setPersistent(true);
-            bs.setUseJmx(true);
-            bs.addConnector(tcpUri);
+            bs = createNewServer();
             bs.start();
             restartDone = true;
          }
 
-         assertEquals(i, message.getIntProperty(PROPERTY_MSG_NUMBER));
+         Assert.assertEquals(i, message.getIntProperty(PROPERTY_MSG_NUMBER));
          try {
             session.commit();
          }
@@ -263,16 +256,17 @@ public class AMQ1925Test extends TestCase implements ExceptionListener {
             i--;
          }
       }
-      assertNull(consumer.receive(500));
+      Assert.assertNull(consumer.receive(500));
 
       consumer.close();
       session.close();
       connection.close();
 
       assertQueueEmpty();
-      assertNull("no exception on connection listener: " + exception, exception);
+      Assert.assertNull("no exception on connection listener: " + exception, exception);
    }
 
+   @Test
    public void testAMQ1925_TXCommited() throws Exception {
       Connection connection = cf.createConnection();
       connection.start();
@@ -281,22 +275,19 @@ public class AMQ1925Test extends TestCase implements ExceptionListener {
 
       for (int i = 0; i < MESSAGE_COUNT; i++) {
          Message message = consumer.receive(5000);
-         assertNotNull(message);
+         Assert.assertNotNull(message);
 
-         assertEquals(i, message.getIntProperty(PROPERTY_MSG_NUMBER));
+         Assert.assertEquals(i, message.getIntProperty(PROPERTY_MSG_NUMBER));
          session.commit();
 
          if (i == 222) {
             // Simulate broker failure & restart
             bs.stop();
-            bs = new BrokerService();
-            bs.setPersistent(true);
-            bs.setUseJmx(true);
-            bs.addConnector(tcpUri);
+            bs = createNewServer();
             bs.start();
          }
       }
-      assertNull(consumer.receive(500));
+      Assert.assertNull(consumer.receive(500));
 
       consumer.close();
       session.close();
@@ -313,7 +304,7 @@ public class AMQ1925Test extends TestCase implements ExceptionListener {
 
       Message msg = consumer.receive(500);
       if (msg != null) {
-         fail(msg.toString());
+         Assert.fail(msg.toString());
       }
 
       consumer.close();
@@ -324,9 +315,12 @@ public class AMQ1925Test extends TestCase implements ExceptionListener {
    }
 
    private void assertQueueLength(int len) throws Exception, IOException {
-      Set<Destination> destinations = bs.getBroker().getDestinations(new ActiveMQQueue(QUEUE_NAME));
-      Queue queue = (Queue) destinations.iterator().next();
-      assertEquals(len, queue.getMessageStore().getMessageCount());
+      QueueImpl queue = (QueueImpl) bs.getActiveMQServer().getPostOffice().getBinding(new SimpleString("jms.queue." + QUEUE_NAME)).getBindable();
+      if (len > queue.getMessageCount()) {
+         //we wait for a moment as the tx might still in afterCommit stage (async op)
+         Thread.sleep(5000);
+      }
+      Assert.assertEquals(len, queue.getMessageCount());
    }
 
    private void sendMessagesToQueue() throws Exception {
@@ -349,30 +343,41 @@ public class AMQ1925Test extends TestCase implements ExceptionListener {
       assertQueueLength(MESSAGE_COUNT);
    }
 
-   @Override
-   protected void setUp() throws Exception {
+   @Before
+   public void setUp() throws Exception {
       exception = null;
-      bs = new BrokerService();
-      bs.setDeleteAllMessagesOnStartup(true);
-      bs.setPersistent(true);
-      bs.setUseJmx(true);
-      TransportConnector connector = bs.addConnector("tcp://localhost:0");
+      bs = createNewServer();
       bs.start();
-      tcpUri = connector.getConnectUri();
+      //auto created queue can't survive a restart, so we need this
+      bs.getJMSServerManager().createQueue(false, QUEUE_NAME, null, true, QUEUE_NAME);
+
+      tcpUri = new URI(newURI(0));
 
       cf = new ActiveMQConnectionFactory("failover://(" + tcpUri + ")");
 
       sendMessagesToQueue();
    }
 
-   @Override
-   protected void tearDown() throws Exception {
-      new ServiceStopper().stop(bs);
+   @After
+   public void tearDown() throws Exception {
+      try {
+         if (bs != null) {
+            bs.stop();
+            bs = null;
+         }
+      } catch (Exception e) {
+         log.error(e);
+      }
+
    }
 
-   @Override
    public void onException(JMSException exception) {
       this.exception = exception;
    }
 
+   private EmbeddedJMS createNewServer() throws Exception {
+      Configuration config = createConfig("localhost", 0);
+      EmbeddedJMS server = new EmbeddedJMS().setConfiguration(config).setJmsConfiguration(new JMSConfigurationImpl());
+      return server;
+   }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/BadConnectionTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/BadConnectionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/BadConnectionTest.java
deleted file mode 100644
index 8cac09a..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/BadConnectionTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * 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.failover;
-
-import java.io.IOException;
-import java.net.URI;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.command.ActiveMQMessage;
-import org.apache.activemq.transport.Transport;
-import org.apache.activemq.transport.TransportFactory;
-import org.apache.activemq.transport.TransportListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- *
- */
-public class BadConnectionTest extends TestCase {
-
-   private static final Logger LOG = LoggerFactory.getLogger(BadConnectionTest.class);
-
-   protected Transport transport;
-
-   public void testConnectingToUnavailableServer() throws Exception {
-      try {
-         transport.asyncRequest(new ActiveMQMessage(), null);
-         fail("This should never succeed");
-      }
-      catch (IOException e) {
-         LOG.info("Caught expected exception: " + e, e);
-      }
-   }
-
-   protected Transport createTransport() throws Exception {
-      return TransportFactory.connect(new URI("failover://(tcp://doesNotExist:1234)?useExponentialBackOff=false&maxReconnectAttempts=3&initialReconnectDelay=100"));
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      transport = createTransport();
-      transport.setTransportListener(new TransportListener() {
-
-         @Override
-         public void onCommand(Object command) {
-         }
-
-         @Override
-         public void onException(IOException error) {
-         }
-
-         @Override
-         public void transportInterupted() {
-         }
-
-         @Override
-         public void transportResumed() {
-         }
-      });
-      transport.start();
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      if (transport != null) {
-         transport.stop();
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ClusterUtil.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ClusterUtil.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ClusterUtil.java
new file mode 100644
index 0000000..42f199f
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ClusterUtil.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.transport.failover;
+
+/**
+ * Utilities to create broker clusters
+ */
+public class ClusterUtil {
+
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ConnectionHangOnStartupTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ConnectionHangOnStartupTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ConnectionHangOnStartupTest.java
index 110e2fc..f40ee4f 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ConnectionHangOnStartupTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ConnectionHangOnStartupTest.java
@@ -22,18 +22,19 @@ import java.util.concurrent.atomic.AtomicReference;
 import javax.jms.Connection;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.xbean.BrokerFactoryBean;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
 import org.junit.After;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.core.io.ClassPathResource;
 
 /**
  * Tests for AMQ-3719
  */
-public class ConnectionHangOnStartupTest {
+public class ConnectionHangOnStartupTest extends OpenwireArtemisBaseTest {
 
    private static final Logger LOG = LoggerFactory.getLogger(ConnectionHangOnStartupTest.class);
 
@@ -41,13 +42,13 @@ public class ConnectionHangOnStartupTest {
    // maxReconnectDelay so that the test runs faster (because it will retry
    // connection sooner)
    protected String uriString = "failover://(tcp://localhost:62001?wireFormat.maxInactivityDurationInitalDelay=1,tcp://localhost:62002?wireFormat.maxInactivityDurationInitalDelay=1)?randomize=false&maxReconnectDelay=200";
-   protected BrokerService master = null;
-   protected AtomicReference<BrokerService> slave = new AtomicReference<>();
+   protected EmbeddedJMS master = null;
+   protected AtomicReference<EmbeddedJMS> slave = new AtomicReference<EmbeddedJMS>();
 
    @After
    public void tearDown() throws Exception {
 
-      BrokerService brokerService = slave.get();
+      EmbeddedJMS brokerService = slave.get();
       if (brokerService != null) {
          brokerService.stop();
       }
@@ -60,28 +61,18 @@ public class ConnectionHangOnStartupTest {
    }
 
    protected void createMaster() throws Exception {
-      BrokerFactoryBean brokerFactory = new BrokerFactoryBean(new ClassPathResource(getMasterXml()));
-      brokerFactory.afterPropertiesSet();
-      master = brokerFactory.getBroker();
+      Configuration config = createConfig("localhost", 0, 62001);
+      master = new EmbeddedJMS().setConfiguration(config).setJmsConfiguration(new JMSConfigurationImpl());
       master.start();
    }
 
    protected void createSlave() throws Exception {
-      BrokerFactoryBean brokerFactory = new BrokerFactoryBean(new ClassPathResource(getSlaveXml()));
-      brokerFactory.afterPropertiesSet();
-      BrokerService broker = brokerFactory.getBroker();
+      Configuration config = createConfig("localhost", 1, 62002);
+      EmbeddedJMS broker = new EmbeddedJMS().setConfiguration(config).setJmsConfiguration(new JMSConfigurationImpl());
       broker.start();
       slave.set(broker);
    }
 
-   protected String getSlaveXml() {
-      return "org/apache/activemq/broker/ft/sharedFileSlave.xml";
-   }
-
-   protected String getMasterXml() {
-      return "org/apache/activemq/broker/ft/sharedFileMaster.xml";
-   }
-
    @Test(timeout = 60000)
    public void testInitialWireFormatNegotiationTimeout() throws Exception {
       final AtomicReference<Connection> conn = new AtomicReference<>();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverBackupLeakTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverBackupLeakTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverBackupLeakTest.java
index cf1d43d..0875a61 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverBackupLeakTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverBackupLeakTest.java
@@ -22,58 +22,59 @@ import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
 import javax.jms.JMSException;
 import javax.jms.Session;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.artemis.api.jms.management.JMSServerControl;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.server.management.ManagementService;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
 import org.apache.activemq.util.Wait;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
 
+import java.util.concurrent.TimeUnit;
+
 /**
  * Ensures connections aren't leaked when when we use backup=true and randomize=false
  */
-public class FailoverBackupLeakTest {
+public class FailoverBackupLeakTest extends OpenwireArtemisBaseTest {
+
+   private EmbeddedJMS s1, s2;
+
+   @Before
+   public void setUp() throws Exception {
 
-   private static BrokerService s1, s2;
+      Configuration config0 = createConfig("127.0.0.1", 0);
+      Configuration config1 = createConfig("127.0.0.1", 1);
 
-   @BeforeClass
-   public static void setUp() throws Exception {
-      s1 = buildBroker("broker1");
-      s2 = buildBroker("broker2");
+      deployClusterConfiguration(config0, 1);
+      deployClusterConfiguration(config1, 0);
 
+      s1 = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
+      s2 = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
       s1.start();
-      s1.waitUntilStarted();
       s2.start();
-      s2.waitUntilStarted();
+
+      Assert.assertTrue(s1.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
+      Assert.assertTrue(s2.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
    }
 
-   @AfterClass
-   public static void tearDown() throws Exception {
+   @After
+   public void tearDown() throws Exception {
       if (s2 != null) {
          s2.stop();
-         s2.waitUntilStopped();
       }
       if (s1 != null) {
          s1.stop();
-         s1.waitUntilStopped();
       }
    }
 
-   private static String getConnectString(BrokerService service) throws Exception {
-      return service.getTransportConnectors().get(0).getPublishableConnectString();
-   }
-
-   private static BrokerService buildBroker(String brokerName) throws Exception {
-      BrokerService service = new BrokerService();
-      service.setBrokerName(brokerName);
-      service.setUseJmx(false);
-      service.setPersistent(false);
-      service.setUseShutdownHook(false);
-      service.addConnector("tcp://0.0.0.0:0?transport.closeAsync=false");
-      return service;
-   }
-
    @Test
    public void backupNoRandomize() throws Exception {
       check("backup=true&randomize=false");
@@ -85,9 +86,12 @@ public class FailoverBackupLeakTest {
    }
 
    private void check(String connectionProperties) throws Exception {
-      String s1URL = getConnectString(s1), s2URL = getConnectString(s2);
+      String s1URL = newURI(0), s2URL = newURI(1);
       String uri = "failover://(" + s1URL + "," + s2URL + ")?" + connectionProperties;
       ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(uri);
+      final int initCount1 = getConnectionCount(s1);
+      final int initCount2 = getConnectionCount(s2);
+
       for (int i = 0; i < 10; i++) {
          buildConnection(factory);
       }
@@ -96,7 +100,7 @@ public class FailoverBackupLeakTest {
 
          @Override
          public boolean isSatisified() throws Exception {
-            return getConnectionCount(s1) == 0;
+            return getConnectionCount(s1) == initCount1;
          }
       }));
 
@@ -104,16 +108,22 @@ public class FailoverBackupLeakTest {
 
          @Override
          public boolean isSatisified() throws Exception {
-            return getConnectionCount(s2) == 0;
+            return getConnectionCount(s2) == initCount2;
          }
       }));
    }
 
-   private int getConnectionCount(BrokerService service) {
-      return service.getTransportConnectors().get(0).getConnections().size();
+   private int getConnectionCount(EmbeddedJMS server) throws Exception {
+      ManagementService managementService = server.getActiveMQServer().getManagementService();
+      JMSServerControl jmsControl = (JMSServerControl) managementService.getResource("jms.server");
+      String[] ids = jmsControl.listConnectionIDs();
+      if (ids != null) {
+         return ids.length;
+      }
+      return 0;
    }
 
-   private void buildConnection(ConnectionFactory local) throws JMSException {
+   private void buildConnection(ConnectionFactory local) throws Exception {
       Connection conn = null;
       Session sess = null;
       try {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.java
index c0c529d..bf43caa 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.java
@@ -16,146 +16,127 @@
  */
 package org.apache.activemq.transport.failover;
 
+import javax.jms.Connection;
+import javax.jms.MessageConsumer;
+import javax.jms.Queue;
+import javax.jms.Session;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-import javax.jms.Connection;
-import javax.jms.MessageConsumer;
-import javax.jms.Queue;
-import javax.jms.Session;
-
-import junit.framework.TestCase;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.TransportConnector;
-import org.apache.activemq.network.NetworkConnector;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
-public class FailoverClusterTest extends TestCase {
+public class FailoverClusterTest extends OpenwireArtemisBaseTest {
 
    private static final int NUMBER = 10;
-   private static final String BROKER_BIND_ADDRESS = "tcp://0.0.0.0:0";
-   private static final String BROKER_A_NAME = "BROKERA";
-   private static final String BROKER_B_NAME = "BROKERB";
-   private BrokerService brokerA;
-   private BrokerService brokerB;
    private String clientUrl;
 
    private final List<ActiveMQConnection> connections = new ArrayList<>();
+   EmbeddedJMS server1;
+   EmbeddedJMS server2;
+
+
+   @Before
+   public void setUp() throws Exception {
+      Configuration config1 = createConfig(1);
+      Configuration config2 = createConfig(2);
+
+      deployClusterConfiguration(config1, 2);
+      deployClusterConfiguration(config2, 1);
+
+      server1 = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
+      server2 = new EmbeddedJMS().setConfiguration(config2).setJmsConfiguration(new JMSConfigurationImpl());
 
+      clientUrl = "failover://(" + newURI(1) + "," + newURI(2) + ")";
+   }
+
+   @After
+   public void tearDown() throws Exception {
+      for (Connection c : connections) {
+         c.close();
+      }
+      server1.stop();
+      server2.stop();
+   }
+
+   @Test
    public void testClusterConnectedAfterClients() throws Exception {
+      server1.start();
       createClients();
-      if (brokerB == null) {
-         brokerB = createBrokerB(BROKER_BIND_ADDRESS);
-      }
-      Thread.sleep(3000);
       Set<String> set = new HashSet<>();
+      server2.start();
+      Assert.assertTrue(server1.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
+      Assert.assertTrue(server2.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
+
+      Thread.sleep(3000);
+
       for (ActiveMQConnection c : connections) {
+         System.out.println("======> adding address: " + c.getTransportChannel().getRemoteAddress());
          set.add(c.getTransportChannel().getRemoteAddress());
       }
-      assertTrue(set.size() > 1);
+      System.out.println("============final size: " + set.size());
+      Assert.assertTrue(set.size() > 1);
    }
 
+   //this test seems the same as the above one as long as artemis broker
+   //is concerned.
+   @Test
    public void testClusterURIOptionsStrip() throws Exception {
+      server1.start();
+
       createClients();
-      if (brokerB == null) {
-         // add in server side only url param, should not be propagated
-         brokerB = createBrokerB(BROKER_BIND_ADDRESS + "?transport.closeAsync=false");
-      }
+      server2.start();
+      Assert.assertTrue(server1.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
+      Assert.assertTrue(server2.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
+
       Thread.sleep(3000);
-      Set<String> set = new HashSet<>();
+
+      Set<String> set = new HashSet<String>();
       for (ActiveMQConnection c : connections) {
          set.add(c.getTransportChannel().getRemoteAddress());
       }
-      assertTrue(set.size() > 1);
+      Assert.assertTrue(set.size() > 1);
    }
 
+   @Test
    public void testClusterConnectedBeforeClients() throws Exception {
 
-      if (brokerB == null) {
-         brokerB = createBrokerB(BROKER_BIND_ADDRESS);
-      }
-      Thread.sleep(5000);
+      server1.start();
+      server2.start();
+      Assert.assertTrue(server1.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
+      Assert.assertTrue(server2.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
+
       createClients();
-      Thread.sleep(2000);
-      brokerA.stop();
-      Thread.sleep(2000);
+      server1.stop();
+      Thread.sleep(1000);
 
-      URI brokerBURI = new URI(brokerB.getTransportConnectors().get(0).getPublishableConnectString());
+      URI brokerBURI = new URI(newURI(2));
       for (ActiveMQConnection c : connections) {
          String addr = c.getTransportChannel().getRemoteAddress();
-         assertTrue(addr.indexOf("" + brokerBURI.getPort()) > 0);
+         Assert.assertTrue(addr.indexOf("" + brokerBURI.getPort()) > 0);
       }
    }
 
-   @Override
-   protected void setUp() throws Exception {
-      if (brokerA == null) {
-         brokerA = createBrokerA(BROKER_BIND_ADDRESS + "?transport.closeAsync=false");
-         clientUrl = "failover://(" + brokerA.getTransportConnectors().get(0).getPublishableConnectString() + ")";
-      }
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      for (Connection c : connections) {
-         c.close();
-      }
-      if (brokerB != null) {
-         brokerB.stop();
-         brokerB = null;
-      }
-      if (brokerA != null) {
-         brokerA.stop();
-         brokerA = null;
-      }
-   }
-
-   protected BrokerService createBrokerA(String uri) throws Exception {
-      BrokerService answer = new BrokerService();
-      answer.setUseJmx(false);
-      configureConsumerBroker(answer, uri);
-      answer.start();
-      return answer;
-   }
-
-   protected void configureConsumerBroker(BrokerService answer, String uri) throws Exception {
-      answer.setBrokerName(BROKER_A_NAME);
-      answer.setPersistent(false);
-      TransportConnector connector = answer.addConnector(uri);
-      connector.setRebalanceClusterClients(true);
-      connector.setUpdateClusterClients(true);
-      answer.setUseShutdownHook(false);
-   }
-
-   protected BrokerService createBrokerB(String uri) throws Exception {
-      BrokerService answer = new BrokerService();
-      answer.setUseJmx(false);
-      configureNetwork(answer, uri);
-      answer.start();
-      return answer;
-   }
-
-   protected void configureNetwork(BrokerService answer, String uri) throws Exception {
-      answer.setBrokerName(BROKER_B_NAME);
-      answer.setPersistent(false);
-      NetworkConnector network = answer.addNetworkConnector("static://" + brokerA.getTransportConnectors().get(0).getPublishableConnectString());
-      network.setDuplex(true);
-      TransportConnector connector = answer.addConnector(uri);
-      connector.setRebalanceClusterClients(true);
-      connector.setUpdateClusterClients(true);
-      answer.setUseShutdownHook(false);
-   }
-
-   @SuppressWarnings("unused")
    protected void createClients() throws Exception {
       ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(clientUrl);
       for (int i = 0; i < NUMBER; i++) {
+         System.out.println("*****create connection using url: " + clientUrl);
          ActiveMQConnection c = (ActiveMQConnection) factory.createConnection();
+         System.out.println("got connection, starting it ...");
          c.start();
+         System.out.println("******Started");
          Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
          Queue queue = s.createQueue(getClass().getName());
          MessageConsumer consumer = s.createConsumer(queue);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java
index 53f0689..1d902e3 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java
@@ -16,7 +16,29 @@
  */
 package org.apache.activemq.transport.failover;
 
-import org.apache.activemq.broker.TransportConnector;
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.activemq.ActiveMQConnection;
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * Complex cluster test that will exercise the dynamic failover capabilities of
@@ -25,36 +47,71 @@ import org.apache.activemq.broker.TransportConnector;
  * connections on the client should start with 3, then have two after the 3rd
  * broker is removed and then show 3 after the 3rd broker is reintroduced.
  */
-public class FailoverComplexClusterTest extends FailoverClusterTestSupport {
+public class FailoverComplexClusterTest extends OpenwireArtemisBaseTest {
 
    private static final String BROKER_A_CLIENT_TC_ADDRESS = "tcp://127.0.0.1:61616";
    private static final String BROKER_B_CLIENT_TC_ADDRESS = "tcp://127.0.0.1:61617";
-   private static final String BROKER_C_CLIENT_TC_ADDRESS = "tcp://127.0.0.1:61618";
-   private static final String BROKER_A_NOB_TC_ADDRESS = "tcp://127.0.0.1:61626";
-   private static final String BROKER_B_NOB_TC_ADDRESS = "tcp://127.0.0.1:61627";
-   private static final String BROKER_C_NOB_TC_ADDRESS = "tcp://127.0.0.1:61628";
-   private static final String BROKER_A_NAME = "BROKERA";
-   private static final String BROKER_B_NAME = "BROKERB";
-   private static final String BROKER_C_NAME = "BROKERC";
+
+   private String clientUrl;
+   private EmbeddedJMS[] servers = new EmbeddedJMS[3];
+
+   private static final int NUMBER_OF_CLIENTS = 30;
+   private final List<ActiveMQConnection> connections = new ArrayList<ActiveMQConnection>();
+
+
+   @Before
+   public void setUp() throws Exception {
+   }
+
+   //default setup for most tests
+   private void commonSetup() throws Exception {
+      Configuration config0 = createConfig(0);
+      Configuration config1 = createConfig(1);
+      Configuration config2 = createConfig(2);
+
+      deployClusterConfiguration(config0, 1, 2);
+      deployClusterConfiguration(config1, 0, 2);
+      deployClusterConfiguration(config2, 0, 1);
+
+      servers[0] = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
+      servers[1] = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
+      servers[2] = new EmbeddedJMS().setConfiguration(config2).setJmsConfiguration(new JMSConfigurationImpl());
+
+      servers[0].start();
+      servers[1].start();
+      servers[2].start();
+
+      Assert.assertTrue(servers[0].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 3));
+      Assert.assertTrue(servers[1].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 3));
+      Assert.assertTrue(servers[2].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 3));
+   }
+
+   @After
+   public void tearDown() throws Exception {
+      shutdownClients();
+      for (EmbeddedJMS server : servers) {
+         if (server != null) {
+            server.stop();
+         }
+      }
+   }
 
    /**
     * Basic dynamic failover 3 broker test
     *
     * @throws Exception
     */
+   @Test
    public void testThreeBrokerClusterSingleConnectorBasic() throws Exception {
-
-      initSingleTcBroker("", null, null);
-
-      Thread.sleep(2000);
-
+      commonSetup();
       setClientUrl("failover://(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + ")");
       createClients();
-      Thread.sleep(2000);
 
+      Thread.sleep(3000);
       runTests(false, null, null, null);
    }
 
+
    /**
     * Tests a 3 broker configuration to ensure that the backup is random and
     * supported in a cluster. useExponentialBackOff is set to false and
@@ -63,10 +120,9 @@ public class FailoverComplexClusterTest extends FailoverClusterTestSupport {
     *
     * @throws Exception
     */
+   @Test
    public void testThreeBrokerClusterSingleConnectorBackupFailoverConfig() throws Exception {
-
-      initSingleTcBroker("", null, null);
-
+      commonSetup();
       Thread.sleep(2000);
 
       setClientUrl("failover://(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + ")?backup=true&backupPoolSize=2&useExponentialBackOff=false&initialReconnectDelay=500");
@@ -84,10 +140,9 @@ public class FailoverComplexClusterTest extends FailoverClusterTestSupport {
     *
     * @throws Exception
     */
+   @Test
    public void testThreeBrokerClusterSingleConnectorWithParams() throws Exception {
-
-      initSingleTcBroker("?transport.closeAsync=false", null, null);
-
+      commonSetup();
       Thread.sleep(2000);
       setClientUrl("failover://(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + ")");
       createClients();
@@ -101,10 +156,9 @@ public class FailoverComplexClusterTest extends FailoverClusterTestSupport {
     *
     * @throws Exception
     */
+   @Test
    public void testThreeBrokerClusterWithClusterFilter() throws Exception {
-
-      initSingleTcBroker("?transport.closeAsync=false", null, null);
-
+      commonSetup();
       Thread.sleep(2000);
       setClientUrl("failover://(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + ")");
       createClients();
@@ -118,10 +172,9 @@ public class FailoverComplexClusterTest extends FailoverClusterTestSupport {
     *
     * @throws Exception
     */
+   @Test
    public void testThreeBrokerClusterMultipleConnectorBasic() throws Exception {
-
-      initMultiTcCluster("", null);
-
+      commonSetup();
       Thread.sleep(2000);
 
       setClientUrl("failover://(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + ")");
@@ -136,9 +189,9 @@ public class FailoverComplexClusterTest extends FailoverClusterTestSupport {
     *
     * @throws Exception
     */
+   @Test
    public void testOriginalBrokerRestart() throws Exception {
-      initSingleTcBroker("", null, null);
-
+      commonSetup();
       Thread.sleep(2000);
 
       setClientUrl("failover://(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + ")");
@@ -147,16 +200,13 @@ public class FailoverComplexClusterTest extends FailoverClusterTestSupport {
 
       assertClientsConnectedToThreeBrokers();
 
-      getBroker(BROKER_A_NAME).stop();
-      getBroker(BROKER_A_NAME).waitUntilStopped();
-      removeBroker(BROKER_A_NAME);
+      stopServer(0);
 
       Thread.sleep(5000);
 
       assertClientsConnectedToTwoBrokers();
 
-      createBrokerA(false, null, null, null);
-      getBroker(BROKER_A_NAME).waitUntilStarted();
+      restartServer(0);
       Thread.sleep(5000);
 
       assertClientsConnectedToThreeBrokers();
@@ -168,10 +218,9 @@ public class FailoverComplexClusterTest extends FailoverClusterTestSupport {
     *
     * @throws Exception
     */
+   @Test
    public void testThreeBrokerClusterClientDistributions() throws Exception {
-
-      initSingleTcBroker("", null, null);
-
+      commonSetup();
       Thread.sleep(2000);
       setClientUrl("failover://(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=false&initialReconnectDelay=500");
       createClients(100);
@@ -186,10 +235,9 @@ public class FailoverComplexClusterTest extends FailoverClusterTestSupport {
     *
     * @throws Exception
     */
+   @Test
    public void testThreeBrokerClusterDestinationFilter() throws Exception {
-
-      initSingleTcBroker("", null, null);
-
+      commonSetup();
       Thread.sleep(2000);
       setClientUrl("failover://(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + ")");
       createClients();
@@ -197,28 +245,25 @@ public class FailoverComplexClusterTest extends FailoverClusterTestSupport {
       runTests(false, null, null, "Queue.TEST.FOO.>");
    }
 
+   @Test
    public void testFailOverWithUpdateClientsOnRemove() throws Exception {
       // Broker A
-      addBroker(BROKER_A_NAME, createBroker(BROKER_A_NAME));
-      TransportConnector connectorA = getBroker(BROKER_A_NAME).addConnector(BROKER_A_CLIENT_TC_ADDRESS);
-      connectorA.setName("openwire");
-      connectorA.setRebalanceClusterClients(true);
-      connectorA.setUpdateClusterClients(true);
-      connectorA.setUpdateClusterClientsOnRemove(true); //If set to false the test succeeds.
-      addNetworkBridge(getBroker(BROKER_A_NAME), "A_2_B_Bridge", "static://(" + BROKER_B_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=false", false, null);
-      getBroker(BROKER_A_NAME).start();
-
+      Configuration config0 = createConfig(0, "?rebalance-cluster-client=true&update-cluster-clients=true&update-cluster-clients-on-remove=true");
       // Broker B
-      addBroker(BROKER_B_NAME, createBroker(BROKER_B_NAME));
-      TransportConnector connectorB = getBroker(BROKER_B_NAME).addConnector(BROKER_B_CLIENT_TC_ADDRESS);
-      connectorB.setName("openwire");
-      connectorB.setRebalanceClusterClients(true);
-      connectorB.setUpdateClusterClients(true);
-      connectorB.setUpdateClusterClientsOnRemove(true); //If set to false the test succeeds.
-      addNetworkBridge(getBroker(BROKER_B_NAME), "B_2_A_Bridge", "static://(" + BROKER_A_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=false", false, null);
-      getBroker(BROKER_B_NAME).start();
-
-      getBroker(BROKER_B_NAME).waitUntilStarted();
+      Configuration config1 = createConfig(1, "?rebalance-cluster-client=true&update-cluster-clients=true&update-cluster-clients-on-remove=true");
+
+      deployClusterConfiguration(config0, 1);
+      deployClusterConfiguration(config1, 0);
+
+      servers[0] = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
+      servers[0].start();
+
+      servers[1] = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
+      servers[1].start();
+
+      servers[0].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2);
+      servers[1].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2);
+
       Thread.sleep(1000);
 
       // create client connecting only to A. It should receive broker B address whet it connects to A.
@@ -227,9 +272,9 @@ public class FailoverComplexClusterTest extends FailoverClusterTestSupport {
       Thread.sleep(5000);
 
       // We stop broker A.
-      logger.info("Stopping broker A whose address is: {}", BROKER_A_CLIENT_TC_ADDRESS);
-      getBroker(BROKER_A_NAME).stop();
-      getBroker(BROKER_A_NAME).waitUntilStopped();
+      servers[0].stop();
+      servers[1].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 1);
+
       Thread.sleep(5000);
 
       // Client should failover to B.
@@ -258,138 +303,150 @@ public class FailoverComplexClusterTest extends FailoverClusterTestSupport {
                          String destinationFilter) throws Exception, InterruptedException {
       assertClientsConnectedToThreeBrokers();
 
-      getBroker(BROKER_C_NAME).stop();
-      getBroker(BROKER_C_NAME).waitUntilStopped();
-      removeBroker(BROKER_C_NAME);
+      stopServer(2);
 
       Thread.sleep(5000);
 
       assertClientsConnectedToTwoBrokers();
 
-      createBrokerC(multi, tcParams, clusterFilter, destinationFilter);
-      getBroker(BROKER_C_NAME).waitUntilStarted();
+      restartServer(2);
+
       Thread.sleep(5000);
 
       assertClientsConnectedToThreeBrokers();
    }
 
-   /**
-    * @param multi
-    * @param tcParams
-    * @param clusterFilter
-    * @param destinationFilter
-    * @throws Exception
-    * @throws InterruptedException
-    */
+   public void setClientUrl(String clientUrl) {
+      this.clientUrl = clientUrl;
+   }
+
+   protected void createClients() throws Exception {
+      createClients(NUMBER_OF_CLIENTS);
+   }
+
+   protected void createClients(int numOfClients) throws Exception {
+      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(clientUrl);
+      for (int i = 0; i < numOfClients; i++) {
+         ActiveMQConnection c = (ActiveMQConnection) factory.createConnection();
+         c.start();
+         Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         Queue queue = s.createQueue(getClass().getName());
+         MessageConsumer consumer = s.createConsumer(queue);
+         connections.add(c);
+      }
+   }
+
+   protected void shutdownClients() throws JMSException {
+      for (Connection c : connections) {
+         c.close();
+      }
+   }
+
+   protected void assertClientsConnectedToThreeBrokers() {
+      Set<String> set = new HashSet<String>();
+      for (ActiveMQConnection c : connections) {
+         if (c.getTransportChannel().getRemoteAddress() != null) {
+            set.add(c.getTransportChannel().getRemoteAddress());
+         }
+      }
+      Assert.assertTrue("Only 3 connections should be found: " + set, set.size() == 3);
+   }
+
+   protected void assertClientsConnectedToTwoBrokers() {
+      Set<String> set = new HashSet<String>();
+      for (ActiveMQConnection c : connections) {
+         if (c.getTransportChannel().getRemoteAddress() != null) {
+            set.add(c.getTransportChannel().getRemoteAddress());
+         }
+      }
+      Assert.assertTrue("Only 2 connections should be found: " + set, set.size() == 2);
+   }
+
+   private void stopServer(int serverID) throws Exception {
+      servers[serverID].stop();
+      for (int i = 0; i < servers.length; i++) {
+         if (i != serverID) {
+            Assert.assertTrue(servers[i].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, servers.length - 1));
+         }
+      }
+   }
+
+   private void restartServer(int serverID) throws Exception {
+      servers[serverID].start();
+
+      for (int i = 0; i < servers.length; i++) {
+         Assert.assertTrue(servers[i].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, servers.length));
+      }
+   }
+
    private void runClientDistributionTests(boolean multi,
                                            String tcParams,
                                            String clusterFilter,
                                            String destinationFilter) throws Exception, InterruptedException {
       assertClientsConnectedToThreeBrokers();
-      assertClientsConnectionsEvenlyDistributed(.25);
+      //if 2/3 or more of total connections connect to one node, we consider it wrong
+      //if 1/4 or less of total connects to one node, we consider it wrong
+      assertClientsConnectionsEvenlyDistributed(.25, .67);
 
-      getBroker(BROKER_C_NAME).stop();
-      getBroker(BROKER_C_NAME).waitUntilStopped();
-      removeBroker(BROKER_C_NAME);
+      stopServer(2);
 
       Thread.sleep(5000);
 
       assertClientsConnectedToTwoBrokers();
-      assertClientsConnectionsEvenlyDistributed(.35);
+      //now there are only 2 nodes
+      //if 2/3 or more of total connections go to either node, we consider it wrong
+      //if 1/3 or less of total connections go to either node, we consider it wrong
+      assertClientsConnectionsEvenlyDistributed(.34, .67);
 
-      createBrokerC(multi, tcParams, clusterFilter, destinationFilter);
-      getBroker(BROKER_C_NAME).waitUntilStarted();
+      restartServer(2);
       Thread.sleep(5000);
 
       assertClientsConnectedToThreeBrokers();
-      assertClientsConnectionsEvenlyDistributed(.20);
-   }
-
-   @Override
-   protected void setUp() throws Exception {
+      //now back to 3 nodes. We assume at least the new node will
+      //have 1/10 of the total connections, and any node's connections
+      //won't exceed 50%
+      assertClientsConnectionsEvenlyDistributed(.10, .50);
    }
 
-   @Override
-   protected void tearDown() throws Exception {
-      shutdownClients();
-      Thread.sleep(2000);
-      destroyBrokerCluster();
-   }
-
-   private void initSingleTcBroker(String params, String clusterFilter, String destinationFilter) throws Exception {
-      createBrokerA(false, params, clusterFilter, null);
-      createBrokerB(false, params, clusterFilter, null);
-      createBrokerC(false, params, clusterFilter, null);
-      getBroker(BROKER_C_NAME).waitUntilStarted();
-   }
-
-   private void initMultiTcCluster(String params, String clusterFilter) throws Exception {
-      createBrokerA(true, params, clusterFilter, null);
-      createBrokerB(true, params, clusterFilter, null);
-      createBrokerC(true, params, clusterFilter, null);
-      getBroker(BROKER_C_NAME).waitUntilStarted();
-   }
-
-   private void createBrokerA(boolean multi,
-                              String params,
-                              String clusterFilter,
-                              String destinationFilter) throws Exception {
-      final String tcParams = (params == null) ? "" : params;
-      if (getBroker(BROKER_A_NAME) == null) {
-         addBroker(BROKER_A_NAME, createBroker(BROKER_A_NAME));
-         addTransportConnector(getBroker(BROKER_A_NAME), "openwire", BROKER_A_CLIENT_TC_ADDRESS + tcParams, true);
-         if (multi) {
-            addTransportConnector(getBroker(BROKER_A_NAME), "network", BROKER_A_NOB_TC_ADDRESS + tcParams, false);
-            addNetworkBridge(getBroker(BROKER_A_NAME), "A_2_B_Bridge", "static://(" + BROKER_B_NOB_TC_ADDRESS + ")?useExponentialBackOff=false", false, clusterFilter);
-            addNetworkBridge(getBroker(BROKER_A_NAME), "A_2_C_Bridge", "static://(" + BROKER_C_NOB_TC_ADDRESS + ")?useExponentialBackOff=false", false, null);
-         }
-         else {
-            addNetworkBridge(getBroker(BROKER_A_NAME), "A_2_B_Bridge", "static://(" + BROKER_B_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=false", false, clusterFilter);
-            addNetworkBridge(getBroker(BROKER_A_NAME), "A_2_C_Bridge", "static://(" + BROKER_C_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=false", false, null);
+   protected void assertClientsConnectionsEvenlyDistributed(double minimumPercentage, double maximumPercentage) {
+      Map<String, Double> clientConnectionCounts = new HashMap<String, Double>();
+      int total = 0;
+      for (ActiveMQConnection c : connections) {
+         String key = c.getTransportChannel().getRemoteAddress();
+         if (key != null) {
+            total++;
+            if (clientConnectionCounts.containsKey(key)) {
+               double count = clientConnectionCounts.get(key);
+               count += 1.0;
+               clientConnectionCounts.put(key, count);
+            }
+            else {
+               clientConnectionCounts.put(key, 1.0);
+            }
          }
-         getBroker(BROKER_A_NAME).start();
       }
-   }
-
-   private void createBrokerB(boolean multi,
-                              String params,
-                              String clusterFilter,
-                              String destinationFilter) throws Exception {
-      final String tcParams = (params == null) ? "" : params;
-      if (getBroker(BROKER_B_NAME) == null) {
-         addBroker(BROKER_B_NAME, createBroker(BROKER_B_NAME));
-         addTransportConnector(getBroker(BROKER_B_NAME), "openwire", BROKER_B_CLIENT_TC_ADDRESS + tcParams, true);
-         if (multi) {
-            addTransportConnector(getBroker(BROKER_B_NAME), "network", BROKER_B_NOB_TC_ADDRESS + tcParams, false);
-            addNetworkBridge(getBroker(BROKER_B_NAME), "B_2_A_Bridge", "static://(" + BROKER_A_NOB_TC_ADDRESS + ")?useExponentialBackOff=false", false, clusterFilter);
-            addNetworkBridge(getBroker(BROKER_B_NAME), "B_2_C_Bridge", "static://(" + BROKER_C_NOB_TC_ADDRESS + ")?useExponentialBackOff=false", false, null);
+      Set<String> keys = clientConnectionCounts.keySet();
+      List<String> errorMsgs = new ArrayList<String>();
+      for (String key : keys) {
+         double count = clientConnectionCounts.get(key);
+         double percentage = count / total;
+         if (percentage < minimumPercentage || percentage > maximumPercentage) {
+            errorMsgs.add("Connections distribution expected to be within range [ " + minimumPercentage
+                    + ", " + maximumPercentage + "].  Actuall distribution was " + percentage + " for connection " + key);
          }
-         else {
-            addNetworkBridge(getBroker(BROKER_B_NAME), "B_2_A_Bridge", "static://(" + BROKER_A_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=false", false, clusterFilter);
-            addNetworkBridge(getBroker(BROKER_B_NAME), "B_2_C_Bridge", "static://(" + BROKER_C_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=false", false, null);
+         if (errorMsgs.size() > 0) {
+            for (String err : errorMsgs) {
+               System.err.println(err);
+            }
+            Assert.fail("Test failed. Please see the log message for details");
          }
-         getBroker(BROKER_B_NAME).start();
       }
    }
 
-   private void createBrokerC(boolean multi,
-                              String params,
-                              String clusterFilter,
-                              String destinationFilter) throws Exception {
-      final String tcParams = (params == null) ? "" : params;
-      if (getBroker(BROKER_C_NAME) == null) {
-         addBroker(BROKER_C_NAME, createBroker(BROKER_C_NAME));
-         addTransportConnector(getBroker(BROKER_C_NAME), "openwire", BROKER_C_CLIENT_TC_ADDRESS + tcParams, true);
-         if (multi) {
-            addTransportConnector(getBroker(BROKER_C_NAME), "network", BROKER_C_NOB_TC_ADDRESS + tcParams, false);
-            addNetworkBridge(getBroker(BROKER_C_NAME), "C_2_A_Bridge", "static://(" + BROKER_A_NOB_TC_ADDRESS + ")?useExponentialBackOff=false", false, clusterFilter);
-            addNetworkBridge(getBroker(BROKER_C_NAME), "C_2_B_Bridge", "static://(" + BROKER_B_NOB_TC_ADDRESS + ")?useExponentialBackOff=false", false, null);
-         }
-         else {
-            addNetworkBridge(getBroker(BROKER_C_NAME), "C_2_A_Bridge", "static://(" + BROKER_A_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=false", false, clusterFilter);
-            addNetworkBridge(getBroker(BROKER_C_NAME), "C_2_B_Bridge", "static://(" + BROKER_B_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=false", false, null);
-         }
-         getBroker(BROKER_C_NAME).start();
+   protected void assertAllConnectedTo(String url) throws Exception {
+      for (ActiveMQConnection c : connections) {
+         Assert.assertEquals(url, c.getTransportChannel().getRemoteAddress());
       }
    }
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java
index e33e7ea..78a8a0b 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java
@@ -39,63 +39,61 @@ import javax.jms.TextMessage;
 
 import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerPlugin;
-import org.apache.activemq.broker.BrokerPluginSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.ConnectionContext;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.TransactionId;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMRules;
+import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
+import org.junit.runner.RunWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.junit.After;
 import org.junit.Test;
 
-public class FailoverConsumerOutstandingCommitTest {
-
+@RunWith(BMUnitRunner.class)
+public class FailoverConsumerOutstandingCommitTest extends OpenwireArtemisBaseTest {
    private static final Logger LOG = LoggerFactory.getLogger(FailoverConsumerOutstandingCommitTest.class);
    private static final String QUEUE_NAME = "FailoverWithOutstandingCommit";
    private static final String MESSAGE_TEXT = "Test message ";
-   private static final String TRANSPORT_URI = "tcp://localhost:0";
-   private String url;
+   private static final String url = newURI(0);
    final int prefetch = 10;
-   BrokerService broker;
+   private static EmbeddedJMS server;
+   private static final AtomicBoolean doByteman = new AtomicBoolean(false);
+   private static CountDownLatch brokerStopLatch = new CountDownLatch(1);
 
    @After
    public void stopBroker() throws Exception {
-      if (broker != null) {
-         broker.stop();
+      if (server != null) {
+         server.stop();
       }
    }
 
-   public void startBroker(boolean deleteAllMessagesOnStartup) throws Exception {
-      broker = createBroker(deleteAllMessagesOnStartup);
-      broker.start();
-   }
-
-   public BrokerService createBroker(boolean deleteAllMessagesOnStartup) throws Exception {
-      return createBroker(deleteAllMessagesOnStartup, TRANSPORT_URI);
-   }
-
-   public BrokerService createBroker(boolean deleteAllMessagesOnStartup, String bindAddress) throws Exception {
-      broker = new BrokerService();
-      broker.addConnector(bindAddress);
-      broker.setDeleteAllMessagesOnStartup(deleteAllMessagesOnStartup);
-      PolicyMap policyMap = new PolicyMap();
-      PolicyEntry defaultEntry = new PolicyEntry();
-
-      // optimizedDispatche and sync dispatch ensure that the dispatch happens
-      // before the commit reply that the consumer.clearDispatchList is waiting for.
-      defaultEntry.setOptimizedDispatch(true);
-      policyMap.setDefaultEntry(defaultEntry);
-      broker.setDestinationPolicy(policyMap);
-
-      url = broker.getTransportConnectors().get(0).getConnectUri().toString();
-
-      return broker;
+   public void startServer() throws Exception {
+      server = createBroker();
+      server.start();
    }
 
    @Test
+   @BMRules(
+      rules = {
+              @BMRule(
+                      name = "set no return response",
+                      targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+                      targetMethod = "processCommitTransactionOnePhase",
+                      targetLocation = "ENTRY",
+                      binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
+                      action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.holdResponse(context)"),
+              @BMRule(
+                      name = "stop broker before commit",
+                      targetClass = "org.apache.activemq.artemis.core.server.impl.ServerSessionImpl",
+                      targetMethod = "commit",
+                      targetLocation = "ENTRY",
+                      action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.stopServerInTransaction()"),
+      }
+   )
    public void testFailoverConsumerDups() throws Exception {
       doTestFailoverConsumerDups(true);
    }
@@ -103,30 +101,9 @@ public class FailoverConsumerOutstandingCommitTest {
    @SuppressWarnings("unchecked")
    public void doTestFailoverConsumerDups(final boolean watchTopicAdvisories) throws Exception {
 
-      broker = createBroker(true);
-
-      broker.setPlugins(new BrokerPlugin[]{new BrokerPluginSupport() {
-         @Override
-         public void commitTransaction(ConnectionContext context,
-                                       TransactionId xid,
-                                       boolean onePhase) throws Exception {
-            // so commit will hang as if reply is lost
-            context.setDontSendReponse(true);
-            Executors.newSingleThreadExecutor().execute(new Runnable() {
-               @Override
-               public void run() {
-                  LOG.info("Stopping broker before commit...");
-                  try {
-                     broker.stop();
-                  }
-                  catch (Exception e) {
-                     e.printStackTrace();
-                  }
-               }
-            });
-         }
-      }});
-      broker.start();
+      server = createBroker();
+      server.start();
+      brokerStopLatch = new CountDownLatch(1);
 
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")");
       cf.setWatchTopicAdvisories(watchTopicAdvisories);
@@ -144,9 +121,9 @@ public class FailoverConsumerOutstandingCommitTest {
       final CountDownLatch messagesReceived = new CountDownLatch(2);
 
       final MessageConsumer testConsumer = consumerSession.createConsumer(destination);
+      doByteman.set(true);
       testConsumer.setMessageListener(new MessageListener() {
 
-         @Override
          public void onMessage(Message message) {
             LOG.info("consume one and commit");
 
@@ -166,7 +143,6 @@ public class FailoverConsumerOutstandingCommitTest {
 
       // may block if broker shutodwn happens quickly
       Executors.newSingleThreadExecutor().execute(new Runnable() {
-         @Override
          public void run() {
             LOG.info("producer started");
             try {
@@ -183,9 +159,11 @@ public class FailoverConsumerOutstandingCommitTest {
       });
 
       // will be stopped by the plugin
-      broker.waitUntilStopped();
-      broker = createBroker(false, url);
-      broker.start();
+      brokerStopLatch.await();
+      server.stop();
+      server = createBroker();
+      doByteman.set(false);
+      server.start();
 
       assertTrue("consumer added through failover", commitDoneLatch.await(20, TimeUnit.SECONDS));
       assertTrue("another message was received after failover", messagesReceived.await(20, TimeUnit.SECONDS));
@@ -194,11 +172,41 @@ public class FailoverConsumerOutstandingCommitTest {
    }
 
    @Test
+   @BMRules(
+      rules = {
+              @BMRule(
+                      name = "set no return response",
+                      targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+                      targetMethod = "processCommitTransactionOnePhase",
+                      targetLocation = "ENTRY",
+                      binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
+                      action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.holdResponse(context)"),
+              @BMRule(
+                      name = "stop broker before commit",
+                      targetClass = "org.apache.activemq.artemis.core.server.impl.ServerSessionImpl",
+                      targetMethod = "commit",
+                      targetLocation = "ENTRY",
+                      action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.stopServerInTransaction();return")})
    public void TestFailoverConsumerOutstandingSendTxIncomplete() throws Exception {
       doTestFailoverConsumerOutstandingSendTx(false);
    }
 
    @Test
+   @BMRules(
+      rules = {
+              @BMRule(
+                      name = "set no return response",
+                      targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+                      targetMethod = "processCommitTransactionOnePhase",
+                      targetLocation = "ENTRY",
+                      binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
+                      action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.holdResponse(context)"),
+              @BMRule(
+                      name = "stop broker after commit",
+                      targetClass = "org.apache.activemq.artemis.core.server.impl.ServerSessionImpl",
+                      targetMethod = "commit",
+                      targetLocation = "AT EXIT",
+                      action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.stopServerInTransaction()")})
    public void TestFailoverConsumerOutstandingSendTxComplete() throws Exception {
       doTestFailoverConsumerOutstandingSendTx(true);
    }
@@ -206,36 +214,9 @@ public class FailoverConsumerOutstandingCommitTest {
    @SuppressWarnings("unchecked")
    public void doTestFailoverConsumerOutstandingSendTx(final boolean doActualBrokerCommit) throws Exception {
       final boolean watchTopicAdvisories = true;
-      broker = createBroker(true);
-
-      broker.setPlugins(new BrokerPlugin[]{new BrokerPluginSupport() {
-         @Override
-         public void commitTransaction(ConnectionContext context,
-                                       TransactionId xid,
-                                       boolean onePhase) throws Exception {
-            // from the consumer perspective whether the commit completed on the broker or
-            // not is irrelevant, the transaction is still in doubt in the absence of a reply
-            if (doActualBrokerCommit) {
-               LOG.info("doing actual broker commit...");
-               super.commitTransaction(context, xid, onePhase);
-            }
-            // so commit will hang as if reply is lost
-            context.setDontSendReponse(true);
-            Executors.newSingleThreadExecutor().execute(new Runnable() {
-               @Override
-               public void run() {
-                  LOG.info("Stopping broker before commit...");
-                  try {
-                     broker.stop();
-                  }
-                  catch (Exception e) {
-                     e.printStackTrace();
-                  }
-               }
-            });
-         }
-      }});
-      broker.start();
+      server = createBroker();
+      server.start();
+      brokerStopLatch = new CountDownLatch(1);
 
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")");
       cf.setWatchTopicAdvisories(watchTopicAdvisories);
@@ -254,11 +235,11 @@ public class FailoverConsumerOutstandingCommitTest {
       final CountDownLatch commitDoneLatch = new CountDownLatch(1);
       final CountDownLatch messagesReceived = new CountDownLatch(3);
       final AtomicBoolean gotCommitException = new AtomicBoolean(false);
-      final ArrayList<TextMessage> receivedMessages = new ArrayList<>();
+      final ArrayList<TextMessage> receivedMessages = new ArrayList<TextMessage>();
       final MessageConsumer testConsumer = consumerSession.createConsumer(destination);
+      doByteman.set(true);
       testConsumer.setMessageListener(new MessageListener() {
 
-         @Override
          public void onMessage(Message message) {
             LOG.info("consume one and commit: " + message);
             assertNotNull("got message", message);
@@ -279,7 +260,6 @@ public class FailoverConsumerOutstandingCommitTest {
 
       // may block if broker shutdown happens quickly
       Executors.newSingleThreadExecutor().execute(new Runnable() {
-         @Override
          public void run() {
             LOG.info("producer started");
             try {
@@ -296,9 +276,11 @@ public class FailoverConsumerOutstandingCommitTest {
       });
 
       // will be stopped by the plugin
-      broker.waitUntilStopped();
-      broker = createBroker(false, url);
-      broker.start();
+      brokerStopLatch.await();
+      server.stop();
+      doByteman.set(false);
+      server = createBroker();
+      server.start();
 
       assertTrue("commit done through failover", commitDoneLatch.await(20, TimeUnit.SECONDS));
       assertTrue("commit failed", gotCommitException.get());
@@ -313,12 +295,13 @@ public class FailoverConsumerOutstandingCommitTest {
       assertEquals("get message 1 eventually", MESSAGE_TEXT + "1", receivedMessages.get(receivedIndex++).getText());
 
       connection.close();
+      server.stop();
    }
 
    @Test
    public void testRollbackFailoverConsumerTx() throws Exception {
-      broker = createBroker(true);
-      broker.start();
+      server = createBroker();
+      server.start();
 
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")");
       cf.setConsumerFailoverRedeliveryWaitPeriod(10000);
@@ -340,10 +323,9 @@ public class FailoverConsumerOutstandingCommitTest {
       assertNotNull(msg);
 
       // restart with outstanding delivered message
-      broker.stop();
-      broker.waitUntilStopped();
-      broker = createBroker(false, url);
-      broker.start();
+      server.stop();
+      server = createBroker();
+      server.start();
 
       consumerSession.rollback();
 
@@ -379,4 +361,29 @@ public class FailoverConsumerOutstandingCommitTest {
       }
       producer.close();
    }
+
+   public static void holdResponse(AMQConnectionContext context) {
+      if (doByteman.get()) {
+         context.setDontSendReponse(true);
+      }
+   }
+
+   public static void stopServerInTransaction() {
+      if (doByteman.get()) {
+         Executors.newSingleThreadExecutor().execute(new Runnable() {
+            public void run() {
+               LOG.info("Stopping broker in transaction...");
+               try {
+                  server.stop();
+               }
+               catch (Exception e) {
+                  e.printStackTrace();
+               }
+               finally {
+                  brokerStopLatch.countDown();
+               }
+            }
+         });
+      }
+   }
 }


[31/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
open wire changes
equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

More or less what I meant by getting rid of PeerBroker.. we can just use the Topology we already have
(cherry picked from commit 5559f05cc57493ad5f54f214c0b6bc3d92820efb)

put back rebalance and test
(cherry picked from commit 9711d6cf26ddaad5b08c0024e27819e74fef02af from branch new2)

fix some configure issues for tests. so far only one of the two bridges seen started
(cherry picked from commit ec1bfdb65bf314c05f12134e96a5e7d1a854b398)

Reverting configuration stuff, adding new cluster base class
(cherry picked from 8267e8196c969fef8dc6248ed7791b31e6e01a03)

fixing cluster test
(cherry picked from commit ab29219c0f89909bd1687e00353a19e4385eb06e)

getting the first test working
(cherry picked from commit 0e724d1cb462345969f96a0e706799628a2c56dd)

fixing clustering tests
(cherry picked from 2a20696cdec44963ba1320b438d84409a1709809)

Starting with nother test FailoverComplexClusterTest

  I added a NewFailoverComplexClusterTest copied from the
  original test. So I can keep the original for reference.
  Once test passed I'll overwrite the original with the
  new one.
(cherry picked from f9e959d91d99676916a3e218738809c7f0c62b99)

Test fixes
(cherry picked from commit 567f57848ed10f54512b25118c54372e6510afdc)

more tests
(cherry picked from 67633c61c64f2bd0ffab4c5bb608922387427ad8)

Finished FailoverComplexClusterTest, now its tests all pass.
(cherry picked from 8ee4bb845fffd6499665801b73ac2e443dda8de5)

Openwire test work update:
  changed some code to pass protocol specific params to accetpors
  FailoverRandomTest ok
  delete a test that is not relevant
  FailoverPriorityTest (still not working)

(cherry picked from commit 3b9eae2d52dc73f58e4f5106c912cddda95388c6)

FailoverPriorityTest is ok now.
(cherry picked from commit a61abdc3349ad846f53b5703c6ff03a68304ac6f)

    - Fix ReconnectTest
    - Update activemq-client to 5.12.0 for activemq5-unit-tests
    - Remove some tests that are removed from 5.12.0
    - Add a synchronization on JMSServerManagerImpl
    internalCreateQueue to avoid NPE in FailoverClusterTest

    (cherry picked from commit 5d44bcf8ce02f3a0936ee12ecf86a3948e2b3a0c)

Fix connection closing issue which causes
tests teardown takes very long time.
(cherry picked from 50bef42d32d2fae705353b96e2b626d4fc722cc6)

InitalReconnectDelayTest.java
SlowConnectionTest.java
TwoBrokerFailoverClusterTest.java
(cherry picked from a5ebfae1a2af938ad10b1dee2d2c9bf11f8d0116)

Fix a few more tests
(cherry picked from 83a316c37f1a1ba7b36a35261a0fee031d606e96)

- Fix tests:
FanoutTransportBrokerTest, FanoutTest
- Disable server auto-creation for cluster tests
(cherry picked from commit c6d7c7b28b1754b1d1898c038f1c9a0952028cbd)

more tests
(cherry picked from commit f4217734492ffe9be1e8380959f13cfb85ab9e1e)

Fix SoWriteTimeoutClientTest
Add a check in OpenwireConnection.disconnect() to prevent it from reentering.

(cherry picked from commit c74ef17f4d038d772c0d8457194bb83282e87211)

Remove command check in OpenWireConnection
Handle ShutdownInfo command properly
ConnectionCleanupTest (a new test from 12.0)

(cherry picked from commit a2512ff083ab691b7cb0abc27711d6ed78739d66)

Clean up all tests under org.apache.activemq.transport.failover package

(Cherry picked from 181c874fa80ae103df3b8619c97141e49aafc847)


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/2bcfd089
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/2bcfd089
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/2bcfd089

Branch: refs/heads/refactor-openwire
Commit: 2bcfd089405c61e446d91280364e15f5ff08e046
Parents: 69c0eb8
Author: Clebert Suconic <cl...@apache.org>
Authored: Wed Jan 13 22:53:59 2016 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:44:21 2016 -0400

----------------------------------------------------------------------
 .../jms/server/impl/JMSServerManagerImpl.java   |   34 +-
 .../protocol/openwire/OpenWireConnection.java   |  294 ++--
 .../openwire/OpenWireProtocolManager.java       |  197 ++-
 .../openwire/amq/AMQConnectionContext.java      |   19 +
 .../core/protocol/openwire/amq/AMQConsumer.java |   16 +-
 .../protocol/openwire/amq/AMQServerSession.java |    8 +-
 .../core/protocol/openwire/amq/AMQSession.java  |   23 +-
 .../artemis/core/config/Configuration.java      |    4 +
 .../core/config/impl/ConfigurationImpl.java     |   19 +
 .../core/remoting/impl/netty/NettyAcceptor.java |    2 +
 .../server/impl/RemotingServiceImpl.java        |    6 +-
 .../core/server/embedded/EmbeddedActiveMQ.java  |    5 +
 tests/activemq5-unit-tests/pom.xml              |   39 +-
 .../broker/ArtemisBrokerWrapperFactory.java     |   32 +
 .../apache/activemq/broker/BrokerService.java   |  133 +-
 .../artemiswrapper/ArtemisBrokerBase.java       |   17 +-
 .../artemiswrapper/ArtemisBrokerWrapper.java    |   24 +-
 .../artemiswrapper/OpenwireArtemisBaseTest.java |  266 ++++
 .../transport/tcp/TcpTransportFactory.java      |   12 +-
 .../activemq/ActiveMQInputStreamTest.java       |  148 --
 .../apache/activemq/AutoFailTestSupport.java    |  159 ++
 .../apache/activemq/ConnectionCleanupTest.java  |   34 +-
 .../activemq/EmbeddedBrokerTestSupport.java     |   96 +-
 .../activemq/JmsQueueTransactionTest.java       |  234 +++
 .../activemq/JmsTransactionTestSupport.java     |  721 +++++++++
 .../org/apache/activemq/LargeStreamletTest.java |  170 --
 .../org/apache/activemq/broker/AMQ4351Test.java |  271 ----
 .../jmx/BrokerViewSlowStoreStartupTest.java     |  395 -----
 .../broker/jmx/HealthViewMBeanTest.java         |  119 --
 .../activemq/broker/jmx/Log4JConfigTest.java    |  194 ---
 .../broker/jmx/MBeanOperationTimeoutTest.java   |  136 --
 .../apache/activemq/broker/jmx/MBeanTest.java   | 1505 ------------------
 .../apache/activemq/broker/jmx/PurgeTest.java   |  258 ---
 .../broker/jmx/TransportConnectorMBeanTest.java |  141 --
 .../region/QueueDuplicatesFromStoreTest.java    |   87 +-
 .../region/SubscriptionAddRemoveQueueTest.java  |   21 +-
 .../region/cursors/NegativeQueueTest.java       |  432 -----
 .../broker/virtual/CompositeQueueTest.java      |  134 --
 .../broker/virtual/CompositeTopicTest.java      |   49 -
 .../DestinationInterceptorDurableSubTest.java   |  283 ----
 .../broker/virtual/FilteredQueueTest.java       |   36 -
 .../MirroredQueueCorrectMemoryUsageTest.java    |  167 --
 .../broker/virtual/MirroredQueueTest.java       |  116 --
 ...MirroredQueueUsingVirtualTopicQueueTest.java |   34 -
 .../broker/virtual/VirtualDestPerfTest.java     |  200 ---
 .../broker/virtual/VirtualTopicDLQTest.java     |  433 -----
 .../VirtualTopicDisconnectSelectorTest.java     |  188 ---
 .../broker/virtual/VirtualTopicPubSubTest.java  |  131 --
 .../VirtualTopicPubSubUsingXBeanTest.java       |   55 -
 .../virtual/VirtualTopicSelectorTest.java       |  108 --
 .../VirtualTopicsAndDurableSubsTest.java        |  117 --
 .../activemq/broker/virtual/composite-queue.xml |   47 -
 .../activemq/broker/virtual/composite-topic.xml |   47 -
 .../broker/virtual/disconnected-selector.xml    |   43 -
 .../activemq/broker/virtual/filtered-queue.xml  |   47 -
 .../broker/virtual/global-virtual-topics.xml    |   42 -
 .../broker/virtual/virtual-individual-dlq.xml   |   80 -
 .../virtual/virtual-topics-and-interceptor.xml  |   50 -
 .../java/org/apache/activemq/bugs/AMQ1282.java  |  206 ---
 .../org/apache/activemq/bugs/AMQ1687Test.java   |  106 --
 .../org/apache/activemq/bugs/AMQ1853Test.java   |  378 -----
 .../java/org/apache/activemq/bugs/AMQ1866.java  |  233 ---
 .../org/apache/activemq/bugs/AMQ1893Test.java   |  192 ---
 .../org/apache/activemq/bugs/AMQ1917Test.java   |  229 ---
 .../org/apache/activemq/bugs/AMQ1936Test.java   |  320 ----
 .../org/apache/activemq/bugs/AMQ2021Test.java   |  275 ----
 .../org/apache/activemq/bugs/AMQ2084Test.java   |  188 ---
 .../org/apache/activemq/bugs/AMQ2103Test.java   |  130 --
 .../activemq/bugs/AMQ2149LevelDBTest.java       |   30 -
 .../org/apache/activemq/bugs/AMQ2149Test.java   |  614 -------
 .../org/apache/activemq/bugs/AMQ2171Test.java   |  150 --
 .../org/apache/activemq/bugs/AMQ2200Test.java   |  100 --
 .../org/apache/activemq/bugs/AMQ2213Test.java   |  101 --
 .../org/apache/activemq/bugs/AMQ2314Test.java   |  181 ---
 .../org/apache/activemq/bugs/AMQ2356Test.java   |  192 ---
 .../org/apache/activemq/bugs/AMQ2364Test.java   |  113 --
 .../org/apache/activemq/bugs/AMQ2383Test.java   |   61 -
 .../org/apache/activemq/bugs/AMQ2401Test.java   |  235 ---
 .../org/apache/activemq/bugs/AMQ2413Test.java   |  344 ----
 .../org/apache/activemq/bugs/AMQ2439Test.java   |   94 --
 .../org/apache/activemq/bugs/AMQ2489Test.java   |  232 ---
 .../org/apache/activemq/bugs/AMQ2512Test.java   |  179 ---
 .../org/apache/activemq/bugs/AMQ2513Test.java   |  105 --
 .../org/apache/activemq/bugs/AMQ2528Test.java   |   79 -
 .../org/apache/activemq/bugs/AMQ2571Test.java   |  115 --
 .../org/apache/activemq/bugs/AMQ2580Test.java   |  195 ---
 .../activemq/bugs/AMQ2584ConcurrentDlqTest.java |  268 ----
 .../org/apache/activemq/bugs/AMQ2584Test.java   |  233 ---
 .../org/apache/activemq/bugs/AMQ2585Test.java   |   82 -
 .../org/apache/activemq/bugs/AMQ2616Test.java   |  118 --
 .../org/apache/activemq/bugs/AMQ2645Test.java   |  112 --
 .../org/apache/activemq/bugs/AMQ2736Test.java   |   98 --
 .../org/apache/activemq/bugs/AMQ2751Test.java   |   97 --
 .../org/apache/activemq/bugs/AMQ2801Test.java   |  199 ---
 .../org/apache/activemq/bugs/AMQ2832Test.java   |  379 -----
 .../org/apache/activemq/bugs/AMQ2870Test.java   |  227 ---
 .../org/apache/activemq/bugs/AMQ2902Test.java   |   96 --
 .../org/apache/activemq/bugs/AMQ2910Test.java   |  130 --
 .../org/apache/activemq/bugs/AMQ2982Test.java   |  184 ---
 .../org/apache/activemq/bugs/AMQ2983Test.java   |  165 --
 .../org/apache/activemq/bugs/AMQ3014Test.java   |  200 ---
 .../org/apache/activemq/bugs/AMQ3120Test.java   |  147 --
 .../org/apache/activemq/bugs/AMQ3140Test.java   |  146 --
 .../org/apache/activemq/bugs/AMQ3141Test.java   |  117 --
 .../org/apache/activemq/bugs/AMQ3145Test.java   |  129 --
 .../org/apache/activemq/bugs/AMQ3157Test.java   |  174 --
 .../org/apache/activemq/bugs/AMQ3167Test.java   |  471 ------
 .../org/apache/activemq/bugs/AMQ3274Test.java   |  763 ---------
 .../org/apache/activemq/bugs/AMQ3324Test.java   |  148 --
 .../org/apache/activemq/bugs/AMQ3352Test.java   |   74 -
 .../org/apache/activemq/bugs/AMQ3405Test.java   |  281 ----
 .../org/apache/activemq/bugs/AMQ3436Test.java   |  203 ---
 .../org/apache/activemq/bugs/AMQ3445Test.java   |  148 --
 .../org/apache/activemq/bugs/AMQ3454Test.java   |   75 -
 .../org/apache/activemq/bugs/AMQ3465Test.java   |  198 ---
 .../org/apache/activemq/bugs/AMQ3529Test.java   |  185 ---
 .../org/apache/activemq/bugs/AMQ3537Test.java   |  105 --
 .../org/apache/activemq/bugs/AMQ3567Test.java   |  212 ---
 .../org/apache/activemq/bugs/AMQ3622Test.java   |  109 --
 .../org/apache/activemq/bugs/AMQ3625Test.java   |  110 --
 .../org/apache/activemq/bugs/AMQ3674Test.java   |  122 --
 .../org/apache/activemq/bugs/AMQ3675Test.java   |  162 --
 .../org/apache/activemq/bugs/AMQ3678Test.java   |  216 ---
 .../org/apache/activemq/bugs/AMQ3732Test.java   |  178 ---
 .../org/apache/activemq/bugs/AMQ3779Test.java   |   77 -
 .../org/apache/activemq/bugs/AMQ3841Test.java   |  119 --
 .../org/apache/activemq/bugs/AMQ3879Test.java   |  113 --
 .../org/apache/activemq/bugs/AMQ3903Test.java   |  144 --
 .../org/apache/activemq/bugs/AMQ3932Test.java   |  164 --
 .../org/apache/activemq/bugs/AMQ3934Test.java   |  106 --
 .../org/apache/activemq/bugs/AMQ3961Test.java   |  185 ---
 .../org/apache/activemq/bugs/AMQ3992Test.java   |  106 --
 .../org/apache/activemq/bugs/AMQ4062Test.java   |  280 ----
 .../org/apache/activemq/bugs/AMQ4083Test.java   |  520 ------
 .../org/apache/activemq/bugs/AMQ4092Test.java   |  234 ---
 .../org/apache/activemq/bugs/AMQ4116Test.java   |  111 --
 .../org/apache/activemq/bugs/AMQ4126Test.java   |  181 ---
 .../org/apache/activemq/bugs/AMQ4133Test.java   |  107 --
 .../org/apache/activemq/bugs/AMQ4147Test.java   |  210 ---
 .../org/apache/activemq/bugs/AMQ4148Test.java   |   93 --
 .../org/apache/activemq/bugs/AMQ4157Test.java   |  178 ---
 .../org/apache/activemq/bugs/AMQ4160Test.java   |  380 -----
 .../org/apache/activemq/bugs/AMQ4212Test.java   |  357 -----
 .../org/apache/activemq/bugs/AMQ4213Test.java   |   88 -
 .../org/apache/activemq/bugs/AMQ4220Test.java   |  119 --
 .../org/apache/activemq/bugs/AMQ4221Test.java   |  274 ----
 .../org/apache/activemq/bugs/AMQ4222Test.java   |  187 ---
 .../org/apache/activemq/bugs/AMQ4323Test.java   |  160 --
 .../org/apache/activemq/bugs/AMQ4356Test.java   |  142 --
 .../org/apache/activemq/bugs/AMQ4361Test.java   |  160 --
 .../org/apache/activemq/bugs/AMQ4368Test.java   |  256 ---
 .../org/apache/activemq/bugs/AMQ4407Test.java   |  174 --
 .../org/apache/activemq/bugs/AMQ4413Test.java   |  246 ---
 .../org/apache/activemq/bugs/AMQ4469Test.java   |  113 --
 .../org/apache/activemq/bugs/AMQ4472Test.java   |   96 --
 .../org/apache/activemq/bugs/AMQ4475Test.java   |  361 -----
 .../bugs/AMQ4485LowLimitLevelDBTest.java        |   40 -
 .../activemq/bugs/AMQ4485LowLimitTest.java      |  473 ------
 ...XBrokersWithNDestsFanoutTransactionTest.java |  358 -----
 .../org/apache/activemq/bugs/AMQ4485Test.java   |  199 ---
 .../org/apache/activemq/bugs/AMQ4487Test.java   |  135 --
 .../org/apache/activemq/bugs/AMQ4504Test.java   |   83 -
 .../org/apache/activemq/bugs/AMQ4513Test.java   |  145 --
 .../org/apache/activemq/bugs/AMQ4517Test.java   |  129 --
 .../org/apache/activemq/bugs/AMQ4518Test.java   |  129 --
 .../org/apache/activemq/bugs/AMQ4530Test.java   |  115 --
 .../org/apache/activemq/bugs/AMQ4531Test.java   |  146 --
 .../org/apache/activemq/bugs/AMQ4554Test.java   |  107 --
 .../org/apache/activemq/bugs/AMQ4582Test.java   |   95 --
 .../org/apache/activemq/bugs/AMQ4595Test.java   |  158 --
 .../org/apache/activemq/bugs/AMQ4607Test.java   |  263 ---
 .../org/apache/activemq/bugs/AMQ4636Test.java   |  263 ---
 .../org/apache/activemq/bugs/AMQ4656Test.java   |  153 --
 .../org/apache/activemq/bugs/AMQ4671Test.java   |   81 -
 .../org/apache/activemq/bugs/AMQ4677Test.java   |  182 ---
 .../org/apache/activemq/bugs/AMQ4853Test.java   |  304 ----
 .../org/apache/activemq/bugs/AMQ4887Test.java   |  168 --
 .../org/apache/activemq/bugs/AMQ4893Test.java   |   86 -
 .../org/apache/activemq/bugs/AMQ4899Test.java   |  197 ---
 .../org/apache/activemq/bugs/AMQ4930Test.java   |  147 --
 .../org/apache/activemq/bugs/AMQ4950Test.java   |  197 ---
 .../org/apache/activemq/bugs/AMQ4952Test.java   |  511 ------
 .../org/apache/activemq/bugs/AMQ5035Test.java   |   83 -
 .../org/apache/activemq/bugs/AMQ5136Test.java   |   98 --
 .../org/apache/activemq/bugs/AMQ5212Test.java   |  225 ---
 .../activemq/bugs/AMQ5266SingleDestTest.java    |  617 -------
 .../bugs/AMQ5266StarvedConsumerTest.java        |  628 --------
 .../org/apache/activemq/bugs/AMQ5266Test.java   |  604 -------
 .../org/apache/activemq/bugs/AMQ5274Test.java   |  133 --
 .../org/apache/activemq/bugs/AMQ5381Test.java   |  178 ---
 .../org/apache/activemq/bugs/AMQ5421Test.java   |  119 --
 .../org/apache/activemq/bugs/AMQ5450Test.java   |  196 ---
 .../org/apache/activemq/bugs/AMQ5567Test.java   |  217 ---
 .../bugs/ActiveMQSlowConsumerManualTest.java    |  250 ---
 .../activemq/bugs/ConnectionPerMessageTest.java |  108 --
 .../org/apache/activemq/bugs/CraigsBugTest.java |   72 -
 .../apache/activemq/bugs/DoubleExpireTest.java  |  134 --
 .../activemq/bugs/DurableConsumerTest.java      |  479 ------
 .../bugs/JMSDurableTopicNoLocalTest.java        |   85 -
 .../bugs/JmsDurableTopicSlowReceiveTest.java    |  185 ---
 .../apache/activemq/bugs/JmsTimeoutTest.java    |  166 --
 .../bugs/MemoryUsageBlockResumeTest.java        |  221 ---
 .../activemq/bugs/MemoryUsageBrokerTest.java    |   93 --
 .../activemq/bugs/MemoryUsageCleanupTest.java   |  258 ---
 .../bugs/MessageExpirationReaperTest.java       |  185 ---
 .../org/apache/activemq/bugs/MessageSender.java |   49 -
 .../activemq/bugs/MissingDataFileTest.java      |  333 ----
 .../OptimizeAcknowledgeWithExpiredMsgsTest.java |  309 ----
 .../activemq/bugs/OutOfOrderTestCase.java       |  133 --
 .../activemq/bugs/QueueWorkerPrefetchTest.java  |  267 ----
 .../bugs/RawRollbackSharedConsumerTests.java    |  134 --
 .../apache/activemq/bugs/RawRollbackTests.java  |  135 --
 .../java/org/apache/activemq/bugs/Receiver.java |   22 -
 .../bugs/RedeliveryPluginHeaderTest.java        |  164 --
 .../apache/activemq/bugs/SlowConsumerTest.java  |  165 --
 ...ReplayAfterStoreCleanupLevelDBStoreTest.java |   30 -
 .../bugs/TempQueueDeleteOnCloseTest.java        |   54 -
 .../bugs/TempStorageBlockedBrokerTest.java      |  266 ----
 .../bugs/TempStorageConfigBrokerTest.java       |  220 ---
 .../activemq/bugs/TempStoreDataCleanupTest.java |  262 ---
 .../TransactedStoreUsageSuspendResumeTest.java  |  196 ---
 .../bugs/TransactionNotStartedErrorTest.java    |  298 ----
 .../bugs/TrapMessageInJDBCStoreTest.java        |  277 ----
 .../activemq/bugs/VMTransportClosureTest.java   |  135 --
 .../activemq/bugs/VerifySteadyEnqueueRate.java  |  148 --
 .../activemq/bugs/amq1095/ActiveMQTestCase.java |  158 --
 .../bugs/amq1095/MessageSelectorTest.java       |  218 ---
 .../apache/activemq/bugs/amq1095/activemq.xml   |   39 -
 .../activemq/bugs/amq1974/TryJmsClient.java     |  155 --
 .../activemq/bugs/amq1974/TryJmsManager.java    |  125 --
 .../bugs/amq3625/conf/JaasStompSSLBroker1.xml   |   65 -
 .../bugs/amq3625/conf/JaasStompSSLBroker2.xml   |   39 -
 .../bugs/amq3625/conf/groups2.properties        |   20 -
 .../activemq/bugs/amq3625/conf/login.config     |   22 -
 .../bugs/amq3625/conf/users2.properties         |   23 -
 .../activemq/bugs/amq3625/keys/broker2.ks       |    0
 .../activemq/bugs/amq3625/keys/client2.ks       |    0
 .../activemq/bugs/amq3625/keys/client2.ts       |    0
 ...InconsistentConnectorPropertiesBehaviour.xml |   46 -
 .../bugs/amq4126/JaasStompSSLBroker.xml         |   46 -
 .../apache/activemq/bugs/amq4126/dns.properties |   17 -
 .../activemq/bugs/amq4126/groups.properties     |   18 -
 .../apache/activemq/bugs/amq4126/login.config   |   30 -
 .../activemq/bugs/amq4126/users.properties      |   18 -
 .../apache/activemq/bugs/amq5035/activemq.xml   |  109 --
 .../bugs/embedded/EmbeddedActiveMQ.java         |  104 --
 .../activemq/bugs/embedded/ThreadExplorer.java  |  148 --
 .../network/CompressionOverNetworkTest.java     |    4 +-
 .../activemq/network/NetworkLoopBackTest.java   |    5 +-
 .../activemq/network/SimpleNetworkTest.java     |    6 +-
 .../store/AutoStorePerDestinationTest.java      |   44 -
 .../store/LevelDBStorePerDestinationTest.java   |   46 -
 .../activemq/store/MessagePriorityTest.java     |  584 -------
 .../apache/activemq/store/StoreOrderTest.java   |  274 ----
 .../activemq/store/StorePerDestinationTest.java |  314 ----
 .../store/jdbc/BrokenPersistenceAdapter.java    |   47 -
 .../store/jdbc/DatabaseLockerConfigTest.java    |   55 -
 .../store/jdbc/JDBCCommitExceptionTest.java     |  176 --
 .../jdbc/JDBCIOExceptionHandlerMockeryTest.java |  110 --
 .../store/jdbc/JDBCIOExceptionHandlerTest.java  |  330 ----
 .../activemq/store/jdbc/JDBCLockTablePrefix.xml |   58 -
 .../store/jdbc/JDBCLockTablePrefixTest.java     |   43 -
 .../store/jdbc/JDBCMessagePriorityTest.java     |  451 ------
 .../store/jdbc/JDBCNegativeQueueTest.java       |   93 --
 .../store/jdbc/JDBCNetworkBrokerDetachTest.java |   37 -
 .../store/jdbc/JDBCPersistenceAdapterTest.java  |   67 -
 .../store/jdbc/JDBCStoreAutoCommitTest.java     |  515 ------
 .../store/jdbc/JDBCStoreBrokerTest.java         |   60 -
 .../activemq/store/jdbc/JDBCStoreOrderTest.java |   62 -
 .../store/jdbc/JDBCTablePrefixAssignedTest.java |  133 --
 .../activemq/store/jdbc/JDBCTestMemory.java     |  157 --
 .../store/jdbc/JDBCXACommitExceptionTest.java   |  161 --
 .../store/jdbc/LeaseDatabaseLockerTest.java     |  273 ----
 .../activemq/store/kahadb/CustomLockerTest.java |   32 -
 .../store/kahadb/KahaDBFastEnqueueTest.java     |  249 ---
 .../store/kahadb/KahaDBIndexLocationTest.java   |  166 --
 .../store/kahadb/KahaDBMessagePriorityTest.java |   41 -
 .../kahadb/KahaDBPersistenceAdapterTest.java    |   39 -
 .../store/kahadb/KahaDBStoreBrokerTest.java     |   66 -
 .../store/kahadb/KahaDBStoreOrderTest.java      |   34 -
 .../kahadb/KahaDBStoreRecoveryBrokerTest.java   |  212 ---
 .../kahadb/KahaDBStoreRecoveryExpiryTest.java   |  113 --
 .../activemq/store/kahadb/KahaDBStoreTest.java  |  113 --
 .../activemq/store/kahadb/KahaDBTest.java       |  241 ---
 .../store/kahadb/KahaDBVersion1/db-1.log        |    0
 .../store/kahadb/KahaDBVersion1/db.data         |    0
 .../store/kahadb/KahaDBVersion1/db.redo         |    0
 .../store/kahadb/KahaDBVersion2/db-1.log        |    0
 .../store/kahadb/KahaDBVersion2/db.data         |    0
 .../store/kahadb/KahaDBVersion2/db.redo         |    0
 .../store/kahadb/KahaDBVersion3/db-1.log        |    0
 .../store/kahadb/KahaDBVersion3/db.data         |    0
 .../store/kahadb/KahaDBVersion3/db.redo         |    0
 .../store/kahadb/KahaDBVersion4/db-1.log        |    0
 .../store/kahadb/KahaDBVersion4/db.data         |    0
 .../store/kahadb/KahaDBVersion4/db.redo         |    0
 .../store/kahadb/KahaDBVersionTest.java         |  182 ---
 .../activemq/store/kahadb/NoSpaceIOTest.java    |  126 --
 .../activemq/store/kahadb/PBMesssagesTest.java  |   56 -
 .../store/kahadb/TempKahaDBStoreBrokerTest.java |   57 -
 .../store/kahadb/perf/KahaBulkLoadingTest.java  |  150 --
 .../kahadb/perf/KahaStoreDurableTopicTest.java  |   43 -
 .../store/kahadb/perf/KahaStoreQueueTest.java   |   45 -
 .../kahadb/perf/TempKahaStoreQueueTest.java     |   45 -
 .../KahaDBFilePendingMessageCursorTest.java     |   96 --
 .../activemq/store/kahadb/plist/PListTest.java  |  669 --------
 .../org/apache/activemq/store/kahadb/shared.xml |   59 -
 .../store/leveldb/LevelDBNegativeQueueTest.java |   38 -
 .../store/leveldb/LevelDBStoreBrokerTest.java   |   68 -
 .../activemq/store/schedulerDB/legacy/db-1.log  |    0
 .../store/schedulerDB/legacy/scheduleDB.data    |    0
 .../store/schedulerDB/legacy/scheduleDB.redo    |    0
 .../activemq/streams/JMSInputStreamTest.java    |  286 ----
 .../activemq/test/JmsResourceProvider.java      |  258 +++
 .../org/apache/activemq/test/TestSupport.java   |  256 +++
 .../activemq/transport/QueueClusterTest.java    |    5 +-
 .../transport/SoWriteTimeoutClientTest.java     |   77 +-
 .../activemq/transport/TopicClusterTest.java    |   71 +-
 .../transport/failover/AMQ1925Test.java         |  129 +-
 .../transport/failover/BadConnectionTest.java   |   85 -
 .../transport/failover/ClusterUtil.java         |   25 +
 .../failover/ConnectionHangOnStartupTest.java   |   33 +-
 .../failover/FailoverBackupLeakTest.java        |   80 +-
 .../transport/failover/FailoverClusterTest.java |  171 +-
 .../failover/FailoverComplexClusterTest.java    |  379 +++--
 .../FailoverConsumerOutstandingCommitTest.java  |  227 +--
 .../FailoverConsumerUnconsumedTest.java         |  242 +--
 .../failover/FailoverDuplicateTest.java         |  151 +-
 .../failover/FailoverPrefetchZeroTest.java      |  119 +-
 .../failover/FailoverPriorityTest.java          |  270 ++--
 .../transport/failover/FailoverRandomTest.java  |   64 +-
 .../FailoverRedeliveryTransactionTest.java      |   28 +-
 .../transport/failover/FailoverTimeoutTest.java |   36 +-
 .../failover/FailoverTransactionTest.java       |  672 +++-----
 .../failover/FailoverTransportBackupsTest.java  |   52 +-
 .../failover/FailoverTransportBrokerTest.java   |  219 ++-
 .../FailoverTransportUriHandlingTest.java       |    1 -
 .../failover/FailoverUpdateURIsTest.java        |   91 +-
 .../transport/failover/FailoverUriTest.java     |    1 +
 .../failover/InitalReconnectDelayTest.java      |   70 +-
 .../transport/failover/ReconnectTest.java       |   60 +-
 .../transport/failover/SlowConnectionTest.java  |    9 +-
 .../failover/TwoBrokerFailoverClusterTest.java  |  160 +-
 .../activemq/transport/fanout/FanoutTest.java   |   30 +-
 .../fanout/FanoutTransportBrokerTest.java       |  218 ++-
 .../transport/tcp/InactivityMonitorTest.java    |   19 +-
 .../transport/tcp/TransportUriTest.java         |   10 -
 .../transport/vm/VMTransportBrokerNameTest.java |   50 -
 .../transport/vm/VMTransportBrokerTest.java     |   38 -
 .../vm/VMTransportEmbeddedBrokerTest.java       |  104 --
 .../transport/vm/VMTransportThreadSafeTest.java |  937 -----------
 .../transport/vm/VMTransportWaitForTest.java    |  139 --
 .../vm/VmTransportNetworkBrokerTest.java        |  151 --
 .../org/apache/activemq/util/LockFileTest.java  |   70 +
 .../org/apache/activemq/util/SocketProxy.java   |  396 +++++
 .../java/org/apache/activemq/util/Wait.java     |   50 +
 356 files changed, 5261 insertions(+), 50675 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java
index 35f584b..9872d0f 100644
--- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java
+++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java
@@ -1047,28 +1047,32 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
    private boolean internalCreateQueue(final String queueName,
                                        final String selectorString,
                                        final boolean durable) throws Exception {
-      if (queues.get(queueName) != null) {
-         return false;
-      }
-      else {
-         ActiveMQQueue activeMQQueue = ActiveMQDestination.createQueue(queueName);
+      // TODO: there was an openwire test failng because of this
+      //       is this really needed for FailoverClusterTest ?
+      synchronized (queues) {
+         if (queues.get(queueName) != null) {
+            return false;
+         }
+         else {
+            ActiveMQQueue activeMQQueue = ActiveMQDestination.createQueue(queueName);
 
-         // Convert from JMS selector to core filter
-         String coreFilterString = null;
+            // Convert from JMS selector to core filter
+            String coreFilterString = null;
 
-         if (selectorString != null) {
-            coreFilterString = SelectorTranslator.convertToActiveMQFilterString(selectorString);
-         }
+            if (selectorString != null) {
+               coreFilterString = SelectorTranslator.convertToActiveMQFilterString(selectorString);
+            }
 
-         Queue queue = server.deployQueue(SimpleString.toSimpleString(activeMQQueue.getAddress()), SimpleString.toSimpleString(activeMQQueue.getAddress()), SimpleString.toSimpleString(coreFilterString), durable, false);
+            Queue queue = server.deployQueue(SimpleString.toSimpleString(activeMQQueue.getAddress()), SimpleString.toSimpleString(activeMQQueue.getAddress()), SimpleString.toSimpleString(coreFilterString), durable, false);
 
-         queues.put(queueName, activeMQQueue);
+            queues.put(queueName, activeMQQueue);
 
-         this.recoverregistryBindings(queueName, PersistedType.Queue);
+            this.recoverregistryBindings(queueName, PersistedType.Queue);
 
-         jmsManagementService.registerQueue(activeMQQueue, queue);
+            jmsManagementService.registerQueue(activeMQQueue, queue);
 
-         return true;
+            return true;
+         }
       }
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
index c2c535e..61e93cb 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.artemis.core.protocol.openwire;
 
+import javax.jms.InvalidClientIDException;
 import javax.jms.InvalidDestinationException;
 import javax.jms.JMSSecurityException;
 import javax.jms.ResourceAllocationException;
@@ -54,8 +55,8 @@ import org.apache.activemq.artemis.spi.core.remoting.Acceptor;
 import org.apache.activemq.artemis.spi.core.remoting.Connection;
 import org.apache.activemq.artemis.spi.core.remoting.ReadyListener;
 import org.apache.activemq.artemis.utils.ConcurrentHashSet;
+import org.apache.activemq.artemis.utils.ConfigurationHelper;
 import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQMessage;
 import org.apache.activemq.command.BrokerInfo;
 import org.apache.activemq.command.Command;
 import org.apache.activemq.command.ConnectionControl;
@@ -79,7 +80,6 @@ import org.apache.activemq.command.MessagePull;
 import org.apache.activemq.command.ProducerAck;
 import org.apache.activemq.command.ProducerId;
 import org.apache.activemq.command.ProducerInfo;
-import org.apache.activemq.command.RemoveInfo;
 import org.apache.activemq.command.RemoveSubscriptionInfo;
 import org.apache.activemq.command.Response;
 import org.apache.activemq.command.SessionId;
@@ -100,6 +100,7 @@ import org.apache.activemq.wireformat.WireFormat;
 
 /**
  * Represents an activemq connection.
+ * ToDo: extends AbstractRemotingConnection
  */
 public class OpenWireConnection implements RemotingConnection, CommandVisitor, SecurityAuth {
 
@@ -121,7 +122,7 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
 
    private final Acceptor acceptorUsed;
 
-   private OpenWireFormat wireFormat;
+   private final OpenWireFormat wireFormat;
 
    private AMQConnectionContext context;
 
@@ -150,6 +151,12 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
 
    private volatile AMQSession advisorySession;
 
+   private String defaultSocketURIString;
+
+   private boolean rebalance;
+   private boolean updateClusterClients;
+   private boolean updateClusterClientsOnRemove;
+
    public OpenWireConnection(Acceptor acceptorUsed,
                              Connection connection,
                              OpenWireProtocolManager openWireProtocolManager,
@@ -159,6 +166,13 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
       this.acceptorUsed = acceptorUsed;
       this.wireFormat = wf;
       this.creationTime = System.currentTimeMillis();
+      this.defaultSocketURIString = connection.getLocalAddress();
+
+      //Clebert: These are parameters specific to openwire cluster with defaults as specified at
+      //http://activemq.apache.org/failover-transport-reference.html
+      rebalance = ConfigurationHelper.getBooleanProperty("rebalance-cluster-clients", true, acceptorUsed.getConfiguration());
+      updateClusterClients = ConfigurationHelper.getBooleanProperty("update-cluster-clients", true, acceptorUsed.getConfiguration());
+      updateClusterClientsOnRemove = ConfigurationHelper.getBooleanProperty("update-cluster-clients-on-remove", true, acceptorUsed.getConfiguration());
    }
 
    @Override
@@ -186,6 +200,9 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
       return info.getPassword();
    }
 
+   public boolean isRebalance() {
+      return rebalance;
+   }
 
    private ConnectionInfo getConnectionInfo() {
       if (state == null) {
@@ -209,6 +226,7 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
 
          Command command = (Command) wireFormat.unmarshal(buffer);
 
+         //logger.log("got command: " + command);
          boolean responseRequired = command.isResponseRequired();
          int commandId = command.getCommandId();
          // the connection handles pings, negotiations directly.
@@ -224,10 +242,7 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
             // amq here starts a read/write monitor thread (detect ttl?)
             negotiate((WireFormatInfo) command);
          }
-         else if (command.getClass() == ConnectionInfo.class || command.getClass() == ConsumerInfo.class || command.getClass() == RemoveInfo.class ||
-                  command.getClass() == SessionInfo.class || command.getClass() == ProducerInfo.class || ActiveMQMessage.class.isAssignableFrom(command.getClass()) ||
-                  command.getClass() == MessageAck.class || command.getClass() == TransactionInfo.class || command.getClass() == DestinationInfo.class ||
-                  command.getClass() == ShutdownInfo.class || command.getClass() == RemoveSubscriptionInfo.class) {
+         else {
             Response response = null;
 
             if (pendingStop) {
@@ -235,6 +250,7 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
             }
             else {
                try {
+                  setLastCommand(command);
                   response = command.visit(this);
                }
                catch (Exception e) {
@@ -242,6 +258,9 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
                      response = new ExceptionResponse(e);
                   }
                }
+               finally {
+                  setLastCommand(null);
+               }
 
                if (response instanceof ExceptionResponse) {
                   if (!responseRequired) {
@@ -255,6 +274,7 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
             if (responseRequired) {
                if (response == null) {
                   response = new Response();
+                  response.setCorrelationId(command.getCommandId());
                }
             }
 
@@ -273,11 +293,6 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
             }
 
          }
-         else {
-            // note!!! wait for negotiation (e.g. use a countdown latch)
-            // before handling any other commands
-            this.protocolManager.handleCommand(this, command);
-         }
       }
       catch (IOException e) {
          ActiveMQServerLogger.LOGGER.error("error decoding", e);
@@ -287,6 +302,12 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
       }
    }
 
+   private void setLastCommand(Command command) {
+      if (context != null) {
+         context.setLastCommand(command);
+      }
+   }
+
    private void negotiate(WireFormatInfo command) throws IOException {
       this.wireFormat.renegotiateWireFormat(command);
       //throw back a brokerInfo here
@@ -390,36 +411,12 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
 
    @Override
    public void fail(ActiveMQException me) {
-      if (me != null) {
-         ActiveMQServerLogger.LOGGER.connectionFailureDetected(me.getMessage(), me.getType());
-      }
-
-      // Then call the listeners
-      callFailureListeners(me);
-
-      callClosingListeners();
-
-      destroyed = true;
-
-      transportConnection.close();
+      fail(me, null);
    }
 
    @Override
    public void destroy() {
-      destroyed = true;
-
-      transportConnection.close();
-
-      try {
-         deleteTempQueues();
-      }
-      catch (Exception e) {
-         //log warning
-      }
-
-      synchronized (sendLock) {
-         callClosingListeners();
-      }
+      fail(null, null);
    }
 
    private void deleteTempQueues() throws Exception {
@@ -452,7 +449,7 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
 
    @Override
    public void disconnect(boolean criticalError) {
-      fail(null);
+      this.disconnect(null, null, criticalError);
    }
 
    @Override
@@ -529,39 +526,9 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
 
    @Override
    public Response processAddConnection(ConnectionInfo info) throws Exception {
-      WireFormatInfo wireFormatInfo = wireFormat.getPreferedWireFormatInfo();
-      // Older clients should have been defaulting this field to true.. but
-      // they were not.
-      if (wireFormatInfo != null && wireFormatInfo.getVersion() <= 2) {
-         info.setClientMaster(true);
-      }
-
-      state = new ConnectionState(info);
-
-      context = new AMQConnectionContext();
-
-      state.reset(info);
-
-      // Setup the context.
-      String clientId = info.getClientId();
-      context.setBroker(protocolManager);
-      context.setClientId(clientId);
-      context.setClientMaster(info.isClientMaster());
-      context.setConnection(this);
-      context.setConnectionId(info.getConnectionId());
-      // for now we pass the manager as the connector and see what happens
-      // it should be related to activemq's Acceptor
-      context.setFaultTolerant(info.isFaultTolerant());
-      context.setUserName(info.getUserName());
-      context.setWireFormatInfo(wireFormatInfo);
-      context.setReconnect(info.isFailoverReconnect());
-      context.setConnectionState(state);
-      if (info.getClientIp() == null) {
-         info.setClientIp(getRemoteAddress());
-      }
-
+      //let protoclmanager handle connection add/remove
       try {
-         protocolManager.addConnection(context, info);
+         protocolManager.addConnection(this, info);
       }
       catch (Exception e) {
          if (e instanceof SecurityException) {
@@ -572,9 +539,9 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
          Response resp = new ExceptionResponse(e);
          return resp;
       }
-      if (info.isManageable()) {
+      if (info.isManageable() && this.isUpdateClusterClients()) {
          // send ConnectionCommand
-         ConnectionControl command = new ConnectionControl();
+         ConnectionControl command = protocolManager.newConnectionControl(rebalance);
          command.setFaultTolerant(protocolManager.isFaultTolerantConfiguration());
          if (info.isFailoverReconnect()) {
             command.setRebalanceConnection(false);
@@ -582,6 +549,7 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
          dispatchAsync(command);
       }
       return null;
+
    }
 
    public void dispatchAsync(Command message) {
@@ -768,6 +736,7 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
          protocolManager.addConsumer(this, info);
       }
       catch (Exception e) {
+         e.printStackTrace();
          if (e instanceof ActiveMQSecurityException) {
             resp = new ExceptionResponse(new JMSSecurityException(e.getMessage()));
          }
@@ -917,8 +886,11 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
    }
 
    @Override
-   public Response processConnectionControl(ConnectionControl arg0) throws Exception {
-      throw new IllegalStateException("not implemented! ");
+   public Response processConnectionControl(ConnectionControl connectionControl) throws Exception {
+      //activemq5 keeps a var to remember only the faultTolerant flag
+      //this can be sent over a reconnected transport as the first command
+      //before restoring the connection.
+      return null;
    }
 
    @Override
@@ -927,8 +899,16 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
    }
 
    @Override
-   public Response processConsumerControl(ConsumerControl arg0) throws Exception {
-      throw new IllegalStateException("not implemented! ");
+   public Response processConsumerControl(ConsumerControl consumerControl) throws Exception {
+      //amq5 clients send this command to restore prefetchSize
+      //after successful reconnect
+      try {
+         protocolManager.updateConsumer(this, consumerControl);
+      }
+      catch (Exception e) {
+         //log error
+      }
+      return null;
    }
 
    @Override
@@ -1089,21 +1069,9 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
 
    @Override
    public Response processRemoveConnection(ConnectionId id, long lastDeliveredSequenceId) throws Exception {
-      // Don't allow things to be added to the connection state while we
-      // are shutting down.
-      state.shutdown();
-      // Cascade the connection stop to the sessions.
-      for (SessionId sessionId : state.getSessionIds()) {
-         try {
-            processRemoveSession(sessionId, lastDeliveredSequenceId);
-         }
-         catch (Throwable e) {
-            // LOG
-         }
-      }
-
+      //we let protocol manager to handle connection add/remove
       try {
-         protocolManager.removeConnection(context, state.getInfo(), null);
+         protocolManager.removeConnection(this, state.getInfo(), null);
       }
       catch (Throwable e) {
          // log
@@ -1162,15 +1130,9 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
       // Don't let new consumers or producers get added while we are closing
       // this down.
       session.shutdown();
-      // Cascade the connection stop to the consumers and producers.
-      for (ConsumerId consumerId : session.getConsumerIds()) {
-         try {
-            processRemoveConsumer(consumerId, lastDeliveredSequenceId);
-         }
-         catch (Throwable e) {
-            // LOG.warn("Failed to remove consumer: {}", consumerId, e);
-         }
-      }
+      // Cascade the connection stop producers.
+      // we don't stop consumer because in core
+      // closing the session will do the job
       for (ProducerId producerId : session.getProducerIds()) {
          try {
             processRemoveProducer(producerId);
@@ -1200,6 +1162,7 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
 
    @Override
    public Response processShutdown(ShutdownInfo info) throws Exception {
+      this.shutdown(false);
       return null;
    }
 
@@ -1234,14 +1197,63 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
       tempQueues.add(queue);
    }
 
+   private void shutdown(boolean fail) {
+      if (fail) {
+         transportConnection.forceClose();
+      }
+      else {
+         transportConnection.close();
+      }
+   }
+
+   private void disconnect(ActiveMQException me, String reason, boolean fail) {
+
+      if (context == null || destroyed) {
+         return;
+      }
+      // Don't allow things to be added to the connection state while we
+      // are shutting down.
+      // is it necessary? even, do we need state at all?
+      state.shutdown();
+
+      // Then call the listeners
+      // this should closes underlying sessions
+      callFailureListeners(me);
+
+      // this should clean up temp dests
+      synchronized (sendLock) {
+         callClosingListeners();
+      }
+
+      destroyed = true;
+
+      //before closing transport, send the last response if any
+      Command command = context.getLastCommand();
+      if (command != null && command.isResponseRequired()) {
+         Response lastResponse = new Response();
+         lastResponse.setCorrelationId(command.getCommandId());
+         dispatchSync(lastResponse);
+         context.setDontSendReponse(true);
+      }
+   }
+
    @Override
    public void disconnect(String reason, boolean fail) {
-      destroy();
+      this.disconnect(null, reason, fail);
    }
 
    @Override
-   public void fail(ActiveMQException e, String message) {
-      destroy();
+   public void fail(ActiveMQException me, String message) {
+      if (me != null) {
+         ActiveMQServerLogger.LOGGER.connectionFailureDetected(me.getMessage(), me.getType());
+      }
+      try {
+         protocolManager.removeConnection(this, this.getConnectionInfo(), me);
+      }
+      catch (InvalidClientIDException e) {
+         ActiveMQServerLogger.LOGGER.warn("Couldn't close connection because invalid clientID", e);
+      }
+      shutdown(true);
    }
 
    public void setAdvisorySession(AMQSession amqSession) {
@@ -1252,8 +1264,82 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
       return this.advisorySession;
    }
 
-   public AMQConnectionContext getConext() {
+   public AMQConnectionContext getContext() {
       return this.context;
    }
 
+   public String getDefaultSocketURIString() {
+      return defaultSocketURIString;
+   }
+
+   public void updateClient(ConnectionControl control) {
+      //      if (!destroyed && context.isFaultTolerant()) {
+      if (updateClusterClients) {
+         dispatchAsync(control);
+      }
+      //      }
+   }
+
+   public boolean isUpdateClusterClients() {
+      return updateClusterClients;
+   }
+
+   public AMQConnectionContext initContext(ConnectionInfo info) {
+      WireFormatInfo wireFormatInfo = wireFormat.getPreferedWireFormatInfo();
+      // Older clients should have been defaulting this field to true.. but
+      // they were not.
+      if (wireFormatInfo != null && wireFormatInfo.getVersion() <= 2) {
+         info.setClientMaster(true);
+      }
+
+      state = new ConnectionState(info);
+
+      context = new AMQConnectionContext();
+
+      state.reset(info);
+
+      // Setup the context.
+      String clientId = info.getClientId();
+      context.setBroker(protocolManager);
+      context.setClientId(clientId);
+      context.setClientMaster(info.isClientMaster());
+      context.setConnection(this);
+      context.setConnectionId(info.getConnectionId());
+      // for now we pass the manager as the connector and see what happens
+      // it should be related to activemq's Acceptor
+      context.setFaultTolerant(info.isFaultTolerant());
+      context.setUserName(info.getUserName());
+      context.setWireFormatInfo(wireFormatInfo);
+      context.setReconnect(info.isFailoverReconnect());
+      context.setConnectionState(state);
+      if (info.getClientIp() == null) {
+         info.setClientIp(getRemoteAddress());
+      }
+
+      return context;
+   }
+
+   //raise the refCount of context
+   public void reconnect(AMQConnectionContext existingContext, ConnectionInfo info) {
+      this.context = existingContext;
+      WireFormatInfo wireFormatInfo = wireFormat.getPreferedWireFormatInfo();
+      // Older clients should have been defaulting this field to true.. but
+      // they were not.
+      if (wireFormatInfo != null && wireFormatInfo.getVersion() <= 2) {
+         info.setClientMaster(true);
+      }
+      if (info.getClientIp() == null) {
+         info.setClientIp(getRemoteAddress());
+      }
+
+      state = new ConnectionState(info);
+      state.reset(info);
+
+      context.setConnection(this);
+      context.setConnectionState(state);
+      context.setClientMaster(info.isClientMaster());
+      context.setFaultTolerant(info.isFaultTolerant());
+      context.setReconnect(true);
+      context.incRefCount();
+   }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
index f916c8f..525844c 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
@@ -21,6 +21,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -37,6 +38,8 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.BaseInterceptor;
 import org.apache.activemq.artemis.api.core.Interceptor;
 import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.api.core.client.ClusterTopologyListener;
+import org.apache.activemq.artemis.api.core.client.TopologyMember;
 import org.apache.activemq.artemis.api.core.management.CoreNotificationType;
 import org.apache.activemq.artemis.api.core.management.ManagementHelper;
 import org.apache.activemq.artemis.core.io.IOCallback;
@@ -52,6 +55,8 @@ import org.apache.activemq.artemis.core.security.CheckType;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.Queue;
+import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
+import org.apache.activemq.artemis.core.server.cluster.ClusterManager;
 import org.apache.activemq.artemis.core.server.management.ManagementService;
 import org.apache.activemq.artemis.core.server.management.Notification;
 import org.apache.activemq.artemis.core.server.management.NotificationListener;
@@ -70,15 +75,15 @@ import org.apache.activemq.command.ActiveMQTopic;
 import org.apache.activemq.command.BrokerId;
 import org.apache.activemq.command.BrokerInfo;
 import org.apache.activemq.command.Command;
-import org.apache.activemq.command.CommandTypes;
+import org.apache.activemq.command.ConnectionControl;
 import org.apache.activemq.command.ConnectionId;
 import org.apache.activemq.command.ConnectionInfo;
+import org.apache.activemq.command.ConsumerControl;
 import org.apache.activemq.command.ConsumerId;
 import org.apache.activemq.command.ConsumerInfo;
 import org.apache.activemq.command.DestinationInfo;
 import org.apache.activemq.command.MessageDispatch;
 import org.apache.activemq.command.MessageId;
-import org.apache.activemq.command.MessagePull;
 import org.apache.activemq.command.ProducerId;
 import org.apache.activemq.command.ProducerInfo;
 import org.apache.activemq.command.RemoveSubscriptionInfo;
@@ -97,7 +102,7 @@ import org.apache.activemq.util.IdGenerator;
 import org.apache.activemq.util.InetAddressUtil;
 import org.apache.activemq.util.LongSequenceGenerator;
 
-public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, NotificationListener {
+public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, NotificationListener, ClusterTopologyListener {
 
    private static final IdGenerator BROKER_ID_GENERATOR = new IdGenerator();
    private static final IdGenerator ID_GENERATOR = new IdGenerator();
@@ -122,17 +127,25 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
    private final CopyOnWriteArrayList<OpenWireConnection> connections = new CopyOnWriteArrayList<>();
 
    protected final ConcurrentMap<ConnectionId, ConnectionInfo> connectionInfos = new ConcurrentHashMap<>();
-
-   private final Map<String, AMQConnectionContext> clientIdSet = new HashMap<>();
+   // Clebert TODO: use ConcurrentHashMap, or maybe use the schema that's already available on Artemis upstream (unique-client-id)
+   private final Map<String, AMQConnectionContext> clientIdSet = new HashMap<String, AMQConnectionContext>();
 
    private String brokerName;
 
+   // Clebert TODO: Artemis already stores the Session. Why do we need a different one here
    private Map<SessionId, AMQSession> sessions = new ConcurrentHashMap<>();
 
+   // Clebert: Artemis already has a Resource Manager. Need to remove this..
+   //          The TransactionID extends XATransactionID, so all we need is to convert the XID here
    private Map<TransactionId, AMQSession> transactions = new ConcurrentHashMap<>();
 
+   // Clebert: Artemis session has meta-data support, perhaps we could reuse it here
    private Map<String, SessionId> sessionIdMap = new ConcurrentHashMap<>();
 
+   private final Map<String, TopologyMember> topologyMap = new ConcurrentHashMap<>();
+
+   private final LinkedList<TopologyMember> members = new LinkedList<>();
+
    private final ScheduledExecutorService scheduledPool;
 
    public OpenWireProtocolManager(OpenWireProtocolManagerFactory factory, ActiveMQServer server) {
@@ -148,6 +161,37 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
          service.addNotificationListener(this);
       }
 
+      final ClusterManager clusterManager = this.server.getClusterManager();
+      ClusterConnection cc = clusterManager.getDefaultConnection(null);
+      if (cc != null) {
+         cc.addClusterTopologyListener(this);
+      }
+   }
+
+   @Override
+   public void nodeUP(TopologyMember member, boolean last) {
+      if (topologyMap.put(member.getNodeId(), member) == null) {
+         updateClientClusterInfo();
+      }
+   }
+
+   public void nodeDown(long eventUID, String nodeID) {
+      if (topologyMap.remove(nodeID) != null) {
+         updateClientClusterInfo();
+      }
+   }
+
+   private void updateClientClusterInfo() {
+
+      synchronized (members) {
+         members.clear();
+         members.addAll(topologyMap.values());
+      }
+
+      for (OpenWireConnection c : this.connections) {
+         ConnectionControl control = newConnectionControl(c.isRebalance());
+         c.updateClient(control);
+      }
    }
 
    @Override
@@ -172,6 +216,7 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
       OpenWireConnection owConn = new OpenWireConnection(acceptorUsed, connection, this, wf);
       owConn.init();
 
+      // TODO CLEBERT What is this constant here? we should get it from TTL initial pings
       return new ConnectionEntry(owConn, null, System.currentTimeMillis(), 1 * 60 * 1000);
    }
 
@@ -229,28 +274,6 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
 
    }
 
-   public void handleCommand(OpenWireConnection openWireConnection, Object command) throws Exception {
-      Command amqCmd = (Command) command;
-      byte type = amqCmd.getDataStructureType();
-      switch (type) {
-         case CommandTypes.CONNECTION_INFO:
-            break;
-         case CommandTypes.CONNECTION_CONTROL:
-            /** The ConnectionControl packet sent from client informs the broker that is capable of supporting dynamic
-             * failover and load balancing.  These features are not yet implemented for Artemis OpenWire.  Instead we
-             * simply drop the packet.  See: ACTIVEMQ6-108 */
-            break;
-         case CommandTypes.MESSAGE_PULL:
-            MessagePull messagePull = (MessagePull) amqCmd;
-            openWireConnection.processMessagePull(messagePull);
-            break;
-         case CommandTypes.CONSUMER_CONTROL:
-            break;
-         default:
-            throw new IllegalStateException("Cannot handle command: " + command);
-      }
-   }
-
    public void sendReply(final OpenWireConnection connection, final Command command) {
       server.getStorageManager().afterCompleteOperations(new IOCallback() {
          @Override
@@ -287,50 +310,50 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
       }
    }
 
-   public void addConnection(AMQConnectionContext context, ConnectionInfo info) throws Exception {
+   public void addConnection(OpenWireConnection connection, ConnectionInfo info) throws Exception {
       String username = info.getUserName();
       String password = info.getPassword();
 
       if (!this.validateUser(username, password)) {
          throw new SecurityException("User name [" + username + "] or password is invalid.");
       }
+
       String clientId = info.getClientId();
       if (clientId == null) {
          throw new InvalidClientIDException("No clientID specified for connection request");
       }
+
       synchronized (clientIdSet) {
-         AMQConnectionContext oldContext = clientIdSet.get(clientId);
-         if (oldContext != null) {
-            if (context.isAllowLinkStealing()) {
-               clientIdSet.remove(clientId);
-               if (oldContext.getConnection() != null) {
-                  OpenWireConnection connection = oldContext.getConnection();
-                  connection.disconnect(true);
-               }
-               else {
-                  // log error
-               }
+         AMQConnectionContext context;
+         context = clientIdSet.get(clientId);
+         if (context != null) {
+            if (info.isFailoverReconnect()) {
+               OpenWireConnection oldConnection = context.getConnection();
+               oldConnection.disconnect(true);
+               connections.remove(oldConnection);
+               connection.reconnect(context, info);
             }
             else {
-               throw new InvalidClientIDException("Broker: " + getBrokerName() + " - Client: " + clientId + " already connected from " + oldContext.getConnection().getRemoteAddress());
+               throw new InvalidClientIDException("Broker: " + getBrokerName() + " - Client: " + clientId + " already connected from " + context.getConnection().getRemoteAddress());
             }
          }
          else {
+            //new connection
+            context = connection.initContext(info);
             clientIdSet.put(clientId, context);
          }
-      }
 
-      connections.add(context.getConnection());
+         connections.add(connection);
 
-      ActiveMQTopic topic = AdvisorySupport.getConnectionAdvisoryTopic();
-      // do not distribute passwords in advisory messages. usernames okay
-      ConnectionInfo copy = info.copy();
-      copy.setPassword("");
-      fireAdvisory(context, topic, copy);
-      connectionInfos.put(copy.getConnectionId(), copy);
+         ActiveMQTopic topic = AdvisorySupport.getConnectionAdvisoryTopic();
+         // do not distribute passwords in advisory messages. usernames okay
+         ConnectionInfo copy = info.copy();
+         copy.setPassword("");
+         fireAdvisory(context, topic, copy);
 
-      // init the conn
-      addSessions(context.getConnection(), context.getConnectionState().getSessionIds());
+         // init the conn
+         addSessions(context.getConnection(), context.getConnectionState().getSessionIds());
+      }
    }
 
    private void fireAdvisory(AMQConnectionContext context, ActiveMQTopic topic, Command copy) throws Exception {
@@ -338,6 +361,7 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
    }
 
    public BrokerId getBrokerId() {
+      // TODO: Use the Storage ID here...
       if (brokerId == null) {
          brokerId = new BrokerId(BROKER_ID_GENERATOR.generateId());
       }
@@ -398,6 +422,40 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
       return brokerName;
    }
 
+   protected ConnectionControl newConnectionControl(boolean rebalance) {
+      ConnectionControl control = new ConnectionControl();
+
+      String uri = generateMembersURI(rebalance);
+      control.setConnectedBrokers(uri);
+
+      control.setRebalanceConnection(rebalance);
+      return control;
+   }
+
+   private String generateMembersURI(boolean flip) {
+      String uri;
+      StringBuffer connectedBrokers = new StringBuffer();
+      String separator = "";
+
+      synchronized (members) {
+         if (members.size() > 0) {
+            for (TopologyMember member : members) {
+               connectedBrokers.append(separator).append(member.toURI());
+               separator = ",";
+            }
+
+            // The flip exists to guarantee even distribution of URIs when sent to the client
+            // in case of failures you won't get all the connections failing to a single server.
+            if (flip && members.size() > 1) {
+               members.addLast(members.removeFirst());
+            }
+         }
+      }
+
+      uri = connectedBrokers.toString();
+      return uri;
+   }
+
    public boolean isFaultTolerantConfiguration() {
       return false;
    }
@@ -448,11 +506,10 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
             if (destination.isQueue()) {
                OpenWireUtil.validateDestination(destination, amqSession);
             }
-            DestinationInfo destInfo = new DestinationInfo(theConn.getConext().getConnectionId(), DestinationInfo.ADD_OPERATION_TYPE, destination);
+            DestinationInfo destInfo = new DestinationInfo(theConn.getContext().getConnectionId(), DestinationInfo.ADD_OPERATION_TYPE, destination);
             this.addDestination(theConn, destInfo);
          }
 
-
          amqSession.createProducer(info);
 
          try {
@@ -466,6 +523,12 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
 
    }
 
+   public void updateConsumer(OpenWireConnection theConn, ConsumerControl consumerControl) {
+      SessionId sessionId = consumerControl.getConsumerId().getParentId();
+      AMQSession amqSession = sessions.get(sessionId);
+      amqSession.updateConsumerPrefetchSize(consumerControl.getConsumerId(), consumerControl.getPrefetch());
+   }
+
    public void addConsumer(OpenWireConnection theConn, ConsumerInfo info) throws Exception {
       // Todo: add a destination interceptors holder here (amq supports this)
       SessionId sessionId = info.getConsumerId().getParentId();
@@ -519,13 +582,23 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
       return amqSession;
    }
 
-   public void removeConnection(AMQConnectionContext context, ConnectionInfo info, Throwable error) {
-      // todo roll back tx
-      this.connections.remove(context.getConnection());
-      this.connectionInfos.remove(info.getConnectionId());
-      String clientId = info.getClientId();
-      if (clientId != null) {
-         this.clientIdSet.remove(clientId);
+   public void removeConnection(OpenWireConnection connection,
+                                ConnectionInfo info,
+                                Throwable error) throws InvalidClientIDException {
+      synchronized (clientIdSet) {
+         String clientId = info.getClientId();
+         if (clientId != null) {
+            AMQConnectionContext context = this.clientIdSet.get(clientId);
+            if (context != null && context.decRefCount() == 0) {
+               //connection is still there and need to close
+               this.clientIdSet.remove(clientId);
+               connection.disconnect(error != null);
+               this.connections.remove(connection);//what's that for?
+            }
+         }
+         else {
+            throw new InvalidClientIDException("No clientID specified for connection disconnect request");
+         }
       }
    }
 
@@ -568,7 +641,7 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
       }
 
       if (!AdvisorySupport.isAdvisoryTopic(dest)) {
-         AMQConnectionContext context = connection.getConext();
+         AMQConnectionContext context = connection.getContext();
          DestinationInfo advInfo = new DestinationInfo(context.getConnectionId(), DestinationInfo.REMOVE_OPERATION_TYPE, dest);
 
          ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(dest);
@@ -598,7 +671,7 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
       }
 
       if (!AdvisorySupport.isAdvisoryTopic(dest)) {
-         AMQConnectionContext context = connection.getConext();
+         AMQConnectionContext context = connection.getContext();
          DestinationInfo advInfo = new DestinationInfo(context.getConnectionId(), DestinationInfo.ADD_OPERATION_TYPE, dest);
 
          ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(dest);
@@ -720,7 +793,7 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
          ActiveMQMessage advisoryMessage = new ActiveMQMessage();
          advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_CONSUMER_ID, consumer.getId().toString());
 
-         fireAdvisory(cc.getConext(), topic, advisoryMessage, consumer.getId());
+         fireAdvisory(cc.getContext(), topic, advisoryMessage, consumer.getId());
       }
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConnectionContext.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConnectionContext.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConnectionContext.java
index a79911c..8071d04 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConnectionContext.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConnectionContext.java
@@ -17,9 +17,11 @@
 package org.apache.activemq.artemis.core.protocol.openwire.amq;
 
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection;
 import org.apache.activemq.artemis.core.protocol.openwire.OpenWireProtocolManager;
+import org.apache.activemq.command.Command;
 import org.apache.activemq.command.ConnectionId;
 import org.apache.activemq.command.ConnectionInfo;
 import org.apache.activemq.command.WireFormatInfo;
@@ -47,6 +49,8 @@ public class AMQConnectionContext {
    private boolean clientMaster = true;
    private ConnectionState connectionState;
    private XATransactionId xid;
+   private AtomicInteger refCount = new AtomicInteger(1);
+   private Command lastCommand;
 
    public AMQConnectionContext() {
       this.messageEvaluationContext = new MessageEvaluationContext();
@@ -248,4 +252,19 @@ public class AMQConnectionContext {
       return false;
    }
 
+   public void incRefCount() {
+      refCount.incrementAndGet();
+   }
+
+   public int decRefCount() {
+      return refCount.decrementAndGet();
+   }
+
+   public void setLastCommand(Command lastCommand) {
+      this.lastCommand = lastCommand;
+   }
+
+   public Command getLastCommand() {
+      return this.lastCommand;
+   }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java
index 7da1f3e..b0f007a 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java
@@ -44,7 +44,6 @@ import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
 
 public class AMQConsumer implements BrowserListener {
-
    private AMQSession session;
    private org.apache.activemq.command.ActiveMQDestination actualDest;
    private ConsumerInfo info;
@@ -52,7 +51,7 @@ public class AMQConsumer implements BrowserListener {
    private long nativeId = -1;
    private SimpleString subQueueName = null;
 
-   private final int prefetchSize;
+   private int prefetchSize;
    private AtomicInteger windowAvailable;
    private final java.util.Queue<MessageInfo> deliveringRefs = new ConcurrentLinkedQueue<>();
    private long messagePullSequence = 0;
@@ -220,7 +219,7 @@ public class AMQConsumer implements BrowserListener {
       else if (ack.isRedeliveredAck()) {
          //client tells that this message is for redlivery.
          //do nothing until poisoned.
-         n = 1;
+         n = ack.getMessageCount();
       }
       else if (ack.isPoisonAck()) {
          //send to dlq
@@ -251,7 +250,7 @@ public class AMQConsumer implements BrowserListener {
       }
       else if (ack.isDeliveredAck() || ack.isExpiredAck()) {
          //ToDo: implement with tests
-         n = 1;
+         n = ack.getMessageCount();
       }
       else {
          Iterator<MessageInfo> iter = deliveringRefs.iterator();
@@ -374,6 +373,15 @@ public class AMQConsumer implements BrowserListener {
       return actualDest;
    }
 
+   public void setPrefetchSize(int prefetchSize) {
+      this.prefetchSize = prefetchSize;
+      this.windowAvailable.set(prefetchSize);
+      this.info.setPrefetchSize(prefetchSize);
+      if (this.prefetchSize > 0) {
+         session.getCoreSession().promptDelivery(nativeId);
+      }
+   }
+
    private class MessagePullHandler {
 
       private long next = -1;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerSession.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerSession.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerSession.java
index 0a3804c..9a938fa 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerSession.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerSession.java
@@ -143,6 +143,8 @@ public class AMQServerSession extends ServerSessionImpl {
    }
 
    //amq specific behavior
+
+   // TODO: move this to AMQSession
    public void amqRollback(Set<Long> acked) throws Exception {
       if (tx == null) {
          // Might be null if XA
@@ -218,7 +220,9 @@ public class AMQServerSession extends ServerSessionImpl {
                                         final boolean supportLargeMessage,
                                         final Integer credits) throws Exception {
       if (this.internal) {
-         //internal sessions doesn't check security
+         // Clebert TODO: PQP!!!!!!!!!!!!!!!!!!!!
+
+         //internal sessions doesn't check security:: Why??? //// what's the reason for that? Where a link?
 
          Binding binding = postOffice.getBinding(queueName);
 
@@ -309,6 +313,8 @@ public class AMQServerSession extends ServerSessionImpl {
       return queue;
    }
 
+
+   // Clebert TODO: Get rid of these mthods
    @Override
    protected void doSend(final ServerMessage msg, final boolean direct) throws Exception {
       if (!this.internal) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
index 926aebd..a5d4709 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
@@ -33,6 +33,7 @@ import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.spi.core.remoting.ReadyListener;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ConnectionInfo;
+import org.apache.activemq.command.ConsumerId;
 import org.apache.activemq.command.ConsumerInfo;
 import org.apache.activemq.command.ExceptionResponse;
 import org.apache.activemq.command.Message;
@@ -136,6 +137,7 @@ public class AMQSession implements SessionCallback {
             getCoreServer().getJMSQueueCreator().create(queueName);
          }
          AMQConsumer consumer = new AMQConsumer(this, d, info, scheduledPool);
+
          consumer.init();
          consumerMap.put(d, consumer);
          consumers.put(consumer.getNativeId(), consumer);
@@ -197,8 +199,15 @@ public class AMQSession implements SessionCallback {
 
    @Override
    public boolean hasCredits(ServerConsumer consumerID) {
-      AMQConsumer amqConsumer = consumers.get(consumerID.getID());
-      return amqConsumer.hasCredits();
+
+      AMQConsumer amqConsumer;
+
+      amqConsumer = consumers.get(consumerID.getID());
+
+      if (amqConsumer != null) {
+         return amqConsumer.hasCredits();
+      }
+      return false;
    }
 
    @Override
@@ -449,6 +458,16 @@ public class AMQSession implements SessionCallback {
       return consumers.get(coreConsumerId);
    }
 
+   public void updateConsumerPrefetchSize(ConsumerId consumerId, int prefetch) {
+      Iterator<AMQConsumer> iterator = consumers.values().iterator();
+      while (iterator.hasNext()) {
+         AMQConsumer consumer = iterator.next();
+         if (consumer.getId().equals(consumerId)) {
+            consumer.setPrefetchSize(prefetch);
+         }
+      }
+   }
+
    private class SendRetryTask implements Runnable {
 
       private ServerMessage coreMsg;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
index d52f53f..4a24b57 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
@@ -947,4 +947,8 @@ public interface Configuration {
    StoreConfiguration getStoreConfiguration();
 
    Configuration setStoreConfiguration(StoreConfiguration storeConfiguration);
+
+   /** It will return all the connectors in a toString manner for debug purposes. */
+   String debugConnectors();
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
index 7784a01..1a9690f 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
@@ -21,7 +21,9 @@ import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import java.io.PrintWriter;
 import java.io.Serializable;
+import java.io.StringWriter;
 import java.lang.reflect.Array;
 import java.net.URI;
 import java.security.AccessController;
@@ -1299,6 +1301,8 @@ public class ConfigurationImpl implements Configuration, Serializable {
    public TransportConfiguration[] getTransportConfigurations(final List<String> connectorNames) {
       TransportConfiguration[] tcConfigs = (TransportConfiguration[]) Array.newInstance(TransportConfiguration.class, connectorNames.size());
       int count = 0;
+      System.out.println(debugConnectors());
+
       for (String connectorName : connectorNames) {
          TransportConfiguration connector = getConnectorConfigurations().get(connectorName);
 
@@ -1314,6 +1318,21 @@ public class ConfigurationImpl implements Configuration, Serializable {
       return tcConfigs;
    }
 
+   public String debugConnectors() {
+      StringWriter stringWriter = new StringWriter();
+      PrintWriter writer = new PrintWriter(stringWriter);
+
+
+      for (Map.Entry<String, TransportConfiguration> connector : getConnectorConfigurations().entrySet()) {
+         writer.println("Connector::" + connector.getKey() + " value = " + connector.getValue());
+      }
+
+      writer.close();
+
+      return stringWriter.toString();
+
+   }
+
    @Override
    public boolean isResolveProtocols() {
       return resolveProtocols;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
index efbc1ea..34cc8cf 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
@@ -169,6 +169,8 @@ public class NettyAcceptor extends AbstractAcceptor {
 
    private final long connectionsAllowed;
 
+   private Map<String, Object> extraConfigs;
+
    public NettyAcceptor(final String name,
                         final ClusterConnection clusterConnection,
                         final Map<String, Object> configuration,

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
index d2cde4b..795bbb5 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
@@ -146,7 +146,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif
       this.flushExecutor = flushExecutor;
 
       ActiveMQServerLogger.LOGGER.addingProtocolSupport(coreProtocolManagerFactory.getProtocols()[0], coreProtocolManagerFactory.getModuleName());
-//      this.protocolMap.put(coreProtocolManagerFactory.getProtocols()[0], coreProtocolManagerFactory.createProtocolManager(server, coreProtocolManagerFactory.filterInterceptors(incomingInterceptors), coreProtocolManagerFactory.filterInterceptors(outgoingInterceptors)));
+      //      this.protocolMap.put(coreProtocolManagerFactory.getProtocols()[0], coreProtocolManagerFactory.createProtocolManager(server, coreProtocolManagerFactory.filterInterceptors(incomingInterceptors), coreProtocolManagerFactory.filterInterceptors(outgoingInterceptors)));
       this.protocolMap.put(coreProtocolManagerFactory.getProtocols()[0], coreProtocolManagerFactory);
 
       if (config.isResolveProtocols()) {
@@ -206,8 +206,8 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif
          @Override
          public ThreadFactory run() {
             return new ActiveMQThreadFactory("ActiveMQ-remoting-threads-" + server.toString() +
-                                                                        "-" +
-                                                                        System.identityHashCode(this), false, Thread.currentThread().getContextClassLoader());
+                                                "-" +
+                                                System.identityHashCode(this), false, Thread.currentThread().getContextClassLoader());
          }
       });
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java
index ef384e0..e3a583f 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/EmbeddedActiveMQ.java
@@ -69,6 +69,11 @@ public class EmbeddedActiveMQ {
     * @return
     */
    public boolean waitClusterForming(long timeWait, TimeUnit unit, int iterations, int servers) throws Exception {
+      if (activeMQServer.getClusterManager().getClusterConnections() == null ||
+         activeMQServer.getClusterManager().getClusterConnections().size() == 0) {
+         return servers == 0;
+      }
+
       for (int i = 0; i < iterations; i++) {
          for (ClusterConnection connection : activeMQServer.getClusterManager().getClusterConnections()) {
             if (connection.getTopology().getMembers().size() == servers) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/pom.xml b/tests/activemq5-unit-tests/pom.xml
index 5b77b7e..e52b9a6 100644
--- a/tests/activemq5-unit-tests/pom.xml
+++ b/tests/activemq5-unit-tests/pom.xml
@@ -29,7 +29,7 @@
 
    <properties>
       <activemq.basedir>${project.basedir}/../..</activemq.basedir>
-      <activemq5.project.version>5.11.1</activemq5.project.version>
+      <activemq5.project.version>5.12.0</activemq5.project.version>
       <jmdns-version>3.4.1</jmdns-version>
       <ftpserver-version>1.0.6</ftpserver-version>
       <jmock-version>2.5.1</jmock-version>
@@ -43,6 +43,7 @@
       <jasypt-version>1.9.2</jasypt-version>
       <directory-version>2.0.0-M6</directory-version>
       <activeio-core-version>3.1.4</activeio-core-version>
+      <byteman.version>2.2.0</byteman.version>
 
    </properties>
 
@@ -62,13 +63,6 @@
 
       <dependency>
          <groupId>org.apache.activemq</groupId>
-         <artifactId>activemq-broker</artifactId>
-         <version>${activemq5.project.version}</version>
-         <type>test-jar</type>
-      </dependency>
-
-      <dependency>
-         <groupId>org.apache.activemq</groupId>
          <artifactId>activemq-jdbc-store</artifactId>
          <version>${activemq5.project.version}</version>
       </dependency>
@@ -313,6 +307,35 @@
          <artifactId>artemis-openwire-protocol</artifactId>
          <version>${project.version}</version>
       </dependency>
+      <dependency>
+         <groupId>org.jboss.byteman</groupId>
+         <artifactId>byteman</artifactId>
+         <version>${byteman.version}</version>
+      </dependency>
+      <dependency>
+         <groupId>org.jboss.byteman</groupId>
+         <artifactId>byteman-submit</artifactId>
+         <scope>test</scope>
+         <version>${byteman.version}</version>
+      </dependency>
+      <dependency>
+         <groupId>org.jboss.byteman</groupId>
+         <artifactId>byteman-install</artifactId>
+         <scope>test</scope>
+         <version>${byteman.version}</version>
+      </dependency>
+      <dependency>
+         <groupId>org.jboss.byteman</groupId>
+         <artifactId>byteman-bmunit</artifactId>
+         <scope>test</scope>
+         <version>${byteman.version}</version>
+         <exclusions>
+            <exclusion>
+               <groupId>org.testng</groupId>
+               <artifactId>testng</artifactId>
+            </exclusion>
+         </exclusions>
+      </dependency>
 
    </dependencies>
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/ArtemisBrokerWrapperFactory.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/ArtemisBrokerWrapperFactory.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/ArtemisBrokerWrapperFactory.java
new file mode 100644
index 0000000..eff9ab3
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/ArtemisBrokerWrapperFactory.java
@@ -0,0 +1,32 @@
+/*
+ * 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.broker;
+
+import org.apache.activemq.broker.artemiswrapper.ArtemisBrokerWrapper;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ArtemisBrokerWrapperFactory {
+   List<ArtemisBrokerWrapper> brokers = new ArrayList<>();
+
+   public static Broker createBroker(BrokerService brokerService) {
+
+      return null;
+   }
+}


[35/60] [abbrv] activemq-artemis git commit: Fixing SslContextNBrokerServiceTest (one of the two)

Posted by cl...@apache.org.
Fixing SslContextNBrokerServiceTest (one of the two)


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/b0d5ea9c
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/b0d5ea9c
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/b0d5ea9c

Branch: refs/heads/refactor-openwire
Commit: b0d5ea9cb2c0a63c7ad2ee3221f3be026b68fff1
Parents: 0465ac5
Author: Howard Gao <ho...@gmail.com>
Authored: Fri Feb 19 21:32:14 2016 +0800
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:44:21 2016 -0400

----------------------------------------------------------------------
 .../apache/activemq/broker/BrokerService.java   | 19 ++++++++
 .../artemiswrapper/ArtemisBrokerWrapper.java    | 46 ++++++++++--------
 .../activemq/transport/tcp/n-brokers-ssl.xml    | 51 ++++++++++++++++++++
 3 files changed, 97 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b0d5ea9c/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
index b7b02b3..99de104 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
@@ -53,6 +53,7 @@ import org.apache.activemq.network.NetworkConnector;
 import org.apache.activemq.network.jms.JmsConnector;
 import org.apache.activemq.proxy.ProxyConnector;
 import org.apache.activemq.security.MessageAuthorizationPolicy;
+import org.apache.activemq.spring.SpringSslContext;
 import org.apache.activemq.store.PListStore;
 import org.apache.activemq.store.PersistenceAdapter;
 import org.apache.activemq.store.PersistenceAdapterFactory;
@@ -100,6 +101,7 @@ public class BrokerService implements Service {
    private Throwable startException = null;
    private boolean startAsync = false;
    public Set<Integer> extraConnectors = new HashSet<>();
+   public Set<Integer> sslConnectors = new HashSet<>();
 
    private List<TransportConnector> transportConnectors = new ArrayList<>();
    private File dataDirectoryFile;
@@ -491,6 +493,15 @@ public class BrokerService implements Service {
 
    public void setTransportConnectors(List<TransportConnector> transportConnectors) throws Exception {
       this.transportConnectors = transportConnectors;
+      for (TransportConnector connector : transportConnectors) {
+         if (connector.getUri().getScheme().equals("ssl")) {
+            this.sslConnectors.add(connector.getUri().getPort());
+            System.out.println(this + " added ssl connector: " + connector.getUri().getPort());
+         }
+         else {
+            this.extraConnectors.add(connector.getUri().getPort());
+         }
+      }
    }
 
    public NetworkConnector addNetworkConnector(NetworkConnector connector) throws Exception {
@@ -698,6 +709,14 @@ public class BrokerService implements Service {
 
    public void setSslContext(SslContext sslContext) {
       this.sslContext = sslContext;
+      if (sslContext instanceof SpringSslContext) {
+         SpringSslContext springContext = (SpringSslContext)sslContext;
+         this.SERVER_SIDE_KEYSTORE = springContext.getKeyStore();
+         this.KEYSTORE_PASSWORD = springContext.getKeyStorePassword();
+         this.SERVER_SIDE_TRUSTSTORE = springContext.getTrustStore();
+         this.TRUSTSTORE_PASSWORD = springContext.getTrustStorePassword();
+         this.storeType = springContext.getKeyStoreType();
+      }
    }
 
    public void setPersistenceFactory(PersistenceAdapterFactory persistenceFactory) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b0d5ea9c/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
index 5cb5048..1c8ce9b 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
@@ -33,13 +33,12 @@ import org.apache.activemq.artemis.core.postoffice.Binding;
 import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
 import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
 import org.apache.activemq.artemis.core.security.Role;
-import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.impl.QueueImpl;
 import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.core.settings.impl.SlowConsumerPolicy;
 import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
-import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManagerImpl;
+import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
 import org.apache.activemq.artemiswrapper.ArtemisBrokerHelper;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.broker.region.policy.PolicyEntry;
@@ -82,25 +81,16 @@ public class ArtemisBrokerWrapper extends ArtemisBrokerBase {
       commonSettings.setDeadLetterAddress(dla);
       commonSettings.setAutoCreateJmsQueues(true);
 
-      HashMap<String, Object> params = new HashMap<String, Object>();
       if (bservice.extraConnectors.size() == 0) {
          serverConfig.addAcceptorConfiguration("home", "tcp://localhost:61616?protocols=OPENWIRE,CORE");
       }
-      if (this.bservice.enableSsl()) {
-         params.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
-         params.put(TransportConstants.PORT_PROP_NAME, 61611);
-         params.put(TransportConstants.PROTOCOLS_PROP_NAME, "OPENWIRE");
-         params.put(TransportConstants.KEYSTORE_PATH_PROP_NAME, bservice.SERVER_SIDE_KEYSTORE);
-         params.put(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME, bservice.KEYSTORE_PASSWORD);
-         params.put(TransportConstants.KEYSTORE_PROVIDER_PROP_NAME, bservice.storeType);
-         if (bservice.SERVER_SIDE_TRUSTSTORE != null) {
-            params.put(TransportConstants.NEED_CLIENT_AUTH_PROP_NAME, true);
-            params.put(TransportConstants.TRUSTSTORE_PATH_PROP_NAME, bservice.SERVER_SIDE_TRUSTSTORE);
-            params.put(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME, bservice.TRUSTSTORE_PASSWORD);
-            params.put(TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME, bservice.storeType);
-         }
-         TransportConfiguration sslTransportConfig = new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, params);
-         serverConfig.getAcceptorConfigurations().add(sslTransportConfig);
+      if (this.bservice.enableSsl() && bservice.sslConnectors.size() == 0) {
+         //default
+         addSSLAcceptor(serverConfig, 61611);
+      }
+
+      for (Integer port : bservice.sslConnectors) {
+         addSSLAcceptor(serverConfig, port);
       }
 
       for (Integer port : bservice.extraConnectors) {
@@ -112,7 +102,7 @@ public class ArtemisBrokerWrapper extends ArtemisBrokerBase {
       //extraServerConfig(serverConfig);
 
       if (enableSecurity) {
-         ActiveMQSecurityManagerImpl sm = (ActiveMQSecurityManagerImpl) server.getSecurityManager();
+         ActiveMQJAASSecurityManager sm = (ActiveMQJAASSecurityManager) server.getSecurityManager();
          SecurityConfiguration securityConfig = sm.getConfiguration();
          securityConfig.addRole("openwireSender", "sender");
          securityConfig.addUser("openwireSender", "SeNdEr");
@@ -175,6 +165,24 @@ public class ArtemisBrokerWrapper extends ArtemisBrokerBase {
 
    }
 
+   private void addSSLAcceptor(Configuration serverConfig, Integer port) {
+      HashMap<String, Object> params = new HashMap<String, Object>();
+      params.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
+      params.put(TransportConstants.PORT_PROP_NAME, port);
+      params.put(TransportConstants.PROTOCOLS_PROP_NAME, "OPENWIRE");
+      params.put(TransportConstants.KEYSTORE_PATH_PROP_NAME, bservice.SERVER_SIDE_KEYSTORE);
+      params.put(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME, bservice.KEYSTORE_PASSWORD);
+      params.put(TransportConstants.KEYSTORE_PROVIDER_PROP_NAME, bservice.storeType);
+      if (bservice.SERVER_SIDE_TRUSTSTORE != null) {
+         params.put(TransportConstants.NEED_CLIENT_AUTH_PROP_NAME, true);
+         params.put(TransportConstants.TRUSTSTORE_PATH_PROP_NAME, bservice.SERVER_SIDE_TRUSTSTORE);
+         params.put(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME, bservice.TRUSTSTORE_PASSWORD);
+         params.put(TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME, bservice.storeType);
+      }
+      TransportConfiguration sslTransportConfig = new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, params);
+      serverConfig.getAcceptorConfigurations().add(sslTransportConfig);
+   }
+
    private void translatePolicyMap(Configuration serverConfig, PolicyMap policyMap) {
       List allEntries = policyMap.getAllEntries();
       Map<String, AddressSettings> settingsMap = serverConfig.getAddressesSettings();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b0d5ea9c/tests/activemq5-unit-tests/src/test/resources/org/apache/activemq/transport/tcp/n-brokers-ssl.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/resources/org/apache/activemq/transport/tcp/n-brokers-ssl.xml b/tests/activemq5-unit-tests/src/test/resources/org/apache/activemq/transport/tcp/n-brokers-ssl.xml
new file mode 100644
index 0000000..4bd5fc7
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/resources/org/apache/activemq/transport/tcp/n-brokers-ssl.xml
@@ -0,0 +1,51 @@
+<?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">
+
+  <amq:broker useJmx="false" persistent="false" start="false" brokerName="dummy">
+
+    <amq:sslContext>
+      <amq:sslContext 
+      		keyStore="dummy.keystore" keyStorePassword="password"/>
+    </amq:sslContext>
+    
+    <amq:transportConnectors>
+      <amq:transportConnector uri="ssl://localhost:62616" />
+    </amq:transportConnectors>
+    
+  </amq:broker>
+
+  <amq:broker useJmx="false" persistent="false" start="false" brokerName="activemq.org">
+    <amq:sslContext>
+      <amq:sslContext 
+      		keyStore="server.keystore" keyStorePassword="password"
+       		trustStore="client.keystore" trustStorePassword="password"/>
+    </amq:sslContext>
+    
+    <amq:transportConnectors>
+      <amq:transportConnector uri="ssl://localhost:63616" />
+    </amq:transportConnectors>
+    
+  </amq:broker>
+</beans>


[36/60] [abbrv] activemq-artemis git commit: removing AMQProducer

Posted by cl...@apache.org.
removing AMQProducer


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/1b629c1e
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/1b629c1e
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/1b629c1e

Branch: refs/heads/refactor-openwire
Commit: 1b629c1eccf568298652b3a2930c3351770d2ebd
Parents: 9898f60
Author: Clebert Suconic <cl...@apache.org>
Authored: Wed Feb 24 22:29:54 2016 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:44:21 2016 -0400

----------------------------------------------------------------------
 .../core/protocol/openwire/amq/AMQProducer.java | 38 --------------------
 1 file changed, 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/1b629c1e/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQProducer.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQProducer.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQProducer.java
deleted file mode 100644
index 848325e..0000000
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQProducer.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.artemis.core.protocol.openwire.amq;
-
-import org.apache.activemq.command.ProducerInfo;
-import org.apache.activemq.artemis.core.protocol.openwire.OpenWireUtil;
-
-public class AMQProducer {
-
-   private AMQSession amqSession;
-   private ProducerInfo info;
-
-   public AMQProducer(AMQSession amqSession, ProducerInfo info) {
-      this.amqSession = amqSession;
-      this.info = info;
-   }
-
-   public void init() throws Exception {
-      // If the destination is specified check that it exists.
-      if (info.getDestination() != null) {
-         OpenWireUtil.validateDestination(info.getDestination(), amqSession);
-      }
-   }
-}


[39/60] [abbrv] activemq-artemis git commit: Progress on refactoring - first pass: using AbstractConnection on OpenWireConnection and adding more TODOs

Posted by cl...@apache.org.
Progress on refactoring - first pass: using AbstractConnection on OpenWireConnection and adding more TODOs


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/e306e53a
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/e306e53a
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/e306e53a

Branch: refs/heads/refactor-openwire
Commit: e306e53a13c35c25975c977415ffd70a5d006a57
Parents: 4adf631
Author: Clebert Suconic <cl...@apache.org>
Authored: Tue Feb 23 21:52:21 2016 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:44:21 2016 -0400

----------------------------------------------------------------------
 .../protocol/AbstractRemotingConnection.java    |    5 +
 .../protocol/openwire/AMQTransactionImpl.java   |   14 +-
 .../protocol/openwire/OpenWireConnection.java   | 1100 +++++++-----------
 .../openwire/OpenWireProtocolManager.java       |   14 +-
 .../openwire/amq/AMQProducerBrokerExchange.java |   51 +-
 .../openwire/amq/AMQServerSessionFactory.java   |    9 +
 .../core/protocol/openwire/amq/AMQSession.java  |   13 +-
 .../openwire/impl/OpenWireServerCallback.java   |   75 ++
 8 files changed, 560 insertions(+), 721 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e306e53a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractRemotingConnection.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractRemotingConnection.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractRemotingConnection.java
index b759ccc..ee2449b 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractRemotingConnection.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractRemotingConnection.java
@@ -104,6 +104,11 @@ public abstract class AbstractRemotingConnection implements RemotingConnection {
       return transportConnection.getID();
    }
 
+
+   public String getLocalAddress() {
+      return transportConnection.getLocalAddress();
+   }
+
    @Override
    public String getRemoteAddress() {
       return transportConnection.getRemoteAddress();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e306e53a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/AMQTransactionImpl.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/AMQTransactionImpl.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/AMQTransactionImpl.java
index e356522..bbd7e95 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/AMQTransactionImpl.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/AMQTransactionImpl.java
@@ -28,22 +28,10 @@ public class AMQTransactionImpl extends TransactionImpl {
 
    private boolean rollbackForClose = false;
 
-   public AMQTransactionImpl(StorageManager storageManager, int timeoutSeconds) {
-      super(storageManager, timeoutSeconds);
-   }
-
-   public AMQTransactionImpl(StorageManager storageManager) {
-      super(storageManager);
-   }
-
    public AMQTransactionImpl(Xid xid, StorageManager storageManager, int timeoutSeconds) {
       super(xid, storageManager, timeoutSeconds);
    }
 
-   public AMQTransactionImpl(long id, Xid xid, StorageManager storageManager) {
-      super(id, xid, storageManager);
-   }
-
    @Override
    public RefsOperation createRefsOperation(Queue queue) {
       return new AMQrefsOperation(queue, storageManager);
@@ -55,6 +43,8 @@ public class AMQTransactionImpl extends TransactionImpl {
          super(queue, storageManager);
       }
 
+
+      // This is because the Rollbacks happen through the consumer, not through the server's
       @Override
       public void afterRollback(Transaction tx) {
          if (rollbackForClose) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e306e53a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
index a6f0f34..dbbb59f 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
@@ -31,6 +31,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.Executor;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
@@ -39,6 +40,9 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException;
 import org.apache.activemq.artemis.api.core.ActiveMQSecurityException;
+import org.apache.activemq.artemis.core.protocol.openwire.OpenWireProtocolManager;
+import org.apache.activemq.artemis.core.protocol.openwire.OpenWireUtil;
+import org.apache.activemq.artemis.core.protocol.openwire.SendingResult;
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQCompositeConsumerBrokerExchange;
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext;
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConsumer;
@@ -50,6 +54,7 @@ import org.apache.activemq.artemis.core.remoting.CloseListener;
 import org.apache.activemq.artemis.core.remoting.FailureListener;
 import org.apache.activemq.artemis.core.security.SecurityAuth;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
+import org.apache.activemq.artemis.spi.core.protocol.AbstractRemotingConnection;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
 import org.apache.activemq.artemis.spi.core.remoting.Acceptor;
 import org.apache.activemq.artemis.spi.core.remoting.Connection;
@@ -101,32 +106,22 @@ import org.apache.activemq.wireformat.WireFormat;
  * Represents an activemq connection.
  * ToDo: extends AbstractRemotingConnection
  */
-public class OpenWireConnection implements RemotingConnection, CommandVisitor, SecurityAuth {
+public class OpenWireConnection extends AbstractRemotingConnection implements SecurityAuth {
 
    private final OpenWireProtocolManager protocolManager;
 
-   private final Connection transportConnection;
-
-   private final long creationTime;
-
-   private final List<FailureListener> failureListeners = new CopyOnWriteArrayList<>();
-
    private final List<CloseListener> closeListeners = new CopyOnWriteArrayList<>();
 
    private boolean destroyed = false;
 
    private final Object sendLock = new Object();
 
-   private volatile boolean dataReceived;
-
    private final Acceptor acceptorUsed;
 
    private final OpenWireFormat wireFormat;
 
    private AMQConnectionContext context;
 
-   private boolean pendingStop;
-
    private Throwable stopError = null;
 
    private final AtomicBoolean stopping = new AtomicBoolean(false);
@@ -154,21 +149,16 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
 
    public OpenWireConnection(Acceptor acceptorUsed,
                              Connection connection,
+                             Executor executor,
                              OpenWireProtocolManager openWireProtocolManager,
                              OpenWireFormat wf) {
+      super(connection, executor);
       this.protocolManager = openWireProtocolManager;
-      this.transportConnection = connection;
       this.acceptorUsed = acceptorUsed;
       this.wireFormat = wf;
-      this.creationTime = System.currentTimeMillis();
       this.defaultSocketURIString = connection.getLocalAddress();
    }
 
-   @Override
-   public boolean isWritable(ReadyListener callback) {
-      return transportConnection.isWritable(callback);
-   }
-
    // SecurityAuth implementation
    @Override
    public String getUsername() {
@@ -181,6 +171,12 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
 
    // SecurityAuth implementation
    @Override
+   public RemotingConnection getRemotingConnection() {
+      return this;
+   }
+
+   // SecurityAuth implementation
+   @Override
    public String getPassword() {
       ConnectionInfo info = getConnectionInfo();
       if (info == null) {
@@ -200,18 +196,15 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
       return info;
    }
 
-   public String getLocalAddress() {
-      return transportConnection.getLocalAddress();
-   }
-
    @Override
    public void bufferReceived(Object connectionID, ActiveMQBuffer buffer) {
+      super.bufferReceived(connectionID, buffer);
       try {
-         dataReceived = true;
+
+         // TODO-NOW: set OperationContext
 
          Command command = (Command) wireFormat.unmarshal(buffer);
 
-         //logger.log("got command: " + command);
          boolean responseRequired = command.isResponseRequired();
          int commandId = command.getCommandId();
          // the connection handles pings, negotiations directly.
@@ -223,36 +216,27 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
             // for some reason KeepAliveInfo.isResponseRequired() is always false
             protocolManager.sendReply(this, info);
          }
-         else if (command.getClass() == WireFormatInfo.class) {
-            // amq here starts a read/write monitor thread (detect ttl?)
-            negotiate((WireFormatInfo) command);
-         }
          else {
             Response response = null;
 
-            if (pendingStop) {
-               response = new ExceptionResponse(this.stopError);
+            try {
+               setLastCommand(command);
+               response = command.visit(new CommandProcessor());
             }
-            else {
-               try {
-                  setLastCommand(command);
-                  response = command.visit(this);
-               }
-               catch (Exception e) {
-                  if (responseRequired) {
-                     response = new ExceptionResponse(e);
-                  }
-               }
-               finally {
-                  setLastCommand(null);
+            catch (Exception e) {
+               if (responseRequired) {
+                  response = new ExceptionResponse(e);
                }
+            }
+            finally {
+               setLastCommand(null);
+            }
 
-               if (response instanceof ExceptionResponse) {
-                  if (!responseRequired) {
-                     Throwable cause = ((ExceptionResponse) response).getException();
-                     serviceException(cause);
-                     response = null;
-                  }
+            if (response instanceof ExceptionResponse) {
+               if (!responseRequired) {
+                  Throwable cause = ((ExceptionResponse) response).getException();
+                  serviceException(cause);
+                  response = null;
                }
             }
 
@@ -272,6 +256,8 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
                }
             }
 
+            // TODO-NOW: response through operation-context
+
             if (response != null && !protocolManager.isStopping()) {
                response.setCorrelationId(commandId);
                dispatchSync(response);
@@ -280,6 +266,8 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
          }
       }
       catch (IOException e) {
+
+         // TODO-NOW: send errors
          ActiveMQServerLogger.LOGGER.error("error decoding", e);
       }
       catch (Throwable t) {
@@ -293,135 +281,11 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
       }
    }
 
-   private void negotiate(WireFormatInfo command) throws IOException {
-      this.wireFormat.renegotiateWireFormat(command);
-      //throw back a brokerInfo here
-      protocolManager.sendBrokerInfo(this);
-   }
-
-   @Override
-   public Object getID() {
-      return transportConnection.getID();
-   }
-
-   @Override
-   public long getCreationTime() {
-      return creationTime;
-   }
-
-   @Override
-   public String getRemoteAddress() {
-      return transportConnection.getRemoteAddress();
-   }
-
-   @Override
-   public void addFailureListener(FailureListener listener) {
-      if (listener == null) {
-         throw new IllegalStateException("FailureListener cannot be null");
-      }
-
-      failureListeners.add(listener);
-   }
-
-   @Override
-   public boolean removeFailureListener(FailureListener listener) {
-      if (listener == null) {
-         throw new IllegalStateException("FailureListener cannot be null");
-      }
-
-      return failureListeners.remove(listener);
-   }
-
-   @Override
-   public void addCloseListener(CloseListener listener) {
-      if (listener == null) {
-         throw new IllegalStateException("CloseListener cannot be null");
-      }
-
-      closeListeners.add(listener);
-   }
-
-   @Override
-   public boolean removeCloseListener(CloseListener listener) {
-      if (listener == null) {
-         throw new IllegalStateException("CloseListener cannot be null");
-      }
-
-      return closeListeners.remove(listener);
-   }
-
-   @Override
-   public List<CloseListener> removeCloseListeners() {
-      List<CloseListener> ret = new ArrayList<>(closeListeners);
-
-      closeListeners.clear();
-
-      return ret;
-   }
-
-   @Override
-   public void setCloseListeners(List<CloseListener> listeners) {
-      closeListeners.clear();
-
-      closeListeners.addAll(listeners);
-   }
-
-   @Override
-   public List<FailureListener> getFailureListeners() {
-      // we do not return the listeners otherwise the remoting service
-      // would NOT destroy the connection.
-      return Collections.emptyList();
-   }
-
-   @Override
-   public List<FailureListener> removeFailureListeners() {
-      List<FailureListener> ret = new ArrayList<>(failureListeners);
-
-      failureListeners.clear();
-
-      return ret;
-   }
-
-   @Override
-   public void setFailureListeners(List<FailureListener> listeners) {
-      failureListeners.clear();
-
-      failureListeners.addAll(listeners);
-   }
-
-   @Override
-   public ActiveMQBuffer createTransportBuffer(int size) {
-      return ActiveMQBuffers.dynamicBuffer(size);
-   }
-
-   @Override
-   public void fail(ActiveMQException me) {
-      fail(me, null);
-   }
-
    @Override
    public void destroy() {
       fail(null, null);
    }
 
-   private void deleteTempQueues() throws Exception {
-      Iterator<ActiveMQDestination> tmpQs = tempQueues.iterator();
-      while (tmpQs.hasNext()) {
-         ActiveMQDestination q = tmpQs.next();
-         protocolManager.removeDestination(this, q);
-      }
-   }
-
-   @Override
-   public RemotingConnection getRemotingConnection() {
-      return this;
-   }
-
-   @Override
-   public Connection getTransportConnection() {
-      return this.transportConnection;
-   }
-
    @Override
    public boolean isClient() {
       return false;
@@ -466,22 +330,6 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
       }
    }
 
-   private void callClosingListeners() {
-      final List<CloseListener> listenersClone = new ArrayList<>(closeListeners);
-
-      for (final CloseListener listener : listenersClone) {
-         try {
-            listener.connectionClosed();
-         }
-         catch (final Throwable t) {
-            // Failure of one listener to execute shouldn't prevent others
-            // from
-            // executing
-            ActiveMQServerLogger.LOGGER.errorCallingFailureListener(t);
-         }
-      }
-   }
-
    // throw a WireFormatInfo to the peer
    public void init() {
       WireFormatInfo info = wireFormat.getPreferedWireFormatInfo();
@@ -509,34 +357,6 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
 
    }
 
-   @Override
-   public Response processAddConnection(ConnectionInfo info) throws Exception {
-      //let protoclmanager handle connection add/remove
-      try {
-         protocolManager.addConnection(this, info);
-      }
-      catch (Exception e) {
-         if (e instanceof SecurityException) {
-            // close this down - in case the peer of this transport doesn't play
-            // nice
-            delayedStop(2000, "Failed with SecurityException: " + e.getLocalizedMessage(), e);
-         }
-         Response resp = new ExceptionResponse(e);
-         return resp;
-      }
-      if (info.isManageable() && protocolManager.isUpdateClusterClients()) {
-         // send ConnectionCommand
-         ConnectionControl command = protocolManager.newConnectionControl();
-         command.setFaultTolerant(protocolManager.isFaultTolerantConfiguration());
-         if (info.isFailoverReconnect()) {
-            command.setRebalanceConnection(false);
-         }
-         dispatchAsync(command);
-      }
-      return null;
-
-   }
-
    public void dispatchAsync(Command message) {
       if (!stopping.get()) {
          dispatchSync(message);
@@ -564,7 +384,7 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
 
    public void serviceExceptionAsync(final IOException e) {
       if (asyncException.compareAndSet(false, true)) {
-         // Why this is not through an executor?
+         // TODO: Why this is not through an executor?
          new Thread("Async Exception Handler") {
             @Override
             public void run() {
@@ -585,12 +405,7 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
          try {
             ConnectionError ce = new ConnectionError();
             ce.setException(e);
-            if (pendingStop) {
-               dispatchSync(ce);
-            }
-            else {
-               dispatchAsync(ce);
-            }
+            dispatchAsync(ce);
          }
          finally {
             inServiceException = false;
@@ -649,89 +464,6 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
       }
    }
 
-   public void delayedStop(final int waitTime, final String reason, Throwable cause) {
-      if (waitTime > 0) {
-         synchronized (this) {
-            pendingStop = true;
-            stopError = cause;
-         }
-      }
-   }
-
-   public void stopAsync() {
-      // If we're in the middle of starting then go no further... for now.
-      synchronized (this) {
-         pendingStop = true;
-      }
-      if (stopping.compareAndSet(false, true)) {
-         if (context != null) {
-            context.getStopping().set(true);
-         }
-      }
-   }
-
-   protected void doStop() throws Exception {
-      /*
-       * What's a duplex bridge? try { synchronized (this) { if (duplexBridge !=
-       * null) { duplexBridge.stop(); } } } catch (Exception ignore) {
-       * LOG.trace("Exception caught stopping. This exception is ignored.",
-       * ignore); }
-       */
-      try {
-         getTransportConnection().close();
-      }
-      catch (Exception e) {
-         // log
-      }
-
-      // Run the MessageDispatch callbacks so that message references get
-      // cleaned up.
-      synchronized (dispatchQueue) {
-         for (Iterator<Command> iter = dispatchQueue.iterator(); iter.hasNext(); ) {
-            Command command = iter.next();
-            if (command.isMessageDispatch()) {
-               MessageDispatch md = (MessageDispatch) command;
-               TransmitCallback sub = md.getTransmitCallback();
-               protocolManager.postProcessDispatch(md);
-               if (sub != null) {
-                  sub.onFailure();
-               }
-            }
-         }
-         dispatchQueue.clear();
-      }
-      //
-      // Remove all logical connection associated with this connection
-      // from the broker.
-      if (!protocolManager.isStopped()) {
-         context.getStopping().set(true);
-         try {
-            processRemoveConnection(state.getInfo().getConnectionId(), 0L);
-         }
-         catch (Throwable ignore) {
-            ignore.printStackTrace();
-         }
-      }
-   }
-
-   @Override
-   public Response processAddConsumer(ConsumerInfo info) {
-      Response resp = null;
-      try {
-         protocolManager.addConsumer(this, info);
-      }
-      catch (Exception e) {
-         e.printStackTrace();
-         if (e instanceof ActiveMQSecurityException) {
-            resp = new ExceptionResponse(new JMSSecurityException(e.getMessage()));
-         }
-         else {
-            resp = new ExceptionResponse(e);
-         }
-      }
-      return resp;
-   }
-
    public void addConsumerBrokerExchange(ConsumerId id,
                                          AMQSession amqSession,
                                          Map<ActiveMQDestination, AMQConsumer> consumerMap) {
@@ -762,222 +494,6 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
       }
    }
 
-   public int getConsumerCount() {
-      int result = 0;
-      for (SessionId sessionId : state.getSessionIds()) {
-         SessionState sessionState = state.getSessionState(sessionId);
-         if (sessionState != null) {
-            result += sessionState.getConsumerIds().size();
-         }
-      }
-      return result;
-   }
-
-   public int getProducerCount() {
-      int result = 0;
-      for (SessionId sessionId : state.getSessionIds()) {
-         SessionState sessionState = state.getSessionState(sessionId);
-         if (sessionState != null) {
-            result += sessionState.getProducerIds().size();
-         }
-      }
-      return result;
-   }
-
-   @Override
-   public Response processAddDestination(DestinationInfo dest) throws Exception {
-      Response resp = null;
-      try {
-         protocolManager.addDestination(this, dest);
-      }
-      catch (Exception e) {
-         if (e instanceof ActiveMQSecurityException) {
-            resp = new ExceptionResponse(new JMSSecurityException(e.getMessage()));
-         }
-         else {
-            resp = new ExceptionResponse(e);
-         }
-      }
-      return resp;
-   }
-
-   @Override
-   public Response processAddProducer(ProducerInfo info) throws Exception {
-      Response resp = null;
-      try {
-         protocolManager.addProducer(this, info);
-      }
-      catch (Exception e) {
-         if (e instanceof ActiveMQSecurityException) {
-            resp = new ExceptionResponse(new JMSSecurityException(e.getMessage()));
-         }
-         else if (e instanceof ActiveMQNonExistentQueueException) {
-            resp = new ExceptionResponse(new InvalidDestinationException(e.getMessage()));
-         }
-         else {
-            resp = new ExceptionResponse(e);
-         }
-      }
-      return resp;
-   }
-
-   @Override
-   public Response processAddSession(SessionInfo info) throws Exception {
-      // Avoid replaying dup commands
-      if (!state.getSessionIds().contains(info.getSessionId())) {
-         protocolManager.addSession(this, info);
-         try {
-            state.addSession(info);
-         }
-         catch (IllegalStateException e) {
-            e.printStackTrace();
-            protocolManager.removeSession(context, info);
-         }
-      }
-      return null;
-   }
-
-   @Override
-   public Response processBeginTransaction(TransactionInfo info) throws Exception {
-      TransactionId txId = info.getTransactionId();
-
-      if (!txMap.containsKey(txId)) {
-         txMap.put(txId, info);
-      }
-      return null;
-   }
-
-   @Override
-   public Response processBrokerInfo(BrokerInfo arg0) throws Exception {
-      throw new IllegalStateException("not implemented! ");
-   }
-
-   @Override
-   public Response processCommitTransactionOnePhase(TransactionInfo info) throws Exception {
-      protocolManager.commitTransactionOnePhase(info);
-      TransactionId txId = info.getTransactionId();
-      txMap.remove(txId);
-
-      return null;
-   }
-
-   @Override
-   public Response processCommitTransactionTwoPhase(TransactionInfo info) throws Exception {
-      protocolManager.commitTransactionTwoPhase(info);
-      TransactionId txId = info.getTransactionId();
-      txMap.remove(txId);
-
-      return null;
-   }
-
-   @Override
-   public Response processConnectionControl(ConnectionControl connectionControl) throws Exception {
-      //activemq5 keeps a var to remember only the faultTolerant flag
-      //this can be sent over a reconnected transport as the first command
-      //before restoring the connection.
-      return null;
-   }
-
-   @Override
-   public Response processConnectionError(ConnectionError arg0) throws Exception {
-      throw new IllegalStateException("not implemented! ");
-   }
-
-   @Override
-   public Response processConsumerControl(ConsumerControl consumerControl) throws Exception {
-      //amq5 clients send this command to restore prefetchSize
-      //after successful reconnect
-      try {
-         protocolManager.updateConsumer(this, consumerControl);
-      }
-      catch (Exception e) {
-         //log error
-      }
-      return null;
-   }
-
-   @Override
-   public Response processControlCommand(ControlCommand arg0) throws Exception {
-      throw new IllegalStateException("not implemented! ");
-   }
-
-   @Override
-   public Response processEndTransaction(TransactionInfo info) throws Exception {
-      protocolManager.endTransaction(info);
-      TransactionId txId = info.getTransactionId();
-
-      if (!txMap.containsKey(txId)) {
-         txMap.put(txId, info);
-      }
-      return null;
-   }
-
-   @Override
-   public Response processFlush(FlushCommand arg0) throws Exception {
-      throw new IllegalStateException("not implemented! ");
-   }
-
-   @Override
-   public Response processForgetTransaction(TransactionInfo info) throws Exception {
-      TransactionId txId = info.getTransactionId();
-      txMap.remove(txId);
-
-      protocolManager.forgetTransaction(info.getTransactionId());
-      return null;
-   }
-
-   @Override
-   public Response processKeepAlive(KeepAliveInfo arg0) throws Exception {
-      throw new IllegalStateException("not implemented! ");
-   }
-
-   @Override
-   public Response processMessage(Message messageSend) {
-      Response resp = null;
-      try {
-         ProducerId producerId = messageSend.getProducerId();
-         AMQProducerBrokerExchange producerExchange = getProducerBrokerExchange(producerId);
-         final AMQConnectionContext pcontext = producerExchange.getConnectionContext();
-         final ProducerInfo producerInfo = producerExchange.getProducerState().getInfo();
-         boolean sendProducerAck = !messageSend.isResponseRequired() && producerInfo.getWindowSize() > 0 && !pcontext.isInRecoveryMode();
-
-         AMQSession session = protocolManager.getSession(producerId.getParentId());
-
-         if (producerExchange.canDispatch(messageSend)) {
-            SendingResult result = session.send(producerExchange, messageSend, sendProducerAck);
-            if (result.isBlockNextSend()) {
-               if (!context.isNetworkConnection() && result.isSendFailIfNoSpace()) {
-                  throw new ResourceAllocationException("Usage Manager Memory Limit reached. Stopping producer (" + producerId + ") to prevent flooding " + result.getBlockingAddress() + "." + " See http://activemq.apache.org/producer-flow-control.html for more info");
-               }
-
-               if (producerInfo.getWindowSize() > 0 || messageSend.isResponseRequired()) {
-                  //in that case don't send the response
-                  //this will force the client to wait until
-                  //the response is got.
-                  context.setDontSendReponse(true);
-               }
-               else {
-                  //hang the connection until the space is available
-                  session.blockingWaitForSpace(producerExchange, result);
-               }
-            }
-            else if (sendProducerAck) {
-               ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), messageSend.getSize());
-               this.dispatchAsync(ack);
-            }
-         }
-      }
-      catch (Throwable e) {
-         if (e instanceof ActiveMQSecurityException) {
-            resp = new ExceptionResponse(new JMSSecurityException(e.getMessage()));
-         }
-         else {
-            resp = new ExceptionResponse(e);
-         }
-      }
-      return resp;
-   }
-
    private AMQProducerBrokerExchange getProducerBrokerExchange(ProducerId id) throws IOException {
       AMQProducerBrokerExchange result = producerExchanges.get(id);
       if (result == null) {
@@ -1007,163 +523,12 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
       return result;
    }
 
-   @Override
-   public Response processMessageAck(MessageAck ack) throws Exception {
-      AMQConsumerBrokerExchange consumerBrokerExchange = consumerExchanges.get(ack.getConsumerId());
-      consumerBrokerExchange.acknowledge(ack);
-      return null;
-   }
-
-   @Override
-   public Response processMessageDispatch(MessageDispatch arg0) throws Exception {
-      throw new IllegalStateException("not implemented! ");
-   }
-
-   @Override
-   public Response processMessageDispatchNotification(MessageDispatchNotification arg0) throws Exception {
-      throw new IllegalStateException("not implemented! ");
-   }
-
-   @Override
-   public Response processMessagePull(MessagePull arg0) throws Exception {
-      AMQConsumerBrokerExchange amqConsumerBrokerExchange = consumerExchanges.get(arg0.getConsumerId());
-      if (amqConsumerBrokerExchange == null) {
-         throw new IllegalStateException("Consumer does not exist");
-      }
-      amqConsumerBrokerExchange.processMessagePull(arg0);
-      return null;
-   }
-
-   @Override
-   public Response processPrepareTransaction(TransactionInfo info) throws Exception {
-      protocolManager.prepareTransaction(info);
-      return null;
-   }
-
-   @Override
-   public Response processProducerAck(ProducerAck arg0) throws Exception {
-      throw new IllegalStateException("not implemented! ");
-   }
-
-   @Override
-   public Response processRecoverTransactions(TransactionInfo info) throws Exception {
-      Set<SessionId> sIds = state.getSessionIds();
-      TransactionId[] recovered = protocolManager.recoverTransactions(sIds);
-      return new DataArrayResponse(recovered);
-   }
-
-   @Override
-   public Response processRemoveConnection(ConnectionId id, long lastDeliveredSequenceId) throws Exception {
-      //we let protocol manager to handle connection add/remove
-      try {
-         protocolManager.removeConnection(this, state.getInfo(), null);
-      }
-      catch (Throwable e) {
-         // log
-      }
-      return null;
-   }
-
-   @Override
-   public Response processRemoveConsumer(ConsumerId id, long lastDeliveredSequenceId) throws Exception {
-      SessionId sessionId = id.getParentId();
-      SessionState ss = state.getSessionState(sessionId);
-      if (ss == null) {
-         throw new IllegalStateException("Cannot remove a consumer from a session that had not been registered: " + sessionId);
-      }
-      ConsumerState consumerState = ss.removeConsumer(id);
-      if (consumerState == null) {
-         throw new IllegalStateException("Cannot remove a consumer that had not been registered: " + id);
-      }
-      ConsumerInfo info = consumerState.getInfo();
-      info.setLastDeliveredSequenceId(lastDeliveredSequenceId);
-
-      AMQConsumerBrokerExchange consumerBrokerExchange = consumerExchanges.get(id);
-
-      consumerBrokerExchange.removeConsumer();
-
-      removeConsumerBrokerExchange(id);
-
-      return null;
-   }
-
    private void removeConsumerBrokerExchange(ConsumerId id) {
       synchronized (consumerExchanges) {
          consumerExchanges.remove(id);
       }
    }
 
-   @Override
-   public Response processRemoveDestination(DestinationInfo info) throws Exception {
-      ActiveMQDestination dest = info.getDestination();
-      protocolManager.removeDestination(this, dest);
-      return null;
-   }
-
-   @Override
-   public Response processRemoveProducer(ProducerId id) throws Exception {
-      protocolManager.removeProducer(id);
-      return null;
-   }
-
-   @Override
-   public Response processRemoveSession(SessionId id, long lastDeliveredSequenceId) throws Exception {
-      SessionState session = state.getSessionState(id);
-      if (session == null) {
-         throw new IllegalStateException("Cannot remove session that had not been registered: " + id);
-      }
-      // Don't let new consumers or producers get added while we are closing
-      // this down.
-      session.shutdown();
-      // Cascade the connection stop producers.
-      // we don't stop consumer because in core
-      // closing the session will do the job
-      for (ProducerId producerId : session.getProducerIds()) {
-         try {
-            processRemoveProducer(producerId);
-         }
-         catch (Throwable e) {
-            // LOG.warn("Failed to remove producer: {}", producerId, e);
-         }
-      }
-      state.removeSession(id);
-      protocolManager.removeSession(context, session.getInfo());
-      return null;
-   }
-
-   @Override
-   public Response processRemoveSubscription(RemoveSubscriptionInfo subInfo) throws Exception {
-      protocolManager.removeSubscription(subInfo);
-      return null;
-   }
-
-   @Override
-   public Response processRollbackTransaction(TransactionInfo info) throws Exception {
-      protocolManager.rollbackTransaction(info);
-      TransactionId txId = info.getTransactionId();
-      txMap.remove(txId);
-      return null;
-   }
-
-   @Override
-   public Response processShutdown(ShutdownInfo info) throws Exception {
-      this.shutdown(false);
-      return null;
-   }
-
-   @Override
-   public Response processWireFormat(WireFormatInfo arg0) throws Exception {
-      throw new IllegalStateException("not implemented! ");
-   }
-
-   public int getMaximumConsumersAllowedPerConnection() {
-      return 1000000;//this belongs to configuration, now hardcoded
-   }
-
-   public int getMaximumProducersAllowedPerConnection() {
-      return 1000000;//this belongs to configuration, now hardcoded
-   }
-
    public void deliverMessage(MessageDispatch dispatch) {
       Message m = dispatch.getMessage();
       if (m != null) {
@@ -1323,4 +688,393 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor, S
       context.setReconnect(true);
       context.incRefCount();
    }
+
+   // This will listen for commands throught the protocolmanager
+   class CommandProcessor implements CommandVisitor {
+
+      @Override
+      public Response processAddConnection(ConnectionInfo info) throws Exception {
+         //let protoclmanager handle connection add/remove
+         try {
+            protocolManager.addConnection(OpenWireConnection.this, info);
+         }
+         catch (Exception e) {
+            Response resp = new ExceptionResponse(e);
+            return resp;
+         }
+         if (info.isManageable() && protocolManager.isUpdateClusterClients()) {
+            // send ConnectionCommand
+            ConnectionControl command = protocolManager.newConnectionControl();
+            command.setFaultTolerant(protocolManager.isFaultTolerantConfiguration());
+            if (info.isFailoverReconnect()) {
+               command.setRebalanceConnection(false);
+            }
+            dispatchAsync(command);
+         }
+         return null;
+
+      }
+
+      @Override
+      public Response processAddProducer(ProducerInfo info) throws Exception {
+         Response resp = null;
+         try {
+            protocolManager.addProducer(OpenWireConnection.this, info);
+         }
+         catch (Exception e) {
+            if (e instanceof ActiveMQSecurityException) {
+               resp = new ExceptionResponse(new JMSSecurityException(e.getMessage()));
+            }
+            else if (e instanceof ActiveMQNonExistentQueueException) {
+               resp = new ExceptionResponse(new InvalidDestinationException(e.getMessage()));
+            }
+            else {
+               resp = new ExceptionResponse(e);
+            }
+         }
+         return resp;
+      }
+
+      @Override
+      public Response processAddConsumer(ConsumerInfo info) {
+         Response resp = null;
+         try {
+            protocolManager.addConsumer(OpenWireConnection.this, info);
+         }
+         catch (Exception e) {
+            e.printStackTrace();
+            if (e instanceof ActiveMQSecurityException) {
+               resp = new ExceptionResponse(new JMSSecurityException(e.getMessage()));
+            }
+            else {
+               resp = new ExceptionResponse(e);
+            }
+         }
+         return resp;
+      }
+
+      @Override
+      public Response processRemoveDestination(DestinationInfo info) throws Exception {
+         ActiveMQDestination dest = info.getDestination();
+         protocolManager.removeDestination(OpenWireConnection.this, dest);
+         return null;
+      }
+
+      @Override
+      public Response processRemoveProducer(ProducerId id) throws Exception {
+         protocolManager.removeProducer(id);
+         return null;
+      }
+
+      @Override
+      public Response processRemoveSession(SessionId id, long lastDeliveredSequenceId) throws Exception {
+         SessionState session = state.getSessionState(id);
+         if (session == null) {
+            throw new IllegalStateException("Cannot remove session that had not been registered: " + id);
+         }
+         // Don't let new consumers or producers get added while we are closing
+         // this down.
+         session.shutdown();
+         // Cascade the connection stop producers.
+         // we don't stop consumer because in core
+         // closing the session will do the job
+         for (ProducerId producerId : session.getProducerIds()) {
+            try {
+               processRemoveProducer(producerId);
+            }
+            catch (Throwable e) {
+               // LOG.warn("Failed to remove producer: {}", producerId, e);
+            }
+         }
+         state.removeSession(id);
+         protocolManager.removeSession(context, session.getInfo());
+         return null;
+      }
+
+      @Override
+      public Response processRemoveSubscription(RemoveSubscriptionInfo subInfo) throws Exception {
+         protocolManager.removeSubscription(subInfo);
+         return null;
+      }
+
+      @Override
+      public Response processRollbackTransaction(TransactionInfo info) throws Exception {
+         protocolManager.rollbackTransaction(info);
+         TransactionId txId = info.getTransactionId();
+         txMap.remove(txId);
+         return null;
+      }
+
+      @Override
+      public Response processShutdown(ShutdownInfo info) throws Exception {
+         OpenWireConnection.this.shutdown(false);
+         return null;
+      }
+
+      @Override
+      public Response processWireFormat(WireFormatInfo command) throws Exception {
+         wireFormat.renegotiateWireFormat(command);
+         //throw back a brokerInfo here
+         protocolManager.sendBrokerInfo(OpenWireConnection.this);
+         return null;
+      }
+
+      @Override
+      public Response processAddDestination(DestinationInfo dest) throws Exception {
+         Response resp = null;
+         try {
+            protocolManager.addDestination(OpenWireConnection.this, dest);
+         }
+         catch (Exception e) {
+            if (e instanceof ActiveMQSecurityException) {
+               resp = new ExceptionResponse(new JMSSecurityException(e.getMessage()));
+            }
+            else {
+               resp = new ExceptionResponse(e);
+            }
+         }
+         return resp;
+      }
+
+      @Override
+      public Response processAddSession(SessionInfo info) throws Exception {
+         // Avoid replaying dup commands
+         if (!state.getSessionIds().contains(info.getSessionId())) {
+            protocolManager.addSession(OpenWireConnection.this, info);
+            try {
+               state.addSession(info);
+            }
+            catch (IllegalStateException e) {
+               e.printStackTrace();
+               protocolManager.removeSession(context, info);
+            }
+         }
+         return null;
+      }
+
+      @Override
+      public Response processBeginTransaction(TransactionInfo info) throws Exception {
+         TransactionId txId = info.getTransactionId();
+
+         if (!txMap.containsKey(txId)) {
+            txMap.put(txId, info);
+         }
+         return null;
+      }
+
+      @Override
+      public Response processBrokerInfo(BrokerInfo arg0) throws Exception {
+         throw new IllegalStateException("not implemented! ");
+      }
+
+      @Override
+      public Response processCommitTransactionOnePhase(TransactionInfo info) throws Exception {
+         protocolManager.commitTransactionOnePhase(info);
+         TransactionId txId = info.getTransactionId();
+         txMap.remove(txId);
+
+         return null;
+      }
+
+      @Override
+      public Response processCommitTransactionTwoPhase(TransactionInfo info) throws Exception {
+         protocolManager.commitTransactionTwoPhase(info);
+         TransactionId txId = info.getTransactionId();
+         txMap.remove(txId);
+
+         return null;
+      }
+
+      @Override
+      public Response processConnectionControl(ConnectionControl connectionControl) throws Exception {
+         //activemq5 keeps a var to remember only the faultTolerant flag
+         //this can be sent over a reconnected transport as the first command
+         //before restoring the connection.
+         return null;
+      }
+
+      @Override
+      public Response processConnectionError(ConnectionError arg0) throws Exception {
+         throw new IllegalStateException("not implemented! ");
+      }
+
+      @Override
+      public Response processConsumerControl(ConsumerControl consumerControl) throws Exception {
+         //amq5 clients send this command to restore prefetchSize
+         //after successful reconnect
+         try {
+            protocolManager.updateConsumer(OpenWireConnection.this, consumerControl);
+         }
+         catch (Exception e) {
+            //log error
+         }
+         return null;
+      }
+
+      @Override
+      public Response processControlCommand(ControlCommand arg0) throws Exception {
+         throw new IllegalStateException("not implemented! ");
+      }
+
+      @Override
+      public Response processEndTransaction(TransactionInfo info) throws Exception {
+         protocolManager.endTransaction(info);
+         TransactionId txId = info.getTransactionId();
+
+         if (!txMap.containsKey(txId)) {
+            txMap.put(txId, info);
+         }
+         return null;
+      }
+
+      @Override
+      public Response processFlush(FlushCommand arg0) throws Exception {
+         throw new IllegalStateException("not implemented! ");
+      }
+
+      @Override
+      public Response processForgetTransaction(TransactionInfo info) throws Exception {
+         TransactionId txId = info.getTransactionId();
+         txMap.remove(txId);
+
+         protocolManager.forgetTransaction(info.getTransactionId());
+         return null;
+      }
+
+      @Override
+      public Response processKeepAlive(KeepAliveInfo arg0) throws Exception {
+         throw new IllegalStateException("not implemented! ");
+      }
+
+      @Override
+      public Response processMessage(Message messageSend) {
+         Response resp = null;
+         try {
+            ProducerId producerId = messageSend.getProducerId();
+            AMQProducerBrokerExchange producerExchange = getProducerBrokerExchange(producerId);
+            final AMQConnectionContext pcontext = producerExchange.getConnectionContext();
+            final ProducerInfo producerInfo = producerExchange.getProducerState().getInfo();
+            boolean sendProducerAck = !messageSend.isResponseRequired() && producerInfo.getWindowSize() > 0 && !pcontext.isInRecoveryMode();
+
+            AMQSession session = protocolManager.getSession(producerId.getParentId());
+
+            // TODO: canDispatch is always returning true;
+            if (producerExchange.canDispatch(messageSend)) {
+               SendingResult result = session.send(producerExchange, messageSend, sendProducerAck);
+               if (result.isBlockNextSend()) {
+                  if (!context.isNetworkConnection() && result.isSendFailIfNoSpace()) {
+                     // TODO see logging
+                     throw new ResourceAllocationException("Usage Manager Memory Limit reached. Stopping producer (" + producerId + ") to prevent flooding " + result.getBlockingAddress() + "." + " See http://activemq.apache.org/producer-flow-control.html for more info");
+                  }
+
+                  if (producerInfo.getWindowSize() > 0 || messageSend.isResponseRequired()) {
+                     //in that case don't send the response
+                     //this will force the client to wait until
+                     //the response is got.
+                     context.setDontSendReponse(true);
+                  }
+                  else {
+                     //hang the connection until the space is available
+                     session.blockingWaitForSpace(producerExchange, result);
+                  }
+               }
+               else if (sendProducerAck) {
+                  ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), messageSend.getSize());
+                  OpenWireConnection.this.dispatchAsync(ack);
+               }
+            }
+         }
+         catch (Throwable e) {
+            if (e instanceof ActiveMQSecurityException) {
+               resp = new ExceptionResponse(new JMSSecurityException(e.getMessage()));
+            }
+            else {
+               resp = new ExceptionResponse(e);
+            }
+         }
+         return resp;
+      }
+
+      @Override
+      public Response processMessageAck(MessageAck ack) throws Exception {
+         AMQConsumerBrokerExchange consumerBrokerExchange = consumerExchanges.get(ack.getConsumerId());
+         consumerBrokerExchange.acknowledge(ack);
+         return null;
+      }
+
+      @Override
+      public Response processMessageDispatch(MessageDispatch arg0) throws Exception {
+         throw new IllegalStateException("not implemented! ");
+      }
+
+      @Override
+      public Response processMessageDispatchNotification(MessageDispatchNotification arg0) throws Exception {
+         throw new IllegalStateException("not implemented! ");
+      }
+
+      @Override
+      public Response processMessagePull(MessagePull arg0) throws Exception {
+         AMQConsumerBrokerExchange amqConsumerBrokerExchange = consumerExchanges.get(arg0.getConsumerId());
+         if (amqConsumerBrokerExchange == null) {
+            throw new IllegalStateException("Consumer does not exist");
+         }
+         amqConsumerBrokerExchange.processMessagePull(arg0);
+         return null;
+      }
+
+      @Override
+      public Response processPrepareTransaction(TransactionInfo info) throws Exception {
+         protocolManager.prepareTransaction(info);
+         return null;
+      }
+
+      @Override
+      public Response processProducerAck(ProducerAck arg0) throws Exception {
+         throw new IllegalStateException("not implemented! ");
+      }
+
+      @Override
+      public Response processRecoverTransactions(TransactionInfo info) throws Exception {
+         Set<SessionId> sIds = state.getSessionIds();
+         TransactionId[] recovered = protocolManager.recoverTransactions(sIds);
+         return new DataArrayResponse(recovered);
+      }
+
+      @Override
+      public Response processRemoveConnection(ConnectionId id, long lastDeliveredSequenceId) throws Exception {
+         //we let protocol manager to handle connection add/remove
+         try {
+            protocolManager.removeConnection(OpenWireConnection.this, state.getInfo(), null);
+         }
+         catch (Throwable e) {
+            // log
+         }
+         return null;
+      }
+
+      @Override
+      public Response processRemoveConsumer(ConsumerId id, long lastDeliveredSequenceId) throws Exception {
+         SessionId sessionId = id.getParentId();
+         SessionState ss = state.getSessionState(sessionId);
+         if (ss == null) {
+            throw new IllegalStateException("Cannot remove a consumer from a session that had not been registered: " + sessionId);
+         }
+         ConsumerState consumerState = ss.removeConsumer(id);
+         if (consumerState == null) {
+            throw new IllegalStateException("Cannot remove a consumer that had not been registered: " + id);
+         }
+         ConsumerInfo info = consumerState.getInfo();
+         info.setLastDeliveredSequenceId(lastDeliveredSequenceId);
+
+         AMQConsumerBrokerExchange consumerBrokerExchange = consumerExchanges.get(id);
+
+         consumerBrokerExchange.removeConsumer();
+
+         removeConsumerBrokerExchange(id);
+
+         return null;
+      }
+
+   }
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e306e53a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
index 014181d..440fcce 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
@@ -219,7 +219,7 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
    @Override
    public ConnectionEntry createConnectionEntry(Acceptor acceptorUsed, Connection connection) {
       OpenWireFormat wf = (OpenWireFormat) wireFactory.createWireFormat();
-      OpenWireConnection owConn = new OpenWireConnection(acceptorUsed, connection, this, wf);
+      OpenWireConnection owConn = new OpenWireConnection(acceptorUsed, connection,  server.getExecutorFactory().getExecutor(), this, wf);
       owConn.init();
 
       // TODO CLEBERT What is this constant here? we should get it from TTL initial pings
@@ -506,9 +506,6 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
 
          ActiveMQDestination destination = info.getDestination();
          if (destination != null && !AdvisorySupport.isAdvisoryTopic(destination)) {
-            if (theConn.getProducerCount() >= theConn.getMaximumProducersAllowedPerConnection()) {
-               throw new IllegalStateException("Can't add producer on connection " + connectionId + ": at maximum limit: " + theConn.getMaximumProducersAllowedPerConnection());
-            }
             if (destination.isQueue()) {
                OpenWireUtil.validateDestination(destination, amqSession);
             }
@@ -549,12 +546,6 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
       }
       // Avoid replaying dup commands
       if (!ss.getConsumerIds().contains(info.getConsumerId())) {
-         ActiveMQDestination destination = info.getDestination();
-         if (destination != null && !AdvisorySupport.isAdvisoryTopic(destination)) {
-            if (theConn.getConsumerCount() >= theConn.getMaximumConsumersAllowedPerConnection()) {
-               throw new IllegalStateException("Can't add consumer on connection " + connectionId + ": at maximum limit: " + theConn.getMaximumConsumersAllowedPerConnection());
-            }
-         }
 
          AMQSession amqSession = sessions.get(sessionId);
          if (amqSession == null) {
@@ -760,6 +751,9 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
       transactions.remove(xid);
    }
 
+   /**
+    * TODO: remove this, use the regular ResourceManager from the Server's
+    * */
    public void registerTx(TransactionId txId, AMQSession amqSession) {
       transactions.put(txId, amqSession);
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e306e53a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQProducerBrokerExchange.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQProducerBrokerExchange.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQProducerBrokerExchange.java
index f94c119..e9c4044 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQProducerBrokerExchange.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQProducerBrokerExchange.java
@@ -29,8 +29,6 @@ public class AMQProducerBrokerExchange {
    private ProducerState producerState;
    private boolean mutable = true;
    private AtomicLong lastSendSequenceNumber = new AtomicLong(-1);
-   private boolean auditProducerSequenceIds;
-   private boolean isNetworkProducer;
    private final FlowControlInfo flowControlInfo = new FlowControlInfo();
 
    public AMQProducerBrokerExchange() {
@@ -92,29 +90,34 @@ public class AMQProducerBrokerExchange {
     * @return false if message should be ignored as a duplicate
     */
    public boolean canDispatch(Message messageSend) {
+      // TODO: auditProduceSequenceIds is never true
       boolean canDispatch = true;
-      if (auditProducerSequenceIds && messageSend.isPersistent()) {
-         final long producerSequenceId = messageSend.getMessageId().getProducerSequenceId();
-         if (isNetworkProducer) {
-            // messages are multiplexed on this producer so we need to query the
-            // persistenceAdapter
-            long lastStoredForMessageProducer = getStoredSequenceIdForMessage(messageSend.getMessageId());
-            if (producerSequenceId <= lastStoredForMessageProducer) {
-               canDispatch = false;
-            }
-         }
-         else if (producerSequenceId <= lastSendSequenceNumber.get()) {
-            canDispatch = false;
-            if (messageSend.isInTransaction()) {
-            }
-            else {
-            }
-         }
-         else {
-            // track current so we can suppress duplicates later in the stream
-            lastSendSequenceNumber.set(producerSequenceId);
-         }
-      }
+      //TODO: DEAD CODE
+//      if (auditProducerSequenceIds && messageSend.isPersistent()) {
+//         final long producerSequenceId = messageSend.getMessageId().getProducerSequenceId();
+//         if (isNetworkProducer) {
+//            // messages are multiplexed on this producer so we need to query the
+//            // persistenceAdapter
+//            long lastStoredForMessageProducer = getStoredSequenceIdForMessage(messageSend.getMessageId());
+//            if (producerSequenceId <= lastStoredForMessageProducer) {
+//               canDispatch = false;
+//            }
+//         }
+//         else if (producerSequenceId <= lastSendSequenceNumber.get()) {
+//            canDispatch = false;
+//            // TODO: WHAT IS THIS?
+//            if (messageSend.isInTransaction()) {
+//
+//
+//            }
+//            else {
+//            }
+//         }
+//         else {
+//            // track current so we can suppress duplicates later in the stream
+//            lastSendSequenceNumber.set(producerSequenceId);
+//         }
+//      }
       return canDispatch;
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e306e53a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerSessionFactory.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerSessionFactory.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerSessionFactory.java
index 9ce21e3..a6ca4a0 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerSessionFactory.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerSessionFactory.java
@@ -32,6 +32,15 @@ import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
 
 public class AMQServerSessionFactory implements ServerSessionFactory {
 
+   private static final AMQServerSessionFactory singleInstance = new AMQServerSessionFactory();
+
+   public static AMQServerSessionFactory getInstance() {
+      return singleInstance;
+   }
+
+   private AMQServerSessionFactory() {
+   }
+
    @Override
    public ServerSessionImpl createCoreSession(String name,
                                               String username,

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e306e53a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
index f5ccb82..0cee3d3 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
@@ -63,8 +63,8 @@ import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
 import org.apache.activemq.wireformat.WireFormat;
 
 public class AMQSession implements SessionCallback {
-   private AMQServerSession coreSession;
    private ConnectionInfo connInfo;
+   private AMQServerSession coreSession;
    private SessionInfo sessInfo;
    private ActiveMQServer server;
    private OpenWireConnection connection;
@@ -91,6 +91,7 @@ public class AMQSession implements SessionCallback {
                      OpenWireProtocolManager manager) {
       this.connInfo = connInfo;
       this.sessInfo = sessInfo;
+
       this.server = server;
       this.connection = connection;
       this.scheduledPool = scheduledPool;
@@ -107,7 +108,7 @@ public class AMQSession implements SessionCallback {
       // now
 
       try {
-         coreSession = (AMQServerSession) server.createSession(name, username, password, minLargeMessageSize, connection, true, false, false, false, null, this, new AMQServerSessionFactory(), true);
+         coreSession = (AMQServerSession) server.createSession(name, username, password, minLargeMessageSize, connection, true, false, false, false, null, this, AMQServerSessionFactory.getInstance(), true);
 
          long sessionId = sessInfo.getSessionId().getValue();
          if (sessionId == -1) {
@@ -144,6 +145,7 @@ public class AMQSession implements SessionCallback {
       }
       connection.addConsumerBrokerExchange(info.getConsumerId(), amqSession, consumerMap);
 
+      // TODO: This is wrong. We should only start when the client starts
       coreSession.start();
       started.set(true);
    }
@@ -281,6 +283,9 @@ public class AMQSession implements SessionCallback {
          coreMsg.setAddress(address);
 
          PagingStoreImpl store = (PagingStoreImpl) server.getPagingManager().getPageStore(address);
+
+
+         // TODO: Improve this, tested with ProducerFlowControlSendFailTest
          if (store.isFull()) {
             result.setBlockNextSend(true);
             result.setBlockPagingStore(store);
@@ -526,8 +531,12 @@ public class AMQSession implements SessionCallback {
       }
    }
 
+   // TODO: remove this, we should do the same as we do on core for blocking
    public void blockingWaitForSpace(AMQProducerBrokerExchange producerExchange,
                                     SendingResult result) throws IOException {
+
+
+      new Exception("blocking").printStackTrace();
       long start = System.currentTimeMillis();
       long nextWarn = start;
       producerExchange.blockingOnFlowControl(true);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e306e53a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/impl/OpenWireServerCallback.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/impl/OpenWireServerCallback.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/impl/OpenWireServerCallback.java
new file mode 100644
index 0000000..8ab3815
--- /dev/null
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/impl/OpenWireServerCallback.java
@@ -0,0 +1,75 @@
+/**
+ * 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.artemis.core.protocol.openwire.impl;
+
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.server.ServerConsumer;
+import org.apache.activemq.artemis.core.server.ServerMessage;
+import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
+import org.apache.activemq.artemis.spi.core.remoting.ReadyListener;
+
+public class OpenWireServerCallback implements SessionCallback {
+
+   @Override
+   public boolean hasCredits(ServerConsumer consumerID) {
+      return false;
+   }
+
+   @Override
+   public void sendProducerCreditsMessage(int credits, SimpleString address) {
+
+   }
+
+   @Override
+   public void sendProducerCreditsFailMessage(int credits, SimpleString address) {
+
+   }
+
+   @Override
+   public int sendMessage(ServerMessage message, ServerConsumer consumerID, int deliveryCount) {
+      return 0;
+   }
+
+   @Override
+   public int sendLargeMessage(ServerMessage message, ServerConsumer consumerID, long bodySize, int deliveryCount) {
+      return 0;
+   }
+
+   @Override
+   public int sendLargeMessageContinuation(ServerConsumer consumerID,
+                                           byte[] body,
+                                           boolean continues,
+                                           boolean requiresResponse) {
+      return 0;
+   }
+
+   @Override
+   public void closed() {
+
+   }
+
+   @Override
+   public void disconnect(ServerConsumer consumerId, String queueName) {
+
+   }
+
+   @Override
+   public boolean isWritable(ReadyListener callback) {
+      return false;
+   }
+}


[46/60] [abbrv] activemq-artemis git commit: producer refactor

Posted by cl...@apache.org.
producer refactor


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/d1909c33
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/d1909c33
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/d1909c33

Branch: refs/heads/refactor-openwire
Commit: d1909c33a6eb92dfd3b75dc6ee2e5f69a0aa3732
Parents: 0a267a3
Author: Clebert Suconic <cl...@apache.org>
Authored: Tue Mar 1 22:31:39 2016 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:45:29 2016 -0400

----------------------------------------------------------------------
 .../remoting/impl/netty/NettyConnection.java    |   4 +
 .../artemis/spi/core/remoting/Connection.java   |   6 +
 .../protocol/openwire/OpenWireConnection.java   | 163 ++++-------
 .../openwire/OpenWireProtocolManager.java       |  15 +-
 .../core/protocol/openwire/SendingResult.java   |  57 ----
 .../core/protocol/openwire/amq/AMQSession.java  | 281 +++++++++----------
 .../openwire/impl/OpenWireServerCallback.java   |  75 -----
 .../artemis/core/paging/PagingStore.java        |   2 +
 .../core/remoting/impl/invm/InVMConnection.java |   6 +
 .../FailoverConsumerOutstandingCommitTest.java  |  25 +-
 .../InvestigationOpenwireTest.java              |  27 ++
 .../storage/PersistMultiThreadTest.java         |   4 +
 12 files changed, 255 insertions(+), 410 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d1909c33/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
index 9268699..3f10227 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
@@ -100,6 +100,10 @@ public class NettyConnection implements Connection {
    }
    // Connection implementation ----------------------------
 
+   @Override
+   public void setAutoRead(boolean autoRead) {
+      channel.config().setAutoRead(autoRead);
+   }
 
    @Override
    public synchronized boolean isWritable(ReadyListener callback) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d1909c33/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/Connection.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/Connection.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/Connection.java
index ed10113..4352d49 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/Connection.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/Connection.java
@@ -44,6 +44,12 @@ public interface Connection {
    void fireReady(boolean ready);
 
    /**
+    * This will disable reading from the channel.
+    * This is basically the same as blocking the reading.
+    * */
+   void setAutoRead(boolean autoRead);
+
+   /**
     * returns the unique id of this wire.
     *
     * @return the id

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d1909c33/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
index 0fd8dc2..1e1e953 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
@@ -19,7 +19,6 @@ package org.apache.activemq.artemis.core.protocol.openwire;
 import javax.jms.InvalidClientIDException;
 import javax.jms.InvalidDestinationException;
 import javax.jms.JMSSecurityException;
-import javax.jms.ResourceAllocationException;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -270,22 +269,26 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
       catch (Exception e) {
          ActiveMQServerLogger.LOGGER.debug(e);
 
-         Response resp;
-         if (e instanceof ActiveMQSecurityException) {
-            resp = new ExceptionResponse(new JMSSecurityException(e.getMessage()));
-         }
-         else if (e instanceof ActiveMQNonExistentQueueException) {
-            resp = new ExceptionResponse(new InvalidDestinationException(e.getMessage()));
-         }
-         else {
-            resp = new ExceptionResponse(e);
-         }
-         try {
-            dispatch(resp);
-         }
-         catch (IOException e2) {
-            ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e2);
-         }
+         sendException(e);
+      }
+   }
+
+   public void sendException(Exception e) {
+      Response resp;
+      if (e instanceof ActiveMQSecurityException) {
+         resp = new ExceptionResponse(new JMSSecurityException(e.getMessage()));
+      }
+      else if (e instanceof ActiveMQNonExistentQueueException) {
+         resp = new ExceptionResponse(new InvalidDestinationException(e.getMessage()));
+      }
+      else {
+         resp = new ExceptionResponse(e);
+      }
+      try {
+         dispatch(resp);
+      }
+      catch (IOException e2) {
+         ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e2);
       }
    }
 
@@ -371,75 +374,18 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
 
    }
 
-   public void dispatchAsync(Command message) {
-      if (!stopping.get()) {
-         dispatchSync(message);
-      }
-      else {
-         if (message.isMessageDispatch()) {
-            MessageDispatch md = (MessageDispatch) message;
-            TransmitCallback sub = md.getTransmitCallback();
-            protocolManager.postProcessDispatch(md);
-            if (sub != null) {
-               sub.onFailure();
-            }
-         }
-      }
-   }
-
-   public void dispatchSync(Command message) {
-      try {
-         processDispatch(message);
-      }
-      catch (IOException e) {
-         serviceExceptionAsync(e);
-      }
-   }
-
-   public void serviceExceptionAsync(final IOException e) {
-      if (asyncException.compareAndSet(false, true)) {
-         // TODO: Why this is not through an executor?
-         new Thread("Async Exception Handler") {
-            @Override
-            public void run() {
-               serviceException(e);
-            }
-         }.start();
-      }
+   public void dispatchAsync(Command message) throws Exception {
+      dispatchSync(message);
    }
 
-   public void serviceException(Throwable e) {
-      // are we a transport exception such as not being able to dispatch
-      // synchronously to a transport
-      if (e instanceof IOException) {
-         serviceTransportException((IOException) e);
-      }
-      else if (!stopping.get() && !inServiceException) {
-         inServiceException = true;
-         try {
-            ConnectionError ce = new ConnectionError();
-            ce.setException(e);
-            dispatchAsync(ce);
-         }
-         finally {
-            inServiceException = false;
-         }
-      }
+   public void dispatchSync(Command message) throws Exception {
+      processDispatch(message);
    }
 
-   public void serviceTransportException(IOException e) {
-      /*
-       * deal with it later BrokerService bService =
-       * connector.getBrokerService(); if (bService.isShutdownOnSlaveFailure())
-       * { if (brokerInfo != null) { if (brokerInfo.isSlaveBroker()) {
-       * LOG.error("Slave has exception: {} shutting down master now.",
-       * e.getMessage(), e); try { doStop(); bService.stop(); } catch (Exception
-       * ex) { LOG.warn("Failed to stop the master", ex); } } } } if
-       * (!stopping.get() && !pendingStop) { transportException.set(e); if
-       * (TRANSPORTLOG.isDebugEnabled()) { TRANSPORTLOG.debug(this + " failed: "
-       * + e, e); } else if (TRANSPORTLOG.isWarnEnabled() && !expected(e)) {
-       * TRANSPORTLOG.warn(this + " failed: " + e); } stopAsync(); }
-       */
+   public void serviceException(Throwable e) throws Exception {
+      ConnectionError ce = new ConnectionError();
+      ce.setException(e);
+      dispatchAsync(ce);
    }
 
    protected void dispatch(Command command) throws IOException {
@@ -570,7 +516,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
       }
    }
 
-   private void disconnect(ActiveMQException me, String reason, boolean fail) {
+   private void disconnect(ActiveMQException me, String reason, boolean fail)  {
 
       if (context == null || destroyed) {
          return;
@@ -596,8 +542,12 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
       if (command != null && command.isResponseRequired()) {
          Response lastResponse = new Response();
          lastResponse.setCorrelationId(command.getCommandId());
-         dispatchSync(lastResponse);
-         context.setDontSendReponse(true);
+         try {
+            dispatchSync(lastResponse);
+         }
+         catch (Throwable e) {
+            ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e);
+         }
       }
    }
 
@@ -632,12 +582,10 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
       return this.context;
    }
 
-   public void updateClient(ConnectionControl control) {
-      //      if (!destroyed && context.isFaultTolerant()) {
+   public void updateClient(ConnectionControl control) throws Exception {
       if (protocolManager.isUpdateClusterClients()) {
          dispatchAsync(control);
       }
-      //      }
    }
 
    public AMQConnectionContext initContext(ConnectionInfo info) {
@@ -1063,9 +1011,16 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
 
       @Override
       public Response processCommitTransactionOnePhase(TransactionInfo info) throws Exception {
-         protocolManager.commitTransactionOnePhase(info);
-         TransactionId txId = info.getTransactionId();
-         txMap.remove(txId);
+         new Exception("commit").printStackTrace();
+         try {
+            protocolManager.commitTransactionOnePhase(info);
+            TransactionId txId = info.getTransactionId();
+            txMap.remove(txId);
+         }
+         catch (Exception e) {
+            e.printStackTrace();
+            throw e;
+         }
 
          return null;
       }
@@ -1150,33 +1105,11 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
 
          AMQSession session = getSession(producerId.getParentId());
 
-         SendingResult result = session.send(producerExchange, messageSend, sendProducerAck);
-         if (result.isBlockNextSend()) {
-            if (!context.isNetworkConnection() && result.isSendFailIfNoSpace()) {
-               // TODO see logging
-               throw new ResourceAllocationException("Usage Manager Memory Limit reached. Stopping producer (" + producerId + ") to prevent flooding " + result.getBlockingAddress() + "." + " See http://activemq.apache.org/producer-flow-control.html for more info");
-            }
-
-            if (producerInfo.getWindowSize() > 0 || messageSend.isResponseRequired()) {
-               //in that case don't send the response
-               //this will force the client to wait until
-               //the response is got.
-               context.setDontSendReponse(true);
-            }
-            else {
-               //hang the connection until the space is available
-               session.blockingWaitForSpace(producerExchange, result);
-            }
-         }
-         else if (sendProducerAck) {
-            // TODO-now: send through OperationContext
-            ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), messageSend.getSize());
-            OpenWireConnection.this.dispatchAsync(ack);
-         }
-
+         session.send(producerInfo, messageSend, sendProducerAck);
          return null;
       }
 
+
       @Override
       public Response processMessageAck(MessageAck ack) throws Exception {
          AMQConsumerBrokerExchange consumerBrokerExchange = consumerExchanges.get(ack.getConsumerId());

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d1909c33/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
index 51c4bec..7445960 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
@@ -40,6 +40,7 @@ import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQProducerBrokerE
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQSession;
 import org.apache.activemq.artemis.core.remoting.impl.netty.NettyServerConnection;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
+import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
 import org.apache.activemq.artemis.core.server.cluster.ClusterManager;
 import org.apache.activemq.artemis.spi.core.protocol.ConnectionEntry;
@@ -192,7 +193,13 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, Cl
 
       for (OpenWireConnection c : this.connections) {
          ConnectionControl control = newConnectionControl();
-         c.updateClient(control);
+         try {
+            c.updateClient(control);
+         }
+         catch (Exception e) {
+            ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e);
+            c.sendException(e);
+         }
       }
    }
 
@@ -365,7 +372,7 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, Cl
          context.setProducerFlowControl(false);
          AMQSession sess = context.getConnection().getAdvisorySession();
          if (sess != null) {
-            sess.send(producerExchange, advisoryMessage, false);
+            sess.send(producerExchange.getProducerState().getInfo(), advisoryMessage, false);
          }
       }
       finally {
@@ -515,7 +522,7 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, Cl
       server.destroyQueue(subQueueName);
    }
 
-   public void sendBrokerInfo(OpenWireConnection connection) {
+   public void sendBrokerInfo(OpenWireConnection connection) throws Exception {
       BrokerInfo brokerInfo = new BrokerInfo();
       brokerInfo.setBrokerName(server.getIdentity());
       brokerInfo.setBrokerId(new BrokerId("" + server.getNodeID()));
@@ -525,7 +532,7 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, Cl
 
       //cluster support yet to support
       brokerInfo.setPeerBrokerInfos(null);
-      connection.dispatchAsync(brokerInfo);
+      connection.dispatch(brokerInfo);
    }
 
    public void setRebalanceClusterClients(boolean rebalance) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d1909c33/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/SendingResult.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/SendingResult.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/SendingResult.java
deleted file mode 100644
index 0e21ca4..0000000
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/SendingResult.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.artemis.core.protocol.openwire;
-
-import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.paging.impl.PagingStoreImpl;
-import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
-
-public class SendingResult {
-
-   private boolean blockNextSend;
-   private PagingStoreImpl blockPagingStore;
-   private SimpleString blockingAddress;
-
-   public void setBlockNextSend(boolean block) {
-      this.blockNextSend = block;
-   }
-
-   public boolean isBlockNextSend() {
-      return this.blockNextSend;
-   }
-
-   public void setBlockPagingStore(PagingStoreImpl store) {
-      this.blockPagingStore = store;
-   }
-
-   public PagingStoreImpl getBlockPagingStore() {
-      return this.blockPagingStore;
-   }
-
-   public void setBlockingAddress(SimpleString address) {
-      this.blockingAddress = address;
-   }
-
-   public SimpleString getBlockingAddress() {
-      return this.blockingAddress;
-   }
-
-   public boolean isSendFailIfNoSpace() {
-      AddressFullMessagePolicy policy = this.blockPagingStore.getAddressFullMessagePolicy();
-      return policy == AddressFullMessagePolicy.FAIL;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d1909c33/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
index 4db5967..b68861e 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
@@ -16,8 +16,8 @@
  */
 package org.apache.activemq.artemis.core.protocol.openwire.amq;
 
+import javax.jms.ResourceAllocationException;
 import javax.transaction.xa.Xid;
-import java.io.IOException;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -26,41 +26,38 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.paging.PagingStore;
+import org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection;
+import org.apache.activemq.artemis.core.protocol.openwire.OpenWireMessageConverter;
+import org.apache.activemq.artemis.core.protocol.openwire.OpenWireProtocolManager;
+import org.apache.activemq.artemis.core.protocol.openwire.OpenWireUtil;
+import org.apache.activemq.artemis.core.server.ActiveMQServer;
+import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
+import org.apache.activemq.artemis.core.server.ServerConsumer;
+import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.SlowConsumerDetectionListener;
+import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
+import org.apache.activemq.artemis.core.transaction.impl.XidImpl;
+import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
+import org.apache.activemq.artemis.spi.core.remoting.Connection;
 import org.apache.activemq.artemis.spi.core.remoting.ReadyListener;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ConnectionInfo;
 import org.apache.activemq.command.ConsumerId;
 import org.apache.activemq.command.ConsumerInfo;
-import org.apache.activemq.command.ExceptionResponse;
 import org.apache.activemq.command.Message;
 import org.apache.activemq.command.MessageAck;
 import org.apache.activemq.command.MessageDispatch;
 import org.apache.activemq.command.ProducerAck;
-import org.apache.activemq.command.ProducerId;
 import org.apache.activemq.command.ProducerInfo;
-import org.apache.activemq.command.Response;
 import org.apache.activemq.command.SessionInfo;
 import org.apache.activemq.command.TransactionId;
 import org.apache.activemq.command.TransactionInfo;
 import org.apache.activemq.command.XATransactionId;
-import org.apache.activemq.artemis.core.paging.impl.PagingStoreImpl;
-import org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection;
-import org.apache.activemq.artemis.core.protocol.openwire.OpenWireMessageConverter;
-import org.apache.activemq.artemis.core.protocol.openwire.OpenWireProtocolManager;
-import org.apache.activemq.artemis.core.protocol.openwire.OpenWireUtil;
-import org.apache.activemq.artemis.core.protocol.openwire.SendingResult;
-import org.apache.activemq.artemis.core.server.ActiveMQServer;
-import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
-import org.apache.activemq.artemis.core.server.ServerConsumer;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
-import org.apache.activemq.artemis.core.transaction.impl.XidImpl;
-import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
 import org.apache.activemq.openwire.OpenWireFormat;
 import org.apache.activemq.wireformat.WireFormat;
 
@@ -106,6 +103,10 @@ public class AMQSession implements SessionCallback {
       this.converter = new OpenWireMessageConverter(marshaller.copy());
    }
 
+   public OpenWireMessageConverter getConverter() {
+      return converter;
+   }
+
    public void initialize() {
       String name = sessInfo.getSessionId().toString();
       String username = connInfo.getUserName();
@@ -226,25 +227,10 @@ public class AMQSession implements SessionCallback {
 
    }
 
-   public AMQServerSession getCoreSession() {
-      return this.coreSession;
-   }
-
-   public ActiveMQServer getCoreServer() {
-      return this.server;
-   }
-
-   public void removeConsumer(long consumerId) throws Exception {
-      boolean failed = !(this.txId != null || this.isTx);
-
-      coreSession.amqCloseConsumer(consumerId, failed);
-      consumers.remove(consumerId);
-   }
 
-   public SendingResult send(AMQProducerBrokerExchange producerExchange,
-                             Message messageSend,
-                             boolean sendProducerAck) throws Exception {
-      SendingResult result = new SendingResult();
+   public void send(final ProducerInfo producerInfo,
+                    final Message messageSend,
+                    boolean sendProducerAck) throws Exception {
       TransactionId tid = messageSend.getTransactionId();
       if (tid != null) {
          resetSessionTx(tid);
@@ -262,39 +248,128 @@ public class AMQSession implements SessionCallback {
          actualDestinations = new ActiveMQDestination[]{destination};
       }
 
-      for (ActiveMQDestination dest : actualDestinations) {
+      ServerMessage originalCoreMsg = getConverter().inbound(messageSend);
+
+      /* ActiveMQ failover transport will attempt to reconnect after connection failure.  Any sent messages that did
+      * not receive acks will be resent.  (ActiveMQ broker handles this by returning a last sequence id received to
+      * the client).  To handle this in Artemis we use a duplicate ID cache.  To do this we check to see if the
+      * message comes from failover connection.  If so we add a DUPLICATE_ID to handle duplicates after a resend. */
+      if (connection.getContext().isFaultTolerant() && !messageSend.getProperties().containsKey(org.apache.activemq.artemis.api.core.Message.HDR_DUPLICATE_DETECTION_ID)) {
+         originalCoreMsg.putStringProperty(org.apache.activemq.artemis.api.core.Message.HDR_DUPLICATE_DETECTION_ID.toString(), messageSend.getMessageId().toString());
+      }
+
+      Runnable runnable;
+
+      if (sendProducerAck) {
+         runnable = new Runnable() {
+            public void run() {
+               try {
+                  ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), messageSend.getSize());
+                  connection.dispatchSync(ack);
+               }
+               catch (Exception e) {
+                  ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e);
+                  connection.sendException(e);
+               }
+
+            }
+         };
+      }
+      else {
+         final Connection transportConnection = connection.getTransportConnection();
+
+//         new Exception("Setting to false").printStackTrace();
+
+         if (transportConnection == null) {
+            // I don't think this could happen, but just in case, avoiding races
+            runnable = null;
+         }
+         else {
+            runnable = new Runnable() {
+               public void run() {
+                  transportConnection.setAutoRead(true);
+               }
+            };
+         }
+      }
+
 
-         ServerMessageImpl coreMsg = (ServerMessageImpl)converter.inbound(messageSend);
+      internalSend(actualDestinations, originalCoreMsg, runnable);
+   }
+
+   private void internalSend(ActiveMQDestination[] actualDestinations,
+                             ServerMessage originalCoreMsg,
+                             final Runnable onComplete) throws Exception {
+
+      Runnable runToUse;
+
+      if (actualDestinations.length <= 1 || onComplete == null) {
+         // if onComplete is null, this will be null ;)
+         runToUse = onComplete;
+      }
+      else {
+         final AtomicInteger count = new AtomicInteger(actualDestinations.length);
+         runToUse = new Runnable() {
+            @Override
+            public void run() {
+               if (count.decrementAndGet() == 0) {
+                  onComplete.run();
+               }
+            }
+         };
+      }
 
-         /* ActiveMQ failover transport will attempt to reconnect after connection failure.  Any sent messages that did
-         * not receive acks will be resent.  (ActiveMQ broker handles this by returning a last sequence id received to
-         * the client).  To handle this in Artemis we use a duplicate ID cache.  To do this we check to see if the
-         * message comes from failover connection.  If so we add a DUPLICATE_ID to handle duplicates after a resend. */
-         if (producerExchange.getConnectionContext().isFaultTolerant() && !messageSend.getProperties().containsKey(org.apache.activemq.artemis.api.core.Message.HDR_DUPLICATE_DETECTION_ID)) {
-            coreMsg.putStringProperty(org.apache.activemq.artemis.api.core.Message.HDR_DUPLICATE_DETECTION_ID.toString(), messageSend.getMessageId().toString());
+      SimpleString[] addresses = new SimpleString[actualDestinations.length];
+      PagingStore[] pagingStores = new PagingStore[actualDestinations.length];
+
+      // We fillup addresses, pagingStores and we will throw failure if that's the case
+      for (int i = 0; i < actualDestinations.length; i++) {
+         ActiveMQDestination dest = actualDestinations[i];
+         addresses[i] = OpenWireUtil.toCoreAddress(dest);
+         pagingStores[i] = server.getPagingManager().getPageStore(addresses[i]);
+         if (pagingStores[i].getAddressFullMessagePolicy() == AddressFullMessagePolicy.FAIL && pagingStores[i].isFull()) {
+            throw new ResourceAllocationException("Queue is full");
          }
-         SimpleString address = OpenWireUtil.toCoreAddress(dest);
-         coreMsg.setAddress(address);
+      }
+
+
+      for (int i = 0; i < actualDestinations.length; i++) {
+
+         ServerMessage coreMsg = originalCoreMsg.copy();
 
-         PagingStoreImpl store = (PagingStoreImpl) server.getPagingManager().getPageStore(address);
+         coreMsg.setAddress(addresses[i]);
 
+         PagingStore store = pagingStores[i];
 
-         // TODO: Improve this, tested with ProducerFlowControlSendFailTest
          if (store.isFull()) {
-            result.setBlockNextSend(true);
-            result.setBlockPagingStore(store);
-            result.setBlockingAddress(address);
-            //now we hold this message send until the store has space.
-            //we do this by put it in a scheduled task
-            ScheduledExecutorService scheduler = server.getScheduledPool();
-            Runnable sendRetryTask = new SendRetryTask(coreMsg, producerExchange, sendProducerAck, messageSend.getSize(), messageSend.getCommandId());
-            scheduler.schedule(sendRetryTask, 10, TimeUnit.MILLISECONDS);
+            connection.getTransportConnection().setAutoRead(false);
          }
-         else {
-            coreSession.send(coreMsg, false);
+
+         getCoreSession().send(coreMsg, false);
+
+         if (runToUse != null) {
+            // if the timeout is >0, it will wait this much milliseconds
+            // before running the the runToUse
+            // this will eventually unblock blocked destinations
+            // playing flow control
+            store.checkMemory(runToUse);
          }
       }
-      return result;
+   }
+
+   public AMQServerSession getCoreSession() {
+      return this.coreSession;
+   }
+
+   public ActiveMQServer getCoreServer() {
+      return this.server;
+   }
+
+   public void removeConsumer(long consumerId) throws Exception {
+      boolean failed = !(this.txId != null || this.isTx);
+
+      coreSession.amqCloseConsumer(consumerId, failed);
+      consumers.remove(consumerId);
    }
 
    public WireFormat getMarshaller() {
@@ -467,92 +542,4 @@ public class AMQSession implements SessionCallback {
          }
       }
    }
-
-   private class SendRetryTask implements Runnable {
-
-      private ServerMessage coreMsg;
-      private AMQProducerBrokerExchange producerExchange;
-      private boolean sendProducerAck;
-      private int msgSize;
-      private int commandId;
-
-      public SendRetryTask(ServerMessage coreMsg,
-                           AMQProducerBrokerExchange producerExchange,
-                           boolean sendProducerAck,
-                           int msgSize,
-                           int commandId) {
-         this.coreMsg = coreMsg;
-         this.producerExchange = producerExchange;
-         this.sendProducerAck = sendProducerAck;
-         this.msgSize = msgSize;
-         this.commandId = commandId;
-      }
-
-      @Override
-      public void run() {
-         synchronized (AMQSession.this) {
-            try {
-               // check pageStore
-               SimpleString address = coreMsg.getAddress();
-               PagingStoreImpl store = (PagingStoreImpl) server.getPagingManager().getPageStore(address);
-               if (store.isFull()) {
-                  // if store is still full, schedule another
-                  server.getScheduledPool().schedule(this, 10, TimeUnit.MILLISECONDS);
-               }
-               else {
-                  // now send the message again.
-                  coreSession.send(coreMsg, false);
-
-                  if (sendProducerAck) {
-                     ProducerInfo producerInfo = producerExchange.getProducerState().getInfo();
-                     ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), msgSize);
-                     connection.dispatchAsync(ack);
-                  }
-                  else {
-                     Response response = new Response();
-                     response.setCorrelationId(commandId);
-                     connection.dispatchAsync(response);
-                  }
-               }
-            }
-            catch (Exception e) {
-               ExceptionResponse response = new ExceptionResponse(e);
-               response.setCorrelationId(commandId);
-               connection.dispatchAsync(response);
-            }
-         }
-
-      }
-   }
-
-   // TODO: remove this, we should do the same as we do on core for blocking
-   public void blockingWaitForSpace(AMQProducerBrokerExchange producerExchange,
-                                    SendingResult result) throws IOException {
-
-
-      new Exception("blocking").printStackTrace();
-      long start = System.currentTimeMillis();
-      long nextWarn = start;
-      producerExchange.blockingOnFlowControl(true);
-
-      AMQConnectionContext context = producerExchange.getConnectionContext();
-      PagingStoreImpl store = result.getBlockPagingStore();
-
-      //Destination.DEFAULT_BLOCKED_PRODUCER_WARNING_INTERVAL
-      long blockedProducerWarningInterval = 30000;
-      ProducerId producerId = producerExchange.getProducerState().getInfo().getProducerId();
-
-      while (store.isFull()) {
-         if (context.getStopping().get()) {
-            throw new IOException("Connection closed, send aborted.");
-         }
-
-         long now = System.currentTimeMillis();
-         if (now >= nextWarn) {
-            ActiveMQServerLogger.LOGGER.memoryLimitReached(producerId.toString(), result.getBlockingAddress().toString(), ((now - start) / 1000));
-            nextWarn = now + blockedProducerWarningInterval;
-         }
-      }
-      producerExchange.blockingOnFlowControl(false);
-   }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d1909c33/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/impl/OpenWireServerCallback.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/impl/OpenWireServerCallback.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/impl/OpenWireServerCallback.java
deleted file mode 100644
index 8ab3815..0000000
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/impl/OpenWireServerCallback.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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.artemis.core.protocol.openwire.impl;
-
-import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.server.ServerConsumer;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
-import org.apache.activemq.artemis.spi.core.remoting.ReadyListener;
-
-public class OpenWireServerCallback implements SessionCallback {
-
-   @Override
-   public boolean hasCredits(ServerConsumer consumerID) {
-      return false;
-   }
-
-   @Override
-   public void sendProducerCreditsMessage(int credits, SimpleString address) {
-
-   }
-
-   @Override
-   public void sendProducerCreditsFailMessage(int credits, SimpleString address) {
-
-   }
-
-   @Override
-   public int sendMessage(ServerMessage message, ServerConsumer consumerID, int deliveryCount) {
-      return 0;
-   }
-
-   @Override
-   public int sendLargeMessage(ServerMessage message, ServerConsumer consumerID, long bodySize, int deliveryCount) {
-      return 0;
-   }
-
-   @Override
-   public int sendLargeMessageContinuation(ServerConsumer consumerID,
-                                           byte[] body,
-                                           boolean continues,
-                                           boolean requiresResponse) {
-      return 0;
-   }
-
-   @Override
-   public void closed() {
-
-   }
-
-   @Override
-   public void disconnect(ServerConsumer consumerId, String queueName) {
-
-   }
-
-   @Override
-   public boolean isWritable(ReadyListener callback) {
-      return false;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d1909c33/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStore.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStore.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStore.java
index e831966..566b91a 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStore.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/PagingStore.java
@@ -126,6 +126,8 @@ public interface PagingStore extends ActiveMQComponent {
 
    boolean checkMemory(Runnable runnable);
 
+   boolean isFull();
+
    /**
     * Write lock the PagingStore.
     *

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d1909c33/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnection.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnection.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnection.java
index 70d6289..db61f89 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnection.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnection.java
@@ -138,6 +138,12 @@ public class InVMConnection implements Connection {
    }
 
    @Override
+   public void setAutoRead(boolean autoRead) {
+      // nothing to be done on the INVM.
+      // maybe we could eventually implement something, but not needed now
+   }
+
+   @Override
    public ActiveMQBuffer createTransportBuffer(final int size) {
       return ActiveMQBuffers.dynamicBuffer(size);
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d1909c33/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java
index 5a160ab..e44a490 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java
@@ -170,20 +170,21 @@ public class FailoverConsumerOutstandingCommitTest extends OpenwireArtemisBaseTe
 
    @Test
    @BMRules(
-      rules = {@BMRule(
-         name = "set no return response",
-         targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor",
-         targetMethod = "processCommitTransactionOnePhase",
-         targetLocation = "ENTRY",
-         binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
-         action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.holdResponse($0)"),
+      rules = {
+         @BMRule(
+            name = "set no return response",
+            targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor",
+            targetMethod = "processCommitTransactionOnePhase",
+            targetLocation = "ENTRY",
+            binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
+            action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.holdResponse($0)"),
 
          @BMRule(
-         name = "stop broker before commit",
-         targetClass = "org.apache.activemq.artemis.core.server.impl.ServerSessionImpl",
-         targetMethod = "commit",
-         targetLocation = "ENTRY",
-         action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.stopServerInTransaction();return")})
+            name = "stop broker before commit",
+            targetClass = "org.apache.activemq.artemis.core.server.impl.ServerSessionImpl",
+            targetMethod = "commit",
+            targetLocation = "ENTRY",
+            action = "org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.stopServerInTransaction();return")})
    public void TestFailoverConsumerOutstandingSendTxIncomplete() throws Exception {
       doTestFailoverConsumerOutstandingSendTx(false);
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d1909c33/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/investigations/InvestigationOpenwireTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/investigations/InvestigationOpenwireTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/investigations/InvestigationOpenwireTest.java
index 914a8e1..1599a2c 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/investigations/InvestigationOpenwireTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/investigations/InvestigationOpenwireTest.java
@@ -29,6 +29,7 @@ import javax.transaction.xa.XAResource;
 import java.util.Collection;
 import java.util.LinkedList;
 
+import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest;
 import org.junit.Assert;
 import org.junit.Test;
@@ -59,6 +60,30 @@ public class InvestigationOpenwireTest extends BasicOpenWireTest {
    }
 
    @Test
+   public void testProducerFlowControl() throws Exception {
+      try {
+
+         ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(urlString);
+
+         factory.setProducerWindowSize(1024 * 64);
+
+         Connection connection = factory.createConnection();
+         Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+         Queue queue = session.createQueue(queueName);
+         MessageProducer producer = session.createProducer(queue);
+         producer.send(session.createTextMessage("test"));
+
+
+         connection.close();
+
+         System.err.println("Done!!!");
+      }
+      catch (Exception e) {
+         e.printStackTrace();
+      }
+   }
+
+   @Test
    public void testAutoAck() throws Exception {
       try {
 
@@ -108,6 +133,7 @@ public class InvestigationOpenwireTest extends BasicOpenWireTest {
          MessageProducer producer = session.createProducer(queue);
          MessageConsumer consumer = session.createConsumer(queue);
          producer.send(session.createTextMessage("test"));
+         producer.send(session.createTextMessage("test2"));
          connection.start();
          Assert.assertNull(consumer.receive(1000));
          session.rollback();
@@ -130,6 +156,7 @@ public class InvestigationOpenwireTest extends BasicOpenWireTest {
    }
 
 
+
    @Test
    public void testClientACK() throws Exception {
       try {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d1909c33/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/PersistMultiThreadTest.java
----------------------------------------------------------------------
diff --git a/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/PersistMultiThreadTest.java b/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/PersistMultiThreadTest.java
index 6351357..cd08b9e 100644
--- a/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/PersistMultiThreadTest.java
+++ b/tests/performance-tests/src/test/java/org/apache/activemq/artemis/tests/performance/storage/PersistMultiThreadTest.java
@@ -301,6 +301,10 @@ public class PersistMultiThreadTest extends ActiveMQTestBase {
          return 0;
       }
 
+      public boolean isFull() {
+         return false;
+      }
+
       @Override
       public void applySetting(AddressSettings addressSettings) {
 


[18/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4212Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4212Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4212Test.java
deleted file mode 100644
index 3504c1f..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4212Test.java
+++ /dev/null
@@ -1,357 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.management.ObjectName;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.store.kahadb.disk.journal.DataFile;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ4212Test {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ4212Test.class);
-
-   private BrokerService service;
-   private String connectionUri;
-   private ActiveMQConnectionFactory cf;
-
-   private final int MSG_COUNT = 256;
-
-   @Before
-   public void setUp() throws IOException, Exception {
-      createBroker(true, false);
-   }
-
-   public void createBroker(boolean deleteAllMessages, boolean recover) throws Exception {
-      service = new BrokerService();
-      service.setBrokerName("InactiveSubTest");
-      service.setDeleteAllMessagesOnStartup(deleteAllMessages);
-      service.setAdvisorySupport(false);
-      service.setPersistent(true);
-      service.setUseJmx(true);
-      service.setKeepDurableSubsActive(false);
-
-      KahaDBPersistenceAdapter pa = new KahaDBPersistenceAdapter();
-      File dataFile = new File("KahaDB");
-      pa.setDirectory(dataFile);
-      pa.setJournalMaxFileLength(10 * 1024);
-      pa.setCheckpointInterval(TimeUnit.SECONDS.toMillis(5));
-      pa.setCleanupInterval(TimeUnit.SECONDS.toMillis(5));
-      pa.setForceRecoverIndex(recover);
-
-      service.setPersistenceAdapter(pa);
-      service.start();
-      service.waitUntilStarted();
-
-      connectionUri = "vm://InactiveSubTest?create=false";
-      cf = new ActiveMQConnectionFactory(connectionUri);
-   }
-
-   private void restartBroker() throws Exception {
-      stopBroker();
-      createBroker(false, false);
-   }
-
-   private void recoverBroker() throws Exception {
-      stopBroker();
-      createBroker(false, true);
-   }
-
-   @After
-   public void stopBroker() throws Exception {
-      if (service != null) {
-         service.stop();
-         service.waitUntilStopped();
-         service = null;
-      }
-   }
-
-   @Test
-   public void testDirableSubPrefetchRecovered() throws Exception {
-
-      ActiveMQQueue queue = new ActiveMQQueue("MyQueue");
-      ActiveMQTopic topic = new ActiveMQTopic("MyDurableTopic");
-
-      // Send to a Queue to create some journal files
-      sendMessages(queue);
-
-      LOG.info("There are currently [{}] journal log files.", getNumberOfJournalFiles());
-
-      createInactiveDurableSub(topic);
-
-      assertTrue("Should have an inactive durable sub", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            ObjectName[] subs = service.getAdminView().getInactiveDurableTopicSubscribers();
-            return subs != null && subs.length == 1 ? true : false;
-         }
-      }));
-
-      // Now send some more to the queue to create even more files.
-      sendMessages(queue);
-
-      LOG.info("There are currently [{}] journal log files.", getNumberOfJournalFiles());
-      assertTrue(getNumberOfJournalFiles() > 1);
-
-      LOG.info("Restarting the broker.");
-      restartBroker();
-      LOG.info("Restarted the broker.");
-
-      LOG.info("There are currently [{}] journal log files.", getNumberOfJournalFiles());
-      assertTrue(getNumberOfJournalFiles() > 1);
-
-      assertTrue("Should have an inactive durable sub", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            ObjectName[] subs = service.getAdminView().getInactiveDurableTopicSubscribers();
-            return subs != null && subs.length == 1 ? true : false;
-         }
-      }));
-
-      // Clear out all queue data
-      service.getAdminView().removeQueue(queue.getQueueName());
-
-      assertTrue("Less than two journal files expected, was " + getNumberOfJournalFiles(), Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return getNumberOfJournalFiles() <= 2;
-         }
-      }, TimeUnit.MINUTES.toMillis(2)));
-
-      LOG.info("Sending {} Messages to the Topic.", MSG_COUNT);
-      // Send some messages to the inactive destination
-      sendMessages(topic);
-
-      LOG.info("Attempt to consume {} messages from the Topic.", MSG_COUNT);
-      assertEquals(MSG_COUNT, consumeFromInactiveDurableSub(topic));
-
-      LOG.info("Recovering the broker.");
-      recoverBroker();
-      LOG.info("Recovering the broker.");
-
-      assertTrue("Should have an inactive durable sub", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            ObjectName[] subs = service.getAdminView().getInactiveDurableTopicSubscribers();
-            return subs != null && subs.length == 1 ? true : false;
-         }
-      }));
-   }
-
-   @Test
-   public void testDurableAcksNotDropped() throws Exception {
-
-      ActiveMQQueue queue = new ActiveMQQueue("MyQueue");
-      ActiveMQTopic topic = new ActiveMQTopic("MyDurableTopic");
-
-      // Create durable sub in first data file.
-      createInactiveDurableSub(topic);
-
-      assertTrue("Should have an inactive durable sub", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            ObjectName[] subs = service.getAdminView().getInactiveDurableTopicSubscribers();
-            return subs != null && subs.length == 1 ? true : false;
-         }
-      }));
-
-      // Send to a Topic
-      sendMessages(topic, 1);
-
-      // Send to a Queue to create some journal files
-      sendMessages(queue);
-
-      LOG.info("Before consume there are currently [{}] journal log files.", getNumberOfJournalFiles());
-
-      // Consume all the Messages leaving acks behind.
-      consumeDurableMessages(topic, 1);
-
-      LOG.info("After consume there are currently [{}] journal log files.", getNumberOfJournalFiles());
-
-      // Now send some more to the queue to create even more files.
-      sendMessages(queue);
-
-      LOG.info("More Queued. There are currently [{}] journal log files.", getNumberOfJournalFiles());
-      assertTrue(getNumberOfJournalFiles() > 1);
-
-      LOG.info("Restarting the broker.");
-      restartBroker();
-      LOG.info("Restarted the broker.");
-
-      LOG.info("There are currently [{}] journal log files.", getNumberOfJournalFiles());
-      assertTrue(getNumberOfJournalFiles() > 1);
-
-      assertTrue("Should have an inactive durable sub", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            ObjectName[] subs = service.getAdminView().getInactiveDurableTopicSubscribers();
-            return subs != null && subs.length == 1 ? true : false;
-         }
-      }));
-
-      // Clear out all queue data
-      service.getAdminView().removeQueue(queue.getQueueName());
-
-      assertTrue("Less than three journal file expected, was " + getNumberOfJournalFiles(), Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return getNumberOfJournalFiles() <= 3;
-         }
-      }, TimeUnit.MINUTES.toMillis(3)));
-
-      // See if we receive any message they should all be acked.
-      tryConsumeExpectNone(topic);
-
-      LOG.info("There are currently [{}] journal log files.", getNumberOfJournalFiles());
-
-      LOG.info("Recovering the broker.");
-      recoverBroker();
-      LOG.info("Recovering the broker.");
-
-      LOG.info("There are currently [{}] journal log files.", getNumberOfJournalFiles());
-
-      assertTrue("Should have an inactive durable sub", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            ObjectName[] subs = service.getAdminView().getInactiveDurableTopicSubscribers();
-            return subs != null && subs.length == 1 ? true : false;
-         }
-      }));
-
-      // See if we receive any message they should all be acked.
-      tryConsumeExpectNone(topic);
-
-      assertTrue("Less than three journal file expected, was " + getNumberOfJournalFiles(), Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return getNumberOfJournalFiles() == 1;
-         }
-      }, TimeUnit.MINUTES.toMillis(1)));
-   }
-
-   private int getNumberOfJournalFiles() throws IOException {
-      Collection<DataFile> files = ((KahaDBPersistenceAdapter) service.getPersistenceAdapter()).getStore().getJournal().getFileMap().values();
-      int reality = 0;
-      for (DataFile file : files) {
-         if (file != null) {
-            reality++;
-         }
-      }
-
-      return reality;
-   }
-
-   private void createInactiveDurableSub(Topic topic) throws Exception {
-      Connection connection = cf.createConnection();
-      connection.setClientID("Inactive");
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer consumer = session.createDurableSubscriber(topic, "Inactive");
-      consumer.close();
-      connection.close();
-   }
-
-   private void consumeDurableMessages(Topic topic, int count) throws Exception {
-      Connection connection = cf.createConnection();
-      connection.setClientID("Inactive");
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer consumer = session.createDurableSubscriber(topic, "Inactive");
-      connection.start();
-      for (int i = 0; i < count; ++i) {
-         if (consumer.receive(TimeUnit.SECONDS.toMillis(10)) == null) {
-            fail("should have received a message");
-         }
-      }
-      consumer.close();
-      connection.close();
-   }
-
-   private void tryConsumeExpectNone(Topic topic) throws Exception {
-      Connection connection = cf.createConnection();
-      connection.setClientID("Inactive");
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer consumer = session.createDurableSubscriber(topic, "Inactive");
-      connection.start();
-      if (consumer.receive(TimeUnit.SECONDS.toMillis(10)) != null) {
-         fail("Should be no messages for this durable.");
-      }
-      consumer.close();
-      connection.close();
-   }
-
-   private int consumeFromInactiveDurableSub(Topic topic) throws Exception {
-      Connection connection = cf.createConnection();
-      connection.setClientID("Inactive");
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer consumer = session.createDurableSubscriber(topic, "Inactive");
-
-      int count = 0;
-
-      while (consumer.receive(10000) != null) {
-         count++;
-      }
-
-      consumer.close();
-      connection.close();
-
-      return count;
-   }
-
-   private void sendMessages(Destination destination) throws Exception {
-      sendMessages(destination, MSG_COUNT);
-   }
-
-   private void sendMessages(Destination destination, int count) throws Exception {
-      Connection connection = cf.createConnection();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = session.createProducer(destination);
-      producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-      for (int i = 0; i < count; ++i) {
-         TextMessage message = session.createTextMessage("Message #" + i + " for destination: " + destination);
-         producer.send(message);
-      }
-      connection.close();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4213Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4213Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4213Test.java
deleted file mode 100644
index c033e97..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4213Test.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.fail;
-
-import javax.jms.JMSException;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerPlugin;
-import org.apache.activemq.broker.BrokerPluginSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.ConnectionContext;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ProducerInfo;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AMQ4213Test {
-
-   private static BrokerService brokerService;
-   private static String BROKER_ADDRESS = "tcp://localhost:0";
-   private static String TEST_QUEUE = "testQueue";
-   private static ActiveMQQueue queue = new ActiveMQQueue(TEST_QUEUE);
-
-   private String connectionUri;
-
-   @SuppressWarnings("unchecked")
-   @Before
-   public void setUp() throws Exception {
-      brokerService = new BrokerService();
-      brokerService.setPersistent(false);
-      brokerService.setUseJmx(true);
-      brokerService.setDeleteAllMessagesOnStartup(true);
-      connectionUri = brokerService.addConnector(BROKER_ADDRESS).getPublishableConnectString();
-
-      brokerService.setPlugins(new BrokerPlugin[]{new BrokerPluginSupport() {
-
-         @Override
-         public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception {
-            throw new javax.jms.JMSSecurityException(connectionUri);
-         }
-      }});
-
-      brokerService.start();
-      brokerService.waitUntilStarted();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      brokerService.stop();
-      brokerService.waitUntilStopped();
-   }
-
-   @Test
-   public void testExceptionOnProducerCreateThrows() throws Exception {
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri);
-      ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
-
-      Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
-      connection.start();
-
-      try {
-         session.createProducer(queue);
-         fail("Should not be able to create this producer.");
-      }
-      catch (JMSException ex) {
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4220Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4220Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4220Test.java
deleted file mode 100644
index 7433b18..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4220Test.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.ArrayList;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.store.PersistenceAdapter;
-import org.apache.activemq.store.kahadb.FilteredKahaDBPersistenceAdapter;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.store.kahadb.MultiKahaDBPersistenceAdapter;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ4220Test {
-
-   static final Logger LOG = LoggerFactory.getLogger(AMQ4220Test.class);
-   private final static int maxFileLength = 1024 * 1024 * 32;
-   private final static String destinationName = "TEST.QUEUE";
-   BrokerService broker;
-
-   @Before
-   public void setUp() throws Exception {
-      prepareBrokerWithMultiStore(true);
-      broker.start();
-      broker.waitUntilStarted();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      broker.stop();
-   }
-
-   protected BrokerService createBroker(PersistenceAdapter kaha) throws Exception {
-      BrokerService broker = new BrokerService();
-      broker.setUseJmx(true);
-      broker.setBrokerName("localhost");
-      broker.setPersistenceAdapter(kaha);
-      return broker;
-   }
-
-   @Test
-   public void testRestartAfterQueueDelete() throws Exception {
-
-      // Ensure we have an Admin View.
-      assertTrue("Broker doesn't have an Admin View.", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return (broker.getAdminView()) != null;
-         }
-      }));
-
-      LOG.info("Adding initial destination: {}", destinationName);
-
-      broker.getAdminView().addQueue(destinationName);
-
-      assertNotNull(broker.getDestination(new ActiveMQQueue(destinationName)));
-
-      LOG.info("Removing initial destination: {}", destinationName);
-
-      broker.getAdminView().removeQueue(destinationName);
-
-      LOG.info("Adding back destination: {}", destinationName);
-
-      broker.getAdminView().addQueue(destinationName);
-
-      assertNotNull(broker.getDestination(new ActiveMQQueue(destinationName)));
-   }
-
-   protected KahaDBPersistenceAdapter createStore(boolean delete) throws IOException {
-      KahaDBPersistenceAdapter kaha = new KahaDBPersistenceAdapter();
-      kaha.setJournalMaxFileLength(maxFileLength);
-      kaha.setCleanupInterval(5000);
-      if (delete) {
-         kaha.deleteAllMessages();
-      }
-      return kaha;
-   }
-
-   public void prepareBrokerWithMultiStore(boolean deleteAllMessages) throws Exception {
-
-      MultiKahaDBPersistenceAdapter multiKahaDBPersistenceAdapter = new MultiKahaDBPersistenceAdapter();
-      if (deleteAllMessages) {
-         multiKahaDBPersistenceAdapter.deleteAllMessages();
-      }
-      ArrayList<FilteredKahaDBPersistenceAdapter> adapters = new ArrayList<>();
-
-      FilteredKahaDBPersistenceAdapter template = new FilteredKahaDBPersistenceAdapter();
-      template.setPersistenceAdapter(createStore(deleteAllMessages));
-      template.setPerDestination(true);
-      adapters.add(template);
-
-      multiKahaDBPersistenceAdapter.setFilteredPersistenceAdapters(adapters);
-      broker = createBroker(multiKahaDBPersistenceAdapter);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4221Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4221Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4221Test.java
deleted file mode 100644
index 0e9c488..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4221Test.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/**
- * 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;
-
-import java.util.HashSet;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import junit.framework.Test;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQPrefetchPolicy;
-import org.apache.activemq.TestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.TransportConnector;
-import org.apache.activemq.broker.region.DestinationStatistics;
-import org.apache.activemq.broker.region.policy.FilePendingQueueMessageStoragePolicy;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.store.kahadb.plist.PListStoreImpl;
-import org.apache.activemq.util.DefaultTestAppender;
-import org.apache.log4j.Level;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.spi.LoggingEvent;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ4221Test extends TestSupport {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ4221Test.class);
-   public int PAYLOAD_SIZE_BYTES = 4 * 1024;
-   public int NUM_TO_SEND = 60000;
-   public int NUM_CONCURRENT_PRODUCERS = 20;
-   public int QUEUE_COUNT = 1;
-   public int TMP_JOURNAL_MAX_FILE_SIZE = 10 * 1024 * 1024;
-
-   public int DLQ_PURGE_INTERVAL = 30000;
-
-   public int MESSAGE_TIME_TO_LIVE = 20000;
-   public int EXPIRE_SWEEP_PERIOD = 200;
-   public int TMP_JOURNAL_GC_PERIOD = 50;
-   public int RECEIVE_POLL_PERIOD = 4000;
-   private int RECEIVE_BATCH = 5000;
-
-   final byte[] payload = new byte[PAYLOAD_SIZE_BYTES];
-   final AtomicInteger counter = new AtomicInteger(0);
-   final HashSet<Throwable> exceptions = new HashSet<>();
-   BrokerService brokerService;
-   private String brokerUrlString;
-   ExecutorService executorService = Executors.newCachedThreadPool();
-   final AtomicBoolean done = new AtomicBoolean(false);
-
-   public static Test suite() {
-      return suite(AMQ4221Test.class);
-   }
-
-   @Override
-   public void setUp() throws Exception {
-
-      LogManager.getRootLogger().addAppender(new DefaultTestAppender() {
-
-         @Override
-         public void doAppend(LoggingEvent event) {
-            if (event.getLevel().isGreaterOrEqual(Level.ERROR)) {
-               System.err.println("exit on error: " + event.getMessage());
-               done.set(true);
-               new Thread() {
-                  @Override
-                  public void run() {
-                     System.exit(787);
-                  }
-               }.start();
-            }
-         }
-      });
-
-      done.set(false);
-      brokerService = new BrokerService();
-      brokerService.setDeleteAllMessagesOnStartup(true);
-      brokerService.setDestinations(new ActiveMQDestination[]{new ActiveMQQueue("ActiveMQ.DLQ")});
-
-      PolicyEntry defaultPolicy = new PolicyEntry();
-      defaultPolicy.setPendingQueuePolicy(new FilePendingQueueMessageStoragePolicy());
-      defaultPolicy.setExpireMessagesPeriod(EXPIRE_SWEEP_PERIOD);
-      defaultPolicy.setProducerFlowControl(false);
-      defaultPolicy.setMemoryLimit(50 * 1024 * 1024);
-
-      brokerService.getSystemUsage().getMemoryUsage().setLimit(50 * 1024 * 1024);
-
-      PolicyMap destinationPolicyMap = new PolicyMap();
-      destinationPolicyMap.setDefaultEntry(defaultPolicy);
-      brokerService.setDestinationPolicy(destinationPolicyMap);
-
-      PListStoreImpl tempDataStore = new PListStoreImpl();
-      tempDataStore.setDirectory(brokerService.getTmpDataDirectory());
-      tempDataStore.setJournalMaxFileLength(TMP_JOURNAL_MAX_FILE_SIZE);
-      tempDataStore.setCleanupInterval(TMP_JOURNAL_GC_PERIOD);
-      tempDataStore.setIndexPageSize(200);
-      tempDataStore.setIndexEnablePageCaching(false);
-
-      brokerService.setTempDataStore(tempDataStore);
-      brokerService.setAdvisorySupport(false);
-      TransportConnector tcp = brokerService.addConnector("tcp://localhost:0");
-      brokerService.start();
-      brokerUrlString = tcp.getPublishableConnectString();
-   }
-
-   @Override
-   public void tearDown() throws Exception {
-      brokerService.stop();
-      brokerService.waitUntilStopped();
-      executorService.shutdownNow();
-   }
-
-   public void testProduceConsumeExpireHalf() throws Exception {
-
-      final org.apache.activemq.broker.region.Queue dlq = (org.apache.activemq.broker.region.Queue) getDestination(brokerService, new ActiveMQQueue("ActiveMQ.DLQ"));
-
-      if (DLQ_PURGE_INTERVAL > 0) {
-         executorService.execute(new Runnable() {
-            @Override
-            public void run() {
-               while (!done.get()) {
-                  try {
-                     Thread.sleep(DLQ_PURGE_INTERVAL);
-                     LOG.info("Purge DLQ, current size: " + dlq.getDestinationStatistics().getMessages().getCount());
-                     dlq.purge();
-                  }
-                  catch (InterruptedException allDone) {
-                  }
-                  catch (Throwable e) {
-                     e.printStackTrace();
-                     exceptions.add(e);
-                  }
-               }
-            }
-         });
-
-      }
-
-      final CountDownLatch latch = new CountDownLatch(QUEUE_COUNT);
-      for (int i = 0; i < QUEUE_COUNT; i++) {
-         final int id = i;
-         executorService.execute(new Runnable() {
-            @Override
-            public void run() {
-               try {
-                  doProduceConsumeExpireHalf(id, latch);
-               }
-               catch (Throwable e) {
-                  e.printStackTrace();
-                  exceptions.add(e);
-               }
-            }
-         });
-      }
-
-      while (!done.get()) {
-         done.set(latch.await(5, TimeUnit.SECONDS));
-      }
-      executorService.shutdown();
-      executorService.awaitTermination(5, TimeUnit.MINUTES);
-
-      assertTrue("no exceptions:" + exceptions, exceptions.isEmpty());
-
-   }
-
-   public void doProduceConsumeExpireHalf(int id, CountDownLatch latch) throws Exception {
-
-      final ActiveMQQueue queue = new ActiveMQQueue("Q" + id);
-
-      final ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerUrlString);
-      ActiveMQPrefetchPolicy prefecthPolicy = new ActiveMQPrefetchPolicy();
-      prefecthPolicy.setAll(0);
-      factory.setPrefetchPolicy(prefecthPolicy);
-      Connection connection = factory.createConnection();
-      connection.start();
-      final MessageConsumer consumer = connection.createSession(false, Session.AUTO_ACKNOWLEDGE).createConsumer(queue, "on = 'true'");
-
-      executorService.execute(new Runnable() {
-         @Override
-         public void run() {
-            try {
-               while (!done.get()) {
-                  Thread.sleep(RECEIVE_POLL_PERIOD);
-                  for (int i = 0; i < RECEIVE_BATCH && !done.get(); i++) {
-
-                     Message message = consumer.receive(1000);
-                     if (message != null) {
-                        counter.incrementAndGet();
-                        if (counter.get() > 0 && counter.get() % 500 == 0) {
-                           LOG.info("received: " + counter.get() + ", " + message.getJMSDestination().toString());
-                        }
-                     }
-                  }
-               }
-            }
-            catch (JMSException ignored) {
-
-            }
-            catch (Exception e) {
-               e.printStackTrace();
-               exceptions.add(e);
-            }
-         }
-      });
-
-      final AtomicInteger accumulator = new AtomicInteger(0);
-      final CountDownLatch producersDone = new CountDownLatch(NUM_CONCURRENT_PRODUCERS);
-
-      for (int i = 0; i < NUM_CONCURRENT_PRODUCERS; i++) {
-         executorService.execute(new Runnable() {
-            @Override
-            public void run() {
-               try {
-                  Connection sendConnection = factory.createConnection();
-                  sendConnection.start();
-                  Session sendSession = sendConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-                  MessageProducer producer = sendSession.createProducer(queue);
-                  producer.setTimeToLive(MESSAGE_TIME_TO_LIVE);
-                  producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
-                  while (accumulator.incrementAndGet() < NUM_TO_SEND && !done.get()) {
-                     BytesMessage message = sendSession.createBytesMessage();
-                     message.writeBytes(payload);
-                     message.setStringProperty("on", String.valueOf(accumulator.get() % 2 == 0));
-                     producer.send(message);
-
-                  }
-                  producersDone.countDown();
-               }
-               catch (Exception e) {
-                  e.printStackTrace();
-                  exceptions.add(e);
-               }
-            }
-         });
-      }
-
-      producersDone.await(10, TimeUnit.MINUTES);
-
-      final DestinationStatistics view = getDestinationStatistics(brokerService, queue);
-      LOG.info("total expired so far " + view.getExpired().getCount() + ", " + queue.getQueueName());
-      latch.countDown();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4222Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4222Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4222Test.java
deleted file mode 100644
index adaf0e5..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4222Test.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/**
- * 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;
-
-import java.lang.reflect.Field;
-import java.net.URI;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.TestSupport;
-import org.apache.activemq.broker.BrokerFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.ProducerBrokerExchange;
-import org.apache.activemq.broker.TransportConnection;
-import org.apache.activemq.broker.TransportConnector;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ProducerId;
-import org.apache.activemq.transport.vm.VMTransportFactory;
-import org.apache.activemq.util.Wait;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author <a href="http://www.christianposta.com/blog">Christian Posta</a>
- */
-public class AMQ4222Test extends TestSupport {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ4222Test.class);
-
-   protected BrokerService brokerService;
-
-   @Override
-   protected void setUp() throws Exception {
-      super.setUp();
-      topic = false;
-      brokerService = createBroker();
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      brokerService.stop();
-      brokerService.waitUntilStopped();
-   }
-
-   protected BrokerService createBroker() throws Exception {
-      BrokerService broker = BrokerFactory.createBroker(new URI("broker:()/localhost?persistent=false"));
-      broker.start();
-      broker.waitUntilStarted();
-      return broker;
-   }
-
-   @Override
-   protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
-      return new ActiveMQConnectionFactory("vm://localhost");
-   }
-
-   public void testTempQueueCleanedUp() throws Exception {
-
-      Destination requestQueue = createDestination();
-
-      Connection producerConnection = createConnection();
-      producerConnection.start();
-      Session producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      MessageProducer producer = producerSession.createProducer(requestQueue);
-      Destination replyTo = producerSession.createTemporaryQueue();
-      MessageConsumer producerSessionConsumer = producerSession.createConsumer(replyTo);
-
-      final CountDownLatch countDownLatch = new CountDownLatch(1);
-      // let's listen to the response on the queue
-      producerSessionConsumer.setMessageListener(new MessageListener() {
-         @Override
-         public void onMessage(Message message) {
-            try {
-               if (message instanceof TextMessage) {
-                  LOG.info("You got a message: " + ((TextMessage) message).getText());
-                  countDownLatch.countDown();
-               }
-            }
-            catch (JMSException e) {
-               e.printStackTrace();
-            }
-         }
-      });
-
-      producer.send(createRequest(producerSession, replyTo));
-
-      Connection consumerConnection = createConnection();
-      consumerConnection.start();
-      Session consumerSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer consumer = consumerSession.createConsumer(requestQueue);
-      final MessageProducer consumerProducer = consumerSession.createProducer(null);
-
-      consumer.setMessageListener(new MessageListener() {
-         @Override
-         public void onMessage(Message message) {
-            try {
-               consumerProducer.send(message.getJMSReplyTo(), message);
-            }
-            catch (JMSException e) {
-               LOG.error("error sending a response on the temp queue");
-               e.printStackTrace();
-            }
-         }
-      });
-
-      countDownLatch.await(2, TimeUnit.SECONDS);
-
-      // producer has not gone away yet...
-      org.apache.activemq.broker.region.Destination tempDestination = getDestination(brokerService, (ActiveMQDestination) replyTo);
-      assertNotNull(tempDestination);
-
-      // clean up
-      producer.close();
-      producerSession.close();
-      producerConnection.close();
-
-      // producer has gone away.. so the temp queue should not exist anymore... let's see..
-      // producer has not gone away yet...
-      tempDestination = getDestination(brokerService, (ActiveMQDestination) replyTo);
-      assertNull(tempDestination);
-
-      // now.. the connection on the broker side for the dude producing to the temp dest will
-      // still have a reference in his producerBrokerExchange.. this will keep the destination
-      // from being reclaimed by GC if there is never another send that producer makes...
-      // let's see if that reference is there...
-      final TransportConnector connector = VMTransportFactory.CONNECTORS.get("localhost");
-      assertNotNull(connector);
-      assertTrue(Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return connector.getConnections().size() == 1;
-         }
-      }));
-      TransportConnection transportConnection = connector.getConnections().get(0);
-      Map<ProducerId, ProducerBrokerExchange> exchanges = getProducerExchangeFromConn(transportConnection);
-      assertEquals(1, exchanges.size());
-      ProducerBrokerExchange exchange = exchanges.values().iterator().next();
-
-      // so this is the reason for the test... we don't want these exchanges to hold a reference
-      // to a region destination.. after a send is completed, the destination is not used anymore on
-      // a producer exchange
-      assertNull(exchange.getRegionDestination());
-      assertNull(exchange.getRegion());
-
-   }
-
-   @SuppressWarnings("unchecked")
-   private Map<ProducerId, ProducerBrokerExchange> getProducerExchangeFromConn(TransportConnection transportConnection) throws NoSuchFieldException, IllegalAccessException {
-      Field f = TransportConnection.class.getDeclaredField("producerExchanges");
-      f.setAccessible(true);
-      Map<ProducerId, ProducerBrokerExchange> producerExchanges = (Map<ProducerId, ProducerBrokerExchange>) f.get(transportConnection);
-      return producerExchanges;
-   }
-
-   private Message createRequest(Session session, Destination replyTo) throws JMSException {
-      Message message = session.createTextMessage("Payload");
-      message.setJMSReplyTo(replyTo);
-      return message;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4323Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4323Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4323Test.java
deleted file mode 100644
index 415dad6..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4323Test.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/**
- * 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;
-
-import java.io.File;
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.util.ConsumerThread;
-import org.apache.activemq.util.ProducerThread;
-import org.apache.activemq.util.Wait;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class AMQ4323Test {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ4323Test.class);
-
-   BrokerService broker = null;
-   File kahaDbDir = null;
-   private final Destination destination = new ActiveMQQueue("q");
-   final String payload = new String(new byte[1024]);
-
-   protected void startBroker(boolean delete) throws Exception {
-      broker = new BrokerService();
-
-      //Start with a clean directory
-      kahaDbDir = new File(broker.getBrokerDataDirectory(), "KahaDB");
-      deleteDir(kahaDbDir);
-
-      broker.setSchedulerSupport(false);
-      broker.setDeleteAllMessagesOnStartup(delete);
-      broker.setPersistent(true);
-      broker.setUseJmx(false);
-      broker.addConnector("tcp://localhost:0");
-
-      PolicyMap map = new PolicyMap();
-      PolicyEntry entry = new PolicyEntry();
-      entry.setUseCache(false);
-      map.setDefaultEntry(entry);
-      broker.setDestinationPolicy(map);
-
-      configurePersistence(broker, delete);
-
-      broker.start();
-      LOG.info("Starting broker..");
-   }
-
-   protected void configurePersistence(BrokerService brokerService, boolean deleteAllOnStart) throws Exception {
-      KahaDBPersistenceAdapter adapter = (KahaDBPersistenceAdapter) brokerService.getPersistenceAdapter();
-
-      // ensure there are a bunch of data files but multiple entries in each
-      adapter.setJournalMaxFileLength(1024 * 20);
-
-      // speed up the test case, checkpoint and cleanup early and often
-      adapter.setCheckpointInterval(500);
-      adapter.setCleanupInterval(500);
-
-      if (!deleteAllOnStart) {
-         adapter.setForceRecoverIndex(true);
-      }
-
-   }
-
-   private boolean deleteDir(File dir) {
-      if (dir.isDirectory()) {
-         String[] children = dir.list();
-         for (int i = 0; i < children.length; i++) {
-            boolean success = deleteDir(new File(dir, children[i]));
-            if (!success) {
-               return false;
-            }
-         }
-      }
-
-      return dir.delete();
-   }
-
-   private int getFileCount(File dir) {
-      if (dir.isDirectory()) {
-         String[] children = dir.list();
-         return children.length;
-      }
-
-      return 0;
-   }
-
-   @Test
-   public void testCleanupOfFiles() throws Exception {
-      final int messageCount = 500;
-      startBroker(true);
-      int fileCount = getFileCount(kahaDbDir);
-      assertEquals(4, fileCount);
-
-      Connection connection = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getConnectUri()).createConnection();
-      connection.start();
-      Session producerSess = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Session consumerSess = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      ProducerThread producer = new ProducerThread(producerSess, destination) {
-         @Override
-         protected Message createMessage(int i) throws Exception {
-            return sess.createTextMessage(payload + "::" + i);
-         }
-      };
-      producer.setMessageCount(messageCount);
-      ConsumerThread consumer = new ConsumerThread(consumerSess, destination);
-      consumer.setBreakOnNull(false);
-      consumer.setMessageCount(messageCount);
-
-      producer.start();
-      producer.join();
-
-      consumer.start();
-      consumer.join();
-
-      assertEquals("consumer got all produced messages", producer.getMessageCount(), consumer.getReceived());
-
-      // verify cleanup
-      assertTrue("gc worked", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            int fileCount = getFileCount(kahaDbDir);
-            LOG.info("current filecount:" + fileCount);
-            return 4 == fileCount;
-         }
-      }));
-
-      broker.stop();
-      broker.waitUntilStopped();
-
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4356Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4356Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4356Test.java
deleted file mode 100644
index 3d4ec84..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4356Test.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import javax.jms.Connection;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AMQ4356Test {
-
-   private static BrokerService brokerService;
-   private static String BROKER_ADDRESS = "tcp://localhost:0";
-
-   private String connectionUri;
-   private ActiveMQConnectionFactory cf;
-   private final String CLIENT_ID = "AMQ4356Test";
-   private final String SUBSCRIPTION_NAME = "AMQ4356Test";
-
-   private void createBroker(boolean deleteOnStart) throws Exception {
-      brokerService = new BrokerService();
-      brokerService.setUseJmx(true);
-      brokerService.setDeleteAllMessagesOnStartup(deleteOnStart);
-      connectionUri = brokerService.addConnector(BROKER_ADDRESS).getPublishableConnectString();
-      brokerService.start();
-      brokerService.waitUntilStarted();
-
-   }
-
-   private void startBroker() throws Exception {
-      createBroker(true);
-   }
-
-   private void restartBroker() throws Exception {
-      brokerService.stop();
-      brokerService.waitUntilStopped();
-      createBroker(false);
-   }
-
-   @Before
-   public void setUp() throws Exception {
-      startBroker();
-      cf = new ActiveMQConnectionFactory(connectionUri);
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      brokerService.stop();
-      brokerService.waitUntilStopped();
-   }
-
-   @Test
-   public void testVirtualTopicUnsubDurable() throws Exception {
-      Connection connection = cf.createConnection();
-      connection.setClientID(CLIENT_ID);
-      connection.start();
-
-      // create consumer 'cluster'
-      ActiveMQQueue queue1 = new ActiveMQQueue(getVirtualTopicConsumerName());
-      ActiveMQQueue queue2 = new ActiveMQQueue(getVirtualTopicConsumerName());
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer c1 = session.createConsumer(queue1);
-      c1.setMessageListener(new MessageListener() {
-         @Override
-         public void onMessage(Message message) {
-         }
-      });
-      MessageConsumer c2 = session.createConsumer(queue2);
-      c2.setMessageListener(new MessageListener() {
-         @Override
-         public void onMessage(Message message) {
-         }
-      });
-
-      ActiveMQTopic topic = new ActiveMQTopic(getVirtualTopicName());
-      MessageConsumer c3 = session.createDurableSubscriber(topic, SUBSCRIPTION_NAME);
-
-      assertEquals(1, brokerService.getAdminView().getDurableTopicSubscribers().length);
-      assertEquals(0, brokerService.getAdminView().getInactiveDurableTopicSubscribers().length);
-
-      c3.close();
-
-      // create topic producer
-      MessageProducer producer = session.createProducer(topic);
-      assertNotNull(producer);
-
-      int total = 10;
-      for (int i = 0; i < total; i++) {
-         producer.send(session.createTextMessage("message: " + i));
-      }
-
-      assertEquals(0, brokerService.getAdminView().getDurableTopicSubscribers().length);
-      assertEquals(1, brokerService.getAdminView().getInactiveDurableTopicSubscribers().length);
-
-      session.unsubscribe(SUBSCRIPTION_NAME);
-      connection.close();
-
-      assertEquals(0, brokerService.getAdminView().getDurableTopicSubscribers().length);
-      assertEquals(0, brokerService.getAdminView().getInactiveDurableTopicSubscribers().length);
-
-      restartBroker();
-
-      assertEquals(0, brokerService.getAdminView().getDurableTopicSubscribers().length);
-      assertEquals(0, brokerService.getAdminView().getInactiveDurableTopicSubscribers().length);
-   }
-
-   protected String getVirtualTopicName() {
-      return "VirtualTopic.TEST";
-   }
-
-   protected String getVirtualTopicConsumerName() {
-      return "Consumer.A.VirtualTopic.TEST";
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4361Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4361Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4361Test.java
deleted file mode 100644
index 27c4f64..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4361Test.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import java.util.Random;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.AtomicReference;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.broker.region.policy.VMPendingQueueMessageStoragePolicy;
-import org.apache.activemq.broker.region.policy.VMPendingSubscriberMessageStoragePolicy;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ4361Test {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ4361Test.class);
-
-   private BrokerService service;
-   private String brokerUrlString;
-
-   @Before
-   public void setUp() throws Exception {
-      service = new BrokerService();
-      service.setDeleteAllMessagesOnStartup(true);
-      service.setUseJmx(false);
-
-      PolicyMap policyMap = new PolicyMap();
-      PolicyEntry policy = new PolicyEntry();
-      policy.setMemoryLimit(1);
-      policy.setPendingSubscriberPolicy(new VMPendingSubscriberMessageStoragePolicy());
-      policy.setPendingQueuePolicy(new VMPendingQueueMessageStoragePolicy());
-      policy.setProducerFlowControl(true);
-      policyMap.setDefaultEntry(policy);
-      service.setDestinationPolicy(policyMap);
-
-      service.setAdvisorySupport(false);
-      brokerUrlString = service.addConnector("tcp://localhost:0").getPublishableConnectString();
-      service.start();
-      service.waitUntilStarted();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      if (service != null) {
-         service.stop();
-         service.waitUntilStopped();
-      }
-   }
-
-   @Test
-   public void testCloseWhenHunk() throws Exception {
-
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerUrlString);
-      connectionFactory.setProducerWindowSize(1024);
-
-      // TINY QUEUE is flow controlled after 1024 bytes
-      final ActiveMQDestination destination = ActiveMQDestination.createDestination("queue://TINY_QUEUE", (byte) 0xff);
-
-      Connection connection = connectionFactory.createConnection();
-      connection.start();
-      final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      final MessageProducer producer = session.createProducer(destination);
-      producer.setTimeToLive(0);
-      producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
-      final AtomicReference<Exception> publishException = new AtomicReference<>(null);
-      final AtomicReference<Exception> closeException = new AtomicReference<>(null);
-      final AtomicLong lastLoop = new AtomicLong(System.currentTimeMillis() + 100);
-
-      Thread pubThread = new Thread(new Runnable() {
-         @Override
-         public void run() {
-            try {
-               byte[] data = new byte[1000];
-               new Random(0xdeadbeef).nextBytes(data);
-               for (int i = 0; i < 10000; i++) {
-                  lastLoop.set(System.currentTimeMillis());
-                  ObjectMessage objMsg = session.createObjectMessage();
-                  objMsg.setObject(data);
-                  producer.send(destination, objMsg);
-               }
-            }
-            catch (Exception e) {
-               publishException.set(e);
-            }
-         }
-      }, "PublishingThread");
-      pubThread.start();
-
-      // wait for publisher to deadlock
-      while (System.currentTimeMillis() - lastLoop.get() < 2000) {
-         Thread.sleep(100);
-      }
-      LOG.info("Publisher deadlock detected.");
-
-      Thread closeThread = new Thread(new Runnable() {
-         @Override
-         public void run() {
-            try {
-               LOG.info("Attempting close..");
-               producer.close();
-            }
-            catch (Exception e) {
-               closeException.set(e);
-            }
-         }
-      }, "ClosingThread");
-      closeThread.start();
-
-      try {
-         closeThread.join(30000);
-      }
-      catch (InterruptedException ie) {
-         assertFalse("Closing thread didn't complete in 10 seconds", true);
-      }
-
-      try {
-         pubThread.join(30000);
-      }
-      catch (InterruptedException ie) {
-         assertFalse("Publishing thread didn't complete in 10 seconds", true);
-      }
-
-      assertNull(closeException.get());
-      assertNotNull(publishException.get());
-   }
-}
-

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4368Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4368Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4368Test.java
deleted file mode 100644
index ef53a0a..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4368Test.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicLong;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ4368Test {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ4368Test.class);
-
-   private BrokerService broker;
-   private ActiveMQConnectionFactory connectionFactory;
-   private final Destination destination = new ActiveMQQueue("large_message_queue");
-   private String connectionUri;
-
-   @Before
-   public void setUp() throws Exception {
-      broker = createBroker();
-      connectionUri = broker.addConnector("tcp://localhost:0").getPublishableConnectString();
-      broker.start();
-      connectionFactory = new ActiveMQConnectionFactory(connectionUri);
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      broker.stop();
-      broker.waitUntilStopped();
-   }
-
-   protected BrokerService createBroker() throws Exception {
-      BrokerService broker = new BrokerService();
-
-      PolicyEntry policy = new PolicyEntry();
-      policy.setUseCache(false);
-      broker.setDestinationPolicy(new PolicyMap());
-      broker.getDestinationPolicy().setDefaultEntry(policy);
-
-      KahaDBPersistenceAdapter kahadb = new KahaDBPersistenceAdapter();
-      kahadb.setCheckForCorruptJournalFiles(true);
-      kahadb.setCleanupInterval(1000);
-
-      kahadb.deleteAllMessages();
-      broker.setPersistenceAdapter(kahadb);
-      broker.getSystemUsage().getMemoryUsage().setLimit(1024 * 1024 * 100);
-      broker.setUseJmx(false);
-
-      return broker;
-   }
-
-   abstract class Client implements Runnable {
-
-      private final String name;
-      final AtomicBoolean done = new AtomicBoolean();
-      CountDownLatch startedLatch;
-      CountDownLatch doneLatch = new CountDownLatch(1);
-      Connection connection;
-      Session session;
-      final AtomicLong size = new AtomicLong();
-
-      Client(String name, CountDownLatch startedLatch) {
-         this.name = name;
-         this.startedLatch = startedLatch;
-      }
-
-      public void start() {
-         LOG.info("Starting: " + name);
-         new Thread(this, name).start();
-      }
-
-      public void stopAsync() {
-         done.set(true);
-      }
-
-      public void stop() throws InterruptedException {
-         stopAsync();
-         if (!doneLatch.await(20, TimeUnit.MILLISECONDS)) {
-            try {
-               connection.close();
-               doneLatch.await();
-            }
-            catch (Exception e) {
-            }
-         }
-      }
-
-      @Override
-      public void run() {
-         try {
-            connection = createConnection();
-            connection.start();
-            try {
-               session = createSession();
-               work();
-            }
-            finally {
-               try {
-                  connection.close();
-               }
-               catch (JMSException ignore) {
-               }
-               LOG.info("Stopped: " + name);
-            }
-         }
-         catch (Exception e) {
-            e.printStackTrace();
-            done.set(true);
-         }
-         finally {
-            doneLatch.countDown();
-         }
-      }
-
-      protected Session createSession() throws JMSException {
-         return connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      }
-
-      protected Connection createConnection() throws JMSException {
-         return connectionFactory.createConnection();
-      }
-
-      abstract protected void work() throws Exception;
-   }
-
-   class ProducingClient extends Client {
-
-      ProducingClient(String name, CountDownLatch startedLatch) {
-         super(name, startedLatch);
-      }
-
-      private String createMessage() {
-         StringBuffer stringBuffer = new StringBuffer();
-         for (long i = 0; i < 1000000; i++) {
-            stringBuffer.append("1234567890");
-         }
-         return stringBuffer.toString();
-      }
-
-      @Override
-      protected void work() throws Exception {
-         String data = createMessage();
-         MessageProducer producer = session.createProducer(destination);
-         startedLatch.countDown();
-         while (!done.get()) {
-            producer.send(session.createTextMessage(data));
-            long i = size.incrementAndGet();
-            if ((i % 1000) == 0) {
-               LOG.info("produced " + i + ".");
-            }
-         }
-      }
-   }
-
-   class ConsumingClient extends Client {
-
-      public ConsumingClient(String name, CountDownLatch startedLatch) {
-         super(name, startedLatch);
-      }
-
-      @Override
-      protected void work() throws Exception {
-         MessageConsumer consumer = session.createConsumer(destination);
-         startedLatch.countDown();
-         while (!done.get()) {
-            Message msg = consumer.receive(100);
-            if (msg != null) {
-               size.incrementAndGet();
-            }
-         }
-      }
-   }
-
-   @Test
-   public void testENTMQ220() throws Exception {
-      LOG.info("Start test.");
-      CountDownLatch producer1Started = new CountDownLatch(1);
-      CountDownLatch producer2Started = new CountDownLatch(1);
-      CountDownLatch listener1Started = new CountDownLatch(1);
-
-      final ProducingClient producer1 = new ProducingClient("1", producer1Started);
-      final ProducingClient producer2 = new ProducingClient("2", producer2Started);
-      final ConsumingClient listener1 = new ConsumingClient("subscriber-1", listener1Started);
-      final AtomicLong lastSize = new AtomicLong();
-
-      try {
-
-         producer1.start();
-         producer2.start();
-         listener1.start();
-
-         producer1Started.await(15, TimeUnit.SECONDS);
-         producer2Started.await(15, TimeUnit.SECONDS);
-         listener1Started.await(15, TimeUnit.SECONDS);
-
-         lastSize.set(listener1.size.get());
-         for (int i = 0; i < 10; i++) {
-            Wait.waitFor(new Wait.Condition() {
-
-               @Override
-               public boolean isSatisified() throws Exception {
-                  return listener1.size.get() > lastSize.get();
-               }
-            });
-            long size = listener1.size.get();
-            LOG.info("Listener 1: consumed: " + (size - lastSize.get()));
-            assertTrue("No messages received on iteration: " + i, size > lastSize.get());
-            lastSize.set(size);
-         }
-      }
-      finally {
-         LOG.info("Stopping clients");
-         producer1.stop();
-         producer2.stop();
-         listener1.stop();
-      }
-   }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4407Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4407Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4407Test.java
deleted file mode 100644
index 38a9398..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4407Test.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.ArrayList;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.Destination;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.store.PersistenceAdapter;
-import org.apache.activemq.store.kahadb.FilteredKahaDBPersistenceAdapter;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.store.kahadb.MultiKahaDBPersistenceAdapter;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ4407Test {
-
-   static final Logger LOG = LoggerFactory.getLogger(AMQ4407Test.class);
-   private final static int maxFileLength = 1024 * 1024 * 32;
-
-   private final static String PREFIX_DESTINATION_NAME = "queue";
-
-   private final static String DESTINATION_NAME = PREFIX_DESTINATION_NAME + ".test";
-   private final static String DESTINATION_NAME_2 = PREFIX_DESTINATION_NAME + "2.test";
-   private final static String DESTINATION_NAME_3 = PREFIX_DESTINATION_NAME + "3.test";
-
-   BrokerService broker;
-
-   @Before
-   public void setUp() throws Exception {
-      prepareBrokerWithMultiStore(true);
-      broker.start();
-      broker.waitUntilStarted();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      broker.stop();
-   }
-
-   protected BrokerService createBroker(PersistenceAdapter kaha) throws Exception {
-      BrokerService broker = new BrokerService();
-      broker.setUseJmx(true);
-      broker.setBrokerName("localhost");
-      broker.setPersistenceAdapter(kaha);
-      return broker;
-   }
-
-   @Test
-   public void testRestartAfterQueueDelete() throws Exception {
-
-      // Ensure we have an Admin View.
-      assertTrue("Broker doesn't have an Admin View.", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return (broker.getAdminView()) != null;
-         }
-      }));
-
-      LOG.info("Adding destinations: {}, {}, {}", new Object[]{DESTINATION_NAME, DESTINATION_NAME_3, DESTINATION_NAME_3});
-      sendMessage(DESTINATION_NAME, "test 1");
-      sendMessage(DESTINATION_NAME_2, "test 1");
-      sendMessage(DESTINATION_NAME_3, "test 1");
-
-      assertNotNull(broker.getDestination(new ActiveMQQueue(DESTINATION_NAME)));
-      assertNotNull(broker.getDestination(new ActiveMQQueue(DESTINATION_NAME_2)));
-      assertNotNull(broker.getDestination(new ActiveMQQueue(DESTINATION_NAME_3)));
-
-      LOG.info("Removing destination: {}", DESTINATION_NAME_2);
-      broker.getAdminView().removeQueue(DESTINATION_NAME_2);
-
-      LOG.info("Recreating destination: {}", DESTINATION_NAME_2);
-      sendMessage(DESTINATION_NAME_2, "test 1");
-
-      Destination destination2 = broker.getDestination(new ActiveMQQueue(DESTINATION_NAME_2));
-      assertNotNull(destination2);
-      assertEquals(1, destination2.getMessageStore().getMessageCount());
-   }
-
-   protected KahaDBPersistenceAdapter createStore(boolean delete) throws IOException {
-      KahaDBPersistenceAdapter kaha = new KahaDBPersistenceAdapter();
-      kaha.setJournalMaxFileLength(maxFileLength);
-      kaha.setCleanupInterval(5000);
-      if (delete) {
-         kaha.deleteAllMessages();
-      }
-      return kaha;
-   }
-
-   public void prepareBrokerWithMultiStore(boolean deleteAllMessages) throws Exception {
-
-      MultiKahaDBPersistenceAdapter multiKahaDBPersistenceAdapter = new MultiKahaDBPersistenceAdapter();
-      if (deleteAllMessages) {
-         multiKahaDBPersistenceAdapter.deleteAllMessages();
-      }
-      ArrayList<FilteredKahaDBPersistenceAdapter> adapters = new ArrayList<>();
-
-      adapters.add(createFilteredKahaDBByDestinationPrefix(PREFIX_DESTINATION_NAME, deleteAllMessages));
-      adapters.add(createFilteredKahaDBByDestinationPrefix(PREFIX_DESTINATION_NAME + "2", deleteAllMessages));
-      adapters.add(createFilteredKahaDBByDestinationPrefix(null, deleteAllMessages));
-
-      multiKahaDBPersistenceAdapter.setFilteredPersistenceAdapters(adapters);
-      broker = createBroker(multiKahaDBPersistenceAdapter);
-   }
-
-   /**
-    * Create filtered KahaDB adapter by destination prefix.
-    *
-    * @param destinationPrefix
-    * @param deleteAllMessages
-    * @return
-    * @throws IOException
-    */
-   private FilteredKahaDBPersistenceAdapter createFilteredKahaDBByDestinationPrefix(String destinationPrefix,
-                                                                                    boolean deleteAllMessages) throws IOException {
-      FilteredKahaDBPersistenceAdapter template = new FilteredKahaDBPersistenceAdapter();
-      template.setPersistenceAdapter(createStore(deleteAllMessages));
-      if (destinationPrefix != null) {
-         template.setQueue(destinationPrefix + ".>");
-      }
-      return template;
-   }
-
-   /**
-    * Send message to particular destination.
-    *
-    * @param destinationName
-    * @param message
-    * @throws JMSException
-    */
-   private void sendMessage(String destinationName, String message) throws JMSException {
-      ActiveMQConnectionFactory f = new ActiveMQConnectionFactory("vm://localhost");
-      f.setAlwaysSyncSend(true);
-      Connection c = f.createConnection();
-      c.start();
-      Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = s.createProducer(new ActiveMQQueue(destinationName));
-      producer.send(s.createTextMessage(message));
-      producer.close();
-      s.close();
-      c.stop();
-   }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4413Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4413Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4413Test.java
deleted file mode 100644
index cd3ed95..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4413Test.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.UUID;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.jms.TopicSubscriber;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- */
-public class AMQ4413Test {
-
-   static final Logger LOG = LoggerFactory.getLogger(AMQ4413Test.class);
-
-   final String brokerUrl = "tcp://localhost:0";
-   private String connectionUri;
-   final int numMsgsTriggeringReconnection = 2;
-   final int numMsgs = 30;
-   final int numTests = 75;
-   final ExecutorService threadPool = Executors.newCachedThreadPool();
-
-   @Test
-   public void testDurableSubMessageLoss() throws Exception {
-      // start embedded broker
-      BrokerService brokerService = new BrokerService();
-      connectionUri = brokerService.addConnector(brokerUrl).getPublishableConnectString();
-      brokerService.setPersistent(false);
-      brokerService.setUseJmx(false);
-      brokerService.setKeepDurableSubsActive(true);
-      brokerService.setAdvisorySupport(false);
-      brokerService.start();
-      LOG.info("##### broker started");
-
-      // repeat test 50 times
-      try {
-         for (int i = 0; i < numTests; ++i) {
-            LOG.info("##### test " + i + " started");
-            test();
-         }
-
-         LOG.info("##### tests are done");
-      }
-      catch (Exception e) {
-         e.printStackTrace();
-         LOG.info("##### tests failed!");
-      }
-      finally {
-         threadPool.shutdown();
-         brokerService.stop();
-         LOG.info("##### broker stopped");
-      }
-   }
-
-   private void test() throws Exception {
-
-      final String topicName = "topic-" + UUID.randomUUID();
-      final String clientId = "client-" + UUID.randomUUID();
-      final String subName = "sub-" + UUID.randomUUID();
-
-      // create (and only create) subscription first
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri);
-      factory.setWatchTopicAdvisories(false);
-      Connection connection = factory.createConnection();
-      connection.setClientID(clientId);
-      connection.start();
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Topic topic = session.createTopic(topicName);
-      TopicSubscriber durableSubscriptionCreator = session.createDurableSubscriber(topic, subName);
-
-      connection.stop();
-      durableSubscriptionCreator.close();
-      session.close();
-      connection.close();
-
-      // publisher task
-      Callable<Boolean> publisher = new Callable<Boolean>() {
-         @Override
-         public Boolean call() throws Exception {
-            Connection connection = null;
-
-            try {
-               ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri);
-               factory.setWatchTopicAdvisories(false);
-               connection = factory.createConnection();
-               Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-               Topic topic = session.createTopic(topicName);
-
-               MessageProducer producer = session.createProducer(topic);
-               producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-               producer.setPriority(Message.DEFAULT_PRIORITY);
-               producer.setTimeToLive(Message.DEFAULT_TIME_TO_LIVE);
-
-               for (int seq = 1; seq <= numMsgs; ++seq) {
-                  TextMessage msg = session.createTextMessage(String.valueOf(seq));
-                  producer.send(msg);
-                  LOG.info("pub sent msg: " + seq);
-                  Thread.sleep(1L);
-               }
-
-               LOG.info("pub is done");
-            }
-            finally {
-               if (connection != null) {
-                  try {
-                     connection.close();
-                  }
-                  catch (JMSException e) {
-                     e.printStackTrace();
-                  }
-               }
-            }
-            return Boolean.TRUE;
-         }
-      };
-
-      // subscriber task
-      Callable<Boolean> durableSubscriber = new Callable<Boolean>() {
-         ActiveMQConnectionFactory factory;
-         Connection connection;
-         Session session;
-         Topic topic;
-         TopicSubscriber consumer;
-
-         @Override
-         public Boolean call() throws Exception {
-            factory = new ActiveMQConnectionFactory(connectionUri);
-            factory.setWatchTopicAdvisories(false);
-
-            try {
-               connect();
-
-               for (int seqExpected = 1; seqExpected <= numMsgs; ++seqExpected) {
-                  TextMessage msg = (TextMessage) consumer.receive(3000L);
-                  if (msg == null) {
-                     LOG.info("expected: " + seqExpected + ", actual: timed out", msg);
-                     return Boolean.FALSE;
-                  }
-
-                  int seq = Integer.parseInt(msg.getText());
-
-                  LOG.info("sub received msg: " + seq);
-
-                  if (seqExpected != seq) {
-                     LOG.info("expected: " + seqExpected + ", actual: " + seq);
-                     return Boolean.FALSE;
-                  }
-
-                  if (seq % numMsgsTriggeringReconnection == 0) {
-                     close(false);
-                     connect();
-
-                     LOG.info("sub reconnected");
-                  }
-               }
-
-               LOG.info("sub is done");
-            }
-            finally {
-               try {
-                  close(true);
-               }
-               catch (Exception e) {
-                  e.printStackTrace();
-               }
-            }
-
-            return Boolean.TRUE;
-         }
-
-         void connect() throws Exception {
-            connection = factory.createConnection();
-            connection.setClientID(clientId);
-            connection.start();
-
-            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-            topic = session.createTopic(topicName);
-            consumer = session.createDurableSubscriber(topic, subName);
-         }
-
-         void close(boolean unsubscribe) throws Exception {
-            if (connection != null) {
-               connection.stop();
-            }
-
-            if (consumer != null) {
-               consumer.close();
-            }
-
-            if (session != null) {
-               if (unsubscribe) {
-                  session.unsubscribe(subName);
-               }
-               session.close();
-            }
-
-            if (connection != null) {
-               connection.close();
-            }
-         }
-      };
-
-      ArrayList<Future<Boolean>> results = new ArrayList<>();
-      results.add(threadPool.submit(publisher));
-      results.add(threadPool.submit(durableSubscriber));
-
-      for (Future<Boolean> result : results) {
-         assertTrue(result.get());
-      }
-   }
-}


[48/60] [abbrv] activemq-artemis git commit: more openwire test fixing added a queuePrefetch config param to AddressSettings

Posted by cl...@apache.org.
more openwire test fixing
added a queuePrefetch config param to AddressSettings


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/30cd9f26
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/30cd9f26
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/30cd9f26

Branch: refs/heads/refactor-openwire
Commit: 30cd9f2632cf07b89f1d8a5f002759db5f4c4954
Parents: d1909c3
Author: Howard Gao <ho...@gmail.com>
Authored: Wed Mar 2 20:55:37 2016 +0800
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:45:29 2016 -0400

----------------------------------------------------------------------
 .../protocol/openwire/OpenWireConnection.java   |  2 +-
 .../openwire/OpenWireProtocolManager.java       |  2 +-
 .../core/protocol/openwire/amq/AMQConsumer.java | 13 +++++++++
 .../core/protocol/openwire/amq/AMQSession.java  |  4 +++
 .../core/settings/impl/AddressSettings.java     | 26 +++++++++++++++++
 .../artemiswrapper/ArtemisBrokerWrapper.java    |  2 ++
 .../transport/tcp/TcpTransportFactory.java      |  9 +++++-
 .../activemq/ActiveMQConnectionFactoryTest.java |  5 +++-
 .../activemq/QueueConsumerPriorityTest.java     |  1 +
 .../activemq/ZeroPrefetchConsumerTest.java      | 30 +++++++++++---------
 10 files changed, 76 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/30cd9f26/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
index 1e1e953..03871ab 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
@@ -388,7 +388,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
       dispatchAsync(ce);
    }
 
-   protected void dispatch(Command command) throws IOException {
+   public void dispatch(Command command) throws IOException {
       this.physicalSend(command);
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/30cd9f26/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
index 7445960..122788e 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
@@ -524,7 +524,7 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, Cl
 
    public void sendBrokerInfo(OpenWireConnection connection) throws Exception {
       BrokerInfo brokerInfo = new BrokerInfo();
-      brokerInfo.setBrokerName(server.getIdentity());
+      brokerInfo.setBrokerName(getBrokerName());
       brokerInfo.setBrokerId(new BrokerId("" + server.getNodeID()));
       brokerInfo.setPeerBrokerInfos(null);
       brokerInfo.setFaultTolerantConfiguration(false);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/30cd9f26/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java
index 221679f..7c2a9bd 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQConsumer.java
@@ -34,7 +34,9 @@ import org.apache.activemq.artemis.core.protocol.openwire.OpenWireUtil;
 import org.apache.activemq.artemis.core.server.QueueQueryResult;
 import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.SlowConsumerDetectionListener;
+import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
+import org.apache.activemq.command.ConsumerControl;
 import org.apache.activemq.command.ConsumerId;
 import org.apache.activemq.command.ConsumerInfo;
 import org.apache.activemq.command.MessageAck;
@@ -136,6 +138,17 @@ public class AMQConsumer implements BrowserListener {
       else {
          SimpleString queueName = new SimpleString("jms.queue." + this.actualDest.getPhysicalName());
          coreSession.createConsumer(nativeId, queueName, selector, info.isBrowser(), false, -1);
+         AddressSettings addrSettings = session.getCoreServer().getAddressSettingsRepository().getMatch(queueName.toString());
+         if (addrSettings != null) {
+            //see PolicyEntry
+            if (prefetchSize != 0 && addrSettings.getQueuePrefetch() == 0) {
+               //sends back a ConsumerControl
+               ConsumerControl cc = new ConsumerControl();
+               cc.setConsumerId(info.getConsumerId());
+               cc.setPrefetch(0);
+               session.getConnection().dispatch(cc);
+            }
+         }
       }
 
       if (info.isBrowser()) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/30cd9f26/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
index b68861e..e3d2266 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
@@ -542,4 +542,8 @@ public class AMQSession implements SessionCallback {
          }
       }
    }
+
+   public OpenWireConnection getConnection() {
+      return connection;
+   }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/30cd9f26/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/AddressSettings.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/AddressSettings.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/AddressSettings.java
index 3309fab..4b53ec6 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/AddressSettings.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/AddressSettings.java
@@ -70,6 +70,8 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
 
    public static final SlowConsumerPolicy DEFAULT_SLOW_CONSUMER_POLICY = SlowConsumerPolicy.NOTIFY;
 
+   public static final int DEFAULT_QUEUE_PREFETCH = 1000;
+
    private AddressFullMessagePolicy addressFullMessagePolicy = null;
 
    private Long maxSizeBytes = null;
@@ -114,6 +116,10 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
 
    private Integer managementBrowsePageSize = AddressSettings.MANAGEMENT_BROWSE_PAGE_SIZE;
 
+   //from amq5
+   //make it transient
+   private transient Integer queuePrefetch = null;
+
    public AddressSettings(AddressSettings other) {
       this.addressFullMessagePolicy = other.addressFullMessagePolicy;
       this.maxSizeBytes = other.maxSizeBytes;
@@ -137,6 +143,7 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
       this.autoCreateJmsQueues = other.autoCreateJmsQueues;
       this.autoDeleteJmsQueues = other.autoDeleteJmsQueues;
       this.managementBrowsePageSize = other.managementBrowsePageSize;
+      this.queuePrefetch = other.queuePrefetch;
    }
 
    public AddressSettings() {
@@ -333,6 +340,15 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
       return this;
    }
 
+   public int getQueuePrefetch() {
+      return queuePrefetch != null ? queuePrefetch : AddressSettings.DEFAULT_QUEUE_PREFETCH;
+   }
+
+   public AddressSettings setQueuePrefetch(int queuePrefetch) {
+      this.queuePrefetch = queuePrefetch;
+      return this;
+   }
+
    /**
     * merge 2 objects in to 1
     *
@@ -403,6 +419,9 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
       if (managementBrowsePageSize == null) {
          managementBrowsePageSize = merged.managementBrowsePageSize;
       }
+      if (queuePrefetch == null) {
+         queuePrefetch = merged.queuePrefetch;
+      }
    }
 
    @Override
@@ -569,6 +588,7 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
       result = prime * result + ((autoCreateJmsQueues == null) ? 0 : autoCreateJmsQueues.hashCode());
       result = prime * result + ((autoDeleteJmsQueues == null) ? 0 : autoDeleteJmsQueues.hashCode());
       result = prime * result + ((managementBrowsePageSize == null) ? 0 : managementBrowsePageSize.hashCode());
+      result = prime * result + ((queuePrefetch == null) ? 0 : queuePrefetch.hashCode());
       return result;
    }
 
@@ -718,6 +738,12 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
       }
       else if (!managementBrowsePageSize.equals(other.managementBrowsePageSize))
          return false;
+      if (queuePrefetch == null) {
+         if (other.queuePrefetch != null)
+            return false;
+      }
+      else if (!queuePrefetch.equals(other.queuePrefetch))
+         return false;
       return true;
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/30cd9f26/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
index 112d425..94faf26 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
@@ -210,6 +210,8 @@ public class ArtemisBrokerWrapper extends ArtemisBrokerBase {
                settings.setAddressFullMessagePolicy(AddressFullMessagePolicy.FAIL);
             }
          }
+         int queuePrefetch = entry.getQueuePrefetch();
+         settings.setQueuePrefetch(queuePrefetch);
       }
 
       PolicyEntry defaultEntry = policyMap.getDefaultEntry();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/30cd9f26/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
index c44dd72..c0ed126 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
@@ -52,10 +52,17 @@ public class TcpTransportFactory extends TransportFactory {
       //here check broker, if no broker, we start one
       Map<String, String> params = URISupport.parseParameters(location);
       String brokerId = params.remove("invmBrokerId");
+      boolean autoCreate = true;
+      String create = params.remove("create");
+      if (create != null)
+      {
+         autoCreate = "true".equals(create);
+      }
+
       URI location1 = URISupport.createRemainingURI(location, Collections.EMPTY_MAP);
 
       LOG.info("deciding whether starting an internal broker: " + brokerService + " flag: " + BrokerService.disableWrapper);
-      if (brokerService == null && !BrokerService.disableWrapper && BrokerService.checkPort(location1.getPort())) {
+      if (autoCreate && brokerService == null && !BrokerService.disableWrapper && BrokerService.checkPort(location1.getPort())) {
 
          LOG.info("starting internal broker: " + location1);
          ArtemisBrokerHelper.startArtemisBroker(location1);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/30cd9f26/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java
index e1ea7e6..8769324 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQConnectionFactoryTest.java
@@ -110,6 +110,7 @@ public class ActiveMQConnectionFactoryTest extends CombinationTestSupport {
       connection.close();
    }
 
+   //we don't support in-vm connector (will we?)
    public void testCreateVMConnectionWithEmbdeddBroker() throws URISyntaxException, JMSException {
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://myBroker2?broker.persistent=false");
       // Make sure the broker is not created until the connection is
@@ -124,7 +125,9 @@ public class ActiveMQConnectionFactoryTest extends CombinationTestSupport {
       connection.close();
 
       // Verify the broker was destroyed.
-      assertNull(BrokerRegistry.getInstance().lookup("myBroker2"));
+      //I comment out this because this is pure client behavior in
+      //amq5. there shouldn't be any use-case like that with Artemis.
+      //assertNull(BrokerRegistry.getInstance().lookup("myBroker2"));
    }
 
    public void testGetBrokerName() throws URISyntaxException, JMSException {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/30cd9f26/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/QueueConsumerPriorityTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/QueueConsumerPriorityTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/QueueConsumerPriorityTest.java
index 296f52b..4ae2feb 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/QueueConsumerPriorityTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/QueueConsumerPriorityTest.java
@@ -30,6 +30,7 @@ import org.apache.activemq.artemiswrapper.ArtemisBrokerHelper;
 import org.apache.activemq.command.ActiveMQQueue;
 import org.apache.activemq.transport.tcp.TcpTransportFactory;
 
+//https://issues.apache.org/jira/browse/ARTEMIS-196
 public class QueueConsumerPriorityTest extends TestCase {
 
    private static final String VM_BROKER_URL = "vm://localhost?broker.persistent=false&broker.useJmx=true";

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/30cd9f26/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java
index 953032b..a9a564b 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java
@@ -26,10 +26,11 @@ import javax.jms.Queue;
 import javax.jms.Session;
 import javax.jms.TextMessage;
 
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
 import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.Subscription;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ActiveMQQueue;
 import org.apache.activemq.command.ConsumerControl;
@@ -349,8 +350,10 @@ public class ZeroPrefetchConsumerTest extends EmbeddedBrokerTestSupport {
       assertEquals("broker config prefetch in effect", 0, consumer.info.getCurrentPrefetchSize());
 
       // verify sub view broker
-      Subscription sub = broker.getRegionBroker().getDestinationMap().get(ActiveMQDestination.transform(brokerZeroQueue)).getConsumers().get(0);
-      assertEquals("broker sub prefetch is correct", 0, sub.getConsumerInfo().getCurrentPrefetchSize());
+      // I comment out this because it checks broker internal
+      // which doesn't apply to artemis broker.
+      //Subscription sub = broker.getRegionBroker().getDestinationMap().get(ActiveMQDestination.transform(brokerZeroQueue)).getConsumers().get(0);
+      //assertEquals("broker sub prefetch is correct", 0, sub.getConsumerInfo().getCurrentPrefetchSize());
 
       // manipulate Prefetch (like failover and stomp)
       ConsumerControl consumerControl = new ConsumerControl();
@@ -361,18 +364,17 @@ public class ZeroPrefetchConsumerTest extends EmbeddedBrokerTestSupport {
       Object reply = ((ActiveMQConnection) connection).getTransport().request(consumerControl);
       assertTrue("good request", !(reply instanceof ExceptionResponse));
       assertEquals("broker config prefetch in effect", 0, consumer.info.getCurrentPrefetchSize());
-      assertEquals("broker sub prefetch is correct", 0, sub.getConsumerInfo().getCurrentPrefetchSize());
    }
 
    @Override
-   protected BrokerService createBroker() throws Exception {
-      BrokerService brokerService = super.createBroker();
-      PolicyMap policyMap = new PolicyMap();
-      PolicyEntry zeroPrefetchPolicy = new PolicyEntry();
-      zeroPrefetchPolicy.setQueuePrefetch(0);
-      policyMap.put(ActiveMQDestination.transform(brokerZeroQueue), zeroPrefetchPolicy);
-      brokerService.setDestinationPolicy(policyMap);
-      return brokerService;
+   public EmbeddedJMS createArtemisBroker() throws Exception {
+      Configuration config0 = createConfig("localhost", 0);
+      String coreQueueAddress = "jms.queue." + brokerZeroQueue.getQueueName();
+      AddressSettings addrSettings = new AddressSettings();
+      addrSettings.setQueuePrefetch(0);
+      config0.getAddressesSettings().put(coreQueueAddress, addrSettings);
+      EmbeddedJMS newbroker = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
+      return newbroker;
    }
 
    @Override


[21/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3274Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3274Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3274Test.java
deleted file mode 100644
index 74c19b7..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3274Test.java
+++ /dev/null
@@ -1,763 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertTrue;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.network.DiscoveryNetworkConnector;
-import org.apache.activemq.network.NetworkConnector;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ3274Test {
-
-   private static final transient Logger LOG = LoggerFactory.getLogger(AMQ3274Test.class);
-
-   protected static int Next_broker_num = 0;
-   protected EmbeddedTcpBroker broker1;
-   protected EmbeddedTcpBroker broker2;
-
-   protected int nextEchoId = 0;
-   protected boolean testError = false;
-
-   protected int echoResponseFill = 0; // Number of "filler" response messages per request
-
-   public AMQ3274Test() throws Exception {
-      broker1 = new EmbeddedTcpBroker();
-      broker2 = new EmbeddedTcpBroker();
-
-      broker1.coreConnectTo(broker2, true);
-      broker2.coreConnectTo(broker1, true);
-   }
-
-   public void logMessage(String msg) {
-      System.out.println(msg);
-      System.out.flush();
-   }
-
-   public void testMessages(Session sess,
-                            MessageProducer req_prod,
-                            Destination resp_dest,
-                            int num_msg) throws Exception {
-      MessageConsumer resp_cons;
-      TextMessage msg;
-      MessageClient cons_client;
-      int cur;
-      int tot_expected;
-
-      resp_cons = sess.createConsumer(resp_dest);
-
-      cons_client = new MessageClient(resp_cons, num_msg);
-      cons_client.start();
-
-      cur = 0;
-      while ((cur < num_msg) && (!testError)) {
-         msg = sess.createTextMessage("MSG AAAA " + cur);
-         msg.setIntProperty("SEQ", 100 + cur);
-         msg.setStringProperty("TEST", "TOPO");
-         msg.setJMSReplyTo(resp_dest);
-
-         if (cur == (num_msg - 1))
-            msg.setBooleanProperty("end-of-response", true);
-
-         req_prod.send(msg);
-
-         cur++;
-      }
-
-      cons_client.waitShutdown(5000);
-
-      if (cons_client.shutdown()) {
-         LOG.debug("Consumer client shutdown complete");
-      }
-      else {
-         LOG.debug("Consumer client shutdown incomplete!!!");
-      }
-
-      tot_expected = num_msg * (echoResponseFill + 1);
-
-      if (cons_client.getNumMsgReceived() == tot_expected) {
-         LOG.info("Have " + tot_expected + " messages, as-expected");
-      }
-      else {
-         LOG.error("Have " + cons_client.getNumMsgReceived() + " messages; expected " + tot_expected);
-         testError = true;
-      }
-
-      resp_cons.close();
-   }
-
-   /**
-    * Test one destination between the given "producer broker" and
-    * "consumer broker" specified.
-    */
-   public void testOneDest(Connection conn,
-                           Session sess,
-                           Destination cons_dest,
-                           String prod_broker_url,
-                           String cons_broker_url,
-                           int num_msg) throws Exception {
-      int echo_id;
-
-      EchoService echo_svc;
-      String echo_queue_name;
-      Destination prod_dest;
-      MessageProducer msg_prod;
-
-      synchronized (this) {
-         echo_id = this.nextEchoId;
-         this.nextEchoId++;
-      }
-
-      echo_queue_name = "echo.queue." + echo_id;
-
-      LOG.trace("destroying the echo queue in case an old one exists");
-      removeQueue(conn, echo_queue_name);
-
-      echo_svc = new EchoService(echo_queue_name, prod_broker_url);
-      echo_svc.start();
-
-      LOG.trace("Creating echo queue and producer");
-      prod_dest = sess.createQueue(echo_queue_name);
-      msg_prod = sess.createProducer(prod_dest);
-
-      testMessages(sess, msg_prod, cons_dest, num_msg);
-
-      echo_svc.shutdown();
-      msg_prod.close();
-   }
-
-   /**
-    * TEST TEMPORARY TOPICS
-    */
-   public void testTempTopic(String prod_broker_url, String cons_broker_url) throws Exception {
-      Connection conn;
-      Session sess;
-      Destination cons_dest;
-      int num_msg;
-
-      num_msg = 5;
-
-      LOG.info("TESTING TEMP TOPICS " + prod_broker_url + " -> " + cons_broker_url + " (" + num_msg + " messages)");
-
-      conn = createConnection(cons_broker_url);
-      conn.start();
-      sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      LOG.trace("Creating destination");
-      cons_dest = sess.createTemporaryTopic();
-
-      testOneDest(conn, sess, cons_dest, prod_broker_url, cons_broker_url, num_msg);
-
-      sess.close();
-      conn.close();
-   }
-
-   /**
-    * TEST TOPICS
-    */
-   public void testTopic(String prod_broker_url, String cons_broker_url) throws Exception {
-      int num_msg;
-
-      Connection conn;
-      Session sess;
-      String topic_name;
-
-      Destination cons_dest;
-
-      num_msg = 5;
-
-      LOG.info("TESTING TOPICS " + prod_broker_url + " -> " + cons_broker_url + " (" + num_msg + " messages)");
-
-      conn = createConnection(cons_broker_url);
-      conn.start();
-      sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      topic_name = "topotest2.perm.topic";
-      LOG.trace("Removing existing Topic");
-      removeTopic(conn, topic_name);
-      LOG.trace("Creating Topic, " + topic_name);
-      cons_dest = sess.createTopic(topic_name);
-
-      testOneDest(conn, sess, cons_dest, prod_broker_url, cons_broker_url, num_msg);
-
-      removeTopic(conn, topic_name);
-      sess.close();
-      conn.close();
-   }
-
-   /**
-    * TEST TEMPORARY QUEUES
-    */
-   public void testTempQueue(String prod_broker_url, String cons_broker_url) throws Exception {
-      int num_msg;
-
-      Connection conn;
-      Session sess;
-
-      Destination cons_dest;
-
-      num_msg = 5;
-
-      LOG.info("TESTING TEMP QUEUES " + prod_broker_url + " -> " + cons_broker_url + " (" + num_msg + " messages)");
-
-      conn = createConnection(cons_broker_url);
-      conn.start();
-      sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      LOG.trace("Creating destination");
-      cons_dest = sess.createTemporaryQueue();
-
-      testOneDest(conn, sess, cons_dest, prod_broker_url, cons_broker_url, num_msg);
-
-      sess.close();
-      conn.close();
-   }
-
-   /**
-    * TEST QUEUES
-    */
-   public void testQueue(String prod_broker_url, String cons_broker_url) throws Exception {
-      int num_msg;
-
-      Connection conn;
-      Session sess;
-      String queue_name;
-
-      Destination cons_dest;
-
-      num_msg = 5;
-
-      LOG.info("TESTING QUEUES " + prod_broker_url + " -> " + cons_broker_url + " (" + num_msg + " messages)");
-
-      conn = createConnection(cons_broker_url);
-      conn.start();
-      sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      queue_name = "topotest2.perm.queue";
-      LOG.trace("Removing existing Queue");
-      removeQueue(conn, queue_name);
-      LOG.trace("Creating Queue, " + queue_name);
-      cons_dest = sess.createQueue(queue_name);
-
-      testOneDest(conn, sess, cons_dest, prod_broker_url, cons_broker_url, num_msg);
-
-      removeQueue(conn, queue_name);
-      sess.close();
-      conn.close();
-   }
-
-   @Test
-   public void run() throws Exception {
-      Thread start1;
-      Thread start2;
-
-      testError = false;
-
-      // Use threads to avoid startup deadlock since the first broker started waits until
-      // it knows the name of the remote broker before finishing its startup, which means
-      // the remote must already be running.
-
-      start1 = new Thread() {
-         @Override
-         public void run() {
-            try {
-               broker1.start();
-            }
-            catch (Exception ex) {
-               LOG.error(null, ex);
-            }
-         }
-      };
-
-      start2 = new Thread() {
-         @Override
-         public void run() {
-            try {
-               broker2.start();
-            }
-            catch (Exception ex) {
-               LOG.error(null, ex);
-            }
-         }
-      };
-
-      start1.start();
-      start2.start();
-
-      start1.join();
-      start2.join();
-
-      if (!testError) {
-         this.testTempTopic(broker1.getConnectionUrl(), broker2.getConnectionUrl());
-      }
-      if (!testError) {
-         this.testTempQueue(broker1.getConnectionUrl(), broker2.getConnectionUrl());
-      }
-      if (!testError) {
-         this.testTopic(broker1.getConnectionUrl(), broker2.getConnectionUrl());
-      }
-      if (!testError) {
-         this.testQueue(broker1.getConnectionUrl(), broker2.getConnectionUrl());
-      }
-      Thread.sleep(100);
-
-      shutdown();
-
-      assertTrue(!testError);
-   }
-
-   public void shutdown() throws Exception {
-      broker1.stop();
-      broker2.stop();
-   }
-
-   /**
-    * @param args the command line arguments
-    */
-   public static void main(String[] args) {
-      AMQ3274Test main_obj;
-
-      try {
-         main_obj = new AMQ3274Test();
-         main_obj.run();
-      }
-      catch (Exception ex) {
-         ex.printStackTrace();
-         LOG.error(null, ex);
-         System.exit(0);
-      }
-   }
-
-   protected Connection createConnection(String url) throws Exception {
-      return org.apache.activemq.ActiveMQConnection.makeConnection(url);
-   }
-
-   protected static void removeQueue(Connection conn, String dest_name) throws java.lang.Exception {
-      org.apache.activemq.command.ActiveMQDestination dest;
-
-      if (conn instanceof org.apache.activemq.ActiveMQConnection) {
-         dest = org.apache.activemq.command.ActiveMQDestination.createDestination(dest_name, org.apache.activemq.command.ActiveMQDestination.QUEUE_TYPE);
-         ((org.apache.activemq.ActiveMQConnection) conn).destroyDestination(dest);
-      }
-   }
-
-   protected static void removeTopic(Connection conn, String dest_name) throws java.lang.Exception {
-      org.apache.activemq.command.ActiveMQDestination dest;
-
-      if (conn instanceof org.apache.activemq.ActiveMQConnection) {
-         dest = org.apache.activemq.command.ActiveMQDestination.createDestination(dest_name, org.apache.activemq.command.ActiveMQDestination.TOPIC_TYPE);
-         ((org.apache.activemq.ActiveMQConnection) conn).destroyDestination(dest);
-      }
-   }
-
-   @SuppressWarnings("rawtypes")
-   public static String fmtMsgInfo(Message msg) throws Exception {
-      StringBuilder msg_desc;
-      String prop;
-      Enumeration prop_enum;
-
-      msg_desc = new StringBuilder();
-      msg_desc = new StringBuilder();
-
-      if (msg instanceof TextMessage) {
-         msg_desc.append(((TextMessage) msg).getText());
-      }
-      else {
-         msg_desc.append("[");
-         msg_desc.append(msg.getClass().getName());
-         msg_desc.append("]");
-      }
-
-      prop_enum = msg.getPropertyNames();
-      while (prop_enum.hasMoreElements()) {
-         prop = (String) prop_enum.nextElement();
-         msg_desc.append("; ");
-         msg_desc.append(prop);
-         msg_desc.append("=");
-         msg_desc.append(msg.getStringProperty(prop));
-      }
-
-      return msg_desc.toString();
-   }
-
-   // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-   // /////////////////////////////////////////////// INTERNAL CLASSES
-   // /////////////////////////////////////////////////
-   // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-   protected class EmbeddedTcpBroker {
-
-      protected BrokerService brokerSvc;
-      protected int brokerNum;
-      protected String brokerName;
-      protected String brokerId;
-      protected int port;
-      protected String tcpUrl;
-
-      public EmbeddedTcpBroker() throws Exception {
-         brokerSvc = new BrokerService();
-
-         synchronized (this.getClass()) {
-            brokerNum = Next_broker_num;
-            Next_broker_num++;
-         }
-
-         brokerName = "broker" + brokerNum;
-         brokerId = "b" + brokerNum;
-
-         brokerSvc.setBrokerName(brokerName);
-         brokerSvc.setBrokerId(brokerId);
-         brokerSvc.setPersistent(false);
-         brokerSvc.setUseJmx(false);
-         tcpUrl = brokerSvc.addConnector("tcp://localhost:0").getPublishableConnectString();
-      }
-
-      public Connection createConnection() throws URISyntaxException, JMSException {
-         Connection result;
-
-         result = org.apache.activemq.ActiveMQConnection.makeConnection(this.tcpUrl);
-
-         return result;
-      }
-
-      public String getConnectionUrl() {
-         return this.tcpUrl;
-      }
-
-      /**
-       * Create network connections to the given broker using the
-       * network-connector configuration of CORE brokers (e.g.
-       * core1.bus.dev1.coresys.tmcs)
-       *
-       * @param other
-       * @param duplex_f
-       */
-      public void coreConnectTo(EmbeddedTcpBroker other, boolean duplex_f) throws Exception {
-         this.makeConnectionTo(other, duplex_f, true);
-         this.makeConnectionTo(other, duplex_f, false);
-      }
-
-      public void start() throws Exception {
-         brokerSvc.start();
-      }
-
-      public void stop() throws Exception {
-         brokerSvc.stop();
-      }
-
-      /**
-       * Make one connection to the other embedded broker, of the specified
-       * type (queue or topic) using the standard CORE broker networking.
-       *
-       * @param other
-       * @param duplex_f
-       * @param queue_f
-       * @throws Exception
-       */
-      protected void makeConnectionTo(EmbeddedTcpBroker other, boolean duplex_f, boolean queue_f) throws Exception {
-         NetworkConnector nw_conn;
-         String prefix;
-         ActiveMQDestination excl_dest;
-         ArrayList<ActiveMQDestination> excludes;
-
-         nw_conn = new DiscoveryNetworkConnector(new URI("static:(" + other.tcpUrl + ")"));
-         nw_conn.setDuplex(duplex_f);
-
-         if (queue_f)
-            nw_conn.setConduitSubscriptions(false);
-         else
-            nw_conn.setConduitSubscriptions(true);
-
-         nw_conn.setNetworkTTL(5);
-         nw_conn.setSuppressDuplicateQueueSubscriptions(true);
-         nw_conn.setDecreaseNetworkConsumerPriority(true);
-         nw_conn.setBridgeTempDestinations(true);
-
-         if (queue_f) {
-            prefix = "queue";
-            excl_dest = ActiveMQDestination.createDestination(">", ActiveMQDestination.QUEUE_TYPE);
-         }
-         else {
-            prefix = "topic";
-            excl_dest = ActiveMQDestination.createDestination(">", ActiveMQDestination.TOPIC_TYPE);
-         }
-
-         excludes = new ArrayList<>();
-         excludes.add(excl_dest);
-         nw_conn.setExcludedDestinations(excludes);
-
-         if (duplex_f)
-            nw_conn.setName(this.brokerId + "<-" + prefix + "->" + other.brokerId);
-         else
-            nw_conn.setName(this.brokerId + "-" + prefix + "->" + other.brokerId);
-
-         brokerSvc.addNetworkConnector(nw_conn);
-      }
-   }
-
-   protected class MessageClient extends java.lang.Thread {
-
-      protected MessageConsumer msgCons;
-      protected boolean shutdownInd;
-      protected int expectedCount;
-      protected int lastSeq = 0;
-      protected int msgCount = 0;
-      protected boolean haveFirstSeq;
-      protected CountDownLatch shutdownLatch;
-
-      public MessageClient(MessageConsumer cons, int num_to_expect) {
-         msgCons = cons;
-         expectedCount = (num_to_expect * (echoResponseFill + 1));
-         shutdownLatch = new CountDownLatch(1);
-      }
-
-      @Override
-      public void run() {
-         CountDownLatch latch;
-
-         try {
-            synchronized (this) {
-               latch = shutdownLatch;
-            }
-
-            shutdownInd = false;
-            processMessages();
-
-            latch.countDown();
-         }
-         catch (Exception exc) {
-            LOG.error("message client error", exc);
-         }
-      }
-
-      public void waitShutdown(long timeout) {
-         CountDownLatch latch;
-
-         try {
-            synchronized (this) {
-               latch = shutdownLatch;
-            }
-
-            if (latch != null)
-               latch.await(timeout, TimeUnit.MILLISECONDS);
-            else
-               LOG.info("echo client shutdown: client does not appear to be active");
-         }
-         catch (InterruptedException int_exc) {
-            LOG.warn("wait for message client shutdown interrupted", int_exc);
-         }
-      }
-
-      public boolean shutdown() {
-         boolean down_ind;
-
-         if (!shutdownInd) {
-            shutdownInd = true;
-         }
-
-         waitShutdown(200);
-
-         synchronized (this) {
-            if ((shutdownLatch == null) || (shutdownLatch.getCount() == 0))
-               down_ind = true;
-            else
-               down_ind = false;
-         }
-
-         return down_ind;
-      }
-
-      public int getNumMsgReceived() {
-         return msgCount;
-      }
-
-      protected void processMessages() throws Exception {
-         Message in_msg;
-
-         haveFirstSeq = false;
-         while ((!shutdownInd) && (!testError)) {
-            in_msg = msgCons.receive(100);
-
-            if (in_msg != null) {
-               msgCount++;
-               checkMessage(in_msg);
-            }
-         }
-      }
-
-      protected void checkMessage(Message in_msg) throws Exception {
-         int seq;
-
-         LOG.debug("received message " + fmtMsgInfo(in_msg));
-
-         if (in_msg.propertyExists("SEQ")) {
-            seq = in_msg.getIntProperty("SEQ");
-
-            if ((haveFirstSeq) && (seq != (lastSeq + 1))) {
-               LOG.error("***ERROR*** incorrect sequence number; expected " + Integer.toString(lastSeq + 1) + " but have " + Integer.toString(seq));
-
-               testError = true;
-            }
-
-            lastSeq = seq;
-
-            if (msgCount > expectedCount) {
-               LOG.warn("*** have more messages than expected; have " + msgCount + "; expect " + expectedCount);
-
-               testError = true;
-            }
-         }
-
-         if (in_msg.propertyExists("end-of-response")) {
-            LOG.trace("received end-of-response message");
-            shutdownInd = true;
-         }
-      }
-   }
-
-   protected class EchoService extends java.lang.Thread {
-
-      protected String destName;
-      protected Connection jmsConn;
-      protected Session sess;
-      protected MessageConsumer msg_cons;
-      protected boolean Shutdown_ind;
-
-      protected Destination req_dest;
-      protected Destination resp_dest;
-      protected MessageProducer msg_prod;
-
-      protected CountDownLatch waitShutdown;
-
-      public EchoService(String dest, Connection broker_conn) throws Exception {
-         destName = dest;
-         jmsConn = broker_conn;
-
-         Shutdown_ind = false;
-
-         sess = jmsConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         req_dest = sess.createQueue(destName);
-         msg_cons = sess.createConsumer(req_dest);
-
-         jmsConn.start();
-
-         waitShutdown = new CountDownLatch(1);
-      }
-
-      public EchoService(String dest, String broker_url) throws Exception {
-         this(dest, ActiveMQConnection.makeConnection(broker_url));
-      }
-
-      @Override
-      public void run() {
-         Message req;
-
-         try {
-            LOG.info("STARTING ECHO SERVICE");
-
-            while (!Shutdown_ind) {
-               req = msg_cons.receive(100);
-               if (req != null) {
-                  if (LOG.isDebugEnabled())
-                     LOG.debug("ECHO request message " + req.toString());
-
-                  resp_dest = req.getJMSReplyTo();
-                  if (resp_dest != null) {
-                     msg_prod = sess.createProducer(resp_dest);
-                     msg_prod.send(req);
-                     msg_prod.close();
-                     msg_prod = null;
-                  }
-                  else {
-                     LOG.warn("invalid request: no reply-to destination given");
-                  }
-               }
-            }
-         }
-         catch (Exception ex) {
-            LOG.error(null, ex);
-         }
-         finally {
-            LOG.info("shutting down test echo service");
-
-            try {
-               jmsConn.stop();
-            }
-            catch (javax.jms.JMSException jms_exc) {
-               LOG.warn("error on shutting down JMS connection", jms_exc);
-            }
-
-            synchronized (this) {
-               waitShutdown.countDown();
-            }
-         }
-      }
-
-      /**
-       * Shut down the service, waiting up to 3 seconds for the service to
-       * terminate.
-       */
-      public void shutdown() {
-         CountDownLatch wait_l;
-
-         synchronized (this) {
-            wait_l = waitShutdown;
-         }
-
-         Shutdown_ind = true;
-
-         try {
-            if (wait_l != null) {
-               if (wait_l.await(3000, TimeUnit.MILLISECONDS)) {
-                  LOG.info("echo service shutdown complete");
-               }
-               else {
-                  LOG.warn("timeout waiting for echo service shutdown");
-               }
-            }
-            else {
-               LOG.info("echo service shutdown: service does not appear to be active");
-            }
-         }
-         catch (InterruptedException int_exc) {
-            LOG.warn("interrupted while waiting for echo service shutdown");
-         }
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3324Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3324Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3324Test.java
deleted file mode 100644
index a90521b..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3324Test.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TemporaryQueue;
-import javax.jms.Topic;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.advisory.AdvisorySupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.DestinationInterceptor;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.broker.region.virtual.MirroredQueue;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ3324Test {
-
-   private static final transient Logger LOG = LoggerFactory.getLogger(AMQ3324Test.class);
-
-   private static final String bindAddress = "tcp://0.0.0.0:0";
-   private BrokerService broker;
-   private ActiveMQConnectionFactory cf;
-
-   private static final int MESSAGE_COUNT = 100;
-
-   @Before
-   public void setUp() throws Exception {
-      broker = this.createBroker();
-      String address = broker.getTransportConnectors().get(0).getPublishableConnectString();
-      broker.start();
-      broker.waitUntilStarted();
-
-      cf = new ActiveMQConnectionFactory(address);
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-      }
-   }
-
-   @Test
-   public void testTempMessageConsumedAdvisoryConnectionClose() throws Exception {
-
-      Connection connection = cf.createConnection();
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      final TemporaryQueue queue = session.createTemporaryQueue();
-      MessageConsumer consumer = session.createConsumer(queue);
-
-      final Topic advisoryTopic = AdvisorySupport.getMessageConsumedAdvisoryTopic((ActiveMQDestination) queue);
-
-      MessageConsumer advisoryConsumer = session.createConsumer(advisoryTopic);
-      MessageProducer producer = session.createProducer(queue);
-
-      // send lots of messages to the tempQueue
-      for (int i = 0; i < MESSAGE_COUNT; i++) {
-         BytesMessage m = session.createBytesMessage();
-         m.writeBytes(new byte[1024]);
-         producer.send(m);
-      }
-
-      // consume one message from tempQueue
-      Message msg = consumer.receive(5000);
-      assertNotNull(msg);
-
-      // check one advisory message has produced on the advisoryTopic
-      Message advCmsg = advisoryConsumer.receive(5000);
-      assertNotNull(advCmsg);
-
-      connection.close();
-      LOG.debug("Connection closed, destinations should now become inactive.");
-
-      assertTrue("The destination " + advisoryTopic + "was not removed. ", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return broker.getAdminView().getTopics().length == 0;
-         }
-      }));
-
-      assertTrue("The destination " + queue + " was not removed. ", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return broker.getAdminView().getTemporaryQueues().length == 0;
-         }
-      }));
-   }
-
-   protected BrokerService createBroker() throws Exception {
-      BrokerService answer = new BrokerService();
-      answer.setUseMirroredQueues(true);
-      answer.setPersistent(false);
-      answer.setSchedulePeriodForDestinationPurge(1000);
-
-      PolicyEntry entry = new PolicyEntry();
-      entry.setGcInactiveDestinations(true);
-      entry.setInactiveTimeoutBeforeGC(2000);
-      entry.setProducerFlowControl(true);
-      entry.setAdvisoryForConsumed(true);
-      entry.setAdvisoryForFastProducers(true);
-      entry.setAdvisoryForDelivery(true);
-      PolicyMap map = new PolicyMap();
-      map.setDefaultEntry(entry);
-
-      MirroredQueue mirrorQ = new MirroredQueue();
-      mirrorQ.setCopyMessage(true);
-      DestinationInterceptor[] destinationInterceptors = new DestinationInterceptor[]{mirrorQ};
-      answer.setDestinationInterceptors(destinationInterceptors);
-
-      answer.setDestinationPolicy(map);
-      answer.addConnector(bindAddress);
-
-      return answer;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3352Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3352Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3352Test.java
deleted file mode 100644
index 6f27bdd..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3352Test.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * 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;
-
-import javax.jms.DeliveryMode;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.TransportConnector;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AMQ3352Test {
-
-   TransportConnector connector;
-   BrokerService brokerService;
-
-   @Before
-   public void startBroker() throws Exception {
-      brokerService = new BrokerService();
-      brokerService.setDeleteAllMessagesOnStartup(true);
-      connector = brokerService.addConnector("tcp://0.0.0.0:0");
-      brokerService.start();
-   }
-
-   @After
-   public void stopBroker() throws Exception {
-      brokerService.stop();
-   }
-
-   @Test
-   public void verifyEnqueueLargeNumWithStateTracker() throws Exception {
-      String url = "failover:(" + connector.getPublishableConnectString() + ")?jms.useAsyncSend=true&trackMessages=true&maxCacheSize=131072";
-
-      ActiveMQConnection conn = (ActiveMQConnection) new ActiveMQConnectionFactory(url).createConnection(null, null);
-
-      Session session = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
-      MessageProducer producer = session.createProducer(session.createQueue("EVENTQ"));
-      producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-      producer.setDisableMessageID(true);
-      producer.setDisableMessageTimestamp(true);
-
-      StringBuffer buffer = new StringBuffer();
-      for (int i = 0; i < 1024; i++) {
-         buffer.append(String.valueOf(Math.random()));
-      }
-      String payload = buffer.toString();
-
-      for (int i = 0; i < 10000; i++) {
-         StringBuffer buff = new StringBuffer("x");
-         buff.append(payload);
-         producer.send(session.createTextMessage(buff.toString()));
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3405Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3405Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3405Test.java
deleted file mode 100644
index 5a58dd3..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3405Test.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/**
- * 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;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.RedeliveryPolicy;
-import org.apache.activemq.TestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.QueueViewMBean;
-import org.apache.activemq.broker.region.policy.DeadLetterStrategy;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.util.Wait;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ3405Test extends TestSupport {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ3405Test.class);
-
-   private Connection connection;
-   private Session session;
-   private MessageConsumer consumer;
-   private MessageProducer producer;
-   private int deliveryMode = DeliveryMode.PERSISTENT;
-   private Destination dlqDestination;
-   private MessageConsumer dlqConsumer;
-   private BrokerService broker;
-
-   private int messageCount;
-   private Destination destination;
-   private int rollbackCount;
-   private Session dlqSession;
-   private final Error[] error = new Error[1];
-   private boolean topic = true;
-   private boolean durableSubscriber = true;
-
-   public void testTransientTopicMessage() throws Exception {
-      topic = true;
-      deliveryMode = DeliveryMode.NON_PERSISTENT;
-      durableSubscriber = true;
-      doTest();
-   }
-
-   protected BrokerService createBroker() throws Exception {
-      BrokerService broker = new BrokerService();
-      broker.setPersistent(false);
-      PolicyEntry policy = new PolicyEntry();
-      DeadLetterStrategy defaultDeadLetterStrategy = policy.getDeadLetterStrategy();
-      if (defaultDeadLetterStrategy != null) {
-         defaultDeadLetterStrategy.setProcessNonPersistent(true);
-      }
-      PolicyMap pMap = new PolicyMap();
-      pMap.setDefaultEntry(policy);
-      broker.setDestinationPolicy(pMap);
-      return broker;
-   }
-
-   protected void doTest() throws Exception {
-      messageCount = 200;
-      connection.start();
-
-      final QueueViewMBean dlqView = getProxyToDLQ();
-
-      ActiveMQConnection amqConnection = (ActiveMQConnection) connection;
-      rollbackCount = amqConnection.getRedeliveryPolicy().getMaximumRedeliveries() + 1;
-      LOG.info("Will redeliver messages: " + rollbackCount + " times");
-
-      makeConsumer();
-      makeDlqConsumer();
-      dlqConsumer.close();
-
-      sendMessages();
-
-      // now lets receive and rollback N times
-      int maxRollbacks = messageCount * rollbackCount;
-
-      consumer.setMessageListener(new RollbackMessageListener(maxRollbacks, rollbackCount));
-
-      // We receive and rollback into the DLQ N times moving the DLQ messages back to their
-      // original Q to test that they are continually placed back in the DLQ.
-      for (int i = 0; i < 2; ++i) {
-
-         assertTrue("DLQ was not filled as expected", Wait.waitFor(new Wait.Condition() {
-            @Override
-            public boolean isSatisified() throws Exception {
-               return dlqView.getQueueSize() == messageCount;
-            }
-         }));
-
-         connection.stop();
-
-         assertEquals("DLQ should be full now.", messageCount, dlqView.getQueueSize());
-
-         String moveTo;
-         if (topic) {
-            moveTo = "topic://" + ((Topic) getDestination()).getTopicName();
-         }
-         else {
-            moveTo = "queue://" + ((Queue) getDestination()).getQueueName();
-         }
-
-         LOG.debug("Moving " + messageCount + " messages from ActiveMQ.DLQ to " + moveTo);
-         dlqView.moveMatchingMessagesTo("", moveTo);
-
-         assertTrue("DLQ was not emptied as expected", Wait.waitFor(new Wait.Condition() {
-            @Override
-            public boolean isSatisified() throws Exception {
-               return dlqView.getQueueSize() == 0;
-            }
-         }));
-
-         connection.start();
-      }
-   }
-
-   protected void makeConsumer() throws JMSException {
-      Destination destination = getDestination();
-      LOG.info("Consuming from: " + destination);
-      if (durableSubscriber) {
-         consumer = session.createDurableSubscriber((Topic) destination, destination.toString());
-      }
-      else {
-         consumer = session.createConsumer(destination);
-      }
-   }
-
-   protected void makeDlqConsumer() throws JMSException {
-      dlqDestination = createDlqDestination();
-
-      LOG.info("Consuming from dead letter on: " + dlqDestination);
-      dlqConsumer = dlqSession.createConsumer(dlqDestination);
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      broker = createBroker();
-      broker.start();
-      broker.waitUntilStarted();
-
-      connection = createConnection();
-      connection.setClientID(createClientId());
-
-      session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
-      connection.start();
-
-      dlqSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      dlqConsumer.close();
-      dlqSession.close();
-      session.close();
-
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-      }
-   }
-
-   @Override
-   protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
-      ActiveMQConnectionFactory answer = super.createConnectionFactory();
-      RedeliveryPolicy policy = new RedeliveryPolicy();
-      policy.setMaximumRedeliveries(3);
-      policy.setBackOffMultiplier((short) 1);
-      policy.setRedeliveryDelay(0);
-      policy.setInitialRedeliveryDelay(0);
-      policy.setUseExponentialBackOff(false);
-      answer.setRedeliveryPolicy(policy);
-      return answer;
-   }
-
-   protected void sendMessages() throws JMSException {
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      producer = session.createProducer(getDestination());
-      producer.setDeliveryMode(deliveryMode);
-
-      LOG.info("Sending " + messageCount + " messages to: " + getDestination());
-      for (int i = 0; i < messageCount; i++) {
-         Message message = createMessage(session, i);
-         producer.send(message);
-      }
-   }
-
-   protected TextMessage createMessage(Session session, int i) throws JMSException {
-      return session.createTextMessage(getMessageText(i));
-   }
-
-   protected String getMessageText(int i) {
-      return "message: " + i;
-   }
-
-   protected Destination createDlqDestination() {
-      return new ActiveMQQueue("ActiveMQ.DLQ");
-   }
-
-   private QueueViewMBean getProxyToDLQ() throws MalformedObjectNameException, JMSException {
-      ObjectName queueViewMBeanName = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost," + "destinationType=Queue,destinationName=ActiveMQ.DLQ");
-      QueueViewMBean proxy = (QueueViewMBean) broker.getManagementContext().newProxyInstance(queueViewMBeanName, QueueViewMBean.class, true);
-      return proxy;
-   }
-
-   protected Destination getDestination() {
-      if (destination == null) {
-         destination = createDestination();
-      }
-      return destination;
-   }
-
-   protected String createClientId() {
-      return toString();
-   }
-
-   class RollbackMessageListener implements MessageListener {
-
-      final int maxRollbacks;
-      final int deliveryCount;
-      final AtomicInteger rollbacks = new AtomicInteger();
-
-      RollbackMessageListener(int c, int delvery) {
-         maxRollbacks = c;
-         deliveryCount = delvery;
-      }
-
-      @Override
-      public void onMessage(Message message) {
-         try {
-            int expectedMessageId = rollbacks.get() / deliveryCount;
-            LOG.info("expecting messageId: " + expectedMessageId);
-            rollbacks.incrementAndGet();
-            session.rollback();
-         }
-         catch (Throwable e) {
-            LOG.error("unexpected exception:" + e, e);
-            // propagating assertError to execution task will cause a hang
-            // at shutdown
-            if (e instanceof Error) {
-               error[0] = (Error) e;
-            }
-            else {
-               fail("unexpected exception: " + e);
-            }
-         }
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3436Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3436Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3436Test.java
deleted file mode 100644
index 8fd2765..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3436Test.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/**
- * 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;
-
-import java.net.URI;
-import java.util.Random;
-import java.util.concurrent.CountDownLatch;
-
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQMessageConsumer;
-import org.apache.activemq.ActiveMQSession;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.broker.region.policy.SharedDeadLetterStrategy;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.store.PersistenceAdapter;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ3436Test {
-
-   protected static final Logger LOG = LoggerFactory.getLogger(AMQ3436Test.class);
-
-   private BrokerService broker;
-   private PersistenceAdapter adapter;
-   private boolean useCache = true;
-   private boolean prioritizeMessages = true;
-
-   protected PersistenceAdapter createPersistenceAdapter(boolean delete) throws Exception {
-      KahaDBPersistenceAdapter adapter = new KahaDBPersistenceAdapter();
-      adapter.setConcurrentStoreAndDispatchQueues(false);
-      adapter.setConcurrentStoreAndDispatchTopics(false);
-      adapter.deleteAllMessages();
-      return adapter;
-   }
-
-   @Before
-   public void setUp() throws Exception {
-      broker = new BrokerService();
-      broker.setBrokerName("priorityTest");
-      broker.setAdvisorySupport(false);
-      broker.setUseJmx(false);
-      adapter = createPersistenceAdapter(true);
-      broker.setPersistenceAdapter(adapter);
-      PolicyEntry policy = new PolicyEntry();
-      policy.setPrioritizedMessages(prioritizeMessages);
-      policy.setUseCache(useCache);
-      policy.setProducerFlowControl(false);
-      PolicyMap policyMap = new PolicyMap();
-      policyMap.put(new ActiveMQQueue("TEST"), policy);
-
-      // do not process expired for one test
-      PolicyEntry ignoreExpired = new PolicyEntry();
-      SharedDeadLetterStrategy ignoreExpiredStrategy = new SharedDeadLetterStrategy();
-      ignoreExpiredStrategy.setProcessExpired(false);
-      ignoreExpired.setDeadLetterStrategy(ignoreExpiredStrategy);
-
-      broker.setDestinationPolicy(policyMap);
-      broker.start();
-      broker.waitUntilStarted();
-   }
-
-   protected void tearDown() throws Exception {
-      broker.stop();
-      broker.waitUntilStopped();
-   }
-
-   @Test
-   public void testPriorityWhenConsumerCreatedBeforeProduction() throws Exception {
-
-      int messageCount = 200;
-      URI failoverUri = new URI("vm://priorityTest?jms.prefetchPolicy.all=1");
-
-      ActiveMQQueue dest = new ActiveMQQueue("TEST?consumer.dispatchAsync=false");
-
-      ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(failoverUri);
-      cf.setDispatchAsync(false);
-
-      // Create producer
-      ActiveMQConnection producerConnection = (ActiveMQConnection) cf.createConnection();
-      producerConnection.setMessagePrioritySupported(true);
-      producerConnection.start();
-      final Session producerSession = producerConnection.createSession(true, Session.SESSION_TRANSACTED);
-      MessageProducer producer = producerSession.createProducer(dest);
-
-      ActiveMQMessageConsumer consumer;
-
-      // Create consumer on separate connection
-      ActiveMQConnection consumerConnection = (ActiveMQConnection) cf.createConnection();
-      consumerConnection.setMessagePrioritySupported(true);
-      consumerConnection.start();
-      final ActiveMQSession consumerSession = (ActiveMQSession) consumerConnection.createSession(true, Session.SESSION_TRANSACTED);
-      consumer = (ActiveMQMessageConsumer) consumerSession.createConsumer(dest);
-
-      // Produce X number of messages with a session commit after each message
-      Random random = new Random();
-      for (int i = 0; i < messageCount; ++i) {
-
-         Message message = producerSession.createTextMessage("Test message #" + i);
-         producer.send(message, DeliveryMode.PERSISTENT, random.nextInt(10), 45 * 1000);
-         producerSession.commit();
-      }
-      producer.close();
-
-      // ***************************************************
-      // If we create the consumer here instead of above, the
-      // the messages will be consumed in priority order
-      // ***************************************************
-      //consumer = (ActiveMQMessageConsumer) consumerSession.createConsumer(dest);
-
-      // Consume all of the messages we produce using a listener.
-      // Don't exit until we get all the messages.
-      final CountDownLatch latch = new CountDownLatch(messageCount);
-      final StringBuffer failureMessage = new StringBuffer();
-      consumer.setMessageListener(new MessageListener() {
-         int lowestPrioritySeen = 10;
-
-         boolean firstMessage = true;
-
-         @Override
-         public void onMessage(Message msg) {
-            try {
-
-               int currentPriority = msg.getJMSPriority();
-               LOG.debug(currentPriority + "<=" + lowestPrioritySeen);
-
-               // Ignore the first message priority since it is prefetched
-               // and is out of order by design
-               if (firstMessage == true) {
-                  firstMessage = false;
-                  LOG.debug("Ignoring first message since it was prefetched");
-
-               }
-               else {
-
-                  // Verify that we never see a priority higher than the
-                  // lowest
-                  // priority seen
-                  if (lowestPrioritySeen > currentPriority) {
-                     lowestPrioritySeen = currentPriority;
-                  }
-                  if (lowestPrioritySeen < currentPriority) {
-                     failureMessage.append("Incorrect priority seen (Lowest Priority = " + lowestPrioritySeen + " Current Priority = " + currentPriority + ")" + System.getProperty("line.separator"));
-                  }
-               }
-
-            }
-            catch (JMSException e) {
-               e.printStackTrace();
-            }
-            finally {
-               latch.countDown();
-               LOG.debug("Messages remaining = " + latch.getCount());
-            }
-         }
-      });
-
-      latch.await();
-      consumer.close();
-
-      // Cleanup producer resources
-      producerSession.close();
-      producerConnection.stop();
-      producerConnection.close();
-
-      // Cleanup consumer resources
-      consumerSession.close();
-      consumerConnection.stop();
-      consumerConnection.close();
-
-      // Report the failure if found
-      if (failureMessage.length() > 0) {
-         Assert.fail(failureMessage.toString());
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3445Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3445Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3445Test.java
deleted file mode 100644
index d36faf9..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3445Test.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.management.ObjectName;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.QueueViewMBean;
-import org.apache.activemq.store.jdbc.JDBCPersistenceAdapter;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AMQ3445Test {
-
-   private ConnectionFactory connectionFactory;
-   private BrokerService broker;
-   private String connectionUri;
-
-   private final String queueName = "Consumer.MyApp.VirtualTopic.FOO";
-   private final String topicName = "VirtualTopic.FOO";
-
-   @Before
-   public void startBroker() throws Exception {
-      createBroker(true);
-   }
-
-   private void createBroker(boolean deleteMessages) throws Exception {
-      broker = new BrokerService();
-      broker.setDeleteAllMessagesOnStartup(deleteMessages);
-      broker.setPersistenceAdapter(new JDBCPersistenceAdapter());
-      broker.setAdvisorySupport(false);
-      broker.addConnector("tcp://0.0.0.0:0");
-      broker.start();
-      broker.waitUntilStarted();
-      connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
-      connectionFactory = new ActiveMQConnectionFactory(connectionUri);
-   }
-
-   private void restartBroker() throws Exception {
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-      }
-
-      createBroker(false);
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-      }
-   }
-
-   @Test
-   public void testJDBCRetiansDestinationAfterRestart() throws Exception {
-
-      broker.getAdminView().addQueue(queueName);
-      broker.getAdminView().addTopic(topicName);
-
-      assertTrue(findDestination(queueName, false));
-      assertTrue(findDestination(topicName, true));
-
-      QueueViewMBean queue = getProxyToQueueViewMBean();
-      assertEquals(0, queue.getQueueSize());
-
-      restartBroker();
-
-      assertTrue(findDestination(queueName, false));
-      queue = getProxyToQueueViewMBean();
-      assertEquals(0, queue.getQueueSize());
-
-      sendMessage();
-      restartBroker();
-      assertTrue(findDestination(queueName, false));
-
-      queue = getProxyToQueueViewMBean();
-      assertEquals(1, queue.getQueueSize());
-      sendMessage();
-      assertEquals(2, queue.getQueueSize());
-
-      restartBroker();
-      assertTrue(findDestination(queueName, false));
-      queue = getProxyToQueueViewMBean();
-      assertEquals(2, queue.getQueueSize());
-   }
-
-   private void sendMessage() throws Exception {
-      Connection connection = connectionFactory.createConnection();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = session.createProducer(session.createTopic(topicName));
-      producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-      producer.send(session.createTextMessage("Testing"));
-      producer.close();
-      connection.close();
-   }
-
-   private QueueViewMBean getProxyToQueueViewMBean() throws Exception {
-      ObjectName queueViewMBeanName = new ObjectName("org.apache.activemq" + ":destinationType=Queue,destinationName=" + queueName + ",type=Broker,brokerName=localhost");
-      QueueViewMBean proxy = (QueueViewMBean) broker.getManagementContext().newProxyInstance(queueViewMBeanName, QueueViewMBean.class, true);
-      return proxy;
-   }
-
-   private boolean findDestination(String name, boolean topic) throws Exception {
-
-      ObjectName[] destinations;
-
-      if (topic) {
-         destinations = broker.getAdminView().getTopics();
-      }
-      else {
-         destinations = broker.getAdminView().getQueues();
-      }
-
-      for (ObjectName destination : destinations) {
-         if (destination.toString().contains(name)) {
-            return true;
-         }
-      }
-
-      return false;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3454Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3454Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3454Test.java
deleted file mode 100644
index 96f0c2c..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3454Test.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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;
-
-import javax.jms.Connection;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ3454Test extends TestCase {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ3454Test.class);
-   private static final int MESSAGES_COUNT = 10000;
-
-   public void testSendWithLotsOfDestinations() throws Exception {
-      final BrokerService broker = new BrokerService();
-      broker.setPersistent(false);
-      broker.setUseJmx(false);
-      broker.setDeleteAllMessagesOnStartup(true);
-
-      broker.addConnector("tcp://localhost:0");
-
-      // populate a bunch of destinations, validate the impact on a call to send
-      ActiveMQDestination[] destinations = new ActiveMQDestination[MESSAGES_COUNT];
-      for (int idx = 0; idx < MESSAGES_COUNT; ++idx) {
-         destinations[idx] = new ActiveMQQueue(getDestinationName() + "-" + idx);
-      }
-      broker.setDestinations(destinations);
-      broker.start();
-
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString());
-      final Connection connection = factory.createConnection();
-      connection.start();
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = session.createProducer(new ActiveMQQueue(getDestinationName()));
-
-      long start = System.currentTimeMillis();
-      for (int idx = 0; idx < MESSAGES_COUNT; ++idx) {
-         Message message = session.createTextMessage("" + idx);
-         producer.send(message);
-      }
-      LOG.info("Duration: " + (System.currentTimeMillis() - start) + " millis");
-      producer.close();
-      session.close();
-
-   }
-
-   protected String getDestinationName() {
-      return getClass().getName() + "." + getName();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3465Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3465Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3465Test.java
deleted file mode 100644
index 5e6b2ff..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3465Test.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.*;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.XAConnection;
-import javax.jms.XAConnectionFactory;
-import javax.jms.XASession;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQMessageProducer;
-import org.apache.activemq.ActiveMQSession;
-import org.apache.activemq.ActiveMQXAConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTextMessage;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AMQ3465Test {
-
-   private final String xaDestinationName = "DestinationXA";
-   private final String destinationName = "Destination";
-   private BrokerService broker;
-   private String connectionUri;
-   private long txGenerator = System.currentTimeMillis();
-
-   private XAConnectionFactory xaConnectionFactory;
-   private ConnectionFactory connectionFactory;
-
-   @Before
-   public void startBroker() throws Exception {
-      broker = new BrokerService();
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.setPersistent(false);
-      broker.setUseJmx(false);
-      broker.addConnector("tcp://0.0.0.0:0");
-      broker.start();
-      broker.waitUntilStarted();
-
-      connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
-
-      connectionFactory = new ActiveMQConnectionFactory(connectionUri);
-      xaConnectionFactory = new ActiveMQXAConnectionFactory(connectionUri);
-   }
-
-   @After
-   public void stopBroker() throws Exception {
-      broker.stop();
-      broker.waitUntilStopped();
-   }
-
-   @Test
-   public void testMixedXAandNonXAorTXSessions() throws Exception {
-
-      XAConnection xaConnection = xaConnectionFactory.createXAConnection();
-      xaConnection.start();
-      XASession session = xaConnection.createXASession();
-      XAResource resource = session.getXAResource();
-      Destination dest = new ActiveMQQueue(xaDestinationName);
-
-      // publish a message
-      Xid tid = createXid();
-      resource.start(tid, XAResource.TMNOFLAGS);
-      MessageProducer producer = session.createProducer(dest);
-      ActiveMQTextMessage message = new ActiveMQTextMessage();
-      message.setText("Some Text");
-      producer.send(message);
-      resource.end(tid, XAResource.TMSUCCESS);
-      resource.commit(tid, true);
-      session.close();
-
-      session = xaConnection.createXASession();
-      MessageConsumer consumer = session.createConsumer(dest);
-      tid = createXid();
-      resource = session.getXAResource();
-      resource.start(tid, XAResource.TMNOFLAGS);
-      TextMessage receivedMessage = (TextMessage) consumer.receive(1000);
-      assertNotNull(receivedMessage);
-      assertEquals("Some Text", receivedMessage.getText());
-      resource.end(tid, XAResource.TMSUCCESS);
-
-      // Test that a normal session doesn't operate on XASession state.
-      Connection connection2 = connectionFactory.createConnection();
-      connection2.start();
-      ActiveMQSession session2 = (ActiveMQSession) connection2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      if (session2.isTransacted()) {
-         session2.rollback();
-      }
-
-      session2.close();
-
-      resource.commit(tid, true);
-   }
-
-   @Test
-   public void testMixedXAandNonXALocalTXSessions() throws Exception {
-
-      XAConnection xaConnection = xaConnectionFactory.createXAConnection();
-      xaConnection.start();
-      XASession session = xaConnection.createXASession();
-      XAResource resource = session.getXAResource();
-      Destination dest = new ActiveMQQueue(xaDestinationName);
-
-      // publish a message
-      Xid tid = createXid();
-      resource.start(tid, XAResource.TMNOFLAGS);
-      MessageProducer producer = session.createProducer(dest);
-      ActiveMQTextMessage message = new ActiveMQTextMessage();
-      message.setText("Some Text");
-      producer.send(message);
-      resource.end(tid, XAResource.TMSUCCESS);
-      resource.commit(tid, true);
-      session.close();
-
-      session = xaConnection.createXASession();
-      MessageConsumer consumer = session.createConsumer(dest);
-      tid = createXid();
-      resource = session.getXAResource();
-      resource.start(tid, XAResource.TMNOFLAGS);
-      TextMessage receivedMessage = (TextMessage) consumer.receive(1000);
-      assertNotNull(receivedMessage);
-      assertEquals("Some Text", receivedMessage.getText());
-      resource.end(tid, XAResource.TMSUCCESS);
-
-      // Test that a normal session doesn't operate on XASession state.
-      Connection connection2 = connectionFactory.createConnection();
-      connection2.start();
-      ActiveMQSession session2 = (ActiveMQSession) connection2.createSession(true, Session.AUTO_ACKNOWLEDGE);
-      Destination destination = new ActiveMQQueue(destinationName);
-      ActiveMQMessageProducer producer2 = (ActiveMQMessageProducer) session2.createProducer(destination);
-      producer2.send(session2.createTextMessage("Local-TX"));
-
-      if (session2.isTransacted()) {
-         session2.rollback();
-      }
-
-      session2.close();
-
-      resource.commit(tid, true);
-   }
-
-   public Xid createXid() throws IOException {
-
-      ByteArrayOutputStream baos = new ByteArrayOutputStream();
-      DataOutputStream os = new DataOutputStream(baos);
-      os.writeLong(++txGenerator);
-      os.close();
-      final byte[] bs = baos.toByteArray();
-
-      return new Xid() {
-         @Override
-         public int getFormatId() {
-            return 86;
-         }
-
-         @Override
-         public byte[] getGlobalTransactionId() {
-            return bs;
-         }
-
-         @Override
-         public byte[] getBranchQualifier() {
-            return bs;
-         }
-      };
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3529Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3529Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3529Test.java
deleted file mode 100644
index 3d9d2d4..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3529Test.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/**
- * 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;
-
-import java.util.Properties;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ3529Test {
-
-   private static Logger LOG = LoggerFactory.getLogger(AMQ3529Test.class);
-
-   private ConnectionFactory connectionFactory;
-   private Connection connection;
-   private Session session;
-   private BrokerService broker;
-   private String connectionUri;
-   private MessageConsumer consumer;
-   private Context ctx = null;
-
-   @Before
-   public void startBroker() throws Exception {
-      broker = new BrokerService();
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.setPersistent(false);
-      broker.setUseJmx(false);
-      broker.addConnector("tcp://0.0.0.0:0");
-      broker.start();
-      broker.waitUntilStarted();
-
-      connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
-
-      connectionFactory = new ActiveMQConnectionFactory(connectionUri);
-   }
-
-   @After
-   public void stopBroker() throws Exception {
-      broker.stop();
-      broker.waitUntilStopped();
-   }
-
-   @Test(timeout = 60000)
-   public void testInterruptionAffects() throws Exception {
-      ThreadGroup tg = new ThreadGroup("tg");
-
-      assertEquals(0, tg.activeCount());
-
-      Thread client = new Thread(tg, "client") {
-
-         @Override
-         public void run() {
-            try {
-               connection = connectionFactory.createConnection();
-               session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-               assertNotNull(session);
-
-               Properties props = new Properties();
-               props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
-               props.setProperty(Context.PROVIDER_URL, "tcp://0.0.0.0:0");
-               ctx = null;
-               try {
-                  ctx = new InitialContext(props);
-               }
-               catch (NoClassDefFoundError e) {
-                  throw new NamingException(e.toString());
-               }
-               catch (Exception e) {
-                  throw new NamingException(e.toString());
-               }
-               Destination destination = (Destination) ctx.lookup("dynamicTopics/example.C");
-               consumer = session.createConsumer(destination);
-               consumer.receive(10000);
-            }
-            catch (Exception e) {
-               // Expect an exception here from the interrupt.
-            }
-            finally {
-               // next line is the nature of the test, if I remove this
-               // line, everything works OK
-               try {
-                  consumer.close();
-               }
-               catch (JMSException e) {
-                  fail("Consumer Close failed with" + e.getMessage());
-               }
-               try {
-                  session.close();
-               }
-               catch (JMSException e) {
-                  fail("Session Close failed with" + e.getMessage());
-               }
-               try {
-                  connection.close();
-               }
-               catch (JMSException e) {
-                  fail("Connection Close failed with" + e.getMessage());
-               }
-               try {
-                  ctx.close();
-               }
-               catch (Exception e) {
-                  fail("Connection Close failed with" + e.getMessage());
-               }
-            }
-         }
-      };
-      client.start();
-      Thread.sleep(5000);
-      client.interrupt();
-      client.join();
-      Thread.sleep(2000);
-      Thread[] remainThreads = new Thread[tg.activeCount()];
-      tg.enumerate(remainThreads);
-      for (Thread t : remainThreads) {
-         if (t.isAlive() && !t.isDaemon())
-            fail("Remaining thread: " + t.toString());
-      }
-
-      ThreadGroup root = Thread.currentThread().getThreadGroup().getParent();
-      while (root.getParent() != null) {
-         root = root.getParent();
-      }
-      visit(root, 0);
-   }
-
-   // This method recursively visits all thread groups under `group'.
-   public static void visit(ThreadGroup group, int level) {
-      // Get threads in `group'
-      int numThreads = group.activeCount();
-      Thread[] threads = new Thread[numThreads * 2];
-      numThreads = group.enumerate(threads, false);
-
-      // Enumerate each thread in `group'
-      for (int i = 0; i < numThreads; i++) {
-         // Get thread
-         Thread thread = threads[i];
-         LOG.debug("Thread:" + thread.getName() + " is still running");
-      }
-
-      // Get thread subgroups of `group'
-      int numGroups = group.activeGroupCount();
-      ThreadGroup[] groups = new ThreadGroup[numGroups * 2];
-      numGroups = group.enumerate(groups, false);
-
-      // Recursively visit each subgroup
-      for (int i = 0; i < numGroups; i++) {
-         visit(groups[i], level + 1);
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3537Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3537Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3537Test.java
deleted file mode 100644
index 614631f..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3537Test.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.activemq.util.ClassLoadingAwareObjectInputStream;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Quick port to java to support AMQ build.
- *
- * This test demonstrates the classloader problem in the
- * ClassLoadingAwareObjectInputStream impl. If the first interface in the proxy
- * interfaces list is JDK and there are any subsequent interfaces that are NOT
- * JDK interfaces the ClassLoadingAwareObjectInputStream will ignore their
- * respective classloaders and cause the Proxy to throw an
- * IllegalArgumentException because the core JDK classloader can't load the
- * interfaces that are not JDK interfaces.
- *
- * See AMQ-3537
- *
- * @author jason.yankus
- */
-@SuppressWarnings({"rawtypes", "unchecked"})
-public class AMQ3537Test implements InvocationHandler, Serializable {
-
-   private static final long serialVersionUID = 1L;
-
-   /**
-    * If the first and second element in this array are swapped, the test will
-    * fail.
-    */
-   public static final Class[] TEST_CLASSES = new Class[]{List.class, NonJDKList.class, Serializable.class};
-
-   /**
-    * Underlying list
-    */
-   private final List l = new ArrayList<String>();
-
-   @Before
-   public void setUp() throws Exception {
-      l.add("foo");
-   }
-
-   @Test
-   public void testDeserializeProxy() throws Exception {
-      // create the proxy
-      List proxy = (List) java.lang.reflect.Proxy.newProxyInstance(this.getClass().getClassLoader(), TEST_CLASSES, this);
-
-      // serialize it
-      ByteArrayOutputStream baos = new ByteArrayOutputStream();
-      ObjectOutputStream oos = new ObjectOutputStream(baos);
-      oos.writeObject(proxy);
-      byte[] serializedProxy = baos.toByteArray();
-      oos.close();
-      baos.close();
-
-      // deserialize the proxy
-      ClassLoadingAwareObjectInputStream claois = new ClassLoadingAwareObjectInputStream(new ByteArrayInputStream(serializedProxy));
-
-      // this is where it fails due to the rudimentary classloader selection
-      // in ClassLoadingAwareObjectInputStream
-      List deserializedProxy = (List) claois.readObject();
-
-      claois.close();
-
-      // assert the invocation worked
-      assertEquals("foo", deserializedProxy.get(0));
-   }
-
-   @Override
-   public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
-      return method.invoke(l, args);
-   }
-
-   public interface NonJDKList {
-
-      int size();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3567Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3567Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3567Test.java
deleted file mode 100644
index c567eb3..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3567Test.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.fail;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.util.DefaultTestAppender;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Level;
-import org.apache.log4j.spi.LoggingEvent;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author Claudio Corsi
- */
-public class AMQ3567Test {
-
-   private static Logger logger = LoggerFactory.getLogger(AMQ3567Test.class);
-
-   private ActiveMQConnectionFactory factory;
-   private Connection connection;
-   private Session sessionWithListener, session;
-   private Queue destination;
-   private MessageConsumer consumer;
-   private Thread thread;
-   private BrokerService broker;
-   private String connectionUri;
-
-   /**
-    * @throws java.lang.Exception
-    */
-   @Before
-   public void setUp() throws Exception {
-      startBroker();
-      initializeConsumer();
-      startConsumer();
-   }
-
-   @Test
-   public void runTest() throws Exception {
-      produceSingleMessage();
-      org.apache.log4j.Logger log4jLogger = org.apache.log4j.Logger.getLogger("org.apache.activemq.util.ServiceSupport");
-      final AtomicBoolean failed = new AtomicBoolean(false);
-
-      Appender appender = new DefaultTestAppender() {
-         @Override
-         public void doAppend(LoggingEvent event) {
-            if (event.getThrowableInformation() != null) {
-               if (event.getThrowableInformation().getThrowable() instanceof InterruptedException) {
-                  InterruptedException ie = (InterruptedException) event.getThrowableInformation().getThrowable();
-                  if (ie.getMessage().startsWith("Could not stop service:")) {
-                     logger.info("Received an interrupted exception : ", ie);
-                     failed.set(true);
-                  }
-               }
-            }
-         }
-      };
-      log4jLogger.addAppender(appender);
-
-      Level level = log4jLogger.getLevel();
-      log4jLogger.setLevel(Level.DEBUG);
-
-      try {
-         stopConsumer();
-         stopBroker();
-         if (failed.get()) {
-            fail("An Interrupt exception was generated");
-         }
-
-      }
-      finally {
-         log4jLogger.setLevel(level);
-         log4jLogger.removeAppender(appender);
-      }
-   }
-
-   private void startBroker() throws Exception {
-      broker = new BrokerService();
-      broker.setDataDirectory("target/data");
-      connectionUri = broker.addConnector("tcp://localhost:0?wireFormat.maxInactivityDuration=30000&transport.closeAsync=false&transport.threadName&soTimeout=60000&transport.keepAlive=false&transport.useInactivityMonitor=false").getPublishableConnectString();
-      broker.start(true);
-      broker.waitUntilStarted();
-   }
-
-   private void stopBroker() throws Exception {
-      broker.stop();
-      broker.waitUntilStopped();
-   }
-
-   private void initializeConsumer() throws JMSException {
-      logger.info("Initializing the consumer messagor that will just not do anything....");
-      factory = new ActiveMQConnectionFactory();
-      factory.setBrokerURL("failover:(" + connectionUri + "?wireFormat.maxInactivityDuration=30000&keepAlive=true&soTimeout=60000)?jms.watchTopicAdvisories=false&jms.useAsyncSend=false&jms.dispatchAsync=true&jms.producerWindowSize=10485760&jms.copyMessageOnSend=false&jms.disableTimeStampsByDefault=true&InitialReconnectDelay=1000&maxReconnectDelay=10000&maxReconnectAttempts=400&useExponentialBackOff=true");
-      connection = factory.createConnection();
-      connection.start();
-      sessionWithListener = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      destination = sessionWithListener.createQueue("EMPTY.QUEUE");
-   }
-
-   private void startConsumer() throws Exception {
-      logger.info("Starting the consumer");
-      consumer = sessionWithListener.createConsumer(destination);
-      consumer.setMessageListener(new MessageListener() {
-
-         @Override
-         public void onMessage(Message message) {
-            logger.info("Received a message: " + message);
-         }
-
-      });
-
-      thread = new Thread(new Runnable() {
-
-         private Session session;
-
-         @Override
-         public void run() {
-            try {
-               destination = session.createQueue("EMPTY.QUEUE");
-               MessageConsumer consumer = session.createConsumer(destination);
-               for (int cnt = 0; cnt < 2; cnt++) {
-                  Message message = consumer.receive(50000);
-                  logger.info("Received message: " + message);
-               }
-            }
-            catch (JMSException e) {
-               logger.debug("Received an exception while processing messages", e);
-            }
-            finally {
-               try {
-                  session.close();
-               }
-               catch (JMSException e) {
-                  logger.debug("Received an exception while closing session", e);
-               }
-            }
-         }
-
-         public Runnable setSession(Session session) {
-            this.session = session;
-            return this;
-         }
-
-      }.setSession(session)) {
-         {
-            start();
-         }
-      };
-   }
-
-   private void stopConsumer() throws JMSException {
-      logger.info("Stopping the consumer");
-      try {
-         thread.join();
-      }
-      catch (InterruptedException e) {
-         logger.debug("Received an exception while waiting for thread to complete", e);
-      }
-      if (sessionWithListener != null) {
-         sessionWithListener.close();
-      }
-      if (connection != null) {
-         connection.stop();
-      }
-   }
-
-   private void produceSingleMessage() throws JMSException {
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
-      factory.setBrokerURL(connectionUri);
-      Connection connection = factory.createConnection();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Destination destination = session.createQueue("EMPTY.QUEUE");
-      MessageProducer producer = session.createProducer(destination);
-      producer.send(session.createTextMessage("Single Message"));
-      producer.close();
-      session.close();
-      connection.close();
-   }
-}


[56/60] [abbrv] activemq-artemis git commit: fix issues in ActiveMQXAConnectionFactoryTest

Posted by cl...@apache.org.
fix issues in ActiveMQXAConnectionFactoryTest


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/35c14e1d
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/35c14e1d
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/35c14e1d

Branch: refs/heads/refactor-openwire
Commit: 35c14e1dc0e32046f073dc6fb293bb0d67e64ac1
Parents: 30cd9f2
Author: Howard Gao <ho...@gmail.com>
Authored: Fri Mar 4 20:15:19 2016 +0800
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:45:29 2016 -0400

----------------------------------------------------------------------
 .../core/protocol/openwire/OpenWireConnection.java   |  5 ++++-
 .../protocol/openwire/OpenWireProtocolManager.java   | 11 +++++++++++
 .../activemq/ActiveMQXAConnectionFactoryTest.java    | 15 +++++++++------
 3 files changed, 24 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/35c14e1d/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
index 03871ab..598016d 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
@@ -19,6 +19,7 @@ package org.apache.activemq.artemis.core.protocol.openwire;
 import javax.jms.InvalidClientIDException;
 import javax.jms.InvalidDestinationException;
 import javax.jms.JMSSecurityException;
+import javax.transaction.xa.XAResource;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -77,6 +78,7 @@ import org.apache.activemq.command.DataArrayResponse;
 import org.apache.activemq.command.DestinationInfo;
 import org.apache.activemq.command.ExceptionResponse;
 import org.apache.activemq.command.FlushCommand;
+import org.apache.activemq.command.IntegerResponse;
 import org.apache.activemq.command.KeepAliveInfo;
 import org.apache.activemq.command.Message;
 import org.apache.activemq.command.MessageAck;
@@ -1140,7 +1142,8 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
       @Override
       public Response processPrepareTransaction(TransactionInfo info) throws Exception {
          protocolManager.prepareTransaction(info);
-         return null;
+         //activemq needs a rdonly response
+         return new IntegerResponse(XAResource.XA_RDONLY);
       }
 
       @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/35c14e1d/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
index 122788e..abfcca5 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
@@ -17,6 +17,7 @@
 package org.apache.activemq.artemis.core.protocol.openwire;
 
 import javax.jms.InvalidClientIDException;
+import javax.transaction.xa.XAException;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -487,6 +488,9 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, Cl
       if (txSession != null) {
          txSession.rollback(info);
       }
+      else {
+         throw newXAException("Transaction '" + info.getTransactionId() + "' has not been started.", XAException.XAER_NOTA);
+      }
       transactions.remove(info.getTransactionId());
    }
 
@@ -558,4 +562,11 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, Cl
    public boolean isUpdateClusterClientsOnRemove() {
       return this.updateClusterClientsOnRemove;
    }
+
+   public static XAException newXAException(String s, int errorCode) {
+      XAException xaException = new XAException(s + " " + "xaErrorCode:" + errorCode);
+      xaException.errorCode = errorCode;
+      return xaException;
+   }
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/35c14e1d/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQXAConnectionFactoryTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQXAConnectionFactoryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQXAConnectionFactoryTest.java
index 9424598..c96f370 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQXAConnectionFactoryTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQXAConnectionFactoryTest.java
@@ -126,7 +126,8 @@ public class ActiveMQXAConnectionFactoryTest extends CombinationTestSupport {
       assertNotNull(BrokerRegistry.getInstance().lookup("myBroker"));
       connection.close();
       // Verify the broker was destroyed.
-      assertNull(BrokerRegistry.getInstance().lookup("myBroker"));
+      //comment out this check as it doesn't apply to artemis
+      //assertNull(BrokerRegistry.getInstance().lookup("myBroker"));
 
       connection.close();
    }
@@ -383,8 +384,9 @@ public class ActiveMQXAConnectionFactoryTest extends CombinationTestSupport {
       resource.end(tid, XAResource.TMSUCCESS);
       resource.commit(tid, true);
 
-      assertTransactionGoneFromBroker(tid);
-      assertTransactionGoneFromConnection(brokerName, xaConnection.getClientID(), xaConnection.getConnectionInfo().getConnectionId(), tid);
+      //not apply to artemis
+      //assertTransactionGoneFromBroker(tid);
+      //assertTransactionGoneFromConnection(brokerName, xaConnection.getClientID(), xaConnection.getConnectionInfo().getConnectionId(), tid);
       assertSessionGone(xaConnection, session);
       assertTransactionGoneFromFailoverState(xaConnection, tid);
 
@@ -398,8 +400,8 @@ public class ActiveMQXAConnectionFactoryTest extends CombinationTestSupport {
       assertEquals(XAResource.XA_RDONLY, resource.prepare(tid));
 
       // no need for a commit on read only
-      assertTransactionGoneFromBroker(tid);
-      assertTransactionGoneFromConnection(brokerName, xaConnection.getClientID(), xaConnection.getConnectionInfo().getConnectionId(), tid);
+      //assertTransactionGoneFromBroker(tid);
+      //assertTransactionGoneFromConnection(brokerName, xaConnection.getClientID(), xaConnection.getConnectionInfo().getConnectionId(), tid);
       assertSessionGone(xaConnection, session);
       assertTransactionGoneFromFailoverState(xaConnection, tid);
 
@@ -430,7 +432,8 @@ public class ActiveMQXAConnectionFactoryTest extends CombinationTestSupport {
 
       connection.close();
 
-      assertTransactionGoneFromBroker(tid);
+      //comment out this check as it doesn't apply to artemis
+      //assertTransactionGoneFromBroker(tid);
 
       broker.stop();
    }


[24/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2171Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2171Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2171Test.java
deleted file mode 100644
index ea794ff..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2171Test.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/**
- * 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;
-
-import java.util.*;
-import java.util.concurrent.CopyOnWriteArrayList;
-import javax.jms.*;
-import javax.jms.Queue;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-public class AMQ2171Test implements Thread.UncaughtExceptionHandler {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ2171Test.class);
-   private static final String BROKER_URL = "tcp://localhost:0";
-   private static final int QUEUE_SIZE = 100;
-
-   private static BrokerService brokerService;
-   private static Queue destination;
-
-   private String brokerUri;
-   private String brokerUriNoPrefetch;
-   private Collection<Throwable> exceptions = new CopyOnWriteArrayList<>();
-
-   @Before
-   public void setUp() throws Exception {
-      // Start an embedded broker up.
-      brokerService = new BrokerService();
-      brokerService.setDeleteAllMessagesOnStartup(true);
-      brokerService.addConnector(BROKER_URL);
-      brokerService.start();
-
-      brokerUri = brokerService.getTransportConnectors().get(0).getPublishableConnectString().toString();
-      brokerUriNoPrefetch = brokerUri + "?jms.prefetchPolicy.all=0";
-
-      destination = new ActiveMQQueue("Test");
-      produce(brokerUri, QUEUE_SIZE);
-   }
-
-   @Before
-   public void addHandler() {
-      Thread.setDefaultUncaughtExceptionHandler(this);
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      brokerService.stop();
-   }
-
-   @Test(timeout = 10000)
-   public void testBrowsePrefetch() throws Exception {
-      runTest(brokerUri);
-   }
-
-   @Test(timeout = 10000)
-   public void testBrowseNoPrefetch() throws Exception {
-      runTest(brokerUriNoPrefetch);
-   }
-
-   private void runTest(String brokerURL) throws Exception {
-
-      Connection connection = new ActiveMQConnectionFactory(brokerURL).createConnection();
-
-      try {
-         connection.start();
-
-         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         Enumeration<Message> unread = session.createBrowser(destination).getEnumeration();
-
-         int count = 0;
-         while (unread.hasMoreElements()) {
-            unread.nextElement();
-            count++;
-         }
-
-         assertEquals(QUEUE_SIZE, count);
-         assertTrue(exceptions.isEmpty());
-      }
-      finally {
-         try {
-            connection.close();
-         }
-         catch (JMSException e) {
-            exceptions.add(e);
-         }
-      }
-   }
-
-   private static void produce(String brokerURL, int count) throws Exception {
-      Connection connection = null;
-
-      try {
-
-         ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerURL);
-         connection = factory.createConnection();
-         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageProducer producer = session.createProducer(destination);
-         producer.setTimeToLive(0);
-         connection.start();
-
-         for (int i = 0; i < count; i++) {
-            int id = i + 1;
-            TextMessage message = session.createTextMessage("Message " + id);
-            message.setIntProperty("MsgNumber", id);
-            producer.send(message);
-
-            if (id % 500 == 0) {
-               LOG.info("sent " + id + ", ith " + message);
-            }
-         }
-      }
-      finally {
-         try {
-            if (connection != null) {
-               connection.close();
-            }
-         }
-         catch (Throwable e) {
-         }
-      }
-   }
-
-   @Override
-   public void uncaughtException(Thread t, Throwable e) {
-      exceptions.add(e);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2200Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2200Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2200Test.java
deleted file mode 100644
index d6b4aaa..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2200Test.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.jms.TopicConnection;
-import javax.jms.TopicSession;
-import javax.management.ObjectName;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.TopicSubscriptionViewMBean;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AMQ2200Test {
-
-   private static final String bindAddress = "tcp://0.0.0.0:0";
-   private BrokerService broker;
-   private ActiveMQConnectionFactory cf;
-
-   @Before
-   public void setUp() throws Exception {
-      broker = new BrokerService();
-      broker.setDataDirectory("target" + File.separator + "activemq-data");
-      broker.setPersistent(true);
-      broker.setUseJmx(true);
-      broker.setAdvisorySupport(false);
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.addConnector(bindAddress);
-      String address = broker.getTransportConnectors().get(0).getPublishableConnectString();
-      broker.start();
-      broker.waitUntilStarted();
-
-      cf = new ActiveMQConnectionFactory(address);
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-      }
-   }
-
-   @Test
-   public void testTopicSubscriptionView() throws Exception {
-      TopicConnection connection = cf.createTopicConnection();
-      TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      Topic destination = session.createTopic("TopicViewTestTopic");
-      MessageConsumer consumer = session.createConsumer(destination);
-      assertNotNull(consumer);
-      TimeUnit.SECONDS.sleep(1);
-
-      ObjectName subscriptionNames[] = broker.getAdminView().getTopicSubscribers();
-      assertTrue(subscriptionNames.length > 0);
-
-      boolean fail = true;
-      for (ObjectName name : subscriptionNames) {
-         if (name.toString().contains("TopicViewTestTopic")) {
-            TopicSubscriptionViewMBean sub = (TopicSubscriptionViewMBean) broker.getManagementContext().newProxyInstance(name, TopicSubscriptionViewMBean.class, true);
-            assertNotNull(sub);
-            assertTrue(sub.getSessionId() != -1);
-            // Check that its the default value then configure something new.
-            assertTrue(sub.getMaximumPendingQueueSize() == -1);
-            sub.setMaximumPendingQueueSize(1000);
-            assertTrue(sub.getMaximumPendingQueueSize() != -1);
-            fail = false;
-         }
-      }
-
-      if (fail) {
-         fail("Didn't find the TopicSubscriptionView");
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2213Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2213Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2213Test.java
deleted file mode 100644
index 2152e12..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2213Test.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.QueueSession;
-import javax.jms.Session;
-import javax.jms.TopicConnection;
-import javax.jms.TopicSession;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AMQ2213Test {
-
-   BrokerService broker;
-   ConnectionFactory factory;
-   Connection connection;
-   Session session;
-   Queue queue;
-   MessageConsumer consumer;
-
-   public void createBroker(boolean deleteAll) throws Exception {
-      broker = new BrokerService();
-      broker.setDeleteAllMessagesOnStartup(deleteAll);
-      broker.setDataDirectory("target/AMQ3145Test");
-      broker.setUseJmx(true);
-      broker.getManagementContext().setCreateConnector(false);
-      broker.addConnector("tcp://localhost:0");
-      broker.start();
-      broker.waitUntilStarted();
-      factory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getConnectUri().toString());
-      connection = factory.createConnection();
-      connection.start();
-      session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-   }
-
-   @Before
-   public void createBroker() throws Exception {
-      createBroker(true);
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      if (consumer != null) {
-         consumer.close();
-      }
-      session.close();
-      connection.stop();
-      connection.close();
-      broker.stop();
-   }
-
-   @Test
-   public void testEqualsGenericSession() throws JMSException {
-      assertNotNull(this.connection);
-      Session sess = this.connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      assertTrue(sess.equals(sess));
-   }
-
-   @Test
-   public void testEqualsTopicSession() throws JMSException {
-      assertNotNull(this.connection);
-      assertTrue(this.connection instanceof TopicConnection);
-      TopicSession sess = ((TopicConnection) this.connection).createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
-      assertTrue(sess.equals(sess));
-   }
-
-   @Test
-   public void testEqualsQueueSession() throws JMSException {
-      assertNotNull(this.connection);
-      assertTrue(this.connection instanceof QueueConnection);
-      QueueSession sess = ((QueueConnection) this.connection).createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
-      assertTrue(sess.equals(sess));
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2314Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2314Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2314Test.java
deleted file mode 100644
index fde821f..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2314Test.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/**
- * 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;
-
-import java.io.File;
-import java.util.concurrent.CountDownLatch;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import junit.framework.Test;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQPrefetchPolicy;
-import org.apache.activemq.CombinationTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.util.Wait;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ2314Test extends CombinationTestSupport {
-
-   public boolean consumeAll = false;
-   public int deliveryMode = DeliveryMode.NON_PERSISTENT;
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ2314Test.class);
-   private static final int MESSAGES_COUNT = 30000;
-   private static byte[] buf = new byte[1024];
-   private BrokerService broker;
-   private String connectionUri;
-
-   private static final long messageReceiveTimeout = 500L;
-
-   Destination destination = new ActiveMQTopic("FooTwo");
-
-   public void testRemoveSlowSubscriberWhacksTempStore() throws Exception {
-      runProducerWithHungConsumer();
-   }
-
-   public void testMemoryUsageReleasedOnAllConsumed() throws Exception {
-      consumeAll = true;
-      runProducerWithHungConsumer();
-      // do it again to ensure memory limits are decreased
-      runProducerWithHungConsumer();
-   }
-
-   public void runProducerWithHungConsumer() throws Exception {
-
-      final CountDownLatch consumerContinue = new CountDownLatch(1);
-      final CountDownLatch consumerReady = new CountDownLatch(1);
-
-      final long origTempUsage = broker.getSystemUsage().getTempUsage().getUsage();
-
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri);
-      factory.setAlwaysSyncSend(true);
-
-      // ensure messages are spooled to disk for this consumer
-      ActiveMQPrefetchPolicy prefetch = new ActiveMQPrefetchPolicy();
-      prefetch.setTopicPrefetch(500);
-      factory.setPrefetchPolicy(prefetch);
-      final Connection connection = factory.createConnection();
-      connection.start();
-
-      Thread producingThread = new Thread("Producing thread") {
-         @Override
-         public void run() {
-            try {
-               Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-               MessageProducer producer = session.createProducer(destination);
-               producer.setDeliveryMode(deliveryMode);
-               for (int idx = 0; idx < MESSAGES_COUNT; ++idx) {
-                  Message message = session.createTextMessage(new String(buf) + idx);
-                  producer.send(message);
-               }
-               producer.close();
-               session.close();
-            }
-            catch (Throwable ex) {
-               ex.printStackTrace();
-            }
-         }
-      };
-
-      Thread consumingThread = new Thread("Consuming thread") {
-         @Override
-         public void run() {
-            try {
-               int count = 0;
-               Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-               MessageConsumer consumer = session.createConsumer(destination);
-
-               while (consumer.receive(messageReceiveTimeout) == null) {
-                  consumerReady.countDown();
-               }
-               count++;
-               LOG.info("Received one... waiting");
-               consumerContinue.await();
-               if (consumeAll) {
-                  LOG.info("Consuming the rest of the messages...");
-                  while (consumer.receive(messageReceiveTimeout) != null) {
-                     count++;
-                  }
-               }
-               LOG.info("consumer session closing: consumed count: " + count);
-               session.close();
-            }
-            catch (Throwable ex) {
-               ex.printStackTrace();
-            }
-         }
-      };
-      consumingThread.start();
-      consumerReady.await();
-
-      producingThread.start();
-      producingThread.join();
-
-      final long tempUsageBySubscription = broker.getSystemUsage().getTempUsage().getUsage();
-      LOG.info("Orig Usage: " + origTempUsage + ", currentUsage: " + tempUsageBySubscription);
-      assertTrue("some temp store has been used", tempUsageBySubscription != origTempUsage);
-      consumerContinue.countDown();
-      consumingThread.join();
-      connection.close();
-
-      LOG.info("Subscription Usage: " + tempUsageBySubscription + ", endUsage: " + broker.getSystemUsage().getTempUsage().getUsage());
-
-      assertTrue("temp usage decreased with removed sub", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return broker.getSystemUsage().getTempUsage().getUsage() < tempUsageBySubscription;
-         }
-      }));
-   }
-
-   @Override
-   public void setUp() throws Exception {
-      super.setAutoFail(true);
-      super.setUp();
-      broker = new BrokerService();
-      broker.setDataDirectory("target" + File.separator + "activemq-data");
-      broker.setPersistent(true);
-      broker.setUseJmx(true);
-      broker.setAdvisorySupport(false);
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.getSystemUsage().getMemoryUsage().setLimit(1024L * 1024 * 64);
-
-      broker.addConnector("tcp://localhost:0").setName("Default");
-      broker.start();
-
-      connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
-   }
-
-   @Override
-   public void tearDown() throws Exception {
-      broker.stop();
-   }
-
-   public static Test suite() {
-      return suite(AMQ2314Test.class);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2356Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2356Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2356Test.java
deleted file mode 100644
index 2f9bb84..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2356Test.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/**
- * 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;
-
-import java.io.File;
-
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.store.kahadb.KahaDBStore;
-
-/*
- AMQ2356Test
- We have an environment where we have a very large number of destinations.
- In an effort to reduce the number of threads I have set the options
- -Dorg.apache.activemq.UseDedicatedTaskRunner=false
-
- and
-
- <policyEntry queue=">" optimizedDispatch="true"/>
-
- Unfortunately this very quickly leads to deadlocked queues.
-
- My environment is:
-
- ActiveMQ 5.2 Ubunty Jaunty kernel 2.6.28-14-generic #47-Ubuntu SMP (although only a single core on my system)
- TCP transportConnector
-
- To reproduce the bug (which I can do 100% of the time) I connect 5 consumers (AUTO_ACK) to 5 different queues.
- Then I start 5 producers and pair them up with a consumer on a queue, and they start sending PERSISTENT messages.
- I've set the producer to send 100 messages and disconnect, and the consumer to receive 100 messages and disconnect.
- The first pair usually gets through their 100 messages and disconnect, at which point all the other pairs have
- deadlocked at less than 30 messages each.
- */
-public class AMQ2356Test extends TestCase {
-
-   protected static final int MESSAGE_COUNT = 1000;
-   protected static final int NUMBER_OF_PAIRS = 10;
-   protected BrokerService broker;
-   protected String brokerURL = ActiveMQConnectionFactory.DEFAULT_BROKER_BIND_URL;
-   protected int destinationCount;
-
-   public void testScenario() throws Exception {
-      for (int i = 0; i < NUMBER_OF_PAIRS; i++) {
-         ActiveMQQueue queue = new ActiveMQQueue(getClass().getName() + ":" + i);
-         ProducerConsumerPair cp = new ProducerConsumerPair();
-         cp.start(this.brokerURL, queue, MESSAGE_COUNT);
-         cp.testRun();
-         cp.stop();
-      }
-   }
-
-   protected Destination getDestination(Session session) throws JMSException {
-      String destinationName = getClass().getName() + "." + destinationCount++;
-      return session.createQueue(destinationName);
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      if (broker == null) {
-         broker = createBroker();
-      }
-      super.setUp();
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      super.tearDown();
-      if (broker != null) {
-         broker.stop();
-      }
-   }
-
-   protected BrokerService createBroker() throws Exception {
-      BrokerService answer = new BrokerService();
-      configureBroker(answer);
-      answer.start();
-      return answer;
-   }
-
-   protected void configureBroker(BrokerService answer) throws Exception {
-      File dataFileDir = new File("target/test-amq-data/bugs/AMQ2356/kahadb");
-      KahaDBStore kaha = new KahaDBStore();
-      kaha.setDirectory(dataFileDir);
-      answer.setUseJmx(false);
-      // Setup a destination policy where it takes only 1 message at a time.
-      PolicyMap policyMap = new PolicyMap();
-      PolicyEntry policy = new PolicyEntry();
-      policy.setOptimizedDispatch(true);
-      policyMap.setDefaultEntry(policy);
-      answer.setDestinationPolicy(policyMap);
-
-      answer.setAdvisorySupport(false);
-      answer.setEnableStatistics(false);
-      answer.setDeleteAllMessagesOnStartup(true);
-      answer.addConnector(brokerURL);
-
-   }
-
-   static class ProducerConsumerPair {
-
-      private Destination destination;
-      private MessageProducer producer;
-      private MessageConsumer consumer;
-      private Connection producerConnection;
-      private Connection consumerConnection;
-      private int numberOfMessages;
-
-      ProducerConsumerPair() {
-
-      }
-
-      void start(String brokerURL, final Destination dest, int msgNum) throws Exception {
-         this.destination = dest;
-         this.numberOfMessages = msgNum;
-         ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(brokerURL);
-         this.producerConnection = cf.createConnection();
-         this.producerConnection.start();
-         this.consumerConnection = cf.createConnection();
-         this.consumerConnection.start();
-         this.producer = createProducer(this.producerConnection);
-         this.consumer = createConsumer(this.consumerConnection);
-      }
-
-      void testRun() throws Exception {
-
-         Session s = this.producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         for (int i = 0; i < this.numberOfMessages; i++) {
-            BytesMessage msg = s.createBytesMessage();
-            msg.writeBytes(new byte[1024]);
-            this.producer.send(msg);
-         }
-         int received = 0;
-         for (int i = 0; i < this.numberOfMessages; i++) {
-            Message msg = this.consumer.receive();
-            assertNotNull(msg);
-            received++;
-         }
-         assertEquals("Messages received on " + this.destination, this.numberOfMessages, received);
-
-      }
-
-      void stop() throws Exception {
-         if (this.producerConnection != null) {
-            this.producerConnection.close();
-         }
-         if (this.consumerConnection != null) {
-            this.consumerConnection.close();
-         }
-      }
-
-      private MessageProducer createProducer(Connection connection) throws Exception {
-         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageProducer result = session.createProducer(this.destination);
-         return result;
-      }
-
-      private MessageConsumer createConsumer(Connection connection) throws Exception {
-
-         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageConsumer result = session.createConsumer(this.destination);
-         return result;
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2364Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2364Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2364Test.java
deleted file mode 100644
index 5f79b6c..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2364Test.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * 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;
-//package org.apache.activemq.transport.failover;
-
-import static org.junit.Assert.assertEquals;
-
-import java.lang.reflect.Field;
-import java.net.URI;
-import java.util.Collection;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CountDownLatch;
-
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ConnectionId;
-import org.apache.activemq.state.ConnectionState;
-import org.apache.activemq.state.ConnectionStateTracker;
-import org.apache.activemq.state.TransactionState;
-import org.apache.activemq.transport.MutexTransport;
-import org.apache.activemq.transport.ResponseCorrelator;
-import org.apache.activemq.transport.failover.FailoverTransport;
-import org.junit.Test;
-
-public class AMQ2364Test {
-
-   @SuppressWarnings("unchecked")
-   @Test
-   public void testRollbackLeak() throws Exception {
-
-      int messageCount = 1000;
-      URI failoverUri = new URI("failover:(vm://localhost)?jms.redeliveryPolicy.maximumRedeliveries=0");
-
-      Destination dest = new ActiveMQQueue("Failover.Leak");
-
-      ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(failoverUri);
-      ActiveMQConnection connection = (ActiveMQConnection) cf.createConnection();
-      connection.start();
-      final Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-
-      MessageProducer producer = session.createProducer(dest);
-
-      for (int i = 0; i < messageCount; ++i)
-         producer.send(session.createTextMessage("Test message #" + i));
-      producer.close();
-      session.commit();
-
-      MessageConsumer consumer = session.createConsumer(dest);
-
-      final CountDownLatch latch = new CountDownLatch(messageCount);
-      consumer.setMessageListener(new MessageListener() {
-
-         @Override
-         public void onMessage(Message msg) {
-            try {
-               session.rollback();
-            }
-            catch (JMSException e) {
-               e.printStackTrace();
-            }
-            finally {
-               latch.countDown();
-            }
-         }
-      });
-
-      latch.await();
-      consumer.close();
-      session.close();
-
-      ResponseCorrelator respCorr = (ResponseCorrelator) connection.getTransport();
-      MutexTransport mutexTrans = (MutexTransport) respCorr.getNext();
-      FailoverTransport failoverTrans = (FailoverTransport) mutexTrans.getNext();
-      Field stateTrackerField = FailoverTransport.class.getDeclaredField("stateTracker");
-      stateTrackerField.setAccessible(true);
-      ConnectionStateTracker stateTracker = (ConnectionStateTracker) stateTrackerField.get(failoverTrans);
-      Field statesField = ConnectionStateTracker.class.getDeclaredField("connectionStates");
-      statesField.setAccessible(true);
-      ConcurrentHashMap<ConnectionId, ConnectionState> states = (ConcurrentHashMap<ConnectionId, ConnectionState>) statesField.get(stateTracker);
-
-      ConnectionState state = states.get(connection.getConnectionInfo().getConnectionId());
-
-      Collection<TransactionState> transactionStates = state.getTransactionStates();
-
-      connection.stop();
-      connection.close();
-
-      assertEquals("Transaction states not cleaned up", 0, transactionStates.size());
-   }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2383Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2383Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2383Test.java
deleted file mode 100644
index f4e7908..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2383Test.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.*;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.junit.Test;
-
-public class AMQ2383Test {
-
-   @Test
-   public void activeMQTest() throws Exception {
-      Destination dest = ActiveMQDestination.createDestination("testQueue", ActiveMQDestination.QUEUE_TYPE);
-      ConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost?broker.useJmx=false&broker.persistent=false");
-      Connection producerConnection = factory.createConnection();
-      producerConnection.start();
-      Connection consumerConnection = factory.createConnection();
-      consumerConnection.start();
-
-      Session producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = producerSession.createProducer(dest);
-      TextMessage sentMsg = producerSession.createTextMessage("test...");
-      producer.send(sentMsg);
-      producerSession.close();
-
-      Session consumerSession = consumerConnection.createSession(true, Session.SESSION_TRANSACTED);
-      MessageConsumer consumer = consumerSession.createConsumer(dest);
-      TextMessage receivedMsg = (TextMessage) consumer.receive();
-      consumerSession.rollback();
-      consumerSession.close();
-
-      assertEquals(sentMsg, receivedMsg);
-
-      producerConnection.close();
-      consumerConnection.close();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2401Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2401Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2401Test.java
deleted file mode 100644
index edd4e8f..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2401Test.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/**
- * 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;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.broker.region.policy.VMPendingQueueMessageStoragePolicy;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * An AMQ-2401 Test
- */
-public class AMQ2401Test extends TestCase implements MessageListener {
-
-   private BrokerService broker;
-   private ActiveMQConnectionFactory factory;
-   private static final int SEND_COUNT = 500;
-   private static final int CONSUMER_COUNT = 50;
-   private static final int PRODUCER_COUNT = 1;
-   private static final int LOG_INTERVAL = 10;
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ2401Test.class);
-
-   private final ArrayList<Service> services = new ArrayList<>(CONSUMER_COUNT + PRODUCER_COUNT);
-   private int count = 0;
-   private CountDownLatch latch;
-
-   @Override
-   protected void setUp() throws Exception {
-      broker = new BrokerService();
-      broker.setDataDirectory("target" + File.separator + "test-data" + File.separator + "AMQ2401Test");
-      broker.setDeleteAllMessagesOnStartup(true);
-      String connectionUri = broker.addConnector("tcp://0.0.0.0:0").getPublishableConnectString();
-      PolicyMap policies = new PolicyMap();
-      PolicyEntry entry = new PolicyEntry();
-      entry.setMemoryLimit(1024 * 100);
-      entry.setProducerFlowControl(true);
-      entry.setPendingQueuePolicy(new VMPendingQueueMessageStoragePolicy());
-      entry.setQueue(">");
-      policies.setDefaultEntry(entry);
-      broker.setDestinationPolicy(policies);
-      broker.setUseJmx(false);
-      broker.start();
-      broker.waitUntilStarted();
-
-      factory = new ActiveMQConnectionFactory(connectionUri);
-      super.setUp();
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      broker.stop();
-      broker.waitUntilStopped();
-   }
-
-   public void testDupsOk() throws Exception {
-
-      latch = new CountDownLatch(SEND_COUNT);
-
-      for (int i = 0; i < CONSUMER_COUNT; i++) {
-         TestConsumer consumer = new TestConsumer();
-         consumer.start();
-         services.add(consumer);
-      }
-      for (int i = 0; i < PRODUCER_COUNT; i++) {
-         TestProducer producer = new TestProducer();
-         producer.start();
-         services.add(producer);
-      }
-
-      waitForMessageReceipt(TimeUnit.SECONDS.toMillis(30));
-   }
-
-   @Override
-   public void onMessage(Message message) {
-      latch.countDown();
-      if (++count % LOG_INTERVAL == 0) {
-         LOG.debug("Received message " + count);
-      }
-
-      try {
-         Thread.sleep(1);
-      }
-      catch (InterruptedException e) {
-         Thread.currentThread().interrupt();
-      }
-   }
-
-   /**
-    * @throws InterruptedException
-    * @throws TimeoutException
-    */
-   private void waitForMessageReceipt(long timeout) throws InterruptedException, TimeoutException {
-      if (!latch.await(timeout, TimeUnit.MILLISECONDS)) {
-         throw new TimeoutException(String.format("Consumner didn't receive expected # of messages, %d of %d received.", latch.getCount(), SEND_COUNT));
-      }
-   }
-
-   private interface Service {
-
-      public void start() throws Exception;
-
-      public void close();
-   }
-
-   private class TestProducer implements Runnable, Service {
-
-      Thread thread;
-      BytesMessage message;
-
-      Connection connection;
-      Session session;
-      MessageProducer producer;
-
-      TestProducer() throws Exception {
-         thread = new Thread(this, "TestProducer");
-         connection = factory.createConnection();
-         connection.start();
-         session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
-         producer = session.createProducer(session.createQueue("AMQ2401Test"));
-      }
-
-      @Override
-      public void start() {
-         thread.start();
-      }
-
-      @Override
-      public void run() {
-
-         int count = SEND_COUNT / PRODUCER_COUNT;
-         for (int i = 1; i <= count; i++) {
-            try {
-               if ((i % LOG_INTERVAL) == 0) {
-                  LOG.debug("Sending: " + i);
-               }
-               message = session.createBytesMessage();
-               message.writeBytes(new byte[1024]);
-               producer.send(message);
-            }
-            catch (JMSException jmse) {
-               jmse.printStackTrace();
-               break;
-            }
-         }
-      }
-
-      @Override
-      public void close() {
-         try {
-            connection.close();
-         }
-         catch (JMSException e) {
-         }
-      }
-   }
-
-   private class TestConsumer implements Runnable, Service {
-
-      ActiveMQConnection connection;
-      Session session;
-      MessageConsumer consumer;
-
-      TestConsumer() throws Exception {
-         factory.setOptimizeAcknowledge(false);
-         connection = (ActiveMQConnection) factory.createConnection();
-
-         session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
-         consumer = session.createConsumer(session.createQueue("AMQ2401Test"));
-
-         consumer.setMessageListener(AMQ2401Test.this);
-      }
-
-      @Override
-      public void start() throws Exception {
-         connection.start();
-      }
-
-      @Override
-      public void close() {
-         try {
-            connection.close();
-         }
-         catch (JMSException e) {
-         }
-      }
-
-      @Override
-      public void run() {
-         while (latch.getCount() > 0) {
-            try {
-               onMessage(consumer.receive());
-            }
-            catch (Exception e) {
-               e.printStackTrace();
-            }
-         }
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2413Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2413Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2413Test.java
deleted file mode 100644
index ed1af90..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2413Test.java
+++ /dev/null
@@ -1,344 +0,0 @@
-/**
- * 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;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Vector;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import junit.framework.Test;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.CombinationTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.broker.region.policy.VMPendingQueueMessageStoragePolicy;
-import org.apache.activemq.command.MessageId;
-import org.apache.activemq.command.ProducerId;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ2413Test extends CombinationTestSupport implements MessageListener {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ2413Test.class);
-   BrokerService broker;
-   private ActiveMQConnectionFactory factory;
-
-   private static final int HANG_THRESHOLD = 60;
-   private static final int SEND_COUNT = 1000;
-   private static final int RECEIVER_THINK_TIME = 1;
-   private static final int CONSUMER_COUNT = 1;
-   private static final int PRODUCER_COUNT = 50;
-   private static final int TO_SEND = SEND_COUNT / PRODUCER_COUNT;
-
-   public int deliveryMode = DeliveryMode.NON_PERSISTENT;
-   public int ackMode = Session.DUPS_OK_ACKNOWLEDGE;
-   public boolean useVMCursor = false;
-   public boolean useOptimizeAcks = false;
-
-   private final ArrayList<Service> services = new ArrayList<>(CONSUMER_COUNT + PRODUCER_COUNT);
-   AtomicInteger count = new AtomicInteger(0);
-   Semaphore receivedMessages;
-   AtomicBoolean running = new AtomicBoolean(false);
-
-   public void initCombos() {
-      addCombinationValues("deliveryMode", new Object[]{DeliveryMode.PERSISTENT, DeliveryMode.NON_PERSISTENT});
-      addCombinationValues("ackMode", new Object[]{Session.DUPS_OK_ACKNOWLEDGE, Session.AUTO_ACKNOWLEDGE});
-      addCombinationValues("useVMCursor", new Object[]{true, false});
-      // addCombinationValues("useOptimizeAcks", new Object[] {true, false});
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      broker = new BrokerService();
-      broker.setDataDirectory("target" + File.separator + "test-data" + File.separator + "AMQ2401Test");
-      broker.setDeleteAllMessagesOnStartup(true);
-
-      KahaDBPersistenceAdapter kahaDb = (KahaDBPersistenceAdapter) broker.getPersistenceAdapter();
-      kahaDb.setConcurrentStoreAndDispatchQueues(false);
-      broker.addConnector("tcp://0.0.0.0:2401");
-      PolicyMap policies = new PolicyMap();
-      PolicyEntry entry = new PolicyEntry();
-      entry.setMemoryLimit(1024 * 1024);
-      entry.setProducerFlowControl(true);
-      if (useVMCursor) {
-         entry.setPendingQueuePolicy(new VMPendingQueueMessageStoragePolicy());
-      }
-      entry.setQueue(">");
-      policies.setDefaultEntry(entry);
-      broker.setDestinationPolicy(policies);
-      broker.start();
-      broker.waitUntilStarted();
-
-      count.set(0);
-      receivedMessages = new Semaphore(0);
-
-      factory = new ActiveMQConnectionFactory("tcp://0.0.0.0:2401");
-      // factory = new ActiveMQConnectionFactory("vm://localhost?broker.useJmx=false&broker.persistent=false");
-      setAutoFail(true);
-      super.setUp();
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      running.set(false);
-      for (Service service : services) {
-         service.close();
-      }
-
-      broker.stop();
-      broker.waitUntilStopped();
-
-      super.tearDown();
-   }
-
-   public void testReceipt() throws Exception {
-
-      running.set(true);
-
-      for (int i = 0; i < CONSUMER_COUNT; i++) {
-         TestConsumer consumer = new TestConsumer();
-         consumer.start();
-         services.add(consumer);
-      }
-      for (int i = 0; i < PRODUCER_COUNT; i++) {
-         TestProducer producer = new TestProducer(i);
-         producer.start();
-         services.add(producer);
-      }
-
-      waitForMessageReceipt();
-   }
-
-   /*
-    * (non-Javadoc)
-    *
-    * @see javax.jms.MessageListener#onMessage(javax.jms.Message)
-    */
-   @Override
-   public void onMessage(Message message) {
-      receivedMessages.release();
-      if (count.incrementAndGet() % 100 == 0) {
-         LOG.info("Received message " + count);
-      }
-      track(message);
-      if (RECEIVER_THINK_TIME > 0) {
-         try {
-            Thread.sleep(RECEIVER_THINK_TIME);
-         }
-         catch (InterruptedException e) {
-            Thread.currentThread().interrupt();
-         }
-      }
-
-   }
-
-   HashMap<ProducerId, boolean[]> tracker = new HashMap<>();
-
-   private synchronized void track(Message message) {
-      try {
-         MessageId id = new MessageId(message.getJMSMessageID());
-         ProducerId pid = id.getProducerId();
-         int seq = (int) id.getProducerSequenceId();
-         boolean[] ids = tracker.get(pid);
-         if (ids == null) {
-            ids = new boolean[TO_SEND + 1];
-            ids[seq] = true;
-            tracker.put(pid, ids);
-         }
-         else {
-            assertTrue("not already received: " + id, !ids[seq]);
-            ids[seq] = true;
-         }
-      }
-      catch (Exception e) {
-         LOG.error(e.toString());
-      }
-   }
-
-   /**
-    * @throws InterruptedException
-    * @throws TimeoutException
-    */
-   private void waitForMessageReceipt() throws InterruptedException, TimeoutException {
-      try {
-         while (count.get() < SEND_COUNT) {
-            if (!receivedMessages.tryAcquire(HANG_THRESHOLD, TimeUnit.SECONDS)) {
-               if (count.get() == SEND_COUNT)
-                  break;
-               verifyTracking();
-               throw new TimeoutException("@count=" + count.get() + " Message not received for more than " + HANG_THRESHOLD + " seconds");
-            }
-         }
-      }
-      finally {
-         running.set(false);
-      }
-   }
-
-   private void verifyTracking() {
-      Vector<MessageId> missing = new Vector<>();
-      for (ProducerId pid : tracker.keySet()) {
-         boolean[] ids = tracker.get(pid);
-         for (int i = 1; i < TO_SEND + 1; i++) {
-            if (!ids[i]) {
-               missing.add(new MessageId(pid, i));
-            }
-         }
-      }
-      assertTrue("No missing messages: " + missing, missing.isEmpty());
-   }
-
-   private interface Service {
-
-      public void start() throws Exception;
-
-      public void close();
-   }
-
-   private class TestProducer implements Runnable, Service {
-
-      Thread thread;
-      BytesMessage message;
-      Connection connection;
-      Session session;
-      MessageProducer producer;
-
-      TestProducer(int id) throws Exception {
-         thread = new Thread(this, "TestProducer-" + id);
-         connection = factory.createConnection();
-         connection.start();
-         session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
-         producer = session.createProducer(session.createQueue("AMQ2401Test"));
-      }
-
-      @Override
-      public void start() {
-         thread.start();
-      }
-
-      @Override
-      public void run() {
-
-         int i = 1;
-         for (; i <= TO_SEND; i++) {
-            try {
-
-               if (+i % 100 == 0) {
-                  LOG.info(Thread.currentThread().getName() + " Sending message " + i);
-               }
-               message = session.createBytesMessage();
-               message.writeBytes(new byte[1024]);
-               producer.setDeliveryMode(deliveryMode);
-               producer.send(message);
-            }
-            catch (JMSException jmse) {
-               jmse.printStackTrace();
-               break;
-            }
-         }
-         LOG.info(Thread.currentThread().getName() + " Sent: " + (i - 1));
-      }
-
-      @Override
-      public void close() {
-         try {
-            connection.close();
-         }
-         catch (JMSException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-         }
-      }
-   }
-
-   private class TestConsumer implements Runnable, Service {
-
-      ActiveMQConnection connection;
-      Session session;
-      MessageConsumer consumer;
-
-      TestConsumer() throws Exception {
-         factory.setOptimizeAcknowledge(false);
-         connection = (ActiveMQConnection) factory.createConnection();
-         if (useOptimizeAcks) {
-            connection.setOptimizeAcknowledge(true);
-         }
-
-         session = connection.createSession(false, ackMode);
-         consumer = session.createConsumer(session.createQueue("AMQ2401Test"));
-
-         consumer.setMessageListener(AMQ2413Test.this);
-      }
-
-      @Override
-      public void start() throws Exception {
-         connection.start();
-      }
-
-      @Override
-      public void close() {
-         try {
-            connection.close();
-         }
-         catch (JMSException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-         }
-      }
-
-      /*
-       * (non-Javadoc)
-       *
-       * @see java.lang.Runnable#run()
-       */
-      @Override
-      public void run() {
-         while (running.get()) {
-            try {
-               onMessage(consumer.receive());
-            }
-            catch (Exception e) {
-               e.printStackTrace();
-            }
-         }
-      }
-   }
-
-   public static Test suite() {
-      return suite(AMQ2413Test.class);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2439Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2439Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2439Test.java
deleted file mode 100644
index f4fb8a2..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2439Test.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * 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;
-
-import java.net.URI;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
-
-import org.apache.activemq.JmsMultipleBrokersTestSupport;
-import org.apache.activemq.broker.jmx.BrokerView;
-import org.apache.activemq.util.Wait;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ2439Test extends JmsMultipleBrokersTestSupport {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ2439Test.class);
-   Destination dest;
-
-   public void testDuplicatesThroughNetwork() throws Exception {
-      assertEquals("received expected amount", 500, receiveExactMessages("BrokerB", 500));
-      assertEquals("received expected amount", 500, receiveExactMessages("BrokerB", 500));
-      validateQueueStats();
-   }
-
-   private void validateQueueStats() throws Exception {
-      final BrokerView brokerView = brokers.get("BrokerA").broker.getAdminView();
-      assertEquals("enequeue is correct", 1000, brokerView.getTotalEnqueueCount());
-
-      assertTrue("dequeue is correct", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            LOG.info("dequeue count (want 1000), is : " + brokerView.getTotalDequeueCount());
-            return 1000 == brokerView.getTotalDequeueCount();
-         }
-      }));
-   }
-
-   protected int receiveExactMessages(String brokerName, int msgCount) throws Exception {
-
-      BrokerItem brokerItem = brokers.get(brokerName);
-      Connection connection = brokerItem.createConnection();
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer consumer = session.createConsumer(dest);
-
-      Message msg;
-      int i;
-      for (i = 0; i < msgCount; i++) {
-         msg = consumer.receive(1000);
-         if (msg == null) {
-            break;
-         }
-      }
-
-      connection.close();
-      brokerItem.connections.remove(connection);
-
-      return i;
-   }
-
-   @Override
-   public void setUp() throws Exception {
-      super.setUp();
-      createBroker(new URI("broker:(tcp://localhost:61616)/BrokerA?persistent=true&deleteAllMessagesOnStartup=true&advisorySupport=false"));
-      createBroker(new URI("broker:(tcp://localhost:61617)/BrokerB?persistent=true&deleteAllMessagesOnStartup=true&useJmx=false"));
-      bridgeBrokers("BrokerA", "BrokerB");
-
-      startAllBrokers();
-
-      // Create queue
-      dest = createDestination("TEST.FOO", false);
-      sendMessages("BrokerA", dest, 1000);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2489Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2489Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2489Test.java
deleted file mode 100644
index bcd2db1..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2489Test.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/**
- * 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;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQSession;
-import org.apache.activemq.TestSupport;
-import org.apache.activemq.command.ActiveMQQueue;
-
-/**
- * In CLIENT_ACKNOWLEDGE and INDIVIDUAL_ACKNOWLEDGE modes following exception
- * occurs when ASYNCH consumers acknowledges messages in not in order they
- * received the messages.
- * <p>
- * Exception thrown on broker side:
- * <p>
- * {@code javax.jms.JMSException: Could not correlate acknowledgment with
- * dispatched message: MessageAck}
- *
- * @author daroo
- */
-public class AMQ2489Test extends TestSupport {
-
-   private final static String SEQ_NUM_PROPERTY = "seqNum";
-
-   private final static int TOTAL_MESSAGES_CNT = 2;
-   private final static int CONSUMERS_CNT = 2;
-
-   private final CountDownLatch LATCH = new CountDownLatch(TOTAL_MESSAGES_CNT);
-
-   private Connection connection;
-
-   @Override
-   protected void setUp() throws Exception {
-      super.setUp();
-      connection = createConnection();
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      if (connection != null) {
-         connection.close();
-         connection = null;
-      }
-      super.tearDown();
-   }
-
-   public void testUnorderedClientAcknowledge() throws Exception {
-      doUnorderedAck(Session.CLIENT_ACKNOWLEDGE);
-   }
-
-   public void testUnorderedIndividualAcknowledge() throws Exception {
-      doUnorderedAck(ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE);
-   }
-
-   /**
-    * Main test method
-    *
-    * @param acknowledgmentMode - ACK mode to be used by consumers
-    * @throws Exception
-    */
-   protected void doUnorderedAck(int acknowledgmentMode) throws Exception {
-      List<Consumer> consumers = null;
-      Session producerSession = null;
-
-      connection.start();
-      // Because exception is thrown on broker side only, let's set up
-      // exception listener to get it
-      final TestExceptionListener exceptionListener = new TestExceptionListener();
-      connection.setExceptionListener(exceptionListener);
-      try {
-         consumers = new ArrayList<>();
-         // start customers
-         for (int i = 0; i < CONSUMERS_CNT; i++) {
-            consumers.add(new Consumer(acknowledgmentMode));
-         }
-
-         // produce few test messages
-         producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         final MessageProducer producer = producerSession.createProducer(new ActiveMQQueue(getQueueName()));
-         producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-         for (int i = 0; i < TOTAL_MESSAGES_CNT; i++) {
-            final Message message = producerSession.createTextMessage("test");
-            // assign each message sequence number
-            message.setIntProperty(SEQ_NUM_PROPERTY, i);
-            producer.send(message);
-         }
-
-         // during each onMessage() calls consumers decreases the LATCH
-         // counter.
-         //
-         // so, let's wait till all messages are consumed.
-         //
-         LATCH.await();
-
-         // wait a bit more to give exception listener a chance be populated
-         // with
-         // broker's error
-         TimeUnit.SECONDS.sleep(1);
-
-         assertFalse(exceptionListener.getStatusText(), exceptionListener.hasExceptions());
-
-      }
-      finally {
-         if (producerSession != null)
-            producerSession.close();
-
-         if (consumers != null) {
-            for (Consumer c : consumers) {
-               c.close();
-            }
-         }
-      }
-   }
-
-   protected String getQueueName() {
-      return getClass().getName() + "." + getName();
-   }
-
-   public final class Consumer implements MessageListener {
-
-      final Session session;
-
-      private Consumer(int acknowledgmentMode) {
-         try {
-            session = connection.createSession(false, acknowledgmentMode);
-            final Queue queue = session.createQueue(getQueueName() + "?consumer.prefetchSize=1");
-            final MessageConsumer consumer = session.createConsumer(queue);
-            consumer.setMessageListener(this);
-         }
-         catch (JMSException e) {
-            e.printStackTrace();
-            throw new RuntimeException(e);
-         }
-      }
-
-      @Override
-      public void onMessage(Message message) {
-         try {
-            // retrieve sequence number assigned by producer...
-            final int seqNum = message.getIntProperty(SEQ_NUM_PROPERTY);
-
-            // ...and let's delay every second message a little bit before
-            // acknowledgment
-            if ((seqNum % 2) == 0) {
-               System.out.println("Delayed message sequence numeber: " + seqNum);
-               try {
-                  TimeUnit.SECONDS.sleep(1);
-               }
-               catch (InterruptedException e) {
-                  Thread.currentThread().interrupt();
-               }
-            }
-
-            message.acknowledge();
-         }
-         catch (JMSException e) {
-            e.printStackTrace();
-            throw new RuntimeException(e);
-         }
-         finally {
-            // decrease LATCH counter in the main test method.
-            LATCH.countDown();
-         }
-      }
-
-      private void close() {
-         if (session != null) {
-            try {
-               session.close();
-            }
-            catch (JMSException e) {
-               e.printStackTrace();
-               throw new RuntimeException(e);
-            }
-         }
-      }
-   }
-
-   public final class TestExceptionListener implements ExceptionListener {
-
-      private final java.util.Queue<Exception> exceptions = new ConcurrentLinkedQueue<>();
-
-      @Override
-      public void onException(JMSException e) {
-         exceptions.add(e);
-      }
-
-      public boolean hasExceptions() {
-         return exceptions.isEmpty() == false;
-      }
-
-      public String getStatusText() {
-         final StringBuilder str = new StringBuilder();
-         str.append("Exceptions count on broker side: " + exceptions.size() + ".\nMessages:\n");
-         for (Exception e : exceptions) {
-            str.append(e.getMessage() + "\n\n");
-         }
-         return str.toString();
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2512Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2512Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2512Test.java
deleted file mode 100644
index b18a7b4..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2512Test.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/**
- * 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;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.store.kahadb.KahaDBStore;
-import org.apache.activemq.util.IOHelper;
-
-public class AMQ2512Test extends EmbeddedBrokerTestSupport {
-
-   private static Connection connection;
-   private final static String QUEUE_NAME = "dee.q";
-   private final static int INITIAL_MESSAGES_CNT = 1000;
-   private final static int WORKER_INTERNAL_ITERATIONS = 100;
-   private final static int TOTAL_MESSAGES_CNT = INITIAL_MESSAGES_CNT * WORKER_INTERNAL_ITERATIONS + INITIAL_MESSAGES_CNT;
-   private final static byte[] payload = new byte[5 * 1024];
-   private final static String TEXT = new String(payload);
-
-   private final static String PRP_INITIAL_ID = "initial-id";
-   private final static String PRP_WORKER_ID = "worker-id";
-
-   private final static CountDownLatch LATCH = new CountDownLatch(TOTAL_MESSAGES_CNT);
-
-   private final static AtomicInteger ON_MSG_COUNTER = new AtomicInteger();
-
-   public void testKahaDBFailure() throws Exception {
-      final ConnectionFactory fac = new ActiveMQConnectionFactory(this.bindAddress);
-      connection = fac.createConnection();
-      final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      final Queue queue = session.createQueue(QUEUE_NAME);
-      final MessageProducer producer = session.createProducer(queue);
-      producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-      connection.start();
-
-      final long startTime = System.nanoTime();
-
-      final List<Consumer> consumers = new ArrayList<>();
-      for (int i = 0; i < 20; i++) {
-         consumers.add(new Consumer("worker-" + i));
-      }
-
-      for (int i = 0; i < INITIAL_MESSAGES_CNT; i++) {
-         final TextMessage msg = session.createTextMessage(TEXT);
-         msg.setStringProperty(PRP_INITIAL_ID, "initial-" + i);
-         producer.send(msg);
-      }
-
-      LATCH.await();
-      final long endTime = System.nanoTime();
-      System.out.println("Total execution time = " + TimeUnit.MILLISECONDS.convert(endTime - startTime, TimeUnit.NANOSECONDS) + " [ms].");
-      System.out.println("Rate = " + TOTAL_MESSAGES_CNT / TimeUnit.SECONDS.convert(endTime - startTime, TimeUnit.NANOSECONDS) + " [msg/s].");
-
-      for (Consumer c : consumers) {
-         c.close();
-      }
-      connection.close();
-   }
-
-   private final static class Consumer implements MessageListener {
-
-      private final String name;
-      private final Session session;
-      private final MessageProducer producer;
-
-      private Consumer(String name) {
-         this.name = name;
-         try {
-            session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-            final Queue queue = session.createQueue(QUEUE_NAME + "?consumer.prefetchSize=10");
-            producer = session.createProducer(queue);
-            producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-            final MessageConsumer consumer = session.createConsumer(queue);
-            consumer.setMessageListener(this);
-         }
-         catch (JMSException e) {
-            e.printStackTrace();
-            throw new RuntimeException(e);
-         }
-      }
-
-      @Override
-      public void onMessage(Message message) {
-         final TextMessage msg = (TextMessage) message;
-         try {
-            if (!msg.propertyExists(PRP_WORKER_ID)) {
-               for (int i = 0; i < WORKER_INTERNAL_ITERATIONS; i++) {
-                  final TextMessage newMsg = session.createTextMessage(msg.getText());
-                  newMsg.setStringProperty(PRP_WORKER_ID, name + "-" + i);
-                  newMsg.setStringProperty(PRP_INITIAL_ID, msg.getStringProperty(PRP_INITIAL_ID));
-                  producer.send(newMsg);
-               }
-            }
-            msg.acknowledge();
-
-         }
-         catch (JMSException e) {
-            e.printStackTrace();
-            throw new RuntimeException(e);
-         }
-         finally {
-            final int onMsgCounter = ON_MSG_COUNTER.getAndIncrement();
-            if (onMsgCounter % 1000 == 0) {
-               System.out.println("message received: " + onMsgCounter);
-            }
-            LATCH.countDown();
-         }
-      }
-
-      private void close() {
-         if (session != null) {
-            try {
-               session.close();
-            }
-            catch (JMSException e) {
-               e.printStackTrace();
-               throw new RuntimeException(e);
-            }
-         }
-      }
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      bindAddress = "tcp://0.0.0.0:61617";
-      super.setUp();
-   }
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      File dataFileDir = new File("target/test-amq-2512/datadb");
-      IOHelper.mkdirs(dataFileDir);
-      IOHelper.deleteChildren(dataFileDir);
-      KahaDBStore kaha = new KahaDBStore();
-      kaha.setDirectory(dataFileDir);
-      BrokerService answer = new BrokerService();
-      answer.setPersistenceAdapter(kaha);
-
-      kaha.setEnableJournalDiskSyncs(false);
-      //kaha.setIndexCacheSize(10);
-      answer.setDataDirectoryFile(dataFileDir);
-      answer.setUseJmx(false);
-      answer.addConnector(bindAddress);
-      return answer;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2513Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2513Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2513Test.java
deleted file mode 100644
index eb25bdd..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2513Test.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/**
- * 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;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.management.ObjectName;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.DestinationViewMBean;
-import org.apache.activemq.broker.jmx.ManagementContext;
-
-/**
- * This unit test verifies an issue when
- * javax.management.InstanceNotFoundException is thrown after subsequent startups when
- * managementContext createConnector="false"
- */
-public class AMQ2513Test extends TestCase {
-
-   private BrokerService broker;
-   private String connectionUri;
-
-   void createBroker(boolean deleteAllMessagesOnStartup) throws Exception {
-      broker = new BrokerService();
-      broker.setBrokerName("localhost");
-      broker.setUseJmx(true);
-      broker.setDeleteAllMessagesOnStartup(deleteAllMessagesOnStartup);
-      broker.addConnector("tcp://localhost:0");
-
-      ManagementContext ctx = new ManagementContext();
-      //if createConnector == true everything is fine
-      ctx.setCreateConnector(false);
-      broker.setManagementContext(ctx);
-
-      broker.start();
-      broker.waitUntilStarted();
-
-      connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
-   }
-
-   public void testJmx() throws Exception {
-      createBroker(true);
-
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri);
-      Connection connection = factory.createConnection();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = session.createProducer(session.createQueue("test"));
-      producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-      connection.start();
-
-      producer.send(session.createTextMessage("test123"));
-
-      DestinationViewMBean dv = createView();
-      assertTrue(dv.getQueueSize() > 0);
-
-      connection.close();
-
-      broker.stop();
-      broker.waitUntilStopped();
-
-      createBroker(false);
-      factory = new ActiveMQConnectionFactory(connectionUri);
-      connection = factory.createConnection();
-      session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      producer = session.createProducer(session.createQueue("test"));
-      producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-      connection.start();
-      producer.send(session.createTextMessage("test123"));
-      connection.close();
-
-      dv = createView();
-      assertTrue(dv.getQueueSize() > 0);
-
-      broker.stop();
-      broker.waitUntilStopped();
-
-   }
-
-   DestinationViewMBean createView() throws Exception {
-      String domain = "org.apache.activemq";
-      ObjectName name = new ObjectName(domain + ":type=Broker,brokerName=localhost," +
-                                          "destinationType=Queue,destinationName=test");
-      return (DestinationViewMBean) broker.getManagementContext().newProxyInstance(name, DestinationViewMBean.class, true);
-   }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2528Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2528Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2528Test.java
deleted file mode 100644
index 148ab32..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2528Test.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * 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;
-
-import javax.jms.Connection;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.broker.region.Queue;
-import org.junit.Assert;
-
-/**
- * This test demonstrates a bug in which calling
- * Queue#removeMatchingMessages("") generates an exception, whereas the JMS
- * specification states that an empty selector is valid.
- */
-public class AMQ2528Test extends EmbeddedBrokerTestSupport {
-
-   /**
-    * Setup the test so that the destination is a queue.
-    */
-   @Override
-   protected void setUp() throws Exception {
-      useTopic = false;
-      super.setUp();
-   }
-
-   /**
-    * This test enqueues test messages to destination and then verifies that
-    * {@link Queue#removeMatchingMessages("")} removes all the messages.
-    */
-   public void testRemoveMatchingMessages() throws Exception {
-      final int NUM_MESSAGES = 100;
-      final String MESSAGE_ID = "id";
-
-      // Enqueue the test messages.
-      Connection conn = createConnection();
-      try {
-         conn.start();
-         Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageProducer producer = session.createProducer(destination);
-         for (int id = 0; id < NUM_MESSAGES; id++) {
-            Message message = session.createMessage();
-            message.setIntProperty(MESSAGE_ID, id);
-            producer.send(message);
-         }
-         producer.close();
-         session.close();
-      }
-      finally {
-         conn.close();
-      }
-
-      // Verify that half of the messages can be removed by selector.
-      Queue queue = (Queue) broker.getRegionBroker().getDestinations(destination).iterator().next();
-
-      Assert.assertEquals(NUM_MESSAGES / 2, queue.removeMatchingMessages(MESSAGE_ID + " < " + NUM_MESSAGES / 2));
-
-      // Verify that the remainder of the messages can be removed by empty
-      // selector.
-      Assert.assertEquals(NUM_MESSAGES - NUM_MESSAGES / 2, queue.removeMatchingMessages(""));
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2571Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2571Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2571Test.java
deleted file mode 100644
index 0c3ef45..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2571Test.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * 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;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TemporaryQueue;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.broker.BrokerService;
-
-public class AMQ2571Test extends EmbeddedBrokerTestSupport {
-
-   public void testTempQueueClosing() {
-      try {
-         ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(this.bindAddress);
-         connectionFactory.setAlwaysSyncSend(true);
-
-         // First create session that will own the TempQueue
-         Connection connectionA = connectionFactory.createConnection();
-         connectionA.start();
-
-         Session sessionA = connectionA.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-         TemporaryQueue tempQueue = sessionA.createTemporaryQueue();
-
-         // Next, create session that will put messages on the queue.
-         Connection connectionB = connectionFactory.createConnection();
-         connectionB.start();
-
-         Session sessionB = connectionB.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-         // Create a producer for connection B.
-         final MessageProducer producerB = sessionB.createProducer(tempQueue);
-         producerB.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
-         final TextMessage message = sessionB.createTextMessage("Testing AMQ TempQueue.");
-
-         Thread sendingThread = new Thread(new Runnable() {
-            @Override
-            public void run() {
-               try {
-                  long end = System.currentTimeMillis() + 5 * 60 * 1000;
-                  // wait for exception on send
-                  while (System.currentTimeMillis() < end) {
-                     producerB.send(message);
-                  }
-               }
-               catch (JMSException e) {
-                  e.printStackTrace();
-               }
-            }
-         });
-
-         // Send 5000 messages.
-         sendingThread.start();
-         // Now close connection A. This will remove the TempQueue.
-         connectionA.close();
-         // Wait for the thread to finish.
-         sendingThread.join(5 * 60 * 1000);
-
-         // Sleep for a while to make sure that we should know that the
-         // TempQueue is gone.
-         //Thread.sleep(50);
-
-         // Now we test if we are able to send again.
-         try {
-            producerB.send(message);
-            fail("Involuntary recreated temporary queue.");
-         }
-         catch (JMSException e) {
-            // Got exception, just as we wanted because the creator of
-            // the TempQueue had closed the connection prior to the send.
-            assertTrue("TempQueue does not exist anymore.", true);
-         }
-      }
-      catch (Exception e) {
-         fail("Unexpected exception " + e);
-      }
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      bindAddress = "vm://localhost";
-      setAutoFail(true);
-      super.setUp();
-   }
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      BrokerService answer = new BrokerService();
-      answer.setPersistent(false);
-      answer.setUseJmx(false);
-      return answer;
-   }
-}
\ No newline at end of file


[03/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
index eb5bc61..c129791 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
@@ -16,29 +16,23 @@
  */
 package org.apache.activemq.transport.failover;
 
-import junit.framework.Test;
-
 import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.ActiveMQMessageConsumer;
 import org.apache.activemq.AutoFailTestSupport;
-import org.apache.activemq.TestSupport;
-import org.apache.activemq.broker.BrokerPlugin;
-import org.apache.activemq.broker.BrokerPluginSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.ConnectionContext;
-import org.apache.activemq.broker.ConsumerBrokerExchange;
-import org.apache.activemq.broker.ProducerBrokerExchange;
-import org.apache.activemq.broker.region.RegionBroker;
-import org.apache.activemq.broker.util.DestinationPathSeparatorBroker;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ConsumerInfo;
-import org.apache.activemq.command.MessageAck;
-import org.apache.activemq.command.TransactionId;
-import org.apache.activemq.store.PersistenceAdapter;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
+import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
 import org.apache.activemq.transport.TransportListener;
 import org.apache.activemq.util.SocketProxy;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMRules;
+import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -69,28 +63,30 @@ import java.util.concurrent.atomic.AtomicBoolean;
 // see https://issues.apache.org/activemq/browse/AMQ-2473
 
 // https://issues.apache.org/activemq/browse/AMQ-2590
-public class FailoverTransactionTest extends TestSupport {
+@RunWith(BMUnitRunner.class)
+public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
 
    private static final Logger LOG = LoggerFactory.getLogger(FailoverTransactionTest.class);
    private static final String QUEUE_NAME = "Failover.WithTx";
-   private static final String TRANSPORT_URI = "tcp://localhost:0";
-   private String url;
-   BrokerService broker;
+   private String url = newURI(0);
 
-   public static Test suite() {
-      return suite(FailoverTransactionTest.class);
-   }
+   private static final AtomicBoolean doByteman = new AtomicBoolean(false);
+   private static CountDownLatch brokerStopLatch;
+
+   private static SocketProxy proxy;
+   private static boolean firstSend;
+   private static int count;
+
+   private static EmbeddedJMS broker;
 
-   @Override
+   @Before
    public void setUp() throws Exception {
-      super.setMaxTestTime(2 * 60 * 1000); // some boxes can be real slow
-      super.setAutoFail(true);
-      super.setUp();
+      doByteman.set(false);
+      brokerStopLatch = new CountDownLatch(1);
    }
 
-   @Override
+   @After
    public void tearDown() throws Exception {
-      super.tearDown();
       stopBroker();
    }
 
@@ -101,39 +97,19 @@ public class FailoverTransactionTest extends TestSupport {
    }
 
    private void startCleanBroker() throws Exception {
-      startBroker(true);
-   }
-
-   public void startBroker(boolean deleteAllMessagesOnStartup) throws Exception {
-      broker = createBroker(deleteAllMessagesOnStartup);
-      broker.start();
+      startBroker();
    }
 
-   public void startBroker(boolean deleteAllMessagesOnStartup, String bindAddress) throws Exception {
-      broker = createBroker(deleteAllMessagesOnStartup, bindAddress);
+   public void startBroker() throws Exception {
+      broker = createBroker();
       broker.start();
    }
 
-   public BrokerService createBroker(boolean deleteAllMessagesOnStartup) throws Exception {
-      return createBroker(deleteAllMessagesOnStartup, TRANSPORT_URI);
-   }
-
-   public BrokerService createBroker(boolean deleteAllMessagesOnStartup, String bindAddress) throws Exception {
-      broker = new BrokerService();
-      broker.setUseJmx(false);
-      broker.setAdvisorySupport(false);
-      broker.addConnector(bindAddress);
-      broker.setDeleteAllMessagesOnStartup(deleteAllMessagesOnStartup);
-
-      url = broker.getTransportConnectors().get(0).getConnectUri().toString();
-
-      return broker;
-   }
-
    public void configureConnectionFactory(ActiveMQConnectionFactory factory) {
       // nothing to do
    }
 
+   @Test
    public void testFailoverProducerCloseBeforeTransaction() throws Exception {
       startCleanBroker();
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")");
@@ -148,55 +124,31 @@ public class FailoverTransactionTest extends TestSupport {
 
       // restart to force failover and connection state recovery before the commit
       broker.stop();
-      startBroker(false, url);
+      startBroker();
 
       session.commit();
-      assertNotNull("we got the message", consumer.receive(20000));
+      Assert.assertNotNull("we got the message", consumer.receive(20000));
       session.commit();
       connection.close();
    }
 
-   public void initCombosForTestFailoverCommitReplyLost() {
-      String osName = System.getProperty("os.name");
-      Object[] persistenceAdapters;
-      if (!osName.equalsIgnoreCase("AIX") && !osName.equalsIgnoreCase("SunOS")) {
-         persistenceAdapters = new Object[]{PersistenceAdapterChoice.KahaDB, PersistenceAdapterChoice.LevelDB, PersistenceAdapterChoice.JDBC};
-      }
-      else {
-         persistenceAdapters = new Object[]{PersistenceAdapterChoice.KahaDB, PersistenceAdapterChoice.JDBC};
-      }
-      addCombinationValues("defaultPersistenceAdapter", persistenceAdapters);
-   }
-
-   @SuppressWarnings("unchecked")
+   @Test
+   @BMRules(
+           rules = {
+                   @BMRule(
+                           name = "set no return response and stop the broker",
+                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+                           targetMethod = "processCommitTransactionOnePhase",
+                           targetLocation = "EXIT",
+                           binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
+                           action = "org.apache.activemq.transport.failover.FailoverTransactionTest.holdResponseAndStopBroker(context)")
+           }
+   )
    public void testFailoverCommitReplyLost() throws Exception {
 
-      broker = createBroker(true);
-      setDefaultPersistenceAdapter(broker);
-
-      broker.setPlugins(new BrokerPlugin[]{new BrokerPluginSupport() {
-         @Override
-         public void commitTransaction(ConnectionContext context,
-                                       TransactionId xid,
-                                       boolean onePhase) throws Exception {
-            super.commitTransaction(context, xid, onePhase);
-            // so commit will hang as if reply is lost
-            context.setDontSendReponse(true);
-            Executors.newSingleThreadExecutor().execute(new Runnable() {
-               @Override
-               public void run() {
-                  LOG.info("Stopping broker post commit...");
-                  try {
-                     broker.stop();
-                  }
-                  catch (Exception e) {
-                     e.printStackTrace();
-                  }
-               }
-            });
-         }
-      }});
-      broker.start();
+      broker = createBroker();
+      startBrokerWithDurableQueue();
+      doByteman.set(true);
 
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")");
       configureConnectionFactory(cf);
@@ -211,14 +163,13 @@ public class FailoverTransactionTest extends TestSupport {
       final CountDownLatch commitDoneLatch = new CountDownLatch(1);
       // broker will die on commit reply so this will hang till restart
       Executors.newSingleThreadExecutor().execute(new Runnable() {
-         @Override
          public void run() {
             LOG.info("doing async commit...");
             try {
                session.commit();
             }
             catch (JMSException e) {
-               assertTrue(e instanceof TransactionRolledBackException);
+               Assert.assertTrue(e instanceof TransactionRolledBackException);
                LOG.info("got commit exception: ", e);
             }
             commitDoneLatch.countDown();
@@ -227,29 +178,27 @@ public class FailoverTransactionTest extends TestSupport {
       });
 
       // will be stopped by the plugin
-      broker.waitUntilStopped();
-      broker = createBroker(false, url);
-      setDefaultPersistenceAdapter(broker);
+      brokerStopLatch.await();
+      doByteman.set(false);
+      broker = createBroker();
       broker.start();
 
-      assertTrue("tx committed through failover", commitDoneLatch.await(30, TimeUnit.SECONDS));
+      Assert.assertTrue("tx committed through failover", commitDoneLatch.await(30, TimeUnit.SECONDS));
 
       // new transaction
       Message msg = consumer.receive(20000);
       LOG.info("Received: " + msg);
-      assertNotNull("we got the message", msg);
-      assertNull("we got just one message", consumer.receive(2000));
+      Assert.assertNotNull("we got the message", msg);
+      Assert.assertNull("we got just one message", consumer.receive(2000));
       session.commit();
       consumer.close();
       connection.close();
 
       // ensure no dangling messages with fresh broker etc
       broker.stop();
-      broker.waitUntilStopped();
 
       LOG.info("Checking for remaining/hung messages..");
-      broker = createBroker(false, url);
-      setDefaultPersistenceAdapter(broker);
+      broker = createBroker();
       broker.start();
 
       // after restart, ensure no dangling messages
@@ -264,152 +213,38 @@ public class FailoverTransactionTest extends TestSupport {
          msg = consumer.receive(5000);
       }
       LOG.info("Received: " + msg);
-      assertNull("no messges left dangling but got: " + msg, msg);
+      Assert.assertNull("no messges left dangling but got: " + msg, msg);
       connection.close();
    }
 
    @SuppressWarnings("unchecked")
+   @Test
    public void testFailoverCommitReplyLostWithDestinationPathSeparator() throws Exception {
-
-      broker = createBroker(true);
-      setDefaultPersistenceAdapter(broker);
-
-      broker.setPlugins(new BrokerPlugin[]{new DestinationPathSeparatorBroker(), new BrokerPluginSupport() {
-         @Override
-         public void commitTransaction(ConnectionContext context,
-                                       TransactionId xid,
-                                       boolean onePhase) throws Exception {
-            super.commitTransaction(context, xid, onePhase);
-            // so commit will hang as if reply is lost
-            context.setDontSendReponse(true);
-            Executors.newSingleThreadExecutor().execute(new Runnable() {
-               @Override
-               public void run() {
-                  LOG.info("Stopping broker post commit...");
-                  try {
-                     broker.stop();
-                  }
-                  catch (Exception e) {
-                     e.printStackTrace();
-                  }
-               }
-            });
-         }
-      }});
-      broker.start();
-
-      ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")");
-      configureConnectionFactory(cf);
-      Connection connection = cf.createConnection();
-      connection.start();
-      final Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
-      Queue destination = session.createQueue(QUEUE_NAME.replace('.', '/') + "?consumer.prefetchSize=0");
-
-      MessageConsumer consumer = session.createConsumer(destination);
-      produceMessage(session, destination);
-
-      final CountDownLatch commitDoneLatch = new CountDownLatch(1);
-      // broker will die on commit reply so this will hang till restart
-      Executors.newSingleThreadExecutor().execute(new Runnable() {
-         @Override
-         public void run() {
-            LOG.info("doing async commit...");
-            try {
-               session.commit();
-            }
-            catch (JMSException e) {
-               assertTrue(e instanceof TransactionRolledBackException);
-               LOG.info("got commit exception: ", e);
-            }
-            commitDoneLatch.countDown();
-            LOG.info("done async commit");
-         }
-      });
-
-      // will be stopped by the plugin
-      broker.waitUntilStopped();
-      broker = createBroker(false, url);
-      setDefaultPersistenceAdapter(broker);
-      broker.setPlugins(new BrokerPlugin[]{new DestinationPathSeparatorBroker()});
-      broker.start();
-
-      assertTrue("tx committed trough failover", commitDoneLatch.await(30, TimeUnit.SECONDS));
-
-      // new transaction
-      Message msg = consumer.receive(20000);
-      LOG.info("Received: " + msg);
-      assertNotNull("we got the message", msg);
-      assertNull("we got just one message", consumer.receive(2000));
-      session.commit();
-      consumer.close();
-      connection.close();
-
-      // ensure no dangling messages with fresh broker etc
-      broker.stop();
-      broker.waitUntilStopped();
-
-      LOG.info("Checking for remaining/hung messages..");
-      broker = createBroker(false, url);
-      setDefaultPersistenceAdapter(broker);
-      broker.setPlugins(new BrokerPlugin[]{new DestinationPathSeparatorBroker()});
-      broker.start();
-
-      // after restart, ensure no dangling messages
-      cf = new ActiveMQConnectionFactory("failover:(" + url + ")");
-      configureConnectionFactory(cf);
-      connection = cf.createConnection();
-      connection.start();
-      Session session2 = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      consumer = session2.createConsumer(destination);
-      msg = consumer.receive(1000);
-      if (msg == null) {
-         msg = consumer.receive(5000);
-      }
-      LOG.info("Received: " + msg);
-      assertNull("no messges left dangling but got: " + msg, msg);
-      connection.close();
-
-      ActiveMQDestination[] destinations = broker.getRegionBroker().getDestinations();
-      for (ActiveMQDestination dest : destinations) {
-         LOG.info("Destinations list: " + dest);
-      }
-      assertEquals("Only one destination", 1, broker.getRegionBroker().getDestinations().length);
-   }
-
-   public void initCombosForTestFailoverSendReplyLost() {
-      addCombinationValues("defaultPersistenceAdapter", new Object[]{PersistenceAdapterChoice.KahaDB, PersistenceAdapterChoice.JDBC
-                              // not implemented for AMQ store or PersistenceAdapterChoice.LevelDB
-                           });
+      //the original test validates destinations using forward slash (/) as
+      //separators instead of dot (.). The broker internally uses a plugin
+      //called DestinationPathSeparatorBroker to convert every occurrence of
+      // "/" into "." inside the server.
+      //Artemis doesn't support "/" so far and this test doesn't make sense therefore.
    }
 
    @SuppressWarnings("unchecked")
+   @Test
+   @BMRules(
+           rules = {
+                   @BMRule(
+                           name = "set no return response and stop the broker",
+                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+                           targetMethod = "processMessage",
+                           targetLocation = "EXIT",
+                           binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
+                           action = "org.apache.activemq.transport.failover.FailoverTransactionTest.holdResponseAndStopBroker(context)")
+           }
+   )
    public void testFailoverSendReplyLost() throws Exception {
 
-      broker = createBroker(true);
-      setDefaultPersistenceAdapter(broker);
-
-      broker.setPlugins(new BrokerPlugin[]{new BrokerPluginSupport() {
-         @Override
-         public void send(ProducerBrokerExchange producerExchange,
-                          org.apache.activemq.command.Message messageSend) throws Exception {
-            // so send will hang as if reply is lost
-            super.send(producerExchange, messageSend);
-            producerExchange.getConnectionContext().setDontSendReponse(true);
-            Executors.newSingleThreadExecutor().execute(new Runnable() {
-               @Override
-               public void run() {
-                  LOG.info("Stopping broker post send...");
-                  try {
-                     broker.stop();
-                  }
-                  catch (Exception e) {
-                     e.printStackTrace();
-                  }
-               }
-            });
-         }
-      }});
-      broker.start();
+      broker = createBroker();
+      startBrokerWithDurableQueue();
+      doByteman.set(true);
 
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")?jms.watchTopicAdvisories=false");
       configureConnectionFactory(cf);
@@ -422,7 +257,6 @@ public class FailoverTransactionTest extends TestSupport {
       final CountDownLatch sendDoneLatch = new CountDownLatch(1);
       // broker will die on send reply so this will hang till restart
       Executors.newSingleThreadExecutor().execute(new Runnable() {
-         @Override
          public void run() {
             LOG.info("doing async send...");
             try {
@@ -431,7 +265,7 @@ public class FailoverTransactionTest extends TestSupport {
             catch (JMSException e) {
                //assertTrue(e instanceof TransactionRolledBackException);
                LOG.error("got send exception: ", e);
-               fail("got unexpected send exception" + e);
+               Assert.fail("got unexpected send exception" + e);
             }
             sendDoneLatch.countDown();
             LOG.info("done async send");
@@ -439,33 +273,27 @@ public class FailoverTransactionTest extends TestSupport {
       });
 
       // will be stopped by the plugin
-      broker.waitUntilStopped();
-      broker = createBroker(false, url);
-      setDefaultPersistenceAdapter(broker);
+      brokerStopLatch.await();
+      doByteman.set(false);
+      broker = createBroker();
       LOG.info("restarting....");
       broker.start();
 
-      assertTrue("message sent through failover", sendDoneLatch.await(30, TimeUnit.SECONDS));
+      Assert.assertTrue("message sent through failover", sendDoneLatch.await(30, TimeUnit.SECONDS));
 
       // new transaction
       Message msg = consumer.receive(20000);
       LOG.info("Received: " + msg);
-      assertNotNull("we got the message", msg);
-      assertNull("we got just one message", consumer.receive(2000));
+      Assert.assertNotNull("we got the message", msg);
+      Assert.assertNull("we got just one message", consumer.receive(2000));
       consumer.close();
       connection.close();
 
-      // verify stats
-      assertEquals("no newly queued messages", 0, ((RegionBroker) broker.getRegionBroker()).getDestinationStatistics().getEnqueues().getCount());
-      assertEquals("1 dequeue", 1, ((RegionBroker) broker.getRegionBroker()).getDestinationStatistics().getDequeues().getCount());
-
       // ensure no dangling messages with fresh broker etc
       broker.stop();
-      broker.waitUntilStopped();
 
       LOG.info("Checking for remaining/hung messages with second restart..");
-      broker = createBroker(false, url);
-      setDefaultPersistenceAdapter(broker);
+      broker = createBroker();
       broker.start();
 
       // after restart, ensure no dangling messages
@@ -480,64 +308,33 @@ public class FailoverTransactionTest extends TestSupport {
          msg = consumer.receive(5000);
       }
       LOG.info("Received: " + msg);
-      assertNull("no messges left dangling but got: " + msg, msg);
+      Assert.assertNull("no messges left dangling but got: " + msg, msg);
       connection.close();
    }
 
-   public void initCombosForTestFailoverConnectionSendReplyLost() {
-      addCombinationValues("defaultPersistenceAdapter", new Object[]{PersistenceAdapterChoice.KahaDB, PersistenceAdapterChoice.JDBC
-                              // last producer message id store feature not implemented for AMQ store
-                              // or PersistenceAdapterChoice.LevelDB
-                           });
-   }
-
    @SuppressWarnings("unchecked")
+   @Test
+   @BMRules(
+           rules = {
+                   @BMRule(
+                           name = "set no return response and stop the broker",
+                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+                           targetMethod = "processMessage",
+                           targetLocation = "EXIT",
+                           binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
+                           action = "org.apache.activemq.transport.failover.FailoverTransactionTest.holdResponseAndStopProxyOnFirstSend(context)")
+           }
+   )
    public void testFailoverConnectionSendReplyLost() throws Exception {
 
-      broker = createBroker(true);
-      PersistenceAdapter store = setDefaultPersistenceAdapter(broker);
-      if (store instanceof KahaDBPersistenceAdapter) {
-         // duplicate checker not updated on canceled tasks, even it
-         // it was, recovery of the audit would fail as the message is
-         // not recorded in the store and the audit may not be up to date.
-         // So if duplicate messages are an absolute no no after restarts,
-         // ConcurrentStoreAndDispatchQueues must be disabled
-         ((KahaDBPersistenceAdapter) store).setConcurrentStoreAndDispatchQueues(false);
-      }
-
-      final SocketProxy proxy = new SocketProxy();
-
-      broker.setPlugins(new BrokerPlugin[]{new BrokerPluginSupport() {
-         private boolean firstSend = true;
-
-         @Override
-         public void send(ProducerBrokerExchange producerExchange,
-                          org.apache.activemq.command.Message messageSend) throws Exception {
-            // so send will hang as if reply is lost
-            super.send(producerExchange, messageSend);
-            if (firstSend) {
-               firstSend = false;
-
-               producerExchange.getConnectionContext().setDontSendReponse(true);
-               Executors.newSingleThreadExecutor().execute(new Runnable() {
-                  @Override
-                  public void run() {
-                     LOG.info("Stopping connection post send...");
-                     try {
-                        proxy.close();
-                     }
-                     catch (Exception e) {
-                        e.printStackTrace();
-                     }
-                  }
-               });
-            }
-         }
-      }});
-      broker.start();
+      broker = createBroker();
+      proxy = new SocketProxy();
+      firstSend = true;
+      startBrokerWithDurableQueue();
 
       proxy.setTarget(new URI(url));
       proxy.open();
+      doByteman.set(true);
 
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + proxy.getUrl().toASCIIString() + ")?jms.watchTopicAdvisories=false");
       configureConnectionFactory(cf);
@@ -550,7 +347,6 @@ public class FailoverTransactionTest extends TestSupport {
       final CountDownLatch sendDoneLatch = new CountDownLatch(1);
       // proxy connection will die on send reply so this will hang on failover reconnect till open
       Executors.newSingleThreadExecutor().execute(new Runnable() {
-         @Override
          public void run() {
             LOG.info("doing async send...");
             try {
@@ -566,29 +362,24 @@ public class FailoverTransactionTest extends TestSupport {
       });
 
       // will be closed by the plugin
-      assertTrue("proxy was closed", proxy.waitUntilClosed(30));
+      Assert.assertTrue("proxy was closed", proxy.waitUntilClosed(30));
       LOG.info("restarting proxy");
       proxy.open();
 
-      assertTrue("message sent through failover", sendDoneLatch.await(30, TimeUnit.SECONDS));
+      Assert.assertTrue("message sent through failover", sendDoneLatch.await(30, TimeUnit.SECONDS));
 
       Message msg = consumer.receive(20000);
       LOG.info("Received: " + msg);
-      assertNotNull("we got the message", msg);
-      assertNull("we got just one message", consumer.receive(2000));
+      Assert.assertNotNull("we got the message", msg);
+      Assert.assertNull("we got just one message", consumer.receive(2000));
       consumer.close();
       connection.close();
 
-      // verify stats, connection dup suppression means dups don't get to broker
-      assertEquals("one queued message", 1, ((RegionBroker) broker.getRegionBroker()).getDestinationStatistics().getEnqueues().getCount());
-
       // ensure no dangling messages with fresh broker etc
       broker.stop();
-      broker.waitUntilStopped();
 
       LOG.info("Checking for remaining/hung messages with restart..");
-      broker = createBroker(false, url);
-      setDefaultPersistenceAdapter(broker);
+      broker = createBroker();
       broker.start();
 
       // after restart, ensure no dangling messages
@@ -603,10 +394,11 @@ public class FailoverTransactionTest extends TestSupport {
          msg = consumer.receive(5000);
       }
       LOG.info("Received: " + msg);
-      assertNull("no messges left dangling but got: " + msg, msg);
+      Assert.assertNull("no messges left dangling but got: " + msg, msg);
       connection.close();
    }
 
+   @Test
    public void testFailoverProducerCloseBeforeTransactionFailWhenDisabled() throws Exception {
       startCleanBroker();
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")?trackTransactionProducers=false");
@@ -621,16 +413,17 @@ public class FailoverTransactionTest extends TestSupport {
 
       // restart to force failover and connection state recovery before the commit
       broker.stop();
-      startBroker(false, url);
+      startBroker();
 
       session.commit();
 
       // without tracking producers, message will not be replayed on recovery
-      assertNull("we got the message", consumer.receive(5000));
+      Assert.assertNull("we got the message", consumer.receive(5000));
       session.commit();
       connection.close();
    }
 
+   @Test
    public void testFailoverMultipleProducerCloseBeforeTransaction() throws Exception {
       startCleanBroker();
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")");
@@ -653,17 +446,18 @@ public class FailoverTransactionTest extends TestSupport {
 
       // restart to force failover and connection state recovery before the commit
       broker.stop();
-      startBroker(false, url);
+      startBroker();
 
       session.commit();
       for (int i = 0; i < count; i++) {
-         assertNotNull("we got all the message: " + count, consumer.receive(20000));
+         Assert.assertNotNull("we got all the message: " + count, consumer.receive(20000));
       }
       session.commit();
       connection.close();
    }
 
    // https://issues.apache.org/activemq/browse/AMQ-2772
+   @Test
    public void testFailoverWithConnectionConsumer() throws Exception {
       startCleanBroker();
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")");
@@ -677,15 +471,12 @@ public class FailoverTransactionTest extends TestSupport {
       final CountDownLatch connectionConsumerGotOne = new CountDownLatch(1);
       final Session poolSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
       connection.createConnectionConsumer(destination, null, new ServerSessionPool() {
-         @Override
          public ServerSession getServerSession() throws JMSException {
             return new ServerSession() {
-               @Override
                public Session getSession() throws JMSException {
                   return poolSession;
                }
 
-               @Override
                public void start() throws JMSException {
                   connectionConsumerGotOne.countDown();
                   poolSession.run();
@@ -707,18 +498,30 @@ public class FailoverTransactionTest extends TestSupport {
 
       // restart to force failover and connection state recovery before the commit
       broker.stop();
-      startBroker(false, url);
+      startBroker();
 
       session.commit();
       for (int i = 0; i < count - 1; i++) {
-         assertNotNull("Failed to get message: " + count, consumer.receive(20000));
+         Assert.assertNotNull("Failed to get message: " + count, consumer.receive(20000));
       }
       session.commit();
       connection.close();
 
-      assertTrue("connectionconsumer did not get a message", connectionConsumerGotOne.await(10, TimeUnit.SECONDS));
+      Assert.assertTrue("connectionconsumer did not get a message", connectionConsumerGotOne.await(10, TimeUnit.SECONDS));
    }
 
+   @Test
+   @BMRules(
+           rules = {
+                   @BMRule(
+                           name = "set no return response and stop the broker",
+                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+                           targetMethod = "processMessageAck",
+                           targetLocation = "ENTRY",
+                           binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
+                           action = "org.apache.activemq.transport.failover.FailoverTransactionTest.holdResponseAndStopBroker(context)")
+           }
+   )
    public void testFailoverConsumerAckLost() throws Exception {
       // as failure depends on hash order of state tracker recovery, do a few times
       for (int i = 0; i < 3; i++) {
@@ -734,31 +537,10 @@ public class FailoverTransactionTest extends TestSupport {
 
    @SuppressWarnings("unchecked")
    public void doTestFailoverConsumerAckLost(final int pauseSeconds) throws Exception {
-      broker = createBroker(true);
-      setDefaultPersistenceAdapter(broker);
-
-      broker.setPlugins(new BrokerPlugin[]{new BrokerPluginSupport() {
-
-         // broker is killed on delivered ack as prefetch is 1
-         @Override
-         public void acknowledge(ConsumerBrokerExchange consumerExchange, final MessageAck ack) throws Exception {
-
-            consumerExchange.getConnectionContext().setDontSendReponse(true);
-            Executors.newSingleThreadExecutor().execute(new Runnable() {
-               @Override
-               public void run() {
-                  LOG.info("Stopping broker on ack: " + ack);
-                  try {
-                     broker.stop();
-                  }
-                  catch (Exception e) {
-                     e.printStackTrace();
-                  }
-               }
-            });
-         }
-      }});
+      broker = createBroker();
       broker.start();
+      brokerStopLatch = new CountDownLatch(1);
+      doByteman.set(true);
 
       Vector<Connection> connections = new Vector<>();
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")");
@@ -789,7 +571,6 @@ public class FailoverTransactionTest extends TestSupport {
       final CountDownLatch commitDoneLatch = new CountDownLatch(1);
       final AtomicBoolean gotTransactionRolledBackException = new AtomicBoolean(false);
       Executors.newSingleThreadExecutor().execute(new Runnable() {
-         @Override
          public void run() {
             LOG.info("doing async commit after consume...");
             try {
@@ -839,12 +620,12 @@ public class FailoverTransactionTest extends TestSupport {
       });
 
       // will be stopped by the plugin
-      broker.waitUntilStopped();
-      broker = createBroker(false, url);
-      setDefaultPersistenceAdapter(broker);
+      brokerStopLatch.await();
+      broker = createBroker();
       broker.start();
+      doByteman.set(false);
 
-      assertTrue("tx committed through failover", commitDoneLatch.await(30, TimeUnit.SECONDS));
+      Assert.assertTrue("tx committed through failover", commitDoneLatch.await(30, TimeUnit.SECONDS));
 
       LOG.info("received message count: " + receivedMessages.size());
 
@@ -852,10 +633,10 @@ public class FailoverTransactionTest extends TestSupport {
       Message msg = consumer1.receive(gotTransactionRolledBackException.get() ? 5000 : 20000);
       LOG.info("post: from consumer1 received: " + msg);
       if (gotTransactionRolledBackException.get()) {
-         assertNotNull("should be available again after commit rollback ex", msg);
+         Assert.assertNotNull("should be available again after commit rollback ex", msg);
       }
       else {
-         assertNull("should be nothing left for consumer as receive should have committed", msg);
+         Assert.assertNull("should be nothing left for consumer as receive should have committed", msg);
       }
       consumerSession1.commit();
 
@@ -864,7 +645,7 @@ public class FailoverTransactionTest extends TestSupport {
          // consumer2 should get other message
          msg = consumer2.receive(10000);
          LOG.info("post: from consumer2 received: " + msg);
-         assertNotNull("got second message on consumer2", msg);
+         Assert.assertNotNull("got second message on consumer2", msg);
          consumerSession2.commit();
       }
 
@@ -874,11 +655,9 @@ public class FailoverTransactionTest extends TestSupport {
 
       // ensure no dangling messages with fresh broker etc
       broker.stop();
-      broker.waitUntilStopped();
 
       LOG.info("Checking for remaining/hung messages..");
-      broker = createBroker(false, url);
-      setDefaultPersistenceAdapter(broker);
+      broker = createBroker();
       broker.start();
 
       // after restart, ensure no dangling messages
@@ -893,36 +672,29 @@ public class FailoverTransactionTest extends TestSupport {
          msg = sweeper.receive(5000);
       }
       LOG.info("Sweep received: " + msg);
-      assertNull("no messges left dangling but got: " + msg, msg);
+      Assert.assertNull("no messges left dangling but got: " + msg, msg);
       connection.close();
+
+      broker.stop();
    }
 
+   @Test
+   @BMRules(
+           rules = {
+                   @BMRule(
+                           name = "set no return response and stop the broker",
+                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+                           targetMethod = "processRemoveConsumer",
+                           targetLocation = "ENTRY",
+                           binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
+                           action = "org.apache.activemq.transport.failover.FailoverTransactionTest.stopBrokerOnCounter(context)")
+           }
+   )
    public void testPoolingNConsumesAfterReconnect() throws Exception {
-      broker = createBroker(true);
-      setDefaultPersistenceAdapter(broker);
+      broker = createBroker();
+      startBrokerWithDurableQueue();
 
-      broker.setPlugins(new BrokerPlugin[]{new BrokerPluginSupport() {
-         int count = 0;
-
-         @Override
-         public void removeConsumer(ConnectionContext context, final ConsumerInfo info) throws Exception {
-            if (count++ == 1) {
-               Executors.newSingleThreadExecutor().execute(new Runnable() {
-                  @Override
-                  public void run() {
-                     LOG.info("Stopping broker on removeConsumer: " + info);
-                     try {
-                        broker.stop();
-                     }
-                     catch (Exception e) {
-                        e.printStackTrace();
-                     }
-                  }
-               });
-            }
-         }
-      }});
-      broker.start();
+      doByteman.set(true);
 
       Vector<Connection> connections = new Vector<>();
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")");
@@ -951,6 +723,7 @@ public class FailoverTransactionTest extends TestSupport {
       for (int i = 0; i < consumerCount; i++) {
          consumers.push(consumerSession.createConsumer(destination));
       }
+
       final ExecutorService executorService = Executors.newCachedThreadPool();
 
       final FailoverTransport failoverTransport = ((ActiveMQConnection) connection).getTransport().narrow(FailoverTransport.class);
@@ -973,7 +746,6 @@ public class FailoverTransactionTest extends TestSupport {
             for (int i = 0; i < consumerCount && !consumers.isEmpty(); i++) {
 
                executorService.execute(new Runnable() {
-                  @Override
                   public void run() {
                      MessageConsumer localConsumer = null;
                      try {
@@ -1011,9 +783,9 @@ public class FailoverTransactionTest extends TestSupport {
       consumer.close();
 
       // will be stopped by the plugin
-      broker.waitUntilStopped();
-      broker = createBroker(false, url);
-      setDefaultPersistenceAdapter(broker);
+      brokerStopLatch.await();
+      doByteman.set(false);
+      broker = createBroker();
       broker.start();
 
       consumer = consumerSession.createConsumer(destination);
@@ -1023,8 +795,9 @@ public class FailoverTransactionTest extends TestSupport {
       for (int i = 0; i < 4 && msg == null; i++) {
          msg = consumer.receive(1000);
       }
+
       LOG.info("post: from consumer1 received: " + msg);
-      assertNotNull("got message after failover", msg);
+      Assert.assertNotNull("got message after failover", msg);
       msg.acknowledge();
 
       for (Connection c : connections) {
@@ -1032,8 +805,15 @@ public class FailoverTransactionTest extends TestSupport {
       }
    }
 
+   private void startBrokerWithDurableQueue() throws Exception {
+      broker.start();
+      //auto created queue can't survive a restart, so we need this
+      broker.getJMSServerManager().createQueue(false, QUEUE_NAME, null, true, QUEUE_NAME);
+   }
+
+   @Test
    public void testAutoRollbackWithMissingRedeliveries() throws Exception {
-      broker = createBroker(true);
+      broker = createBroker();
       broker.start();
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")");
       configureConnectionFactory(cf);
@@ -1047,32 +827,32 @@ public class FailoverTransactionTest extends TestSupport {
       produceMessage(producerSession, destination);
 
       Message msg = consumer.receive(20000);
-      assertNotNull(msg);
+      Assert.assertNotNull(msg);
 
       broker.stop();
-      broker = createBroker(false, url);
+      broker = createBroker();
       // use empty jdbc store so that default wait(0) for redeliveries will timeout after failover
-      setPersistenceAdapter(broker, PersistenceAdapterChoice.JDBC);
       broker.start();
 
       try {
          consumerSession.commit();
-         fail("expected transaciton rolledback ex");
+         Assert.fail("expected transaciton rolledback ex");
       }
       catch (TransactionRolledBackException expected) {
       }
 
       broker.stop();
-      broker = createBroker(false, url);
+      broker = createBroker();
       broker.start();
 
-      assertNotNull("should get rolledback message from original restarted broker", consumer.receive(20000));
+      Assert.assertNotNull("should get rolledback message from original restarted broker", consumer.receive(20000));
       connection.close();
    }
 
+   @Test
    public void testWaitForMissingRedeliveries() throws Exception {
       LOG.info("testWaitForMissingRedeliveries()");
-      broker = createBroker(true);
+      broker = createBroker();
       broker.start();
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")?jms.consumerFailoverRedeliveryWaitPeriod=30000");
       configureConnectionFactory(cf);
@@ -1088,18 +868,15 @@ public class FailoverTransactionTest extends TestSupport {
       if (msg == null) {
          AutoFailTestSupport.dumpAllThreads("missing-");
       }
-      assertNotNull("got message just produced", msg);
+      Assert.assertNotNull("got message just produced", msg);
 
       broker.stop();
-      broker = createBroker(false, url);
-      // use empty jdbc store so that wait for re-deliveries occur when failover resumes
-      setPersistenceAdapter(broker, PersistenceAdapterChoice.JDBC);
+      broker = createBroker();
       broker.start();
 
       final CountDownLatch commitDone = new CountDownLatch(1);
       // will block pending re-deliveries
       Executors.newSingleThreadExecutor().execute(new Runnable() {
-         @Override
          public void run() {
             LOG.info("doing async commit...");
             try {
@@ -1112,18 +889,19 @@ public class FailoverTransactionTest extends TestSupport {
       });
 
       broker.stop();
-      broker = createBroker(false, url);
+      broker = createBroker();
       broker.start();
 
-      assertTrue("commit was successful", commitDone.await(30, TimeUnit.SECONDS));
+      Assert.assertTrue("commit was successful", commitDone.await(30, TimeUnit.SECONDS));
 
-      assertNull("should not get committed message", consumer.receive(5000));
+      Assert.assertNull("should not get committed message", consumer.receive(5000));
       connection.close();
    }
 
+   @Test
    public void testReDeliveryWhilePending() throws Exception {
       LOG.info("testReDeliveryWhilePending()");
-      broker = createBroker(true);
+      broker = createBroker();
       broker.start();
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")?jms.consumerFailoverRedeliveryWaitPeriod=10000");
       configureConnectionFactory(cf);
@@ -1139,13 +917,13 @@ public class FailoverTransactionTest extends TestSupport {
       if (msg == null) {
          AutoFailTestSupport.dumpAllThreads("missing-");
       }
-      assertNotNull("got message just produced", msg);
+      Assert.assertNotNull("got message just produced", msg);
 
       // add another consumer into the mix that may get the message after restart
       MessageConsumer consumer2 = consumerSession.createConsumer(consumerSession.createQueue(QUEUE_NAME + "?consumer.prefetchSize=1"));
 
       broker.stop();
-      broker = createBroker(false, url);
+      broker = createBroker();
       broker.start();
 
       final CountDownLatch commitDone = new CountDownLatch(1);
@@ -1154,7 +932,6 @@ public class FailoverTransactionTest extends TestSupport {
 
       // commit may fail if other consumer gets the message on restart
       Executors.newSingleThreadExecutor().execute(new Runnable() {
-         @Override
          public void run() {
             LOG.info("doing async commit...");
             try {
@@ -1169,24 +946,24 @@ public class FailoverTransactionTest extends TestSupport {
          }
       });
 
-      assertTrue("commit completed ", commitDone.await(15, TimeUnit.SECONDS));
+      Assert.assertTrue("commit completed ", commitDone.await(15, TimeUnit.SECONDS));
 
       // either message redelivered in existing tx or consumed by consumer2
       // should not be available again in any event
-      assertNull("consumer should not get rolled back on non redelivered message or duplicate", consumer.receive(5000));
+      Assert.assertNull("consumer should not get rolled back on non redelivered message or duplicate", consumer.receive(5000));
 
       // consumer replay is hashmap order dependent on a failover connection state recover so need to deal with both cases
       if (exceptions.isEmpty()) {
          LOG.info("commit succeeded, message was redelivered to the correct consumer after restart so commit was fine");
-         assertNull("consumer2 not get a second message consumed by 1", consumer2.receive(2000));
+         Assert.assertNull("consumer2 not get a second message consumed by 1", consumer2.receive(2000));
       }
       else {
          LOG.info("commit failed, consumer2 should get it", exceptions.get(0));
-         assertNotNull("consumer2 got message", consumer2.receive(2000));
+         Assert.assertNotNull("consumer2 got message", consumer2.receive(2000));
          consumerSession.commit();
          // no message should be in dlq
          MessageConsumer dlqConsumer = consumerSession.createConsumer(consumerSession.createQueue("ActiveMQ.DLQ"));
-         assertNull("nothing in the dlq", dlqConsumer.receive(5000));
+         Assert.assertNull("nothing in the dlq", dlqConsumer.receive(5000));
       }
       connection.close();
    }
@@ -1198,4 +975,63 @@ public class FailoverTransactionTest extends TestSupport {
       producer.close();
    }
 
+   public static void holdResponseAndStopBroker(final AMQConnectionContext context) {
+      if (doByteman.get()) {
+         context.setDontSendReponse(true);
+         Executors.newSingleThreadExecutor().execute(new Runnable() {
+            public void run() {
+               LOG.info("Stopping broker post commit...");
+               try {
+                  broker.stop();
+               }
+               catch (Exception e) {
+                  e.printStackTrace();
+               }
+               finally {
+                  brokerStopLatch.countDown();
+               }
+            }
+         });
+      }
+   }
+
+   public static void holdResponseAndStopProxyOnFirstSend(final AMQConnectionContext context) {
+      if (doByteman.get()) {
+         if (firstSend) {
+            firstSend = false;
+            context.setDontSendReponse(true);
+            Executors.newSingleThreadExecutor().execute(new Runnable() {
+               public void run() {
+                  LOG.info("Stopping connection post send...");
+                  try {
+                     proxy.close();
+                  }
+                  catch (Exception e) {
+                     e.printStackTrace();
+                  }
+               }
+            });
+         }
+      }
+   }
+
+   public static void stopBrokerOnCounter(final AMQConnectionContext context) {
+      if (doByteman.get()) {
+         if (count++ == 1) {
+            Executors.newSingleThreadExecutor().execute(new Runnable() {
+               public void run() {
+                  try {
+                     broker.stop();
+                  }
+                  catch (Exception e) {
+                     e.printStackTrace();
+                  }
+                  finally {
+                     brokerStopLatch.countDown();
+                  }
+               }
+            });
+         }
+      }
+   }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportBackupsTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportBackupsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportBackupsTest.java
index 0ba3939..149af92 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportBackupsTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportBackupsTest.java
@@ -23,7 +23,8 @@ import static org.junit.Assert.assertTrue;
 import java.io.IOException;
 import java.net.URI;
 
-import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
 import org.apache.activemq.transport.Transport;
 import org.apache.activemq.transport.TransportFactory;
 import org.apache.activemq.transport.TransportListener;
@@ -34,7 +35,7 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class FailoverTransportBackupsTest {
+public class FailoverTransportBackupsTest extends OpenwireArtemisBaseTest {
 
    private static final Logger LOG = LoggerFactory.getLogger(FailoverTransportBackupsTest.class);
 
@@ -43,23 +44,11 @@ public class FailoverTransportBackupsTest {
    private int transportInterruptions;
    private int transportResumptions;
 
-   BrokerService broker1;
-   BrokerService broker2;
-   BrokerService broker3;
+   EmbeddedJMS[] servers = new EmbeddedJMS[3];
 
    @Before
    public void setUp() throws Exception {
-      broker1 = createBroker("1");
-      broker2 = createBroker("2");
-      broker3 = createBroker("3");
-
-      broker1.start();
-      broker2.start();
-      broker3.start();
-
-      broker1.waitUntilStarted();
-      broker2.waitUntilStarted();
-      broker3.waitUntilStarted();
+      setUpClusterServers(servers);
 
       // Reset stats
       transportInterruptions = 0;
@@ -71,13 +60,7 @@ public class FailoverTransportBackupsTest {
       if (transport != null) {
          transport.stop();
       }
-
-      broker1.stop();
-      broker1.waitUntilStopped();
-      broker2.stop();
-      broker2.waitUntilStopped();
-      broker3.stop();
-      broker3.waitUntilStopped();
+      shutDownClusterServers(servers);
    }
 
    @Test
@@ -111,7 +94,7 @@ public class FailoverTransportBackupsTest {
          }
       }));
 
-      broker1.stop();
+      servers[0].stop();
 
       assertTrue("Timed out waiting for Backups to connect.", Wait.waitFor(new Wait.Condition() {
          @Override
@@ -124,7 +107,7 @@ public class FailoverTransportBackupsTest {
       assertTrue("Incorrect number of Transport interruptions", transportInterruptions >= 1);
       assertTrue("Incorrect number of Transport resumptions", transportResumptions >= 1);
 
-      broker2.stop();
+      servers[1].stop();
 
       assertTrue("Timed out waiting for Backups to connect.", Wait.waitFor(new Wait.Condition() {
          @Override
@@ -153,7 +136,7 @@ public class FailoverTransportBackupsTest {
          }
       }));
 
-      broker1.stop();
+      servers[0].stop();
 
       assertTrue("Timed out waiting for Backups to connect.", Wait.waitFor(new Wait.Condition() {
          @Override
@@ -163,7 +146,7 @@ public class FailoverTransportBackupsTest {
          }
       }));
 
-      broker2.stop();
+      servers[1].stop();
 
       assertTrue("Timed out waiting for Backups to connect.", Wait.waitFor(new Wait.Condition() {
          @Override
@@ -174,20 +157,11 @@ public class FailoverTransportBackupsTest {
       }));
    }
 
-   private BrokerService createBroker(String name) throws Exception {
-      BrokerService bs = new BrokerService();
-      bs.setBrokerName(name);
-      bs.setUseJmx(false);
-      bs.setPersistent(false);
-      bs.addConnector("tcp://localhost:0");
-      return bs;
-   }
-
    protected Transport createTransport(int backups) throws Exception {
       String connectionUri = "failover://(" +
-         broker1.getTransportConnectors().get(0).getPublishableConnectString() + "," +
-         broker2.getTransportConnectors().get(0).getPublishableConnectString() + "," +
-         broker3.getTransportConnectors().get(0).getPublishableConnectString() + ")";
+         newURI(0) + "," +
+         newURI(1) + "," +
+         newURI(2) + ")";
 
       if (backups > 0) {
          connectionUri += "?randomize=false&backup=true&backupPoolSize=" + backups;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportBrokerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportBrokerTest.java
index 806faca..15d28d3 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportBrokerTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportBrokerTest.java
@@ -18,41 +18,205 @@ package org.apache.activemq.transport.failover;
 
 import java.io.IOException;
 import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.concurrent.TimeUnit;
 
 import javax.jms.DeliveryMode;
+import javax.jms.MessageNotWriteableException;
 
-import junit.framework.Test;
-
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
 import org.apache.activemq.broker.StubConnection;
-import org.apache.activemq.broker.TransportConnector;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.command.ActiveMQTextMessage;
 import org.apache.activemq.command.ActiveMQTopic;
 import org.apache.activemq.command.BrokerInfo;
+import org.apache.activemq.command.ConnectionId;
 import org.apache.activemq.command.ConnectionInfo;
 import org.apache.activemq.command.ConsumerInfo;
+import org.apache.activemq.command.Message;
+import org.apache.activemq.command.MessageDispatch;
+import org.apache.activemq.command.MessageId;
 import org.apache.activemq.command.ProducerInfo;
 import org.apache.activemq.command.SessionInfo;
-import org.apache.activemq.network.NetworkTestSupport;
 import org.apache.activemq.transport.Transport;
 import org.apache.activemq.transport.TransportFactory;
 import org.apache.activemq.transport.TransportListener;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class FailoverTransportBrokerTest extends NetworkTestSupport {
+@RunWith(Parameterized.class)
+public class FailoverTransportBrokerTest extends OpenwireArtemisBaseTest {
 
    private static final Logger LOG = LoggerFactory.getLogger(FailoverTransportBrokerTest.class);
+   protected ArrayList<StubConnection> connections = new ArrayList<StubConnection>();
+   protected long idGenerator;
+   protected int msgIdGenerator;
+   protected int maxWait = 10000;
+   public static final boolean FAST_NO_MESSAGE_LEFT_ASSERT = System.getProperty("FAST_NO_MESSAGE_LEFT_ASSERT", "true").equals("true");
+
+   @Parameterized.Parameters
+   public static Collection<Object[]> getParams()
+   {
+      return Arrays.asList(new Object[][] {
+              {Integer.valueOf(DeliveryMode.NON_PERSISTENT), new ActiveMQQueue("TEST")},
+              {Integer.valueOf(DeliveryMode.NON_PERSISTENT), new ActiveMQTopic("TEST")},
+              {Integer.valueOf(DeliveryMode.PERSISTENT), new ActiveMQQueue("TEST")},
+              {Integer.valueOf(DeliveryMode.PERSISTENT), new ActiveMQTopic("TEST")}
+      });
+   }
+
+   private EmbeddedJMS server;
+   private EmbeddedJMS remoteServer;
 
    public ActiveMQDestination destination;
    public int deliveryMode;
 
-   public void initCombosForTestPublisherFailsOver() {
-      addCombinationValues("deliveryMode", new Object[]{Integer.valueOf(DeliveryMode.NON_PERSISTENT), Integer.valueOf(DeliveryMode.PERSISTENT)});
-      addCombinationValues("destination", new Object[]{new ActiveMQQueue("TEST"), new ActiveMQTopic("TEST")});
+   public FailoverTransportBrokerTest(int deliveryMode, ActiveMQDestination destination) {
+      this.deliveryMode = deliveryMode;
+      this.destination = destination;
+   }
+
+   @Before
+   public void setUp() throws Exception {
+      Configuration config0 = createConfig(0);
+      server = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
+      Configuration config1 = createConfig(1);
+      remoteServer = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
+      server.start();
+      remoteServer.start();
+   }
+
+   @After
+   public void tearDown() throws Exception {
+      for (StubConnection conn : connections) {
+         try {
+            conn.stop();
+         }
+         catch (Exception e) {
+         }
+      }
+      try {
+         remoteServer.stop();
+      }
+      catch (Exception e) {
+      }
+      try {
+         server.stop();
+      }
+      catch (Exception e) {
+      }
+   }
+
+   protected StubConnection createConnection() throws Exception {
+      Transport transport = TransportFactory.connect(new URI(newURI(0)));
+      StubConnection connection = new StubConnection(transport);
+      connections.add(connection);
+      return connection;
+   }
+
+   protected StubConnection createRemoteConnection() throws Exception {
+      Transport transport = TransportFactory.connect(new URI(newURI(1)));
+      StubConnection connection = new StubConnection(transport);
+      connections.add(connection);
+      return connection;
+   }
+
+   protected ConnectionInfo createConnectionInfo() throws Exception {
+      ConnectionInfo info = new ConnectionInfo();
+      info.setConnectionId(new ConnectionId("connection:" + (++idGenerator)));
+      info.setClientId(info.getConnectionId().getValue());
+      return info;
+   }
+
+   protected SessionInfo createSessionInfo(ConnectionInfo connectionInfo) throws Exception {
+      SessionInfo info = new SessionInfo(connectionInfo, ++idGenerator);
+      return info;
+   }
+
+   protected ConsumerInfo createConsumerInfo(SessionInfo sessionInfo,
+                                             ActiveMQDestination destination) throws Exception {
+      ConsumerInfo info = new ConsumerInfo(sessionInfo, ++idGenerator);
+      info.setBrowser(false);
+      info.setDestination(destination);
+      info.setPrefetchSize(1000);
+      info.setDispatchAsync(false);
+      return info;
+   }
+
+   protected ProducerInfo createProducerInfo(SessionInfo sessionInfo) throws Exception {
+      ProducerInfo info = new ProducerInfo(sessionInfo, ++idGenerator);
+      return info;
    }
 
+   protected Message createMessage(ProducerInfo producerInfo, ActiveMQDestination destination, int deliveryMode) {
+      Message message = createMessage(producerInfo, destination);
+      message.setPersistent(deliveryMode == DeliveryMode.PERSISTENT);
+      return message;
+   }
+
+   protected Message createMessage(ProducerInfo producerInfo, ActiveMQDestination destination) {
+      ActiveMQTextMessage message = new ActiveMQTextMessage();
+      message.setMessageId(new MessageId(producerInfo, ++msgIdGenerator));
+      message.setDestination(destination);
+      message.setPersistent(false);
+      try {
+         message.setText("Test Message Payload.");
+      }
+      catch (MessageNotWriteableException e) {
+      }
+      return message;
+   }
+
+   public Message receiveMessage(StubConnection connection) throws InterruptedException {
+      return receiveMessage(connection, maxWait);
+   }
+
+   public Message receiveMessage(StubConnection connection, long timeout) throws InterruptedException {
+      while (true) {
+         Object o = connection.getDispatchQueue().poll(timeout, TimeUnit.MILLISECONDS);
+
+         if (o == null) {
+            return null;
+         }
+         if (o instanceof MessageDispatch) {
+
+            MessageDispatch dispatch = (MessageDispatch) o;
+            if (dispatch.getMessage() == null) {
+               return null;
+            }
+            dispatch.setMessage(dispatch.getMessage().copy());
+            dispatch.getMessage().setRedeliveryCounter(dispatch.getRedeliveryCounter());
+            return dispatch.getMessage();
+         }
+      }
+   }
+
+   protected void assertNoMessagesLeft(StubConnection connection) throws InterruptedException {
+      long wait = FAST_NO_MESSAGE_LEFT_ASSERT ? 0 : maxWait;
+      while (true) {
+         Object o = connection.getDispatchQueue().poll(wait, TimeUnit.MILLISECONDS);
+         if (o == null) {
+            return;
+         }
+         if (o instanceof MessageDispatch && ((MessageDispatch) o).getMessage() != null) {
+            Assert.fail("Received a message: " + ((MessageDispatch) o).getMessage().getMessageId());
+         }
+      }
+   }
+
+   @Test
    public void testPublisherFailsOver() throws Exception {
 
       // Start a normal consumer on the local broker
@@ -92,19 +256,22 @@ public class FailoverTransportBrokerTest extends NetworkTestSupport {
       // See which broker we were connected to.
       StubConnection connectionA;
       StubConnection connectionB;
-      TransportConnector serverA;
-      if (connector.getServer().getConnectURI().equals(ft.getConnectedTransportURI())) {
+
+
+      EmbeddedJMS serverA;
+
+      if (new URI(newURI(0)).equals(ft.getConnectedTransportURI())) {
          connectionA = connection1;
          connectionB = connection2;
-         serverA = connector;
+         serverA = server;
       }
       else {
          connectionA = connection2;
          connectionB = connection1;
-         serverA = remoteConnector;
+         serverA = remoteServer;
       }
 
-      assertNotNull(receiveMessage(connectionA));
+      Assert.assertNotNull(receiveMessage(connectionA));
       assertNoMessagesLeft(connectionB);
 
       // Dispose the server so that it fails over to the other server.
@@ -113,7 +280,7 @@ public class FailoverTransportBrokerTest extends NetworkTestSupport {
 
       connection3.request(createMessage(producerInfo3, destination, deliveryMode));
 
-      assertNotNull(receiveMessage(connectionB));
+      Assert.assertNotNull(receiveMessage(connectionB));
       assertNoMessagesLeft(connectionA);
 
    }
@@ -150,34 +317,16 @@ public class FailoverTransportBrokerTest extends NetworkTestSupport {
       while (count++ < 20 && info[0] == null) {
          TimeUnit.SECONDS.sleep(1);
       }
-      assertNotNull("got a valid brokerInfo after 20 secs", info[0]);
-      assertNull("no peer brokers present", info[0].getPeerBrokerInfos());
-   }
-
-   @Override
-   protected String getLocalURI() {
-      return "tcp://localhost:0?wireFormat.tcpNoDelayEnabled=true";
-   }
-
-   @Override
-   protected String getRemoteURI() {
-      return "tcp://localhost:0?wireFormat.tcpNoDelayEnabled=true";
+      Assert.assertNotNull("got a valid brokerInfo after 20 secs", info[0]);
+      Assert.assertNull("no peer brokers present", info[0].getPeerBrokerInfos());
    }
 
    protected StubConnection createFailoverConnection(TransportListener listener) throws Exception {
-      URI failoverURI = new URI("failover://" + connector.getServer().getConnectURI() + "," + remoteConnector.getServer().getConnectURI() + "");
+      URI failoverURI = new URI("failover://" + newURI(0) + "," + newURI(1) + "");
       Transport transport = TransportFactory.connect(failoverURI);
       StubConnection connection = new StubConnection(transport, listener);
       connections.add(connection);
       return connection;
    }
 
-   public static Test suite() {
-      return suite(FailoverTransportBrokerTest.class);
-   }
-
-   public static void main(String[] args) {
-      junit.textui.TestRunner.run(suite());
-   }
-
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportUriHandlingTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportUriHandlingTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportUriHandlingTest.java
index 8155575..d64cc58 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportUriHandlingTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportUriHandlingTest.java
@@ -22,7 +22,6 @@ import java.lang.reflect.Field;
 import java.net.URI;
 import java.util.Collection;
 
-import org.apache.activemq.transport.failover.FailoverTransport;
 import org.junit.Test;
 
 public class FailoverTransportUriHandlingTest {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUpdateURIsTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUpdateURIsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUpdateURIsTest.java
index e792228..002a788 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUpdateURIsTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUpdateURIsTest.java
@@ -30,38 +30,46 @@ import javax.jms.Session;
 import junit.framework.TestCase;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.broker.TransportConnector;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
 import org.apache.activemq.network.NetworkConnector;
 import org.apache.log4j.Logger;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class FailoverUpdateURIsTest extends TestCase {
+public class FailoverUpdateURIsTest extends OpenwireArtemisBaseTest {
 
    private static final String QUEUE_NAME = "test.failoverupdateuris";
    private static final Logger LOG = Logger.getLogger(FailoverUpdateURIsTest.class);
 
-   String firstTcpUri = "tcp://localhost:61616";
-   String secondTcpUri = "tcp://localhost:61626";
+   String firstTcpUri = newURI(0);
+   String secondTcpUri = newURI(10);
    Connection connection = null;
-   BrokerService bs1 = null;
-   BrokerService bs2 = null;
+   EmbeddedJMS server0 = null;
+   EmbeddedJMS server1 = null;
 
-   @Override
+   @After
    public void tearDown() throws Exception {
       if (connection != null) {
          connection.close();
       }
-      if (bs1 != null) {
-         bs1.stop();
+      if (server0 != null) {
+         server0.stop();
       }
-      if (bs2 != null) {
-         bs2.stop();
+      if (server1 != null) {
+         server1.stop();
       }
    }
 
+   @Test
    public void testUpdateURIsViaFile() throws Exception {
 
-      String targetDir = "target/" + getName();
+      String targetDir = "target/testUpdateURIsViaFile";
       new File(targetDir).mkdir();
       File updateFile = new File(targetDir + "/updateURIsFile.txt");
       LOG.info(updateFile);
@@ -72,8 +80,9 @@ public class FailoverUpdateURIsTest extends TestCase {
       out.write(firstTcpUri.getBytes());
       out.close();
 
-      bs1 = createBroker("bs1", firstTcpUri);
-      bs1.start();
+      Configuration config0 = createConfig(0);
+      server0 = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
+      server0.start();
 
       // no failover uri's to start with, must be read from file...
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:()?updateURIsURL=file:///" + updateFile.getAbsoluteFile());
@@ -86,14 +95,14 @@ public class FailoverUpdateURIsTest extends TestCase {
       Message message = session.createTextMessage("Test message");
       producer.send(message);
       Message msg = consumer.receive(2000);
-      assertNotNull(msg);
+      Assert.assertNotNull(msg);
 
-      bs1.stop();
-      bs1.waitUntilStopped();
-      bs1 = null;
+      server0.stop();
+      server0 = null;
 
-      bs2 = createBroker("bs2", secondTcpUri);
-      bs2.start();
+      Configuration config1 = createConfig(10);
+      server1 = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
+      server1.start();
 
       // add the transport uri for broker number 2
       out = new FileOutputStream(updateFile, true);
@@ -103,25 +112,16 @@ public class FailoverUpdateURIsTest extends TestCase {
 
       producer.send(message);
       msg = consumer.receive(2000);
-      assertNotNull(msg);
-   }
-
-   private BrokerService createBroker(String name, String tcpUri) throws Exception {
-      BrokerService bs = new BrokerService();
-      bs.setBrokerName(name);
-      bs.setUseJmx(false);
-      bs.setPersistent(false);
-      bs.addConnector(tcpUri);
-      return bs;
+      Assert.assertNotNull(msg);
    }
 
+   @Test
    public void testAutoUpdateURIs() throws Exception {
-
-      bs1 = new BrokerService();
-      bs1.setUseJmx(false);
-      TransportConnector transportConnector = bs1.addConnector(firstTcpUri);
-      transportConnector.setUpdateClusterClients(true);
-      bs1.start();
+      Configuration config0 = createConfig(0);
+      deployClusterConfiguration(config0, 10);
+      server0 = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
+      server0.start();
+      Assert.assertTrue(server0.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 1));
 
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + firstTcpUri + ")");
       connection = cf.createConnection();
@@ -133,24 +133,23 @@ public class FailoverUpdateURIsTest extends TestCase {
       Message message = session.createTextMessage("Test message");
       producer.send(message);
       Message msg = consumer.receive(4000);
-      assertNotNull(msg);
+      Assert.assertNotNull(msg);
 
-      bs2 = createBroker("bs2", secondTcpUri);
-      NetworkConnector networkConnector = bs2.addNetworkConnector("static:(" + firstTcpUri + ")");
-      networkConnector.setDuplex(true);
-      bs2.start();
-      LOG.info("started brokerService 2");
-      bs2.waitUntilStarted();
+      Configuration config1 = createConfig(10);
+      deployClusterConfiguration(config1, 0);
+      server1 = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
+      server1.start();
+      Assert.assertTrue(server0.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
+      Assert.assertTrue(server1.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
 
       TimeUnit.SECONDS.sleep(4);
 
       LOG.info("stopping brokerService 1");
-      bs1.stop();
-      bs1.waitUntilStopped();
-      bs1 = null;
+      server0.stop();
+      server0 = null;
 
       producer.send(message);
       msg = consumer.receive(4000);
-      assertNotNull(msg);
+      Assert.assertNotNull(msg);
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUriTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUriTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUriTest.java
index ae637ef..a028832 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUriTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUriTest.java
@@ -43,4 +43,5 @@ public class FailoverUriTest extends TransportUriTest {
    public static Test suite() {
       return suite(FailoverUriTest.class);
    }
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/InitalReconnectDelayTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/InitalReconnectDelayTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/InitalReconnectDelayTest.java
index 34e7333..dad241c 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/InitalReconnectDelayTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/InitalReconnectDelayTest.java
@@ -18,6 +18,7 @@ package org.apache.activemq.transport.failover;
 
 import java.io.IOException;
 import java.util.Date;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import javax.jms.Connection;
 import javax.jms.Message;
@@ -26,9 +27,13 @@ import javax.jms.Queue;
 import javax.jms.Session;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
 import org.apache.activemq.transport.TransportListener;
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -36,19 +41,20 @@ import org.slf4j.LoggerFactory;
 
 import static org.junit.Assert.*;
 
-public class InitalReconnectDelayTest {
+public class InitalReconnectDelayTest extends OpenwireArtemisBaseTest {
 
    private static final transient Logger LOG = LoggerFactory.getLogger(InitalReconnectDelayTest.class);
-   protected BrokerService broker1;
-   protected BrokerService broker2;
+   protected EmbeddedJMS server1;
+   protected EmbeddedJMS server2;
+
+//   protected BrokerService broker1;
+//   protected BrokerService broker2;
 
    @Test
    public void testInitialReconnectDelay() throws Exception {
 
-      String uriString = "failover://(tcp://localhost:" +
-         broker1.getTransportConnectors().get(0).getConnectUri().getPort() +
-         ",tcp://localhost:" +
-         broker2.getTransportConnectors().get(0).getConnectUri().getPort() +
+      String uriString = "failover://(" + newURI(1) +
+         "," + newURI(2) +
          ")?randomize=false&initialReconnectDelay=15000";
 
       ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(uriString);
@@ -67,7 +73,7 @@ public class InitalReconnectDelayTest {
       //Halt the broker1...
       LOG.info("Stopping the Broker1...");
       start = (new Date()).getTime();
-      broker1.stop();
+      server1.stop();
 
       LOG.info("Attempting to send... failover should kick in...");
       producer.send(session.createTextMessage("TEST"));
@@ -81,10 +87,8 @@ public class InitalReconnectDelayTest {
    @Test
    public void testNoSuspendedCallbackOnNoReconnect() throws Exception {
 
-      String uriString = "failover://(tcp://localhost:" +
-         broker1.getTransportConnectors().get(0).getConnectUri().getPort() +
-         ",tcp://localhost:" +
-         broker2.getTransportConnectors().get(0).getConnectUri().getPort() +
+      String uriString = "failover://(" + newURI(1) +
+         "," + newURI(2) +
          ")?randomize=false&maxReconnectAttempts=0";
 
       ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(uriString);
@@ -124,7 +128,7 @@ public class InitalReconnectDelayTest {
       calls.set(0);
 
       LOG.info("Stopping the Broker1...");
-      broker1.stop();
+      server1.stop();
 
       LOG.info("Attempting to send... failover should throw on disconnect");
       try {
@@ -140,25 +144,19 @@ public class InitalReconnectDelayTest {
    @Before
    public void setUp() throws Exception {
 
-      final String dataDir = "target/data/shared";
+      Configuration config1 = createConfig(1);
+      Configuration config2 = createConfig(2);
 
-      broker1 = new BrokerService();
+      deployClusterConfiguration(config1, 2);
+      deployClusterConfiguration(config2, 1);
 
-      broker1.setBrokerName("broker1");
-      broker1.setDeleteAllMessagesOnStartup(true);
-      broker1.setDataDirectory(dataDir);
-      broker1.addConnector("tcp://localhost:0");
-      broker1.setUseJmx(false);
-      broker1.start();
-      broker1.waitUntilStarted();
+      server1 = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
+      server2 = new EmbeddedJMS().setConfiguration(config2).setJmsConfiguration(new JMSConfigurationImpl());
 
-      broker2 = new BrokerService();
-      broker2.setBrokerName("broker2");
-      broker2.setDataDirectory(dataDir);
-      broker2.setUseJmx(false);
-      broker2.addConnector("tcp://localhost:0");
-      broker2.start();
-      broker2.waitUntilStarted();
+      server1.start();
+      server2.start();
+      Assert.assertTrue(server1.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
+      Assert.assertTrue(server2.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
 
    }
 
@@ -172,16 +170,8 @@ public class InitalReconnectDelayTest {
 
    @After
    public void tearDown() throws Exception {
-
-      if (broker1.isStarted()) {
-         broker1.stop();
-         broker1.waitUntilStopped();
-      }
-
-      if (broker2.isStarted()) {
-         broker2.stop();
-         broker2.waitUntilStopped();
-      }
+      server1.stop();
+      server2.stop();
    }
 
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ReconnectTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ReconnectTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ReconnectTest.java
index 4ba5516..83d43af 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ReconnectTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ReconnectTest.java
@@ -28,29 +28,33 @@ import javax.jms.JMSException;
 import javax.jms.MessageConsumer;
 import javax.jms.MessageProducer;
 import javax.jms.Session;
-
-import junit.framework.TestCase;
+import javax.jms.TextMessage;
 
 import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.TransportConnector;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
 import org.apache.activemq.command.ActiveMQQueue;
 import org.apache.activemq.transport.TransportListener;
 import org.apache.activemq.transport.mock.MockTransport;
-import org.apache.activemq.util.ServiceStopper;
 import org.apache.activemq.util.Wait;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class ReconnectTest extends TestCase {
+public class ReconnectTest extends OpenwireArtemisBaseTest {
 
    public static final int MESSAGES_PER_ITTERATION = 10;
    public static final int WORKER_COUNT = 10;
 
    private static final Logger LOG = LoggerFactory.getLogger(ReconnectTest.class);
 
-   private BrokerService bs;
+   private EmbeddedJMS bs;
    private URI tcpUri;
    private final AtomicInteger resumedCount = new AtomicInteger();
    private final AtomicInteger interruptedCount = new AtomicInteger();
@@ -102,7 +106,7 @@ public class ReconnectTest extends TestCase {
       }
 
       public void start() {
-         new Thread(this).start();
+         new Thread(this, name).start();
       }
 
       public void stop() {
@@ -129,13 +133,19 @@ public class ReconnectTest extends TestCase {
             MessageConsumer consumer = session.createConsumer(queue);
             MessageProducer producer = session.createProducer(queue);
             producer.setDeliveryMode(DeliveryMode.PERSISTENT);
+
             while (!stop.get()) {
+
                for (int i = 0; i < MESSAGES_PER_ITTERATION; i++) {
-                  producer.send(session.createTextMessage("TEST:" + i));
+                  TextMessage text = session.createTextMessage(name + " TEST:" + i);
+                  text.setStringProperty("myprop", name + " TEST:" + i);
+                  producer.send(text);
                }
+
                for (int i = 0; i < MESSAGES_PER_ITTERATION; i++) {
-                  consumer.receive();
+                  TextMessage m = (TextMessage) consumer.receive();
                }
+
                iterations.incrementAndGet();
             }
             session.close();
@@ -159,11 +169,12 @@ public class ReconnectTest extends TestCase {
       public synchronized void assertNoErrors() {
          if (error != null) {
             error.printStackTrace();
-            fail("Worker " + name + " got Exception: " + error);
+            Assert.fail("Worker " + name + " got Exception: " + error);
          }
       }
    }
 
+   @Test
    public void testReconnects() throws Exception {
 
       for (int k = 1; k < 10; k++) {
@@ -181,7 +192,7 @@ public class ReconnectTest extends TestCase {
                LOG.info("Test run " + k + ": Waiting for worker " + i + " to finish an iteration.");
                Thread.sleep(1000);
             }
-            assertTrue("Test run " + k + ": Worker " + i + " never completed an interation.", c != 0);
+            Assert.assertTrue("Test run " + k + ": Worker " + i + " never completed an interation.", c != 0);
             workers[i].assertNoErrors();
          }
 
@@ -192,7 +203,7 @@ public class ReconnectTest extends TestCase {
             workers[i].failConnection();
          }
 
-         assertTrue("Timed out waiting for all connections to be interrupted.", Wait.waitFor(new Wait.Condition() {
+         Assert.assertTrue("Timed out waiting for all connections to be interrupted.", Wait.waitFor(new Wait.Condition() {
             @Override
             public boolean isSatisified() throws Exception {
                LOG.debug("Test run waiting for connections to get interrupted.. at: " + interruptedCount.get());
@@ -201,7 +212,7 @@ public class ReconnectTest extends TestCase {
          }, TimeUnit.SECONDS.toMillis(60)));
 
          // Wait for the connections to re-establish...
-         assertTrue("Timed out waiting for all connections to be resumed.", Wait.waitFor(new Wait.Condition() {
+         Assert.assertTrue("Timed out waiting for all connections to be resumed.", Wait.waitFor(new Wait.Condition() {
             @Override
             public boolean isSatisified() throws Exception {
                LOG.debug("Test run waiting for connections to get resumed.. at: " + resumedCount.get());
@@ -220,26 +231,25 @@ public class ReconnectTest extends TestCase {
       }
    }
 
-   @Override
-   protected void setUp() throws Exception {
-      bs = new BrokerService();
-      bs.setPersistent(false);
-      bs.setUseJmx(true);
-      TransportConnector connector = bs.addConnector("tcp://localhost:0");
+   @Before
+   public void setUp() throws Exception {
+      Configuration config = createConfig(0);
+      bs = new EmbeddedJMS().setConfiguration(config).setJmsConfiguration(new JMSConfigurationImpl());
       bs.start();
-      tcpUri = connector.getConnectUri();
+      tcpUri = new URI(newURI(0));
+
       workers = new Worker[WORKER_COUNT];
       for (int i = 0; i < WORKER_COUNT; i++) {
-         workers[i] = new Worker("" + i);
+         workers[i] = new Worker("worker-" + i);
          workers[i].start();
       }
    }
 
-   @Override
-   protected void tearDown() throws Exception {
+   @After
+   public void tearDown() throws Exception {
       for (int i = 0; i < WORKER_COUNT; i++) {
          workers[i].stop();
       }
-      new ServiceStopper().stop(bs);
+      bs.stop();
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/SlowConnectionTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/SlowConnectionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/SlowConnectionTest.java
index 3a55473..ed6040d 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/SlowConnectionTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/SlowConnectionTest.java
@@ -24,15 +24,16 @@ import java.util.concurrent.CountDownLatch;
 import javax.jms.Connection;
 import javax.net.ServerSocketFactory;
 
-import junit.framework.TestCase;
-
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.util.Wait;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class SlowConnectionTest extends TestCase {
+public class SlowConnectionTest {
 
    private CountDownLatch socketReadyLatch = new CountDownLatch(1);
 
+   @Test
    public void testSlowConnection() throws Exception {
 
       MockBroker broker = new MockBroker();
@@ -57,7 +58,7 @@ public class SlowConnectionTest extends TestCase {
       }).start();
 
       int count = 0;
-      assertTrue("Transport count: " + count + ", expected <= 1", Wait.waitFor(new Wait.Condition() {
+      Assert.assertTrue("Transport count: " + count + ", expected <= 1", Wait.waitFor(new Wait.Condition() {
          @Override
          public boolean isSatisified() throws Exception {
             int count = 0;


[04/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerUnconsumedTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerUnconsumedTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerUnconsumedTest.java
index 2779f52..75c27d7 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerUnconsumedTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerUnconsumedTest.java
@@ -22,6 +22,8 @@ import java.util.Vector;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.jms.Destination;
 import javax.jms.JMSException;
@@ -37,97 +39,105 @@ import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.ActiveMQMessageConsumer;
 import org.apache.activemq.ActiveMQMessageTransformation;
 import org.apache.activemq.ActiveMQSession;
-import org.apache.activemq.broker.BrokerPlugin;
-import org.apache.activemq.broker.BrokerPluginSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.ConnectionContext;
-import org.apache.activemq.broker.region.Subscription;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext;
+import org.apache.activemq.artemis.core.server.impl.QueueImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
 import org.apache.activemq.command.ConsumerId;
-import org.apache.activemq.command.ConsumerInfo;
 import org.apache.activemq.command.SessionId;
 import org.apache.activemq.util.Wait;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMRules;
+import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.runner.RunWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.junit.After;
 import org.junit.Test;
 
 // see https://issues.apache.org/activemq/browse/AMQ-2573
-public class FailoverConsumerUnconsumedTest {
-
+@RunWith(BMUnitRunner.class)
+public class FailoverConsumerUnconsumedTest extends OpenwireArtemisBaseTest {
    private static final Logger LOG = LoggerFactory.getLogger(FailoverConsumerUnconsumedTest.class);
    private static final String QUEUE_NAME = "FailoverWithUnconsumed";
-   private static final String TRANSPORT_URI = "tcp://localhost:0";
-   private String url;
+   private static final AtomicBoolean doByteman = new AtomicBoolean(false);
+
+   private static int maxConsumers = 2;
+   private static AtomicInteger consumerCount = new AtomicInteger(0);
+   private static CountDownLatch brokerStopLatch = new CountDownLatch(1);
+   private static AtomicBoolean watchTopicAdvisories = new AtomicBoolean(false);
+
+   private String url = newURI(0);
    final int prefetch = 10;
-   BrokerService broker;
+   private static EmbeddedJMS broker;
 
    @After
-   public void stopBroker() throws Exception {
+   public void tearDown() throws Exception {
       if (broker != null) {
          broker.stop();
+         broker = null;
       }
    }
 
-   public void startBroker(boolean deleteAllMessagesOnStartup) throws Exception {
-      broker = createBroker(deleteAllMessagesOnStartup);
-      broker.start();
-   }
-
-   public BrokerService createBroker(boolean deleteAllMessagesOnStartup) throws Exception {
-      return createBroker(deleteAllMessagesOnStartup, TRANSPORT_URI);
-   }
-
-   public BrokerService createBroker(boolean deleteAllMessagesOnStartup, String bindAddress) throws Exception {
-      broker = new BrokerService();
-      broker.addConnector(bindAddress);
-      broker.setDeleteAllMessagesOnStartup(deleteAllMessagesOnStartup);
-
-      this.url = broker.getTransportConnectors().get(0).getConnectUri().toString();
-
-      return broker;
+   @Before
+   public void setUp() throws Exception {
+      consumerCount.set(0);
    }
 
    @Test
+   @BMRules(
+           rules = {
+                   @BMRule(
+                           name = "set no return response and stop the broker",
+                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+                           targetMethod = "processAddConsumer",
+                           targetLocation = "ENTRY",
+                           binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
+                           action = "org.apache.activemq.transport.failover.FailoverConsumerUnconsumedTest.holdResponseAndStopBroker2(context)")
+           }
+   )
    public void testFailoverConsumerDups() throws Exception {
+      watchTopicAdvisories.set(true);
       doTestFailoverConsumerDups(true);
    }
 
    @Test
+   @BMRules(
+           rules = {
+                   @BMRule(
+                           name = "set no return response and stop the broker",
+                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+                           targetMethod = "processAddConsumer",
+                           targetLocation = "ENTRY",
+                           binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
+                           action = "org.apache.activemq.transport.failover.FailoverConsumerUnconsumedTest.holdResponseAndStopBroker2(context)")
+           }
+   )
    public void testFailoverConsumerDupsNoAdvisoryWatch() throws Exception {
+      watchTopicAdvisories.set(false);
       doTestFailoverConsumerDups(false);
    }
 
    @SuppressWarnings("unchecked")
    @Test
+   @BMRules(
+           rules = {
+                   @BMRule(
+                           name = "set no return response and stop the broker",
+                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+                           targetMethod = "processAddConsumer",
+                           targetLocation = "ENTRY",
+                           binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
+                           action = "org.apache.activemq.transport.failover.FailoverConsumerUnconsumedTest.holdResponseAndStopBroker(context)")
+           }
+   )
    public void testFailoverClientAckMissingRedelivery() throws Exception {
-
-      final int maxConsumers = 2;
-      broker = createBroker(true);
-
-      broker.setPlugins(new BrokerPlugin[]{new BrokerPluginSupport() {
-         int consumerCount;
-
-         // broker is killed on x create consumer
-         @Override
-         public Subscription addConsumer(ConnectionContext context, final ConsumerInfo info) throws Exception {
-            if (++consumerCount == maxConsumers) {
-               context.setDontSendReponse(true);
-               Executors.newSingleThreadExecutor().execute(new Runnable() {
-                  @Override
-                  public void run() {
-                     LOG.info("Stopping broker on consumer: " + info.getConsumerId());
-                     try {
-                        broker.stop();
-                     }
-                     catch (Exception e) {
-                        e.printStackTrace();
-                     }
-                  }
-               });
-            }
-            return super.addConsumer(context, info);
-         }
-      }});
+      maxConsumers = 2;
+      brokerStopLatch = new CountDownLatch(1);
+      broker = createBroker();
       broker.start();
 
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")");
@@ -139,7 +149,9 @@ public class FailoverConsumerUnconsumedTest {
       final Session consumerSession = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
       final Queue destination = consumerSession.createQueue(QUEUE_NAME + "?jms.consumer.prefetch=" + prefetch);
 
-      final Vector<TestConsumer> testConsumers = new Vector<>();
+      doByteman.set(true);
+
+      final Vector<TestConsumer> testConsumers = new Vector<TestConsumer>();
       TestConsumer testConsumer = new TestConsumer(consumerSession, destination, connection);
       testConsumer.setMessageListener(new MessageListener() {
          @Override
@@ -157,7 +169,6 @@ public class FailoverConsumerUnconsumedTest {
       produceMessage(consumerSession, destination, maxConsumers * prefetch);
 
       assertTrue("add messages are delivered", Wait.waitFor(new Wait.Condition() {
-         @Override
          public boolean isSatisified() throws Exception {
             int totalDelivered = 0;
             for (TestConsumer testConsumer : testConsumers) {
@@ -172,7 +183,6 @@ public class FailoverConsumerUnconsumedTest {
       final CountDownLatch shutdownConsumerAdded = new CountDownLatch(1);
 
       Executors.newSingleThreadExecutor().execute(new Runnable() {
-         @Override
          public void run() {
             try {
                LOG.info("add last consumer...");
@@ -198,17 +208,16 @@ public class FailoverConsumerUnconsumedTest {
          }
       });
 
-      // will be stopped by the plugin
-      broker.waitUntilStopped();
+      brokerStopLatch.await();
+      doByteman.set(false);
 
-      broker = createBroker(false, this.url);
+      broker = createBroker();
       broker.start();
 
       assertTrue("consumer added through failover", shutdownConsumerAdded.await(30, TimeUnit.SECONDS));
 
       // each should again get prefetch messages - all unacked deliveries should be rolledback
       assertTrue("after restart all messages are re dispatched", Wait.waitFor(new Wait.Condition() {
-         @Override
          public boolean isSatisified() throws Exception {
             int totalDelivered = 0;
             for (TestConsumer testConsumer : testConsumers) {
@@ -220,55 +229,19 @@ public class FailoverConsumerUnconsumedTest {
          }
       }));
 
-      assertTrue("after restart each got prefetch amount", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            for (TestConsumer testConsumer : testConsumers) {
-               long delivered = testConsumer.deliveredSize();
-               LOG.info(testConsumer.getConsumerId() + " delivered: " + delivered);
-               if (delivered != prefetch) {
-                  return false;
-               }
-            }
-            return true;
-         }
-      }));
-
       connection.close();
    }
 
    @SuppressWarnings("unchecked")
    public void doTestFailoverConsumerDups(final boolean watchTopicAdvisories) throws Exception {
 
-      final int maxConsumers = 4;
-      broker = createBroker(true);
-
-      broker.setPlugins(new BrokerPlugin[]{new BrokerPluginSupport() {
-         int consumerCount;
-
-         // broker is killed on x create consumer
-         @Override
-         public Subscription addConsumer(ConnectionContext context, final ConsumerInfo info) throws Exception {
-            if (++consumerCount == maxConsumers + (watchTopicAdvisories ? 1 : 0)) {
-               context.setDontSendReponse(true);
-               Executors.newSingleThreadExecutor().execute(new Runnable() {
-                  @Override
-                  public void run() {
-                     LOG.info("Stopping broker on consumer: " + info.getConsumerId());
-                     try {
-                        broker.stop();
-                     }
-                     catch (Exception e) {
-                        e.printStackTrace();
-                     }
-                  }
-               });
-            }
-            return super.addConsumer(context, info);
-         }
-      }});
+      maxConsumers = 4;
+      broker = createBroker();
       broker.start();
 
+      brokerStopLatch = new CountDownLatch(1);
+      doByteman.set(true);
+
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")");
       cf.setWatchTopicAdvisories(watchTopicAdvisories);
 
@@ -283,10 +256,11 @@ public class FailoverConsumerUnconsumedTest {
          testConsumers.add(new TestConsumer(consumerSession, destination, connection));
       }
 
+      assureQueueMessages(0, new SimpleString("jms.queue." + QUEUE_NAME));
+
       produceMessage(consumerSession, destination, maxConsumers * prefetch);
 
       assertTrue("add messages are dispatched", Wait.waitFor(new Wait.Condition() {
-         @Override
          public boolean isSatisified() throws Exception {
             int totalUnconsumed = 0;
             for (TestConsumer testConsumer : testConsumers) {
@@ -301,7 +275,6 @@ public class FailoverConsumerUnconsumedTest {
       final CountDownLatch shutdownConsumerAdded = new CountDownLatch(1);
 
       Executors.newSingleThreadExecutor().execute(new Runnable() {
-         @Override
          public void run() {
             try {
                LOG.info("add last consumer...");
@@ -315,12 +288,8 @@ public class FailoverConsumerUnconsumedTest {
          }
       });
 
-      // will be stopped by the plugin
-      broker.waitUntilStopped();
-
       // verify interrupt
       assertTrue("add messages dispatched and unconsumed are cleaned up", Wait.waitFor(new Wait.Condition() {
-         @Override
          public boolean isSatisified() throws Exception {
             int totalUnconsumed = 0;
             for (TestConsumer testConsumer : testConsumers) {
@@ -332,14 +301,16 @@ public class FailoverConsumerUnconsumedTest {
          }
       }));
 
-      broker = createBroker(false, this.url);
+      brokerStopLatch.await();
+      doByteman.set(false);
+
+      broker = createBroker();
       broker.start();
 
       assertTrue("consumer added through failover", shutdownConsumerAdded.await(30, TimeUnit.SECONDS));
 
       // each should again get prefetch messages - all unconsumed deliveries should be rolledback
       assertTrue("after start all messages are re dispatched", Wait.waitFor(new Wait.Condition() {
-         @Override
          public boolean isSatisified() throws Exception {
             int totalUnconsumed = 0;
             for (TestConsumer testConsumer : testConsumers) {
@@ -354,6 +325,11 @@ public class FailoverConsumerUnconsumedTest {
       connection.close();
    }
 
+   private void assureQueueMessages(int num, SimpleString queueName) {
+      QueueImpl queue = (QueueImpl) broker.getActiveMQServer().getPostOffice().getBinding(queueName).getBindable();
+      Assert.assertEquals(num, queue.getMessageCount());
+   }
+
    private void produceMessage(final Session producerSession, Queue destination, long count) throws JMSException {
       MessageProducer producer = producerSession.createProducer(destination);
       for (int i = 0; i < count; i++) {
@@ -385,4 +361,44 @@ public class FailoverConsumerUnconsumedTest {
       idGen -= 5;
       return idGen;
    }
+
+   public static void holdResponseAndStopBroker(AMQConnectionContext context) {
+      if (doByteman.get()) {
+         if (consumerCount.incrementAndGet() == maxConsumers) {
+            context.setDontSendReponse(true);
+            Executors.newSingleThreadExecutor().execute(new Runnable() {
+               public void run() {
+                  try {
+                     broker.stop();
+                     brokerStopLatch.countDown();
+                  }
+                  catch (Exception e) {
+                     e.printStackTrace();
+                  }
+               }
+            });
+         }
+      }
+   }
+
+   public static void holdResponseAndStopBroker2(AMQConnectionContext context) {
+      if (doByteman.get()) {
+         if (consumerCount.incrementAndGet() == maxConsumers + (watchTopicAdvisories.get() ? 1 : 0)) {
+            context.setDontSendReponse(true);
+            Executors.newSingleThreadExecutor().execute(new Runnable() {
+               public void run() {
+                  try {
+                     broker.stop();
+                     Assert.assertEquals(1, brokerStopLatch.getCount());
+                     brokerStopLatch.countDown();
+                  }
+                  catch (Exception e) {
+                     e.printStackTrace();
+                  }
+               }
+            });
+         }
+      }
+   }
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverDuplicateTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverDuplicateTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverDuplicateTest.java
index cb15940..e801b3c 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverDuplicateTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverDuplicateTest.java
@@ -33,25 +33,35 @@ import javax.jms.Session;
 import javax.jms.TextMessage;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.TestSupport;
-import org.apache.activemq.broker.BrokerPlugin;
-import org.apache.activemq.broker.BrokerPluginSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.ProducerBrokerExchange;
-import org.apache.activemq.broker.region.RegionBroker;
+import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
 import org.apache.activemq.util.Wait;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMRules;
+import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class FailoverDuplicateTest extends TestSupport {
+@RunWith(BMUnitRunner.class)
+public class FailoverDuplicateTest extends OpenwireArtemisBaseTest {
 
    private static final Logger LOG = LoggerFactory.getLogger(FailoverDuplicateTest.class);
    private static final String QUEUE_NAME = "TestQueue";
-   private static final String TRANSPORT_URI = "tcp://localhost:0";
-   private String url;
-   BrokerService broker;
 
-   @Override
+   private static final AtomicBoolean doByteman = new AtomicBoolean(false);
+   private static final AtomicBoolean first = new AtomicBoolean(false);
+   private static final CountDownLatch gotMessageLatch = new CountDownLatch(1);
+   private static final CountDownLatch producersDone = new CountDownLatch(1);
+
+   private String url = newURI(0);
+   EmbeddedJMS broker;
+
+   @After
    public void tearDown() throws Exception {
       stopBroker();
    }
@@ -63,72 +73,38 @@ public class FailoverDuplicateTest extends TestSupport {
    }
 
    public void startBroker(boolean deleteAllMessagesOnStartup) throws Exception {
-      broker = createBroker(deleteAllMessagesOnStartup);
+      broker = createBroker();
       broker.start();
    }
 
-   public void startBroker(boolean deleteAllMessagesOnStartup, String bindAddress) throws Exception {
-      broker = createBroker(deleteAllMessagesOnStartup, bindAddress);
+   public void startBroker() throws Exception {
+      broker = createBroker();
       broker.start();
    }
 
-   public BrokerService createBroker(boolean deleteAllMessagesOnStartup) throws Exception {
-      return createBroker(deleteAllMessagesOnStartup, TRANSPORT_URI);
-   }
-
-   public BrokerService createBroker(boolean deleteAllMessagesOnStartup, String bindAddress) throws Exception {
-      broker = new BrokerService();
-      broker.setUseJmx(false);
-      broker.setAdvisorySupport(false);
-      broker.addConnector(bindAddress);
-      broker.setDeleteAllMessagesOnStartup(deleteAllMessagesOnStartup);
-
-      url = broker.getTransportConnectors().get(0).getConnectUri().toString();
-
-      return broker;
-   }
-
    public void configureConnectionFactory(ActiveMQConnectionFactory factory) {
       factory.setAuditMaximumProducerNumber(2048);
       factory.setOptimizeAcknowledge(true);
    }
 
    @SuppressWarnings("unchecked")
+   @Test
+   @BMRules(
+           rules = {
+                   @BMRule(
+                           name = "set no return response and stop the broker",
+                           targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+                           targetMethod = "processMessage",
+                           targetLocation = "EXIT",
+                           binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
+                           action = "org.apache.activemq.transport.failover.FailoverDuplicateTest.holdResponseAndStopConn(context)")
+           }
+   )
    public void testFailoverSendReplyLost() throws Exception {
 
-      broker = createBroker(true);
-      setDefaultPersistenceAdapter(broker);
-
-      final CountDownLatch gotMessageLatch = new CountDownLatch(1);
-      final CountDownLatch producersDone = new CountDownLatch(1);
-      final AtomicBoolean first = new AtomicBoolean(false);
-      broker.setPlugins(new BrokerPlugin[]{new BrokerPluginSupport() {
-         @Override
-         public void send(final ProducerBrokerExchange producerExchange,
-                          org.apache.activemq.command.Message messageSend) throws Exception {
-            // so send will hang as if reply is lost
-            super.send(producerExchange, messageSend);
-            if (first.compareAndSet(false, true)) {
-               producerExchange.getConnectionContext().setDontSendReponse(true);
-               Executors.newSingleThreadExecutor().execute(new Runnable() {
-                  @Override
-                  public void run() {
-                     try {
-                        LOG.info("Waiting for recepit");
-                        assertTrue("message received on time", gotMessageLatch.await(60, TimeUnit.SECONDS));
-                        assertTrue("new producers done on time", producersDone.await(120, TimeUnit.SECONDS));
-                        LOG.info("Stopping connection post send and receive and multiple producers");
-                        producerExchange.getConnectionContext().getConnection().stop();
-                     }
-                     catch (Exception e) {
-                        e.printStackTrace();
-                     }
-                  }
-               });
-            }
-         }
-      }});
+      broker = createBroker();
       broker.start();
+      doByteman.set(true);
 
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")?jms.watchTopicAdvisories=false");
       configureConnectionFactory(cf);
@@ -164,14 +140,14 @@ public class FailoverDuplicateTest extends TestSupport {
             }
             catch (JMSException e) {
                LOG.error("got send exception: ", e);
-               fail("got unexpected send exception" + e);
+               Assert.fail("got unexpected send exception" + e);
             }
             sendDoneLatch.countDown();
             LOG.info("done async send");
          }
       });
 
-      assertTrue("one message got through on time", gotMessageLatch.await(20, TimeUnit.SECONDS));
+      Assert.assertTrue("one message got through on time", gotMessageLatch.await(20, TimeUnit.SECONDS));
       // send more messages, blow producer audit
       final int numProducers = 1050;
       final int numPerProducer = 2;
@@ -186,7 +162,7 @@ public class FailoverDuplicateTest extends TestSupport {
          }
       }
 
-      assertTrue("message sent complete through failover", sendDoneLatch.await(30, TimeUnit.SECONDS));
+      Assert.assertTrue("message sent complete through failover", sendDoneLatch.await(30, TimeUnit.SECONDS));
 
       Wait.waitFor(new Wait.Condition() {
          @Override
@@ -195,29 +171,16 @@ public class FailoverDuplicateTest extends TestSupport {
             return totalSent <= receivedCount.get();
          }
       });
-      assertEquals("we got all produced messages", totalSent, receivedCount.get());
+      Assert.assertEquals("we got all produced messages", totalSent, receivedCount.get());
       sendConnection.close();
       receiveConnection.close();
 
-      // verify stats
-      assertEquals("expect all messages are dequeued with one duplicate to dlq", totalSent + 2, ((RegionBroker) broker.getRegionBroker()).getDestinationStatistics().getEnqueues().getCount());
-
-      Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            LOG.info("dequeues : " + ((RegionBroker) broker.getRegionBroker()).getDestinationStatistics().getDequeues().getCount());
-            return totalSent + 1 <= ((RegionBroker) broker.getRegionBroker()).getDestinationStatistics().getDequeues().getCount();
-         }
-      });
-      assertEquals("dequeue correct, including duplicate dispatch poisoned", totalSent + 1, ((RegionBroker) broker.getRegionBroker()).getDestinationStatistics().getDequeues().getCount());
-
       // ensure no dangling messages with fresh broker etc
       broker.stop();
-      broker.waitUntilStopped();
+      doByteman.set(false);
 
       LOG.info("Checking for remaining/hung messages with second restart..");
-      broker = createBroker(false, url);
-      setDefaultPersistenceAdapter(broker);
+      broker = createBroker();
       broker.start();
 
       // after restart, ensure no dangling messages
@@ -231,7 +194,7 @@ public class FailoverDuplicateTest extends TestSupport {
       if (msg == null) {
          msg = consumer.receive(5000);
       }
-      assertNull("no messges left dangling but got: " + msg, msg);
+      Assert.assertNull("no messges left dangling but got: " + msg, msg);
 
       sendConnection.close();
    }
@@ -247,4 +210,28 @@ public class FailoverDuplicateTest extends TestSupport {
       }
       producer.close();
    }
+
+   public static void holdResponseAndStopConn(final AMQConnectionContext context) {
+      if (doByteman.get()) {
+         if (first.compareAndSet(false, true)) {
+            context.setDontSendReponse(true);
+            Executors.newSingleThreadExecutor().execute(new Runnable() {
+               @Override
+               public void run() {
+                  try {
+                     LOG.info("Waiting for recepit");
+                     Assert.assertTrue("message received on time", gotMessageLatch.await(60, TimeUnit.SECONDS));
+                     Assert.assertTrue("new producers done on time", producersDone.await(120, TimeUnit.SECONDS));
+                     LOG.info("Stopping connection post send and receive and multiple producers");
+                     context.getConnection().fail(null, "test Failoverduplicatetest");
+                  }
+                  catch (Exception e) {
+                     e.printStackTrace();
+                  }
+               }
+            });
+         }
+      }
+   }
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPrefetchZeroTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPrefetchZeroTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPrefetchZeroTest.java
index 57899ba..fcb60e5 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPrefetchZeroTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPrefetchZeroTest.java
@@ -6,7 +6,7 @@
  * (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
+ * 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,
@@ -16,10 +16,6 @@
  */
 package org.apache.activemq.transport.failover;
 
-import java.util.Vector;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageConsumer;
@@ -27,31 +23,42 @@ import javax.jms.MessageProducer;
 import javax.jms.Queue;
 import javax.jms.Session;
 import javax.jms.TextMessage;
+import java.util.Vector;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerPlugin;
-import org.apache.activemq.broker.BrokerPluginSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.ConnectionContext;
-import org.apache.activemq.command.MessagePull;
-import org.apache.activemq.command.Response;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMRules;
+import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
 import org.junit.After;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import static org.junit.Assert.assertTrue;
 
 // see: https://issues.apache.org/activemq/browse/AMQ-2877
-public class FailoverPrefetchZeroTest {
+@RunWith(BMUnitRunner.class)
+public class FailoverPrefetchZeroTest extends OpenwireArtemisBaseTest {
 
    private static final Logger LOG = LoggerFactory.getLogger(FailoverPrefetchZeroTest.class);
    private static final String QUEUE_NAME = "FailoverPrefetchZero";
-   private static final String TRANSPORT_URI = "tcp://localhost:0";
-   private String url;
+
+   private static final AtomicBoolean doByteman = new AtomicBoolean(false);
+   private static final CountDownLatch pullDone = new CountDownLatch(1);
+   private static CountDownLatch brokerStopLatch = new CountDownLatch(1);
+
+   private String url = newURI(0);
    final int prefetch = 0;
-   BrokerService broker;
+   private static EmbeddedJMS broker;
 
    @After
    public void stopBroker() throws Exception {
@@ -60,52 +67,25 @@ public class FailoverPrefetchZeroTest {
       }
    }
 
-   public void startBroker(boolean deleteAllMessagesOnStartup) throws Exception {
-      broker = createBroker(deleteAllMessagesOnStartup);
+   public void startBroker() throws Exception {
+      broker = createBroker();
       broker.start();
    }
 
-   public BrokerService createBroker(boolean deleteAllMessagesOnStartup) throws Exception {
-      return createBroker(deleteAllMessagesOnStartup, TRANSPORT_URI);
-   }
-
-   public BrokerService createBroker(boolean deleteAllMessagesOnStartup, String bindAddress) throws Exception {
-      broker = new BrokerService();
-      broker.addConnector(bindAddress);
-      broker.setDeleteAllMessagesOnStartup(deleteAllMessagesOnStartup);
-
-      url = broker.getTransportConnectors().get(0).getConnectUri().toString();
-
-      return broker;
-   }
-
    @SuppressWarnings("unchecked")
    @Test
+   @BMRules(
+      rules = {@BMRule(
+         name = "set no return response and stop the broker",
+         targetClass = "org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection",
+         targetMethod = "processMessagePull",
+         targetLocation = "ENTRY",
+         binding = "owconn:OpenWireConnection = $0; context = owconn.getContext()",
+         action = "org.apache.activemq.transport.failover.FailoverPrefetchZeroTest.holdResponseAndStopBroker(context)")})
    public void testPrefetchZeroConsumerThroughRestart() throws Exception {
-      broker = createBroker(true);
-
-      final CountDownLatch pullDone = new CountDownLatch(1);
-      broker.setPlugins(new BrokerPlugin[]{new BrokerPluginSupport() {
-         @Override
-         public Response messagePull(ConnectionContext context, final MessagePull pull) throws Exception {
-            context.setDontSendReponse(true);
-            pullDone.countDown();
-            Executors.newSingleThreadExecutor().execute(new Runnable() {
-               @Override
-               public void run() {
-                  LOG.info("Stopping broker on pull: " + pull);
-                  try {
-                     broker.stop();
-                  }
-                  catch (Exception e) {
-                     e.printStackTrace();
-                  }
-               }
-            });
-            return null;
-         }
-      }});
+      broker = createBroker();
       broker.start();
+      doByteman.set(true);
 
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")");
       cf.setWatchTopicAdvisories(false);
@@ -122,7 +102,6 @@ public class FailoverPrefetchZeroTest {
       final CountDownLatch receiveDone = new CountDownLatch(1);
       final Vector<Message> received = new Vector<>();
       Executors.newSingleThreadExecutor().execute(new Runnable() {
-         @Override
          public void run() {
             try {
                LOG.info("receive one...");
@@ -141,8 +120,9 @@ public class FailoverPrefetchZeroTest {
 
       // will be stopped by the plugin
       assertTrue("pull completed on broker", pullDone.await(30, TimeUnit.SECONDS));
-      broker.waitUntilStopped();
-      broker = createBroker(false, url);
+      brokerStopLatch.await();
+      doByteman.set(false);
+      broker = createBroker();
       broker.start();
 
       assertTrue("receive completed through failover", receiveDone.await(30, TimeUnit.SECONDS));
@@ -160,4 +140,25 @@ public class FailoverPrefetchZeroTest {
       }
       producer.close();
    }
+
+   public static void holdResponseAndStopBroker(final AMQConnectionContext context) {
+      if (doByteman.get()) {
+         context.setDontSendReponse(true);
+         pullDone.countDown();
+         Executors.newSingleThreadExecutor().execute(new Runnable() {
+            public void run() {
+               try {
+                  broker.stop();
+               }
+               catch (Exception e) {
+                  e.printStackTrace();
+               }
+               finally {
+                  brokerStopLatch.countDown();
+               }
+            }
+         });
+      }
+   }
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPriorityTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPriorityTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPriorityTest.java
index b8860a7..6e559e7 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPriorityTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPriorityTest.java
@@ -16,58 +16,106 @@
  */
 package org.apache.activemq.transport.failover;
 
+import java.util.ArrayList;
 import java.util.HashMap;
-
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.activemq.ActiveMQConnection;
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class FailoverPriorityTest extends FailoverClusterTestSupport {
+import javax.jms.Connection;
+import javax.jms.JMSException;
+
+public class FailoverPriorityTest extends OpenwireArtemisBaseTest {
 
    protected final Logger LOG = LoggerFactory.getLogger(getClass());
 
    private static final String BROKER_A_CLIENT_TC_ADDRESS = "tcp://127.0.0.1:61616";
    private static final String BROKER_B_CLIENT_TC_ADDRESS = "tcp://127.0.0.1:61617";
    private static final String BROKER_C_CLIENT_TC_ADDRESS = "tcp://127.0.0.1:61618";
-   private final HashMap<String, String> urls = new HashMap<>();
+   private final HashMap<Integer, String> urls = new HashMap<>();
+
+   private final List<ActiveMQConnection> connections = new ArrayList<ActiveMQConnection>();
+   private EmbeddedJMS[] servers = new EmbeddedJMS[3];
+   private String clientUrl;
 
-   @Override
+   @Before
    public void setUp() throws Exception {
-      super.setUp();
-      urls.put(BROKER_A_NAME, BROKER_A_CLIENT_TC_ADDRESS);
-      urls.put(BROKER_B_NAME, BROKER_B_CLIENT_TC_ADDRESS);
+      urls.put(0, BROKER_A_CLIENT_TC_ADDRESS);
+      urls.put(1, BROKER_B_CLIENT_TC_ADDRESS);
    }
 
-   private static final String BROKER_A_NAME = "BROKERA";
-   private static final String BROKER_B_NAME = "BROKERB";
-   private static final String BROKER_C_NAME = "BROKERC";
+   @After
+   public void tearDown() throws Exception {
+      shutdownClients();
+      for (EmbeddedJMS server : servers) {
+         if (server != null) {
+            server.stop();
+         }
+      }
+   }
 
+   @Test
    public void testPriorityBackup() throws Exception {
-      createBrokerA();
-      createBrokerB();
-      getBroker(BROKER_B_NAME).waitUntilStarted();
+      Configuration config0 = createConfig("127.0.0.1", 0);
+      Configuration config1 = createConfig("127.0.0.1", 1);
+
+      deployClusterConfiguration(config0, 1);
+      deployClusterConfiguration(config1, 0);
+
+      servers[0] = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
+      servers[1] = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
+      servers[0].start();
+      servers[1].start();
+
+      Assert.assertTrue(servers[0].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
+      Assert.assertTrue(servers[1].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
+
       Thread.sleep(1000);
 
       setClientUrl("failover:(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + ")?randomize=false&priorityBackup=true&initialReconnectDelay=1000&useExponentialBackOff=false");
       createClients(5);
 
-      assertAllConnectedTo(urls.get(BROKER_A_NAME));
+      assertAllConnectedTo(urls.get(0));
 
-      restart(false, BROKER_A_NAME, BROKER_B_NAME);
+      restart(false, 0, 1);
 
       for (int i = 0; i < 3; i++) {
-         restart(true, BROKER_A_NAME, BROKER_B_NAME);
+         restart(true, 0, 1);
       }
 
       Thread.sleep(5000);
 
-      restart(false, BROKER_A_NAME, BROKER_B_NAME);
+      restart(false, 0, 1);
 
    }
 
+   @Test
    public void testPriorityBackupList() throws Exception {
-      createBrokerA();
-      createBrokerB();
-      getBroker(BROKER_B_NAME).waitUntilStarted();
+      Configuration config0 = createConfig("127.0.0.1", 0);
+      Configuration config1 = createConfig("127.0.0.1", 1);
+
+      deployClusterConfiguration(config0, 1);
+      deployClusterConfiguration(config1, 0);
+
+      servers[0] = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
+      servers[1] = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
+      servers[0].start();
+      servers[1].start();
+
+      Assert.assertTrue(servers[0].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
+      Assert.assertTrue(servers[1].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
       Thread.sleep(1000);
 
       setClientUrl("failover:(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + ")?randomize=false&priorityBackup=true&priorityURIs=tcp://127.0.0.1:61617&initialReconnectDelay=1000&useExponentialBackOff=false");
@@ -75,154 +123,166 @@ public class FailoverPriorityTest extends FailoverClusterTestSupport {
 
       Thread.sleep(3000);
 
-      assertAllConnectedTo(urls.get(BROKER_B_NAME));
+      assertAllConnectedTo(urls.get(1));
 
-      restart(false, BROKER_B_NAME, BROKER_A_NAME);
+      restart(false, 1, 0);
 
       for (int i = 0; i < 3; i++) {
-         restart(true, BROKER_B_NAME, BROKER_A_NAME);
+         restart(true, 1, 0);
       }
 
-      restart(false, BROKER_B_NAME, BROKER_A_NAME);
-
+      restart(false, 1, 0);
    }
 
+   @Test
    public void testThreeBrokers() throws Exception {
-      // Broker A
-      addBroker(BROKER_A_NAME, createBroker(BROKER_A_NAME));
-      addTransportConnector(getBroker(BROKER_A_NAME), "openwire", BROKER_A_CLIENT_TC_ADDRESS, false);
-      addNetworkBridge(getBroker(BROKER_A_NAME), "A_2_B_Bridge", "static://(" + BROKER_B_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=false", false, null);
-      addNetworkBridge(getBroker(BROKER_A_NAME), "A_2_C_Bridge", "static://(" + BROKER_C_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=false", false, null);
-      getBroker(BROKER_A_NAME).start();
-
-      // Broker B
-      addBroker(BROKER_B_NAME, createBroker(BROKER_B_NAME));
-      addTransportConnector(getBroker(BROKER_B_NAME), "openwire", BROKER_B_CLIENT_TC_ADDRESS, false);
-      addNetworkBridge(getBroker(BROKER_B_NAME), "B_2_A_Bridge", "static://(" + BROKER_A_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=false", false, null);
-      addNetworkBridge(getBroker(BROKER_B_NAME), "B_2_C_Bridge", "static://(" + BROKER_C_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=false", false, null);
-      getBroker(BROKER_B_NAME).start();
-
-      // Broker C
-      addBroker(BROKER_C_NAME, createBroker(BROKER_C_NAME));
-      addTransportConnector(getBroker(BROKER_C_NAME), "openwire", BROKER_C_CLIENT_TC_ADDRESS, false);
-      addNetworkBridge(getBroker(BROKER_C_NAME), "C_2_A_Bridge", "static://(" + BROKER_A_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=false", false, null);
-      addNetworkBridge(getBroker(BROKER_C_NAME), "C_2_B_Bridge", "static://(" + BROKER_B_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=false", false, null);
-      getBroker(BROKER_C_NAME).start();
-
-      getBroker(BROKER_C_NAME).waitUntilStarted();
+      commonSetup();
       Thread.sleep(1000);
 
       setClientUrl("failover:(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + "," + BROKER_C_CLIENT_TC_ADDRESS + ")?randomize=false&priorityBackup=true&initialReconnectDelay=1000&useExponentialBackOff=false");
 
       createClients(5);
 
-      assertAllConnectedTo(urls.get(BROKER_A_NAME));
-
-      restart(true, BROKER_A_NAME, BROKER_B_NAME);
+      assertAllConnectedTo(urls.get(0));
 
+      restart(true, 0, 1, 3);
    }
 
+   @Test
    public void testPriorityBackupAndUpdateClients() throws Exception {
-      // Broker A
-      addBroker(BROKER_A_NAME, createBroker(BROKER_A_NAME));
-      addTransportConnector(getBroker(BROKER_A_NAME), "openwire", BROKER_A_CLIENT_TC_ADDRESS, true);
-      addNetworkBridge(getBroker(BROKER_A_NAME), "A_2_B_Bridge", "static://(" + BROKER_B_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=false", false, null);
-      getBroker(BROKER_A_NAME).start();
-
-      // Broker B
-      addBroker(BROKER_B_NAME, createBroker(BROKER_B_NAME));
-      addTransportConnector(getBroker(BROKER_B_NAME), "openwire", BROKER_B_CLIENT_TC_ADDRESS, true);
-      addNetworkBridge(getBroker(BROKER_B_NAME), "B_2_A_Bridge", "static://(" + BROKER_A_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=false", false, null);
-      getBroker(BROKER_B_NAME).start();
-
-      getBroker(BROKER_B_NAME).waitUntilStarted();
+      Configuration config0 = createConfig("127.0.0.1", 0);
+      Configuration config1 = createConfig("127.0.0.1", 1);
+
+      deployClusterConfiguration(config0, 1);
+      deployClusterConfiguration(config1, 0);
+
+      servers[0] = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
+      servers[1] = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
+      servers[0].start();
+      servers[1].start();
+
+      Assert.assertTrue(servers[0].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
+      Assert.assertTrue(servers[1].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
+
       Thread.sleep(1000);
 
       setClientUrl("failover:(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + ")?randomize=false&priorityBackup=true&initialReconnectDelay=1000&useExponentialBackOff=false");
 
-      LOG.info("Client URI will be: " + getClientUrl());
-
       createClients(5);
 
       // Let's wait a little bit longer just in case it takes a while to realize that the
       // Broker A is the one with higher priority.
       Thread.sleep(5000);
 
-      assertAllConnectedTo(urls.get(BROKER_A_NAME));
+      assertAllConnectedTo(urls.get(0));
    }
 
-   private void restart(boolean primary, String primaryName, String secondaryName) throws Exception {
+   private void restart(boolean primary, int primaryID, int secondaryID) throws Exception {
+      restart(primary, primaryID, secondaryID, 2);
+   }
+
+   private void restart(boolean primary, int primaryID, int secondaryID, int total) throws Exception {
 
       Thread.sleep(1000);
 
       if (primary) {
-         LOG.info("Stopping " + primaryName);
-         stopBroker(primaryName);
+         LOG.info("Stopping " + primaryID);
+         stopBroker(primaryID);
+         Assert.assertTrue(servers[secondaryID].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, total - 1));
       }
       else {
-         LOG.info("Stopping " + secondaryName);
-         stopBroker(secondaryName);
+         LOG.info("Stopping " + secondaryID);
+         stopBroker(secondaryID);
+         Assert.assertTrue(servers[primaryID].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, total - 1));
       }
       Thread.sleep(5000);
 
       if (primary) {
-         assertAllConnectedTo(urls.get(secondaryName));
+         assertAllConnectedTo(urls.get(secondaryID));
       }
       else {
-         assertAllConnectedTo(urls.get(primaryName));
+         assertAllConnectedTo(urls.get(primaryID));
       }
 
       if (primary) {
-         LOG.info("Starting " + primaryName);
-         createBrokerByName(primaryName);
-         getBroker(primaryName).waitUntilStarted();
+         Configuration config = createConfig("127.0.0.1", primaryID);
+
+         deployClusterConfiguration(config, secondaryID);
+
+         servers[primaryID] = new EmbeddedJMS().setConfiguration(config).setJmsConfiguration(new JMSConfigurationImpl());
+         servers[primaryID].start();
+
+         Assert.assertTrue(servers[primaryID].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, total));
+         Assert.assertTrue(servers[secondaryID].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, total));
       }
       else {
-         LOG.info("Starting " + secondaryName);
-         createBrokerByName(secondaryName);
-         getBroker(secondaryName).waitUntilStarted();
+         Configuration config = createConfig("127.0.0.1", secondaryID);
+
+         deployClusterConfiguration(config, primaryID);
+
+         servers[secondaryID] = new EmbeddedJMS().setConfiguration(config).setJmsConfiguration(new JMSConfigurationImpl());
+         servers[secondaryID].start();
+
+         Assert.assertTrue(servers[primaryID].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, total));
+         Assert.assertTrue(servers[secondaryID].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, total));
       }
 
       Thread.sleep(5000);
 
-      assertAllConnectedTo(urls.get(primaryName));
+      assertAllConnectedTo(urls.get(primaryID));
 
    }
 
-   private void createBrokerByName(String name) throws Exception {
-      if (name.equals(BROKER_A_NAME)) {
-         createBrokerA();
-      }
-      else if (name.equals(BROKER_B_NAME)) {
-         createBrokerB();
-      }
-      else {
-         throw new Exception("Unknown broker " + name);
+   private void stopBroker(int serverID) throws Exception {
+      servers[serverID].stop();
+   }
+
+   public void setClientUrl(String clientUrl) {
+      this.clientUrl = clientUrl;
+   }
+
+   protected void createClients(int numOfClients) throws Exception {
+      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(clientUrl);
+      for (int i = 0; i < numOfClients; i++) {
+         ActiveMQConnection c = (ActiveMQConnection) factory.createConnection();
+         c.start();
+         connections.add(c);
       }
    }
 
-   private void createBrokerA() throws Exception {
-      if (getBroker(BROKER_A_NAME) == null) {
-         addBroker(BROKER_A_NAME, createBroker(BROKER_A_NAME));
-         addTransportConnector(getBroker(BROKER_A_NAME), "openwire", BROKER_A_CLIENT_TC_ADDRESS, false);
-         addNetworkBridge(getBroker(BROKER_A_NAME), "A_2_B_Bridge", "static://(" + BROKER_B_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=false", false, null);
-         getBroker(BROKER_A_NAME).start();
+   protected void shutdownClients() throws JMSException {
+      for (Connection c : connections) {
+         c.close();
       }
    }
 
-   private void createBrokerB() throws Exception {
-      if (getBroker(BROKER_B_NAME) == null) {
-         addBroker(BROKER_B_NAME, createBroker(BROKER_B_NAME));
-         addTransportConnector(getBroker(BROKER_B_NAME), "openwire", BROKER_B_CLIENT_TC_ADDRESS, false);
-         addNetworkBridge(getBroker(BROKER_B_NAME), "B_2_A_Bridge", "static://(" + BROKER_A_CLIENT_TC_ADDRESS + ")?useExponentialBackOff=false", false, null);
-         getBroker(BROKER_B_NAME).start();
+   protected void assertAllConnectedTo(String url) throws Exception {
+      for (ActiveMQConnection c : connections) {
+         Assert.assertEquals(url, c.getTransportChannel().getRemoteAddress());
       }
    }
 
-   @Override
-   protected void tearDown() throws Exception {
-      shutdownClients();
-      destroyBrokerCluster();
+   //default setup for most tests
+   private void commonSetup() throws Exception {
+      Configuration config0 = createConfig("127.0.0.1", 0);
+      Configuration config1 = createConfig("127.0.0.1", 1);
+      Configuration config2 = createConfig("127.0.0.1", 2);
+
+      deployClusterConfiguration(config0, 1, 2);
+      deployClusterConfiguration(config1, 0, 2);
+      deployClusterConfiguration(config2, 0, 1);
+
+      servers[0] = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
+      servers[1] = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
+      servers[2] = new EmbeddedJMS().setConfiguration(config2).setJmsConfiguration(new JMSConfigurationImpl());
+
+      servers[0].start();
+      servers[1].start();
+      servers[2].start();
+
+      Assert.assertTrue(servers[0].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 3));
+      Assert.assertTrue(servers[1].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 3));
+      Assert.assertTrue(servers[2].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 3));
    }
 
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRandomTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRandomTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRandomTest.java
index 54dd3e3..80f83db 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRandomTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRandomTest.java
@@ -17,47 +17,59 @@
 
 package org.apache.activemq.transport.failover;
 
-import junit.framework.TestCase;
-
 import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.concurrent.TimeUnit;
 
-public class FailoverRandomTest extends TestCase {
+public class FailoverRandomTest extends OpenwireArtemisBaseTest {
 
-   BrokerService brokerA, brokerB;
+   private EmbeddedJMS server0, server1;
 
-   @Override
+   @Before
    public void setUp() throws Exception {
-      brokerA = createBroker("A");
-      brokerB = createBroker("B");
-   }
+      Configuration config0 = createConfig(0);
+      Configuration config1 = createConfig(1);
 
-   @Override
-   public void tearDown() throws Exception {
-      brokerA.stop();
-      brokerB.stop();
+      deployClusterConfiguration(config0, 1);
+      deployClusterConfiguration(config1, 0);
+
+      server0 = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
+      server1 = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());
+
+      server0.start();
+      server1.start();
+
+      server0.getActiveMQServer().setIdentity("BrokerA");
+      server1.getActiveMQServer().setIdentity("BrokerB");
+
+      Assert.assertTrue(server0.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
+      Assert.assertTrue(server1.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
    }
 
-   private BrokerService createBroker(String name) throws Exception {
-      BrokerService broker = new BrokerService();
-      broker.setBrokerName("Broker" + name);
-      broker.addConnector("tcp://localhost:0");
-      broker.getManagementContext().setCreateConnector(false);
-      broker.setPersistent(false);
-      broker.setUseJmx(false);
-      broker.start();
-      return broker;
+   @After
+   public void tearDown() throws Exception {
+      server0.stop();
+      server1.stop();
    }
 
+   @Test
    public void testRandomConnections() throws Exception {
-      String failoverUrl = "failover:(" + brokerA.getTransportConnectors().get(0).getConnectUri() + "," + brokerB.getTransportConnectors().get(0).getConnectUri() + ")";
+      String failoverUrl = "failover:(" + newURI(0) + "," + newURI(1) + ")";
       ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(failoverUrl);
 
       ActiveMQConnection connection = (ActiveMQConnection) cf.createConnection();
       connection.start();
       String brokerName1 = connection.getBrokerName();
-      assertNotNull(brokerName1);
+      Assert.assertNotNull(brokerName1);
       connection.close();
 
       String brokerName2 = brokerName1;
@@ -66,9 +78,9 @@ public class FailoverRandomTest extends TestCase {
          connection = (ActiveMQConnection) cf.createConnection();
          connection.start();
          brokerName2 = connection.getBrokerName();
-         assertNotNull(brokerName2);
+         Assert.assertNotNull(brokerName2);
          connection.close();
       }
-      assertTrue(brokerName1 + "!=" + brokerName2, !brokerName1.equals(brokerName2));
+      Assert.assertTrue(brokerName1 + "!=" + brokerName2, !brokerName1.equals(brokerName2));
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRedeliveryTransactionTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRedeliveryTransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRedeliveryTransactionTest.java
index 6b7a2bb..3be2593 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRedeliveryTransactionTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverRedeliveryTransactionTest.java
@@ -16,19 +16,15 @@
  */
 package org.apache.activemq.transport.failover;
 
-import junit.framework.Test;
-
 import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.broker.region.policy.PolicyEntry;
 import org.apache.activemq.broker.region.policy.PolicyMap;
+import org.junit.Test;
 
 public class FailoverRedeliveryTransactionTest extends FailoverTransactionTest {
 
-   public static Test suite() {
-      return suite(FailoverRedeliveryTransactionTest.class);
-   }
-
    @Override
    public void configureConnectionFactory(ActiveMQConnectionFactory factory) {
       super.configureConnectionFactory(factory);
@@ -36,26 +32,24 @@ public class FailoverRedeliveryTransactionTest extends FailoverTransactionTest {
    }
 
    @Override
-   public BrokerService createBroker(boolean deleteAllMessagesOnStartup, String bindAddress) throws Exception {
-      BrokerService brokerService = super.createBroker(deleteAllMessagesOnStartup, bindAddress);
+   public EmbeddedJMS createBroker() throws Exception {
+      EmbeddedJMS brokerService = super.createBroker();
       PolicyMap policyMap = new PolicyMap();
       PolicyEntry defaultEntry = new PolicyEntry();
       defaultEntry.setPersistJMSRedelivered(true);
       policyMap.setDefaultEntry(defaultEntry);
-      brokerService.setDestinationPolicy(policyMap);
+      //revisit: do we support sth like persistJMSRedelivered?
+      //brokerService.setDestinationPolicy(policyMap);
       return brokerService;
    }
 
    // no point rerunning these
    @Override
+   @Test
    public void testFailoverProducerCloseBeforeTransaction() throws Exception {
    }
 
    @Override
-   public void initCombosForTestFailoverCommitReplyLost() {
-   }
-
-   @Override
    public void testFailoverCommitReplyLost() throws Exception {
    }
 
@@ -64,18 +58,10 @@ public class FailoverRedeliveryTransactionTest extends FailoverTransactionTest {
    }
 
    @Override
-   public void initCombosForTestFailoverSendReplyLost() {
-   }
-
-   @Override
    public void testFailoverSendReplyLost() throws Exception {
    }
 
    @Override
-   public void initCombosForTestFailoverConnectionSendReplyLost() {
-   }
-
-   @Override
    public void testFailoverConnectionSendReplyLost() throws Exception {
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTimeoutTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTimeoutTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTimeoutTest.java
index 07a8436..c5ee02f 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTimeoutTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTimeoutTest.java
@@ -30,40 +30,43 @@ import javax.jms.TextMessage;
 
 import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
 import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class FailoverTimeoutTest {
+public class FailoverTimeoutTest extends OpenwireArtemisBaseTest {
 
    private static final Logger LOG = LoggerFactory.getLogger(FailoverTimeoutTest.class);
 
    private static final String QUEUE_NAME = "test.failovertimeout";
-   BrokerService bs;
+   EmbeddedJMS server;
    URI tcpUri;
 
    @Before
    public void setUp() throws Exception {
-      bs = new BrokerService();
-      bs.setUseJmx(false);
-      bs.addConnector("tcp://localhost:0");
-      bs.start();
-      tcpUri = bs.getTransportConnectors().get(0).getConnectUri();
+      Configuration config = createConfig(0);
+      server = new EmbeddedJMS().setConfiguration(config).setJmsConfiguration(new JMSConfigurationImpl());
+      server.start();
+      tcpUri = new URI(newURI(0));
    }
 
    @After
    public void tearDown() throws Exception {
-      if (bs != null) {
-         bs.stop();
+      if (server != null) {
+         server.stop();
       }
    }
 
    @Test
    public void testTimoutDoesNotFailConnectionAttempts() throws Exception {
-      bs.stop();
+      server.stop();
       long timeout = 1000;
 
       long startTime = System.currentTimeMillis();
@@ -99,7 +102,7 @@ public class FailoverTimeoutTest {
       TextMessage message = session.createTextMessage("Test message");
       producer.send(message);
 
-      bs.stop();
+      server.stop();
 
       try {
          producer.send(message);
@@ -108,15 +111,14 @@ public class FailoverTimeoutTest {
          assertEquals("Failover timeout of " + timeout + " ms reached.", jmse.getMessage());
       }
 
-      bs = new BrokerService();
-      bs.setUseJmx(false);
-      bs.addConnector(tcpUri);
-      bs.start();
-      bs.waitUntilStarted();
+      Configuration config = createConfig(0);
+      server = new EmbeddedJMS().setConfiguration(config).setJmsConfiguration(new JMSConfigurationImpl());
+      server.start();
 
       producer.send(message);
 
-      bs.stop();
+      server.stop();
+      server = null;
    }
 
    @Test


[14/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5266SingleDestTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5266SingleDestTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5266SingleDestTest.java
deleted file mode 100644
index 98fc79b..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5266SingleDestTest.java
+++ /dev/null
@@ -1,617 +0,0 @@
-/**
- * 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;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeSet;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.RedeliveryPolicy;
-import org.apache.activemq.TestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.TransportConnector;
-import org.apache.activemq.broker.region.RegionBroker;
-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.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Non transactional concurrent producer/consumer to single dest
- */
-@RunWith(Parameterized.class)
-public class AMQ5266SingleDestTest {
-
-   static Logger LOG = LoggerFactory.getLogger(AMQ5266SingleDestTest.class);
-   String activemqURL;
-   BrokerService brokerService;
-
-   public int numDests = 1;
-   public int messageSize = 10 * 1000;
-
-   @Parameterized.Parameter(0)
-   public int publisherMessagesPerThread = 1000;
-
-   @Parameterized.Parameter(1)
-   public int publisherThreadCount = 20;
-
-   @Parameterized.Parameter(2)
-   public int consumerThreadsPerQueue = 5;
-
-   @Parameterized.Parameter(3)
-   public int destMemoryLimit = 50 * 1024;
-
-   @Parameterized.Parameter(4)
-   public boolean useCache = true;
-
-   @Parameterized.Parameter(5)
-   public TestSupport.PersistenceAdapterChoice persistenceAdapterChoice = TestSupport.PersistenceAdapterChoice.KahaDB;
-
-   @Parameterized.Parameter(6)
-   public boolean optimizeDispatch = false;
-
-   @Parameterized.Parameters(name = "#{0},producerThreads:{1},consumerThreads:{2},mL:{3},useCache:{4},useDefaultStore:{5},optimizedDispatch:{6}")
-   public static Iterable<Object[]> parameters() {
-      return Arrays.asList(new Object[][]{{1000, 40, 40, 1024 * 1024 * 1, true, TestSupport.PersistenceAdapterChoice.KahaDB, false}, {1000, 40, 40, 1024 * 1024 * 1, true, TestSupport.PersistenceAdapterChoice.LevelDB, false}, {1000, 40, 40, 1024 * 1024 * 1, true, TestSupport.PersistenceAdapterChoice.JDBC, false},});
-   }
-
-   public int consumerBatchSize = 25;
-
-   @BeforeClass
-   public static void derbyTestMode() throws Exception {
-      System.setProperty("derby.system.durability", "test");
-   }
-
-   @Before
-   public void startBroker() throws Exception {
-      brokerService = new BrokerService();
-
-      TestSupport.setPersistenceAdapter(brokerService, persistenceAdapterChoice);
-      brokerService.setDeleteAllMessagesOnStartup(true);
-      brokerService.setUseJmx(false);
-      brokerService.setAdvisorySupport(false);
-
-      PolicyMap policyMap = new PolicyMap();
-      PolicyEntry defaultEntry = new PolicyEntry();
-      defaultEntry.setUseConsumerPriority(false); // java.lang.IllegalArgumentException: Comparison method violates its general contract!
-      defaultEntry.setMaxProducersToAudit(publisherThreadCount);
-      defaultEntry.setEnableAudit(true);
-      defaultEntry.setUseCache(useCache);
-      defaultEntry.setMaxPageSize(1000);
-      defaultEntry.setOptimizedDispatch(optimizeDispatch);
-      defaultEntry.setMemoryLimit(destMemoryLimit);
-      defaultEntry.setExpireMessagesPeriod(0);
-      policyMap.setDefaultEntry(defaultEntry);
-      brokerService.setDestinationPolicy(policyMap);
-
-      brokerService.getSystemUsage().getMemoryUsage().setLimit(64 * 1024 * 1024);
-
-      TransportConnector transportConnector = brokerService.addConnector("tcp://0.0.0.0:0");
-      brokerService.start();
-      activemqURL = transportConnector.getPublishableConnectString();
-      activemqURL += "?jms.watchTopicAdvisories=false"; // ensure all messages are queue or dlq messages
-   }
-
-   @After
-   public void stopBroker() throws Exception {
-      if (brokerService != null) {
-         brokerService.stop();
-      }
-   }
-
-   @Test
-   public void test() throws Exception {
-
-      String activemqQueues = "activemq";
-      for (int i = 1; i < numDests; i++) {
-         activemqQueues += ",activemq" + i;
-      }
-
-      int consumerWaitForConsumption = 5 * 60 * 1000;
-
-      ExportQueuePublisher publisher = null;
-      ExportQueueConsumer consumer = null;
-
-      LOG.info("Publisher will publish " + (publisherMessagesPerThread * publisherThreadCount) + " messages to each queue specified.");
-      LOG.info("\nBuilding Publisher...");
-
-      publisher = new ExportQueuePublisher(activemqURL, activemqQueues, publisherMessagesPerThread, publisherThreadCount);
-
-      LOG.info("Building Consumer...");
-
-      consumer = new ExportQueueConsumer(activemqURL, activemqQueues, consumerThreadsPerQueue, consumerBatchSize, publisherMessagesPerThread * publisherThreadCount);
-
-      long totalStart = System.currentTimeMillis();
-
-      LOG.info("Starting Publisher...");
-
-      publisher.start();
-
-      LOG.info("Starting Consumer...");
-
-      consumer.start();
-
-      int distinctPublishedCount = 0;
-
-      LOG.info("Waiting For Publisher Completion...");
-
-      publisher.waitForCompletion();
-
-      List<String> publishedIds = publisher.getIDs();
-      distinctPublishedCount = new TreeSet<>(publishedIds).size();
-
-      LOG.info("Publisher Complete. Published: " + publishedIds.size() + ", Distinct IDs Published: " + distinctPublishedCount);
-      LOG.info("Publisher duration: {}", TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - totalStart));
-
-      long endWait = System.currentTimeMillis() + consumerWaitForConsumption;
-      while (!consumer.completed() && System.currentTimeMillis() < endWait) {
-         try {
-            int secs = (int) (endWait - System.currentTimeMillis()) / 1000;
-            LOG.info("Waiting For Consumer Completion. Time left: " + secs + " secs");
-            Thread.sleep(1000);
-         }
-         catch (Exception e) {
-         }
-      }
-
-      LOG.info("\nConsumer Complete: " + consumer.completed() + ", Shutting Down.");
-
-      LOG.info("Total duration: {}", TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - totalStart));
-
-      consumer.shutdown();
-
-      TimeUnit.SECONDS.sleep(2);
-
-      LOG.info("Consumer Stats:");
-
-      for (Map.Entry<String, List<String>> entry : consumer.getIDs().entrySet()) {
-
-         List<String> idList = entry.getValue();
-
-         int distinctConsumed = new TreeSet<>(idList).size();
-
-         StringBuilder sb = new StringBuilder();
-         sb.append("   Queue: " + entry.getKey() +
-                      " -> Total Messages Consumed: " + idList.size() +
-                      ", Distinct IDs Consumed: " + distinctConsumed);
-
-         int diff = distinctPublishedCount - distinctConsumed;
-         sb.append(" ( " + (diff > 0 ? diff : "NO") + " STUCK MESSAGES " + " ) ");
-         LOG.info(sb.toString());
-
-         assertEquals("expect to get all messages!", 0, diff);
-
-      }
-
-      // verify empty dlq
-      assertEquals("No pending messages", 0L, ((RegionBroker) brokerService.getRegionBroker()).getDestinationStatistics().getMessages().getCount());
-   }
-
-   public class ExportQueuePublisher {
-
-      private final String amqUser = ActiveMQConnection.DEFAULT_USER;
-      private final String amqPassword = ActiveMQConnection.DEFAULT_PASSWORD;
-      private ActiveMQConnectionFactory connectionFactory = null;
-      private String activemqURL = null;
-      private String activemqQueues = null;
-      // Collection of distinct IDs that the publisher has published.
-      // After a message is published, its UUID will be written to this list for tracking.
-      // This list of IDs (or distinct count) will be used to compare to the consumed list of IDs.
-      //private Set<String> ids = Collections.synchronizedSet(new TreeSet<String>());
-      private List<String> ids = Collections.synchronizedList(new ArrayList<String>());
-      private List<PublisherThread> threads;
-
-      public ExportQueuePublisher(String activemqURL,
-                                  String activemqQueues,
-                                  int messagesPerThread,
-                                  int threadCount) throws Exception {
-
-         this.activemqURL = activemqURL;
-         this.activemqQueues = activemqQueues;
-
-         threads = new ArrayList<>();
-
-         // Build the threads and tell them how many messages to publish
-         for (int i = 0; i < threadCount; i++) {
-            PublisherThread pt = new PublisherThread(messagesPerThread);
-            threads.add(pt);
-         }
-      }
-
-      public List<String> getIDs() {
-         return ids;
-      }
-
-      // Kick off threads
-      public void start() throws Exception {
-
-         for (PublisherThread pt : threads) {
-            pt.start();
-         }
-      }
-
-      // Wait for threads to complete. They will complete once they've published all of their messages.
-      public void waitForCompletion() throws Exception {
-
-         for (PublisherThread pt : threads) {
-            pt.join();
-            pt.close();
-         }
-      }
-
-      private Session newSession(QueueConnection queueConnection) throws Exception {
-         return queueConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      }
-
-      private synchronized QueueConnection newQueueConnection() throws Exception {
-
-         if (connectionFactory == null) {
-            connectionFactory = new ActiveMQConnectionFactory(amqUser, amqPassword, activemqURL);
-         }
-
-         // Set the redelivery count to -1 (infinite), or else messages will start dropping
-         // after the queue has had a certain number of failures (default is 6)
-         RedeliveryPolicy policy = connectionFactory.getRedeliveryPolicy();
-         policy.setMaximumRedeliveries(-1);
-
-         QueueConnection amqConnection = connectionFactory.createQueueConnection();
-         amqConnection.start();
-         return amqConnection;
-      }
-
-      private class PublisherThread extends Thread {
-
-         private int count;
-         private QueueConnection qc;
-         private Session session;
-         private MessageProducer mp;
-
-         private PublisherThread(int count) throws Exception {
-
-            this.count = count;
-
-            // Each Thread has its own Connection and Session, so no sync worries
-            qc = newQueueConnection();
-            session = newSession(qc);
-
-            // In our code, when publishing to multiple queues,
-            // we're using composite destinations like below
-            Queue q = new ActiveMQQueue(activemqQueues);
-            mp = session.createProducer(q);
-         }
-
-         @Override
-         public void run() {
-
-            try {
-
-               // Loop until we've published enough messages
-               while (count-- > 0) {
-
-                  TextMessage tm = session.createTextMessage(getMessageText());
-                  String id = UUID.randomUUID().toString();
-                  tm.setStringProperty("KEY", id);
-                  ids.add(id);                            // keep track of the key to compare against consumer
-
-                  mp.send(tm);
-               }
-            }
-            catch (Exception e) {
-               e.printStackTrace();
-            }
-         }
-
-         // Called by waitForCompletion
-         public void close() {
-
-            try {
-               mp.close();
-            }
-            catch (Exception e) {
-            }
-
-            try {
-               session.close();
-            }
-            catch (Exception e) {
-            }
-
-            try {
-               qc.close();
-            }
-            catch (Exception e) {
-            }
-         }
-      }
-
-   }
-
-   String messageText;
-
-   private String getMessageText() {
-
-      if (messageText == null) {
-
-         synchronized (this) {
-
-            if (messageText == null) {
-
-               StringBuilder sb = new StringBuilder();
-               for (int i = 0; i < messageSize; i++) {
-                  sb.append("X");
-               }
-               messageText = sb.toString();
-            }
-         }
-      }
-
-      return messageText;
-   }
-
-   public class ExportQueueConsumer {
-
-      private final String amqUser = ActiveMQConnection.DEFAULT_USER;
-      private final String amqPassword = ActiveMQConnection.DEFAULT_PASSWORD;
-      private final int totalToExpect;
-      private ActiveMQConnectionFactory connectionFactory = null;
-      private String activemqURL = null;
-      private String activemqQueues = null;
-      private String[] queues = null;
-      // Map of IDs that were consumed, keyed by queue name.
-      // We'll compare these against what was published to know if any got stuck or dropped.
-      private Map<String, List<String>> idsByQueue = new HashMap<>();
-      private Map<String, List<ConsumerThread>> threads;
-
-      public ExportQueueConsumer(String activemqURL,
-                                 String activemqQueues,
-                                 int threadsPerQueue,
-                                 int batchSize,
-                                 int totalToExpect) throws Exception {
-
-         this.activemqURL = activemqURL;
-         this.activemqQueues = activemqQueues;
-         this.totalToExpect = totalToExpect;
-
-         queues = this.activemqQueues.split(",");
-
-         for (int i = 0; i < queues.length; i++) {
-            queues[i] = queues[i].trim();
-         }
-
-         threads = new HashMap<>();
-
-         // For each queue, create a list of threads and set up the list of ids
-         for (String q : queues) {
-
-            List<ConsumerThread> list = new ArrayList<>();
-
-            idsByQueue.put(q, Collections.synchronizedList(new ArrayList<String>()));
-
-            for (int i = 0; i < threadsPerQueue; i++) {
-               list.add(new ConsumerThread(q, batchSize));
-            }
-
-            threads.put(q, list);
-         }
-      }
-
-      public Map<String, List<String>> getIDs() {
-         return idsByQueue;
-      }
-
-      // Start the threads
-      public void start() throws Exception {
-
-         for (List<ConsumerThread> list : threads.values()) {
-
-            for (ConsumerThread ct : list) {
-
-               ct.start();
-            }
-         }
-      }
-
-      // Tell the threads to stop
-      // Then wait for them to stop
-      public void shutdown() throws Exception {
-
-         for (List<ConsumerThread> list : threads.values()) {
-
-            for (ConsumerThread ct : list) {
-
-               ct.shutdown();
-            }
-         }
-
-         for (List<ConsumerThread> list : threads.values()) {
-
-            for (ConsumerThread ct : list) {
-
-               ct.join();
-            }
-         }
-      }
-
-      private Session newSession(QueueConnection queueConnection) throws Exception {
-         return queueConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      }
-
-      private synchronized QueueConnection newQueueConnection() throws Exception {
-
-         if (connectionFactory == null) {
-            connectionFactory = new ActiveMQConnectionFactory(amqUser, amqPassword, activemqURL);
-         }
-
-         // Set the redelivery count to -1 (infinite), or else messages will start dropping
-         // after the queue has had a certain number of failures (default is 6)
-         RedeliveryPolicy policy = connectionFactory.getRedeliveryPolicy();
-         policy.setMaximumRedeliveries(-1);
-
-         QueueConnection amqConnection = connectionFactory.createQueueConnection();
-         amqConnection.start();
-         return amqConnection;
-      }
-
-      public boolean completed() {
-         for (List<ConsumerThread> list : threads.values()) {
-
-            for (ConsumerThread ct : list) {
-
-               if (ct.isAlive()) {
-                  LOG.info("thread for {} is still alive.", ct.qName);
-                  return false;
-               }
-            }
-         }
-         return true;
-      }
-
-      private class ConsumerThread extends Thread {
-
-         private int batchSize;
-         private QueueConnection qc;
-         private Session session;
-         private MessageConsumer mc;
-         private List<String> idList;
-         private boolean shutdown = false;
-         private String qName;
-
-         private ConsumerThread(String queueName, int batchSize) throws Exception {
-
-            this.batchSize = batchSize;
-
-            // Each thread has its own connection and session
-            qName = queueName;
-            qc = newQueueConnection();
-            session = newSession(qc);
-            Queue q = session.createQueue(queueName + "?consumer.prefetchSize=" + batchSize);
-            mc = session.createConsumer(q);
-
-            idList = idsByQueue.get(queueName);
-         }
-
-         @Override
-         public void run() {
-
-            try {
-
-               int count = 0;
-
-               // Keep reading as long as it hasn't been told to shutdown
-               while (!shutdown) {
-
-                  if (idList.size() >= totalToExpect) {
-                     LOG.info("Got {} for q: {}", +idList.size(), qName);
-                     break;
-                  }
-                  Message m = mc.receive(4000);
-
-                  if (m != null) {
-
-                     // We received a non-null message, add the ID to our list
-
-                     idList.add(m.getStringProperty("KEY"));
-
-                     count++;
-
-                     // If we've reached our batch size, commit the batch and reset the count
-
-                     if (count == batchSize) {
-                        count = 0;
-                     }
-                  }
-                  else {
-
-                     // We didn't receive anything this time, commit any current batch and reset the count
-
-                     count = 0;
-
-                     // Sleep a little before trying to read after not getting a message
-
-                     try {
-                        if (idList.size() < totalToExpect) {
-                           LOG.info("did not receive on {}, current count: {}", qName, idList.size());
-                        }
-                        //sleep(3000);
-                     }
-                     catch (Exception e) {
-                     }
-                  }
-               }
-            }
-            catch (Exception e) {
-               e.printStackTrace();
-            }
-            finally {
-
-               // Once we exit, close everything
-               close();
-            }
-         }
-
-         public void shutdown() {
-            shutdown = true;
-         }
-
-         public void close() {
-
-            try {
-               mc.close();
-            }
-            catch (Exception e) {
-            }
-
-            try {
-               session.close();
-            }
-            catch (Exception e) {
-            }
-
-            try {
-               qc.close();
-            }
-            catch (Exception e) {
-
-            }
-         }
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5266StarvedConsumerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5266StarvedConsumerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5266StarvedConsumerTest.java
deleted file mode 100644
index c7bc6d2..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5266StarvedConsumerTest.java
+++ /dev/null
@@ -1,628 +0,0 @@
-/**
- * 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;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeSet;
-import java.util.UUID;
-import java.util.concurrent.CyclicBarrier;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.RedeliveryPolicy;
-import org.apache.activemq.TestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.TransportConnector;
-import org.apache.activemq.broker.region.RegionBroker;
-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.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.assertEquals;
-
-/*
- * pause producers if consumers stall and verify broker drained before resume
- */
-@RunWith(Parameterized.class)
-public class AMQ5266StarvedConsumerTest {
-
-   static Logger LOG = LoggerFactory.getLogger(AMQ5266StarvedConsumerTest.class);
-   String activemqURL;
-   BrokerService brokerService;
-
-   public int messageSize = 1000;
-
-   @Parameterized.Parameter(0)
-   public int publisherMessagesPerThread = 1000;
-
-   @Parameterized.Parameter(1)
-   public int publisherThreadCount = 20;
-
-   @Parameterized.Parameter(2)
-   public int consumerThreadsPerQueue = 5;
-
-   @Parameterized.Parameter(3)
-   public int destMemoryLimit = 50 * 1024;
-
-   @Parameterized.Parameter(4)
-   public boolean useCache = true;
-
-   @Parameterized.Parameter(5)
-   public TestSupport.PersistenceAdapterChoice persistenceAdapterChoice = TestSupport.PersistenceAdapterChoice.KahaDB;
-
-   @Parameterized.Parameter(6)
-   public boolean optimizeDispatch = false;
-   private AtomicBoolean didNotReceive = new AtomicBoolean(false);
-
-   @Parameterized.Parameters(name = "#{0},producerThreads:{1},consumerThreads:{2},mL:{3},useCache:{4},store:{5},optimizedDispatch:{6}")
-   public static Iterable<Object[]> parameters() {
-      return Arrays.asList(new Object[][]{{1000, 40, 5, 1024 * 1024, false, TestSupport.PersistenceAdapterChoice.KahaDB, true}, {1000, 40, 5, 1024 * 1024, false, TestSupport.PersistenceAdapterChoice.LevelDB, true}, {1000, 40, 5, 1024 * 1024, false, TestSupport.PersistenceAdapterChoice.JDBC, true},
-
-         {500, 20, 20, 1024 * 1024, false, TestSupport.PersistenceAdapterChoice.KahaDB, true}, {500, 20, 20, 1024 * 1024, false, TestSupport.PersistenceAdapterChoice.LevelDB, true}, {500, 20, 20, 1024 * 1024, false, TestSupport.PersistenceAdapterChoice.JDBC, true},});
-   }
-
-   public int consumerBatchSize = 5;
-
-   @Before
-   public void startBroker() throws Exception {
-      brokerService = new BrokerService();
-      TestSupport.setPersistenceAdapter(brokerService, persistenceAdapterChoice);
-      brokerService.setDeleteAllMessagesOnStartup(true);
-      brokerService.setUseJmx(false);
-      brokerService.setAdvisorySupport(false);
-
-      PolicyMap policyMap = new PolicyMap();
-      PolicyEntry defaultEntry = new PolicyEntry();
-      defaultEntry.setUseConsumerPriority(false); // java.lang.IllegalArgumentException: Comparison method violates its general contract!
-      defaultEntry.setMaxAuditDepth(publisherThreadCount);
-      defaultEntry.setEnableAudit(true);
-      defaultEntry.setUseCache(useCache);
-      defaultEntry.setMaxPageSize(1000);
-      defaultEntry.setOptimizedDispatch(optimizeDispatch);
-      defaultEntry.setMemoryLimit(destMemoryLimit);
-      defaultEntry.setExpireMessagesPeriod(0);
-      policyMap.setDefaultEntry(defaultEntry);
-      brokerService.setDestinationPolicy(policyMap);
-
-      brokerService.getSystemUsage().getMemoryUsage().setLimit(512 * 1024 * 1024);
-
-      TransportConnector transportConnector = brokerService.addConnector("tcp://0.0.0.0:0");
-      brokerService.start();
-      activemqURL = transportConnector.getPublishableConnectString();
-   }
-
-   @After
-   public void stopBroker() throws Exception {
-      if (brokerService != null) {
-         brokerService.stop();
-      }
-   }
-
-   CyclicBarrier globalProducerHalt = new CyclicBarrier(publisherThreadCount, new Runnable() {
-      @Override
-      public void run() {
-         // wait for queue size to go to zero
-         try {
-            while (((RegionBroker) brokerService.getRegionBroker()).getDestinationStatistics().getMessages().getCount() > 0) {
-               LOG.info("Total messageCount: " + ((RegionBroker) brokerService.getRegionBroker()).getDestinationStatistics().getMessages().getCount());
-               TimeUnit.SECONDS.sleep(5);
-            }
-         }
-         catch (Exception ignored) {
-            ignored.printStackTrace();
-         }
-      }
-   });
-
-   @Test(timeout = 30 * 60 * 1000)
-   public void test() throws Exception {
-
-      String activemqQueues = "activemq,activemq2,activemq3,activemq4";//,activemq5,activemq6,activemq7,activemq8,activemq9";
-
-      int consumerWaitForConsumption = 5 * 60 * 1000;
-
-      ExportQueuePublisher publisher = null;
-      ExportQueueConsumer consumer = null;
-
-      LOG.info("Publisher will publish " + (publisherMessagesPerThread * publisherThreadCount) + " messages to each queue specified.");
-      LOG.info("\nBuilding Publisher...");
-
-      publisher = new ExportQueuePublisher(activemqURL, activemqQueues, publisherMessagesPerThread, publisherThreadCount);
-
-      LOG.info("Building Consumer...");
-
-      consumer = new ExportQueueConsumer(activemqURL, activemqQueues, consumerThreadsPerQueue, consumerBatchSize, publisherMessagesPerThread * publisherThreadCount);
-
-      LOG.info("Starting Publisher...");
-
-      publisher.start();
-
-      LOG.info("Starting Consumer...");
-
-      consumer.start();
-
-      int distinctPublishedCount = 0;
-
-      LOG.info("Waiting For Publisher Completion...");
-
-      publisher.waitForCompletion();
-
-      List<String> publishedIds = publisher.getIDs();
-      distinctPublishedCount = new TreeSet<>(publishedIds).size();
-
-      LOG.info("Publisher Complete. Published: " + publishedIds.size() + ", Distinct IDs Published: " + distinctPublishedCount);
-
-      long endWait = System.currentTimeMillis() + consumerWaitForConsumption;
-      while (!consumer.completed() && System.currentTimeMillis() < endWait) {
-         try {
-            int secs = (int) (endWait - System.currentTimeMillis()) / 1000;
-            LOG.info("Waiting For Consumer Completion. Time left: " + secs + " secs");
-            Thread.sleep(10000);
-         }
-         catch (Exception e) {
-         }
-      }
-
-      LOG.info("\nConsumer Complete: " + consumer.completed() + ", Shutting Down.");
-
-      consumer.shutdown();
-
-      LOG.info("Consumer Stats:");
-
-      for (Map.Entry<String, List<String>> entry : consumer.getIDs().entrySet()) {
-
-         List<String> idList = entry.getValue();
-
-         int distinctConsumed = new TreeSet<>(idList).size();
-
-         StringBuilder sb = new StringBuilder();
-         sb.append("   Queue: " + entry.getKey() +
-                      " -> Total Messages Consumed: " + idList.size() +
-                      ", Distinct IDs Consumed: " + distinctConsumed);
-
-         int diff = distinctPublishedCount - distinctConsumed;
-         sb.append(" ( " + (diff > 0 ? diff : "NO") + " STUCK MESSAGES " + " ) ");
-         LOG.info(sb.toString());
-
-         assertEquals("expect to get all messages!", 0, diff);
-
-      }
-   }
-
-   public class ExportQueuePublisher {
-
-      private final String amqUser = ActiveMQConnection.DEFAULT_USER;
-      private final String amqPassword = ActiveMQConnection.DEFAULT_PASSWORD;
-      private ActiveMQConnectionFactory connectionFactory = null;
-      private String activemqURL = null;
-      private String activemqQueues = null;
-      // Collection of distinct IDs that the publisher has published.
-      // After a message is published, its UUID will be written to this list for tracking.
-      // This list of IDs (or distinct count) will be used to compare to the consumed list of IDs.
-      //private Set<String> ids = Collections.synchronizedSet(new TreeSet<String>());
-      private List<String> ids = Collections.synchronizedList(new ArrayList<String>());
-      private List<PublisherThread> threads;
-
-      public ExportQueuePublisher(String activemqURL,
-                                  String activemqQueues,
-                                  int messagesPerThread,
-                                  int threadCount) throws Exception {
-
-         this.activemqURL = activemqURL;
-         this.activemqQueues = activemqQueues;
-
-         threads = new ArrayList<>();
-
-         // Build the threads and tell them how many messages to publish
-         for (int i = 0; i < threadCount; i++) {
-            PublisherThread pt = new PublisherThread(messagesPerThread);
-            threads.add(pt);
-         }
-      }
-
-      public List<String> getIDs() {
-         return ids;
-      }
-
-      // Kick off threads
-      public void start() throws Exception {
-
-         for (PublisherThread pt : threads) {
-            pt.start();
-         }
-      }
-
-      // Wait for threads to complete. They will complete once they've published all of their messages.
-      public void waitForCompletion() throws Exception {
-
-         for (PublisherThread pt : threads) {
-            pt.join();
-            pt.close();
-         }
-      }
-
-      private Session newSession(QueueConnection queueConnection) throws Exception {
-         return queueConnection.createSession(true, Session.SESSION_TRANSACTED);
-      }
-
-      private synchronized QueueConnection newQueueConnection() throws Exception {
-
-         if (connectionFactory == null) {
-            connectionFactory = new ActiveMQConnectionFactory(amqUser, amqPassword, activemqURL);
-            connectionFactory.setWatchTopicAdvisories(false);
-         }
-
-         // Set the redelivery count to -1 (infinite), or else messages will start dropping
-         // after the queue has had a certain number of failures (default is 6)
-         RedeliveryPolicy policy = connectionFactory.getRedeliveryPolicy();
-         policy.setMaximumRedeliveries(-1);
-
-         QueueConnection amqConnection = connectionFactory.createQueueConnection();
-         amqConnection.start();
-         return amqConnection;
-      }
-
-      private class PublisherThread extends Thread {
-
-         private int count;
-         private QueueConnection qc;
-         private Session session;
-         private MessageProducer mp;
-         private Queue q;
-
-         private PublisherThread(int count) throws Exception {
-
-            this.count = count;
-
-            // Each Thread has its own Connection and Session, so no sync worries
-            qc = newQueueConnection();
-            session = newSession(qc);
-
-            // In our code, when publishing to multiple queues,
-            // we're using composite destinations like below
-            q = new ActiveMQQueue(activemqQueues);
-            mp = session.createProducer(null);
-         }
-
-         @Override
-         public void run() {
-
-            try {
-
-               // Loop until we've published enough messages
-               while (count-- > 0) {
-
-                  TextMessage tm = session.createTextMessage(getMessageText());
-                  String id = UUID.randomUUID().toString();
-                  tm.setStringProperty("KEY", id);
-                  ids.add(id);                            // keep track of the key to compare against consumer
-
-                  mp.send(q, tm);
-                  session.commit();
-
-                  if (didNotReceive.get()) {
-                     globalProducerHalt.await();
-                  }
-               }
-            }
-            catch (Exception e) {
-               e.printStackTrace();
-            }
-         }
-
-         // Called by waitForCompletion
-         public void close() {
-
-            try {
-               mp.close();
-            }
-            catch (Exception e) {
-            }
-
-            try {
-               session.close();
-            }
-            catch (Exception e) {
-            }
-
-            try {
-               qc.close();
-            }
-            catch (Exception e) {
-            }
-         }
-      }
-
-   }
-
-   String messageText;
-
-   private String getMessageText() {
-
-      if (messageText == null) {
-
-         synchronized (this) {
-
-            if (messageText == null) {
-
-               StringBuilder sb = new StringBuilder();
-               for (int i = 0; i < messageSize; i++) {
-                  sb.append("X");
-               }
-               messageText = sb.toString();
-            }
-         }
-      }
-
-      return messageText;
-   }
-
-   public class ExportQueueConsumer {
-
-      private final String amqUser = ActiveMQConnection.DEFAULT_USER;
-      private final String amqPassword = ActiveMQConnection.DEFAULT_PASSWORD;
-      private final int totalToExpect;
-      private ActiveMQConnectionFactory connectionFactory = null;
-      private String activemqURL = null;
-      private String activemqQueues = null;
-      private String[] queues = null;
-      // Map of IDs that were consumed, keyed by queue name.
-      // We'll compare these against what was published to know if any got stuck or dropped.
-      private Map<String, List<String>> idsByQueue = new HashMap<>();
-      private Map<String, List<ConsumerThread>> threads;
-
-      public ExportQueueConsumer(String activemqURL,
-                                 String activemqQueues,
-                                 int threadsPerQueue,
-                                 int batchSize,
-                                 int totalToExpect) throws Exception {
-
-         this.activemqURL = activemqURL;
-         this.activemqQueues = activemqQueues;
-         this.totalToExpect = totalToExpect;
-
-         queues = this.activemqQueues.split(",");
-
-         for (int i = 0; i < queues.length; i++) {
-            queues[i] = queues[i].trim();
-         }
-
-         threads = new HashMap<>();
-
-         // For each queue, create a list of threads and set up the list of ids
-         for (String q : queues) {
-
-            List<ConsumerThread> list = new ArrayList<>();
-
-            idsByQueue.put(q, Collections.synchronizedList(new ArrayList<String>()));
-
-            for (int i = 0; i < threadsPerQueue; i++) {
-               list.add(new ConsumerThread(q, batchSize));
-            }
-
-            threads.put(q, list);
-         }
-      }
-
-      public Map<String, List<String>> getIDs() {
-         return idsByQueue;
-      }
-
-      // Start the threads
-      public void start() throws Exception {
-
-         for (List<ConsumerThread> list : threads.values()) {
-
-            for (ConsumerThread ct : list) {
-
-               ct.start();
-            }
-         }
-      }
-
-      // Tell the threads to stop
-      // Then wait for them to stop
-      public void shutdown() throws Exception {
-
-         for (List<ConsumerThread> list : threads.values()) {
-
-            for (ConsumerThread ct : list) {
-
-               ct.shutdown();
-            }
-         }
-
-         for (List<ConsumerThread> list : threads.values()) {
-
-            for (ConsumerThread ct : list) {
-
-               ct.join();
-            }
-         }
-      }
-
-      private Session newSession(QueueConnection queueConnection) throws Exception {
-         return queueConnection.createSession(true, Session.SESSION_TRANSACTED);
-      }
-
-      private synchronized QueueConnection newQueueConnection() throws Exception {
-
-         if (connectionFactory == null) {
-            connectionFactory = new ActiveMQConnectionFactory(amqUser, amqPassword, activemqURL);
-            connectionFactory.setWatchTopicAdvisories(false);
-         }
-
-         // Set the redelivery count to -1 (infinite), or else messages will start dropping
-         // after the queue has had a certain number of failures (default is 6)
-         RedeliveryPolicy policy = connectionFactory.getRedeliveryPolicy();
-         policy.setMaximumRedeliveries(-1);
-
-         QueueConnection amqConnection = connectionFactory.createQueueConnection();
-         amqConnection.start();
-         return amqConnection;
-      }
-
-      public boolean completed() {
-         for (List<ConsumerThread> list : threads.values()) {
-
-            for (ConsumerThread ct : list) {
-
-               if (ct.isAlive()) {
-                  LOG.info("thread for {} is still alive.", ct.qName);
-                  return false;
-               }
-            }
-         }
-         return true;
-      }
-
-      private class ConsumerThread extends Thread {
-
-         private int batchSize;
-         private QueueConnection qc;
-         private Session session;
-         private MessageConsumer mc;
-         private List<String> idList;
-         private boolean shutdown = false;
-         private String qName;
-
-         private ConsumerThread(String queueName, int batchSize) throws Exception {
-
-            this.batchSize = batchSize;
-
-            // Each thread has its own connection and session
-            qName = queueName;
-            qc = newQueueConnection();
-            session = newSession(qc);
-            Queue q = session.createQueue(queueName + "?consumer.prefetchSize=" + batchSize);
-            mc = session.createConsumer(q);
-
-            idList = idsByQueue.get(queueName);
-         }
-
-         @Override
-         public void run() {
-
-            try {
-
-               int count = 0;
-
-               // Keep reading as long as it hasn't been told to shutdown
-               while (!shutdown) {
-
-                  if (idList.size() >= totalToExpect) {
-                     LOG.info("Got {} for q: {}", +idList.size(), qName);
-                     session.commit();
-                     break;
-                  }
-                  Message m = mc.receive(4000);
-
-                  if (m != null) {
-
-                     // We received a non-null message, add the ID to our list
-
-                     idList.add(m.getStringProperty("KEY"));
-
-                     count++;
-
-                     // If we've reached our batch size, commit the batch and reset the count
-
-                     if (count == batchSize) {
-                        session.commit();
-                        count = 0;
-                     }
-                  }
-                  else {
-
-                     // We didn't receive anything this time, commit any current batch and reset the count
-
-                     session.commit();
-                     count = 0;
-
-                     // Sleep a little before trying to read after not getting a message
-
-                     try {
-                        if (idList.size() < totalToExpect) {
-                           LOG.info("did not receive on {}, current count: {}", qName, idList.size());
-                           didNotReceive.set(true);
-                        }
-                        //sleep(3000);
-                     }
-                     catch (Exception e) {
-                     }
-                  }
-               }
-            }
-            catch (Exception e) {
-               e.printStackTrace();
-            }
-            finally {
-
-               // Once we exit, close everything
-               close();
-            }
-         }
-
-         public void shutdown() {
-            shutdown = true;
-         }
-
-         public void close() {
-
-            try {
-               mc.close();
-            }
-            catch (Exception e) {
-            }
-
-            try {
-               session.close();
-            }
-            catch (Exception e) {
-            }
-
-            try {
-               qc.close();
-            }
-            catch (Exception e) {
-
-            }
-         }
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5266Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5266Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5266Test.java
deleted file mode 100644
index c5712b8..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5266Test.java
+++ /dev/null
@@ -1,604 +0,0 @@
-/**
- * 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;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeSet;
-import java.util.UUID;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.RedeliveryPolicy;
-import org.apache.activemq.TestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.TransportConnector;
-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.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Stuck messages test client.
- * <br>
- * Will kick of publisher and consumer simultaneously, and will usually result in stuck messages on the queue.
- */
-@RunWith(Parameterized.class)
-public class AMQ5266Test {
-
-   static Logger LOG = LoggerFactory.getLogger(AMQ5266Test.class);
-   String activemqURL = "tcp://localhost:61617";
-   BrokerService brokerService;
-
-   public int messageSize = 1000;
-
-   @Parameterized.Parameter(0)
-   public int publisherMessagesPerThread = 1000;
-
-   @Parameterized.Parameter(1)
-   public int publisherThreadCount = 20;
-
-   @Parameterized.Parameter(2)
-   public int consumerThreadsPerQueue = 5;
-
-   @Parameterized.Parameter(3)
-   public int destMemoryLimit = 50 * 1024;
-
-   @Parameterized.Parameter(4)
-   public boolean useCache = true;
-
-   @Parameterized.Parameter(5)
-   public TestSupport.PersistenceAdapterChoice persistenceAdapterChoice = TestSupport.PersistenceAdapterChoice.KahaDB;
-
-   @Parameterized.Parameter(6)
-   public boolean optimizeDispatch = false;
-
-   @Parameterized.Parameters(name = "#{0},producerThreads:{1},consumerThreads:{2},mL:{3},useCache:{4},store:{5},optimizedDispatch:{6}")
-   public static Iterable<Object[]> parameters() {
-      return Arrays.asList(new Object[][]{{1, 1, 1, 50 * 1024, false, TestSupport.PersistenceAdapterChoice.JDBC, true}, {1000, 20, 5, 50 * 1024, true, TestSupport.PersistenceAdapterChoice.JDBC, false}, {100, 20, 5, 50 * 1024, false, TestSupport.PersistenceAdapterChoice.JDBC, false}, {1000, 5, 20, 50 * 1024, true, TestSupport.PersistenceAdapterChoice.JDBC, false}, {1000, 20, 20, 1024 * 1024, true, TestSupport.PersistenceAdapterChoice.JDBC, false},
-
-         {1, 1, 1, 50 * 1024, false, TestSupport.PersistenceAdapterChoice.KahaDB, true}, {100, 5, 5, 50 * 1024, false, TestSupport.PersistenceAdapterChoice.KahaDB, false}, {1000, 20, 5, 50 * 1024, true, TestSupport.PersistenceAdapterChoice.KahaDB, false}, {100, 20, 5, 50 * 1024, false, TestSupport.PersistenceAdapterChoice.KahaDB, false}, {1000, 5, 20, 50 * 1024, true, TestSupport.PersistenceAdapterChoice.KahaDB, false}, {1000, 20, 20, 1024 * 1024, true, TestSupport.PersistenceAdapterChoice.KahaDB, false},
-
-         {1, 1, 1, 50 * 1024, false, TestSupport.PersistenceAdapterChoice.LevelDB, true}, {100, 5, 5, 50 * 1024, false, TestSupport.PersistenceAdapterChoice.LevelDB, false}, {1000, 20, 5, 50 * 1024, true, TestSupport.PersistenceAdapterChoice.LevelDB, false}, {100, 20, 5, 50 * 1024, false, TestSupport.PersistenceAdapterChoice.LevelDB, false}, {1000, 5, 20, 50 * 1024, true, TestSupport.PersistenceAdapterChoice.LevelDB, false}, {1000, 20, 20, 1024 * 1024, true, TestSupport.PersistenceAdapterChoice.LevelDB, false},
-
-      });
-   }
-
-   public int consumerBatchSize = 5;
-
-   @Before
-   public void startBroker() throws Exception {
-      brokerService = new BrokerService();
-      TestSupport.setPersistenceAdapter(brokerService, persistenceAdapterChoice);
-      brokerService.setDeleteAllMessagesOnStartup(true);
-      brokerService.setUseJmx(false);
-
-      PolicyMap policyMap = new PolicyMap();
-      PolicyEntry defaultEntry = new PolicyEntry();
-      defaultEntry.setUseConsumerPriority(false); // java.lang.IllegalArgumentException: Comparison method violates its general contract!
-      defaultEntry.setMaxAuditDepth(publisherThreadCount);
-      defaultEntry.setEnableAudit(true);
-      defaultEntry.setUseCache(useCache);
-      defaultEntry.setMaxPageSize(1000);
-      defaultEntry.setOptimizedDispatch(optimizeDispatch);
-      defaultEntry.setMemoryLimit(destMemoryLimit);
-      defaultEntry.setExpireMessagesPeriod(0);
-      policyMap.setDefaultEntry(defaultEntry);
-      brokerService.setDestinationPolicy(policyMap);
-
-      brokerService.getSystemUsage().getMemoryUsage().setLimit(512 * 1024 * 1024);
-
-      TransportConnector transportConnector = brokerService.addConnector("tcp://0.0.0.0:0");
-      brokerService.start();
-      activemqURL = transportConnector.getPublishableConnectString();
-   }
-
-   @After
-   public void stopBroker() throws Exception {
-      if (brokerService != null) {
-         brokerService.stop();
-      }
-   }
-
-   @Test
-   public void test() throws Exception {
-
-      String activemqQueues = "activemq,activemq2";//,activemq3,activemq4,activemq5,activemq6,activemq7,activemq8,activemq9";
-
-      int consumerWaitForConsumption = 5 * 60 * 1000;
-
-      ExportQueuePublisher publisher = null;
-      ExportQueueConsumer consumer = null;
-
-      LOG.info("Publisher will publish " + (publisherMessagesPerThread * publisherThreadCount) + " messages to each queue specified.");
-      LOG.info("\nBuilding Publisher...");
-
-      publisher = new ExportQueuePublisher(activemqURL, activemqQueues, publisherMessagesPerThread, publisherThreadCount);
-
-      LOG.info("Building Consumer...");
-
-      consumer = new ExportQueueConsumer(activemqURL, activemqQueues, consumerThreadsPerQueue, consumerBatchSize, publisherMessagesPerThread * publisherThreadCount);
-
-      LOG.info("Starting Publisher...");
-
-      publisher.start();
-
-      LOG.info("Starting Consumer...");
-
-      consumer.start();
-
-      int distinctPublishedCount = 0;
-
-      LOG.info("Waiting For Publisher Completion...");
-
-      publisher.waitForCompletion();
-
-      List<String> publishedIds = publisher.getIDs();
-      distinctPublishedCount = new TreeSet<>(publishedIds).size();
-
-      LOG.info("Publisher Complete. Published: " + publishedIds.size() + ", Distinct IDs Published: " + distinctPublishedCount);
-
-      long endWait = System.currentTimeMillis() + consumerWaitForConsumption;
-      while (!consumer.completed() && System.currentTimeMillis() < endWait) {
-         try {
-            int secs = (int) (endWait - System.currentTimeMillis()) / 1000;
-            LOG.info("Waiting For Consumer Completion. Time left: " + secs + " secs");
-            Thread.sleep(10000);
-         }
-         catch (Exception e) {
-         }
-      }
-
-      LOG.info("\nConsumer Complete: " + consumer.completed() + ", Shutting Down.");
-
-      consumer.shutdown();
-
-      LOG.info("Consumer Stats:");
-
-      for (Map.Entry<String, List<String>> entry : consumer.getIDs().entrySet()) {
-
-         List<String> idList = entry.getValue();
-
-         int distinctConsumed = new TreeSet<>(idList).size();
-
-         StringBuilder sb = new StringBuilder();
-         sb.append("   Queue: " + entry.getKey() +
-                      " -> Total Messages Consumed: " + idList.size() +
-                      ", Distinct IDs Consumed: " + distinctConsumed);
-
-         int diff = distinctPublishedCount - distinctConsumed;
-         sb.append(" ( " + (diff > 0 ? diff : "NO") + " STUCK MESSAGES " + " ) ");
-         LOG.info(sb.toString());
-
-         assertEquals("expect to get all messages!", 0, diff);
-
-      }
-   }
-
-   public class ExportQueuePublisher {
-
-      private final String amqUser = ActiveMQConnection.DEFAULT_USER;
-      private final String amqPassword = ActiveMQConnection.DEFAULT_PASSWORD;
-      private ActiveMQConnectionFactory connectionFactory = null;
-      private String activemqURL = null;
-      private String activemqQueues = null;
-      // Collection of distinct IDs that the publisher has published.
-      // After a message is published, its UUID will be written to this list for tracking.
-      // This list of IDs (or distinct count) will be used to compare to the consumed list of IDs.
-      //private Set<String> ids = Collections.synchronizedSet(new TreeSet<String>());
-      private List<String> ids = Collections.synchronizedList(new ArrayList<String>());
-      private List<PublisherThread> threads;
-
-      public ExportQueuePublisher(String activemqURL,
-                                  String activemqQueues,
-                                  int messagesPerThread,
-                                  int threadCount) throws Exception {
-
-         this.activemqURL = activemqURL;
-         this.activemqQueues = activemqQueues;
-
-         threads = new ArrayList<>();
-
-         // Build the threads and tell them how many messages to publish
-         for (int i = 0; i < threadCount; i++) {
-            PublisherThread pt = new PublisherThread(messagesPerThread);
-            threads.add(pt);
-         }
-      }
-
-      public List<String> getIDs() {
-         return ids;
-      }
-
-      // Kick off threads
-      public void start() throws Exception {
-
-         for (PublisherThread pt : threads) {
-            pt.start();
-         }
-      }
-
-      // Wait for threads to complete. They will complete once they've published all of their messages.
-      public void waitForCompletion() throws Exception {
-
-         for (PublisherThread pt : threads) {
-            pt.join();
-            pt.close();
-         }
-      }
-
-      private Session newSession(QueueConnection queueConnection) throws Exception {
-         return queueConnection.createSession(true, Session.SESSION_TRANSACTED);
-      }
-
-      private synchronized QueueConnection newQueueConnection() throws Exception {
-
-         if (connectionFactory == null) {
-            connectionFactory = new ActiveMQConnectionFactory(amqUser, amqPassword, activemqURL);
-         }
-
-         // Set the redelivery count to -1 (infinite), or else messages will start dropping
-         // after the queue has had a certain number of failures (default is 6)
-         RedeliveryPolicy policy = connectionFactory.getRedeliveryPolicy();
-         policy.setMaximumRedeliveries(-1);
-
-         QueueConnection amqConnection = connectionFactory.createQueueConnection();
-         amqConnection.start();
-         return amqConnection;
-      }
-
-      private class PublisherThread extends Thread {
-
-         private int count;
-         private QueueConnection qc;
-         private Session session;
-         private MessageProducer mp;
-
-         private PublisherThread(int count) throws Exception {
-
-            this.count = count;
-
-            // Each Thread has its own Connection and Session, so no sync worries
-            qc = newQueueConnection();
-            session = newSession(qc);
-
-            // In our code, when publishing to multiple queues,
-            // we're using composite destinations like below
-            Queue q = new ActiveMQQueue(activemqQueues);
-            mp = session.createProducer(q);
-         }
-
-         @Override
-         public void run() {
-
-            try {
-
-               // Loop until we've published enough messages
-               while (count-- > 0) {
-
-                  TextMessage tm = session.createTextMessage(getMessageText());
-                  String id = UUID.randomUUID().toString();
-                  tm.setStringProperty("KEY", id);
-                  ids.add(id);                            // keep track of the key to compare against consumer
-
-                  mp.send(tm);
-                  session.commit();
-               }
-            }
-            catch (Exception e) {
-               e.printStackTrace();
-            }
-         }
-
-         // Called by waitForCompletion
-         public void close() {
-
-            try {
-               mp.close();
-            }
-            catch (Exception e) {
-            }
-
-            try {
-               session.close();
-            }
-            catch (Exception e) {
-            }
-
-            try {
-               qc.close();
-            }
-            catch (Exception e) {
-            }
-         }
-      }
-
-   }
-
-   String messageText;
-
-   private String getMessageText() {
-
-      if (messageText == null) {
-
-         synchronized (this) {
-
-            if (messageText == null) {
-
-               StringBuilder sb = new StringBuilder();
-               for (int i = 0; i < messageSize; i++) {
-                  sb.append("X");
-               }
-               messageText = sb.toString();
-            }
-         }
-      }
-
-      return messageText;
-   }
-
-   public class ExportQueueConsumer {
-
-      private final String amqUser = ActiveMQConnection.DEFAULT_USER;
-      private final String amqPassword = ActiveMQConnection.DEFAULT_PASSWORD;
-      private final int totalToExpect;
-      private ActiveMQConnectionFactory connectionFactory = null;
-      private String activemqURL = null;
-      private String activemqQueues = null;
-      private String[] queues = null;
-      // Map of IDs that were consumed, keyed by queue name.
-      // We'll compare these against what was published to know if any got stuck or dropped.
-      private Map<String, List<String>> idsByQueue = new HashMap<>();
-      private Map<String, List<ConsumerThread>> threads;
-
-      public ExportQueueConsumer(String activemqURL,
-                                 String activemqQueues,
-                                 int threadsPerQueue,
-                                 int batchSize,
-                                 int totalToExpect) throws Exception {
-
-         this.activemqURL = activemqURL;
-         this.activemqQueues = activemqQueues;
-         this.totalToExpect = totalToExpect;
-
-         queues = this.activemqQueues.split(",");
-
-         for (int i = 0; i < queues.length; i++) {
-            queues[i] = queues[i].trim();
-         }
-
-         threads = new HashMap<>();
-
-         // For each queue, create a list of threads and set up the list of ids
-         for (String q : queues) {
-
-            List<ConsumerThread> list = new ArrayList<>();
-
-            idsByQueue.put(q, Collections.synchronizedList(new ArrayList<String>()));
-
-            for (int i = 0; i < threadsPerQueue; i++) {
-               list.add(new ConsumerThread(q, batchSize));
-            }
-
-            threads.put(q, list);
-         }
-      }
-
-      public Map<String, List<String>> getIDs() {
-         return idsByQueue;
-      }
-
-      // Start the threads
-      public void start() throws Exception {
-
-         for (List<ConsumerThread> list : threads.values()) {
-
-            for (ConsumerThread ct : list) {
-
-               ct.start();
-            }
-         }
-      }
-
-      // Tell the threads to stop
-      // Then wait for them to stop
-      public void shutdown() throws Exception {
-
-         for (List<ConsumerThread> list : threads.values()) {
-
-            for (ConsumerThread ct : list) {
-
-               ct.shutdown();
-            }
-         }
-
-         for (List<ConsumerThread> list : threads.values()) {
-
-            for (ConsumerThread ct : list) {
-
-               ct.join();
-            }
-         }
-      }
-
-      private Session newSession(QueueConnection queueConnection) throws Exception {
-         return queueConnection.createSession(true, Session.SESSION_TRANSACTED);
-      }
-
-      private synchronized QueueConnection newQueueConnection() throws Exception {
-
-         if (connectionFactory == null) {
-            connectionFactory = new ActiveMQConnectionFactory(amqUser, amqPassword, activemqURL);
-         }
-
-         // Set the redelivery count to -1 (infinite), or else messages will start dropping
-         // after the queue has had a certain number of failures (default is 6)
-         RedeliveryPolicy policy = connectionFactory.getRedeliveryPolicy();
-         policy.setMaximumRedeliveries(-1);
-
-         QueueConnection amqConnection = connectionFactory.createQueueConnection();
-         amqConnection.start();
-         return amqConnection;
-      }
-
-      public boolean completed() {
-         for (List<ConsumerThread> list : threads.values()) {
-
-            for (ConsumerThread ct : list) {
-
-               if (ct.isAlive()) {
-                  LOG.info("thread for {} is still alive.", ct.qName);
-                  return false;
-               }
-            }
-         }
-         return true;
-      }
-
-      private class ConsumerThread extends Thread {
-
-         private int batchSize;
-         private QueueConnection qc;
-         private Session session;
-         private MessageConsumer mc;
-         private List<String> idList;
-         private boolean shutdown = false;
-         private String qName;
-
-         private ConsumerThread(String queueName, int batchSize) throws Exception {
-
-            this.batchSize = batchSize;
-
-            // Each thread has its own connection and session
-            qName = queueName;
-            qc = newQueueConnection();
-            session = newSession(qc);
-            Queue q = session.createQueue(queueName + "?consumer.prefetchSize=" + batchSize);
-            mc = session.createConsumer(q);
-
-            idList = idsByQueue.get(queueName);
-         }
-
-         @Override
-         public void run() {
-
-            try {
-
-               int count = 0;
-
-               // Keep reading as long as it hasn't been told to shutdown
-               while (!shutdown) {
-
-                  if (idList.size() >= totalToExpect) {
-                     LOG.info("Got {} for q: {}", +idList.size(), qName);
-                     session.commit();
-                     break;
-                  }
-                  Message m = mc.receive(4000);
-
-                  if (m != null) {
-
-                     // We received a non-null message, add the ID to our list
-
-                     idList.add(m.getStringProperty("KEY"));
-
-                     count++;
-
-                     // If we've reached our batch size, commit the batch and reset the count
-
-                     if (count == batchSize) {
-                        session.commit();
-                        count = 0;
-                     }
-                  }
-                  else {
-
-                     // We didn't receive anything this time, commit any current batch and reset the count
-
-                     session.commit();
-                     count = 0;
-
-                     // Sleep a little before trying to read after not getting a message
-
-                     try {
-                        if (idList.size() < totalToExpect) {
-                           LOG.info("did not receive on {}, current count: {}", qName, idList.size());
-                        }
-                        //sleep(3000);
-                     }
-                     catch (Exception e) {
-                     }
-                  }
-               }
-            }
-            catch (Exception e) {
-               e.printStackTrace();
-            }
-            finally {
-
-               // Once we exit, close everything
-               close();
-            }
-         }
-
-         public void shutdown() {
-            shutdown = true;
-         }
-
-         public void close() {
-
-            try {
-               mc.close();
-            }
-            catch (Exception e) {
-            }
-
-            try {
-               session.close();
-            }
-            catch (Exception e) {
-            }
-
-            try {
-               qc.close();
-            }
-            catch (Exception e) {
-
-            }
-         }
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5274Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5274Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5274Test.java
deleted file mode 100644
index d4c02fb..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5274Test.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * 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;
-
-import java.util.concurrent.TimeUnit;
-import javax.jms.Connection;
-import javax.jms.JMSException;
-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.ActiveMQConnectionFactory;
-import org.apache.activemq.RedeliveryPolicy;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.BrokerMBeanSupport;
-import org.apache.activemq.broker.jmx.QueueViewMBean;
-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.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class AMQ5274Test {
-
-   static Logger LOG = LoggerFactory.getLogger(AMQ5274Test.class);
-   String activemqURL;
-   BrokerService brokerService;
-   ActiveMQQueue dest = new ActiveMQQueue("TestQ");
-
-   @Before
-   public void startBroker() throws Exception {
-      brokerService = new BrokerService();
-      brokerService.setPersistent(false);
-      PolicyMap policyMap = new PolicyMap();
-      PolicyEntry defaultPolicy = new PolicyEntry();
-      defaultPolicy.setExpireMessagesPeriod(1000);
-      policyMap.setDefaultEntry(defaultPolicy);
-      brokerService.setDestinationPolicy(policyMap);
-      activemqURL = brokerService.addConnector("tcp://localhost:0").getPublishableConnectString();
-      brokerService.start();
-   }
-
-   @After
-   public void stopBroker() throws Exception {
-      if (brokerService != null) {
-         brokerService.stop();
-      }
-   }
-
-   @Test
-   public void test() throws Exception {
-      LOG.info("Starting Test");
-      assertTrue(brokerService.isStarted());
-
-      produce();
-      consumeAndRollback();
-
-      // check reported queue size using JMX
-      long queueSize = getQueueSize();
-      assertEquals("Queue " + dest.getPhysicalName() + " not empty, reporting " + queueSize + " messages.", 0, queueSize);
-   }
-
-   private void consumeAndRollback() throws JMSException, InterruptedException {
-      ActiveMQConnection connection = createConnection();
-      RedeliveryPolicy noRedelivery = new RedeliveryPolicy();
-      noRedelivery.setMaximumRedeliveries(0);
-      connection.setRedeliveryPolicy(noRedelivery);
-      connection.start();
-      Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-      MessageConsumer consumer = session.createConsumer(dest);
-      Message m;
-      while ((m = consumer.receive(4000)) != null) {
-         LOG.info("Got:" + m);
-         TimeUnit.SECONDS.sleep(1);
-         session.rollback();
-      }
-      connection.close();
-   }
-
-   private void produce() throws Exception {
-      Connection connection = createConnection();
-      connection.start();
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = session.createProducer(dest);
-      producer.setTimeToLive(10000);
-      for (int i = 0; i < 20; i++) {
-         producer.send(session.createTextMessage("i=" + i));
-      }
-      connection.close();
-   }
-
-   private ActiveMQConnection createConnection() throws JMSException {
-      return (ActiveMQConnection) new ActiveMQConnectionFactory(activemqURL).createConnection();
-   }
-
-   public long getQueueSize() throws Exception {
-      long queueSize = 0;
-      try {
-         QueueViewMBean queueViewMBean = (QueueViewMBean) brokerService.getManagementContext().newProxyInstance(BrokerMBeanSupport.createDestinationName(brokerService.getBrokerObjectName(), dest), QueueViewMBean.class, false);
-         queueSize = queueViewMBean.getQueueSize();
-         LOG.info("QueueSize for destination {} is {}", dest, queueSize);
-      }
-      catch (Exception ex) {
-         LOG.error("Error retrieving QueueSize from JMX ", ex);
-         throw ex;
-      }
-      return queueSize;
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5381Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5381Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5381Test.java
deleted file mode 100644
index a05d56d..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5381Test.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/**
- * 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;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.Arrays;
-import java.util.Random;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQBytesMessage;
-import org.apache.activemq.command.ActiveMQMessage;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
-
-public class AMQ5381Test {
-
-   public static final byte[] ORIG_MSG_CONTENT = randomByteArray();
-   public static final String AMQ5381_EXCEPTION_MESSAGE = "java.util.zip.DataFormatException: incorrect header check";
-
-   private BrokerService brokerService;
-   private String brokerURI;
-
-   @Rule
-   public TestName name = new TestName();
-
-   @Before
-   public void startBroker() throws Exception {
-      brokerService = new BrokerService();
-      brokerService.setPersistent(false);
-      brokerService.setUseJmx(false);
-      brokerService.addConnector("tcp://localhost:0");
-      brokerService.start();
-      brokerService.waitUntilStarted();
-
-      brokerURI = brokerService.getTransportConnectorByScheme("tcp").getPublishableConnectString();
-   }
-
-   @After
-   public void stopBroker() throws Exception {
-      if (brokerService != null) {
-         brokerService.stop();
-      }
-   }
-
-   private ActiveMQConnection createConnection(boolean useCompression) throws Exception {
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerURI);
-      factory.setUseCompression(useCompression);
-      Connection connection = factory.createConnection();
-      connection.start();
-      return (ActiveMQConnection) connection;
-   }
-
-   @Test
-   public void amq5381Test() throws Exception {
-
-      // Consumer Configured for (useCompression=true)
-      final ActiveMQConnection consumerConnection = createConnection(true);
-      final Session consumerSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      final Queue consumerQueue = consumerSession.createQueue(name.getMethodName());
-      final MessageConsumer consumer = consumerSession.createConsumer(consumerQueue);
-
-      // Producer Configured for (useCompression=false)
-      final ActiveMQConnection producerConnection = createConnection(false);
-      final Session producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      final Queue producerQueue = producerSession.createQueue(name.getMethodName());
-
-      try {
-
-         final ActiveMQBytesMessage messageProduced = (ActiveMQBytesMessage) producerSession.createBytesMessage();
-         messageProduced.writeBytes(ORIG_MSG_CONTENT);
-         Assert.assertFalse(messageProduced.isReadOnlyBody());
-
-         Assert.assertFalse("Produced Message's 'compressed' flag should remain false until the message is sent (where it will be compressed, if necessary)", messageProduced.isCompressed());
-
-         final MessageProducer producer = producerSession.createProducer(null);
-         producer.send(producerQueue, messageProduced);
-
-         Assert.assertEquals("Once sent, the produced Message's 'compressed' flag should match its Connection's 'useCompression' flag", producerConnection.isUseCompression(), messageProduced.isCompressed());
-
-         final ActiveMQBytesMessage messageConsumed = (ActiveMQBytesMessage) consumer.receive();
-         Assert.assertNotNull(messageConsumed);
-         Assert.assertTrue("Consumed Message should be read-only", messageConsumed.isReadOnlyBody());
-         Assert.assertEquals("Consumed Message's 'compressed' flag should match the produced Message's 'compressed' flag", messageProduced.isCompressed(), messageConsumed.isCompressed());
-
-         // ensure consumed message content matches what was originally set
-         final byte[] consumedMsgContent = new byte[(int) messageConsumed.getBodyLength()];
-         messageConsumed.readBytes(consumedMsgContent);
-
-         Assert.assertTrue("Consumed Message content should match the original Message content", Arrays.equals(ORIG_MSG_CONTENT, consumedMsgContent));
-
-         // make message writable so the consumer can modify and reuse it
-         makeWritable(messageConsumed);
-
-         // modify message, attempt to trigger DataFormatException due
-         // to old incorrect compression logic
-         try {
-            messageConsumed.setStringProperty(this.getClass().getName(), "test");
-         }
-         catch (JMSException jmsE) {
-            if (AMQ5381_EXCEPTION_MESSAGE.equals(jmsE.getMessage())) {
-               StringWriter sw = new StringWriter();
-               PrintWriter pw = new PrintWriter(sw);
-               jmsE.printStackTrace(pw);
-
-               Assert.fail("AMQ5381 Error State Achieved: attempted to decompress BytesMessage contents that are not compressed\n" + sw.toString());
-            }
-            else {
-               throw jmsE;
-            }
-         }
-
-         Assert.assertEquals("The consumed Message's 'compressed' flag should still match the produced Message's 'compressed' flag after it has been made writable", messageProduced.isCompressed(), messageConsumed.isCompressed());
-
-         // simulate re-publishing message
-         simulatePublish(messageConsumed);
-
-         // ensure consumed message content matches what was originally set
-         final byte[] modifiedMsgContent = new byte[(int) messageConsumed.getBodyLength()];
-         messageConsumed.readBytes(modifiedMsgContent);
-
-         Assert.assertTrue("After the message properties are modified and it is re-published, its message content should still match the original message content", Arrays.equals(ORIG_MSG_CONTENT, modifiedMsgContent));
-      }
-      finally {
-         producerSession.close();
-         producerConnection.close();
-         consumerSession.close();
-         consumerConnection.close();
-      }
-   }
-
-   protected static final int MAX_RANDOM_BYTE_ARRAY_SIZE_KB = 128;
-
-   protected static byte[] randomByteArray() {
-      final Random random = new Random();
-      final byte[] byteArray = new byte[random.nextInt(MAX_RANDOM_BYTE_ARRAY_SIZE_KB * 1024)];
-      random.nextBytes(byteArray);
-
-      return byteArray;
-   }
-
-   protected static void makeWritable(final ActiveMQMessage message) {
-      message.setReadOnlyBody(false);
-      message.setReadOnlyProperties(false);
-   }
-
-   protected static void simulatePublish(final ActiveMQBytesMessage message) throws JMSException {
-      message.reset();
-      message.onSend();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5421Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5421Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5421Test.java
deleted file mode 100644
index 0e9e310..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5421Test.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * 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;
-
-import java.net.URI;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.AbortSlowAckConsumerStrategy;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ5421Test {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ5421Test.class);
-
-   private static final int DEST_COUNT = 1000;
-   private final Destination[] destination = new Destination[DEST_COUNT];
-   private final MessageProducer[] producer = new MessageProducer[DEST_COUNT];
-   private BrokerService brokerService;
-   private String connectionUri;
-
-   protected ConnectionFactory createConnectionFactory() throws Exception {
-      ActiveMQConnectionFactory conFactory = new ActiveMQConnectionFactory(connectionUri);
-      conFactory.setWatchTopicAdvisories(false);
-      return conFactory;
-   }
-
-   protected AbortSlowAckConsumerStrategy createSlowConsumerStrategy() {
-      AbortSlowAckConsumerStrategy strategy = new AbortSlowAckConsumerStrategy();
-      strategy.setCheckPeriod(2000);
-      strategy.setMaxTimeSinceLastAck(5000);
-      strategy.setIgnoreIdleConsumers(false);
-
-      return strategy;
-   }
-
-   @Before
-   public void setUp() throws Exception {
-      brokerService = BrokerFactory.createBroker(new URI("broker://()/localhost?persistent=false&useJmx=true"));
-      PolicyEntry policy = new PolicyEntry();
-
-      policy.setSlowConsumerStrategy(createSlowConsumerStrategy());
-      policy.setQueuePrefetch(10);
-      policy.setTopicPrefetch(10);
-      PolicyMap pMap = new PolicyMap();
-      pMap.setDefaultEntry(policy);
-      brokerService.setDestinationPolicy(pMap);
-      brokerService.addConnector("tcp://0.0.0.0:0");
-      brokerService.start();
-
-      connectionUri = brokerService.getTransportConnectorByScheme("tcp").getPublishableConnectString();
-   }
-
-   @Test
-   public void testManyTempDestinations() throws Exception {
-      Connection connection = createConnectionFactory().createConnection();
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      for (int i = 0; i < DEST_COUNT; i++) {
-         destination[i] = session.createTemporaryQueue();
-         LOG.debug("Created temp queue: [}", i);
-      }
-
-      for (int i = 0; i < DEST_COUNT; i++) {
-         producer[i] = session.createProducer(destination[i]);
-         LOG.debug("Created producer: {}", i);
-         TextMessage msg = session.createTextMessage(" testMessage " + i);
-         producer[i].send(msg);
-         LOG.debug("message sent: {}", i);
-         MessageConsumer consumer = session.createConsumer(destination[i]);
-         Message message = consumer.receive(1000);
-         Assert.assertTrue(message.equals(msg));
-      }
-
-      for (int i = 0; i < DEST_COUNT; i++) {
-         producer[i].close();
-      }
-
-      connection.close();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      brokerService.stop();
-      brokerService.waitUntilStopped();
-   }
-}


[37/60] [abbrv] activemq-artemis git commit: adding profile openwire-tests (to replace activemq5-unit-tests

Posted by cl...@apache.org.
adding profile openwire-tests (to replace activemq5-unit-tests


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/8e29ff7f
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/8e29ff7f
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/8e29ff7f

Branch: refs/heads/refactor-openwire
Commit: 8e29ff7ff2ad5054d4784612644c9fcb01042efc
Parents: f150638
Author: Clebert Suconic <cl...@apache.org>
Authored: Wed Feb 24 13:53:44 2016 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:44:21 2016 -0400

----------------------------------------------------------------------
 tests/pom.xml | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8e29ff7f/tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/pom.xml b/tests/pom.xml
index bb54b95..630da1e 100644
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -84,6 +84,7 @@
          </modules>
       </profile>
       <profile>
+         <!-- deprecated: use openwire-tests -->
          <id>activemq5-unit-tests</id>
          <modules>
             <module>activemq5-unit-tests</module>
@@ -93,6 +94,15 @@
          </properties>
       </profile>
       <profile>
+         <id>openwire-tests</id>
+         <modules>
+            <module>activemq5-unit-tests</module>
+         </modules>
+         <properties>
+            <skipActiveMQ5Tests>false</skipActiveMQ5Tests>
+         </properties>
+      </profile>
+      <profile>
          <id>release</id>
          <modules>
             <module>activemq5-unit-tests</module>


[17/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4469Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4469Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4469Test.java
deleted file mode 100644
index e80b05c..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4469Test.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.TransportConnector;
-import org.apache.activemq.transport.tcp.TcpTransportServer;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.jms.support.JmsUtils;
-
-public class AMQ4469Test {
-
-   private static final int maxConnections = 100;
-
-   private final ExecutorService executor = Executors.newCachedThreadPool();
-   private String connectionUri;
-   private BrokerService service;
-   private TransportConnector connector;
-
-   @Before
-   public void setUp() throws Exception {
-      service = new BrokerService();
-      service.setPersistent(false);
-      service.setUseJmx(false);
-      connector = service.addConnector("tcp://0.0.0.0:0?maximumConnections=" + maxConnections);
-      connectionUri = connector.getPublishableConnectString();
-      service.start();
-      service.waitUntilStarted();
-   }
-
-   protected ConnectionFactory createConnectionFactory() throws Exception {
-      return new ActiveMQConnectionFactory(connectionUri);
-   }
-
-   @Test
-   public void testMaxConnectionControl() throws Exception {
-      final ConnectionFactory cf = createConnectionFactory();
-      final CountDownLatch startupLatch = new CountDownLatch(1);
-      for (int i = 0; i < maxConnections + 20; i++) {
-         executor.submit(new Runnable() {
-            @Override
-            public void run() {
-               Connection conn = null;
-               try {
-                  startupLatch.await();
-                  conn = cf.createConnection();
-                  conn.start();
-               }
-               catch (Exception e) {
-                  e.printStackTrace();
-                  JmsUtils.closeConnection(conn);
-               }
-            }
-         });
-      }
-
-      TcpTransportServer transportServer = (TcpTransportServer) connector.getServer();
-      // ensure the max connections is in effect
-      assertEquals(maxConnections, transportServer.getMaximumConnections());
-      // No connections at first
-      assertEquals(0, connector.getConnections().size());
-      // Release the latch to set up connections in parallel
-      startupLatch.countDown();
-      TimeUnit.SECONDS.sleep(5);
-
-      final TransportConnector connector = this.connector;
-
-      // Expect the max connections is created
-      assertTrue("Expected: " + maxConnections + " found: " + connector.getConnections().size(), Wait.waitFor(new Wait.Condition() {
-                    @Override
-                    public boolean isSatisified() throws Exception {
-                       return connector.getConnections().size() == maxConnections;
-                    }
-                 }));
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      executor.shutdown();
-
-      service.stop();
-      service.waitUntilStopped();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4472Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4472Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4472Test.java
deleted file mode 100644
index b7ae444..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4472Test.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * 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;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-public class AMQ4472Test {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ4472Test.class);
-
-   @Test
-   public void testLostMessage() {
-      Connection connection = null;
-      try {
-         ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.useJmx=false");
-         connection = connectionFactory.createConnection();
-         connection.start();
-
-         Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-         Destination test_data_destination = session.createQueue("test" + System.currentTimeMillis());
-
-         MessageConsumer consumer = session.createConsumer(test_data_destination);
-         LOG.info("Consumer 1 connected");
-
-         MessageProducer producer = session.createProducer(test_data_destination);
-         producer.send(session.createTextMessage("Message 1"));
-
-         // committing the session prior to the close
-         session.commit();
-
-         // starting a new transaction
-         producer.send(session.createTextMessage("Message 2"));
-
-         // in a new transaction, with prefetch>0, the message
-         // 1 will be pending till second commit
-         LOG.info("Closing consumer 1...");
-         consumer.close();
-
-         // create a consumer
-         consumer = session.createConsumer(test_data_destination);
-         LOG.info("Consumer 2 connected");
-
-         // retrieve message previously committed to tmp queue
-         Message message = consumer.receive(10000);
-         if (message != null) {
-            LOG.info("Got message 1:", message);
-            assertEquals("expected message", "Message 1", ((TextMessage) message).getText());
-            session.commit();
-         }
-         else {
-            LOG.error("Expected message but it never arrived");
-         }
-         assertNotNull(message);
-      }
-      catch (Exception e) {
-         e.printStackTrace();
-      }
-      finally {
-         try {
-            connection.close();
-         }
-         catch (JMSException e) {
-         }
-      }
-   }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4475Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4475Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4475Test.java
deleted file mode 100644
index 558bc08..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4475Test.java
+++ /dev/null
@@ -1,361 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertFalse;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerPlugin;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.DeadLetterStrategy;
-import org.apache.activemq.broker.region.policy.IndividualDeadLetterStrategy;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.broker.util.TimeStampingBrokerPlugin;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTextMessage;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AMQ4475Test {
-
-   private final Log LOG = LogFactory.getLog(AMQ4475Test.class);
-
-   private final int NUM_MSGS = 1000;
-   private final int MAX_THREADS = 20;
-
-   private BrokerService broker;
-   private String connectionUri;
-
-   private final ExecutorService executor = Executors.newFixedThreadPool(MAX_THREADS);
-   private final ActiveMQQueue original = new ActiveMQQueue("jms/AQueue");
-   private final ActiveMQQueue rerouted = new ActiveMQQueue("jms/AQueue_proxy");
-
-   @Before
-   public void setUp() throws Exception {
-      TimeStampingBrokerPlugin tsbp = new TimeStampingBrokerPlugin();
-      tsbp.setZeroExpirationOverride(432000000);
-      tsbp.setTtlCeiling(432000000);
-      tsbp.setFutureOnly(true);
-
-      broker = new BrokerService();
-      broker.setPersistent(false);
-      broker.setUseJmx(true);
-      broker.setPlugins(new BrokerPlugin[]{tsbp});
-      connectionUri = broker.addConnector("tcp://localhost:0").getPublishableConnectString();
-
-      // Configure Dead Letter Strategy
-      DeadLetterStrategy strategy = new IndividualDeadLetterStrategy();
-      strategy.setProcessExpired(true);
-      ((IndividualDeadLetterStrategy) strategy).setUseQueueForQueueMessages(true);
-      ((IndividualDeadLetterStrategy) strategy).setQueuePrefix("DLQ.");
-      strategy.setProcessNonPersistent(true);
-
-      // Add policy and individual DLQ strategy
-      PolicyEntry policy = new PolicyEntry();
-      policy.setTimeBeforeDispatchStarts(3000);
-      policy.setDeadLetterStrategy(strategy);
-
-      PolicyMap pMap = new PolicyMap();
-      pMap.setDefaultEntry(policy);
-
-      broker.setDestinationPolicy(pMap);
-      broker.start();
-      broker.waitUntilStarted();
-   }
-
-   @After
-   public void after() throws Exception {
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-      }
-   }
-
-   @Test
-   public void testIndividualDeadLetterAndTimeStampPlugin() {
-      LOG.info("Starting test ..");
-
-      long startTime = System.nanoTime();
-
-      // Produce to network
-      List<Future<ProducerTask>> tasks = new ArrayList<>();
-
-      for (int index = 0; index < 1; index++) {
-         ProducerTask p = new ProducerTask(connectionUri, original, NUM_MSGS);
-         Future<ProducerTask> future = executor.submit(p, p);
-         tasks.add(future);
-      }
-
-      ForwardingConsumerThread f1 = new ForwardingConsumerThread(original, rerouted, NUM_MSGS);
-      f1.start();
-      ConsumerThread c1 = new ConsumerThread(connectionUri, rerouted, NUM_MSGS);
-      c1.start();
-
-      LOG.info("Waiting on consumers and producers to exit");
-
-      try {
-         for (Future<ProducerTask> future : tasks) {
-            ProducerTask e = future.get();
-            LOG.info("[Completed] " + e.dest.getPhysicalName());
-         }
-         executor.shutdown();
-         LOG.info("Producing threads complete, waiting on ACKs");
-         f1.join(TimeUnit.MINUTES.toMillis(2));
-         c1.join(TimeUnit.MINUTES.toMillis(2));
-      }
-      catch (ExecutionException e) {
-         LOG.warn("Caught unexpected exception: {}", e);
-         throw new RuntimeException(e);
-      }
-      catch (InterruptedException ie) {
-         LOG.warn("Caught unexpected exception: {}", ie);
-         throw new RuntimeException(ie);
-      }
-
-      assertFalse(f1.isFailed());
-      assertFalse(c1.isFailed());
-
-      long estimatedTime = System.nanoTime() - startTime;
-
-      LOG.info("Testcase duration (seconds): " + estimatedTime / 1000000000.0);
-      LOG.info("Consumers and producers exited, all msgs received as expected");
-   }
-
-   public class ProducerTask implements Runnable {
-
-      private final String uri;
-      private final ActiveMQQueue dest;
-      private final int count;
-
-      public ProducerTask(String uri, ActiveMQQueue dest, int count) {
-         this.uri = uri;
-         this.dest = dest;
-         this.count = count;
-      }
-
-      @Override
-      public void run() {
-
-         Connection connection = null;
-         try {
-            String destName = "";
-
-            try {
-               destName = dest.getQueueName();
-            }
-            catch (JMSException e) {
-               LOG.warn("Caught unexpected exception: {}", e);
-            }
-
-            ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(uri);
-
-            connection = connectionFactory.createConnection();
-
-            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-            MessageProducer producer = session.createProducer(dest);
-            connection.start();
-
-            producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-
-            String msg = "Test Message";
-
-            for (int i = 0; i < count; i++) {
-               producer.send(session.createTextMessage(msg + dest.getQueueName() + " " + i));
-            }
-
-            LOG.info("[" + destName + "] Sent " + count + " msgs");
-         }
-         catch (Exception e) {
-            LOG.warn("Caught unexpected exception: {}", e);
-         }
-         finally {
-            try {
-               connection.close();
-            }
-            catch (Throwable e) {
-               LOG.warn("Caught unexpected exception: {}", e);
-            }
-         }
-      }
-   }
-
-   public class ForwardingConsumerThread extends Thread {
-
-      private final ActiveMQQueue original;
-      private final ActiveMQQueue forward;
-      private int blockSize = 0;
-      private final int PARALLEL = 1;
-      private boolean failed;
-
-      public ForwardingConsumerThread(ActiveMQQueue original, ActiveMQQueue forward, int total) {
-         this.original = original;
-         this.forward = forward;
-         this.blockSize = total / PARALLEL;
-      }
-
-      public boolean isFailed() {
-         return failed;
-      }
-
-      @Override
-      public void run() {
-         Connection connection = null;
-         try {
-
-            for (int index = 0; index < PARALLEL; index++) {
-
-               ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
-
-               connection = factory.createConnection();
-               Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-               MessageConsumer consumer = session.createConsumer(original);
-               MessageProducer producer = session.createProducer(forward);
-               connection.start();
-               int count = 0;
-
-               while (count < blockSize) {
-
-                  Message msg1 = consumer.receive(10000);
-                  if (msg1 != null) {
-                     if (msg1 instanceof ActiveMQTextMessage) {
-                        if (count % 100 == 0) {
-                           LOG.info("Consuming -> " + ((ActiveMQTextMessage) msg1).getDestination() + " count=" + count);
-                        }
-
-                        producer.send(msg1);
-
-                        count++;
-                     }
-                     else {
-                        LOG.info("Skipping unknown msg type " + msg1);
-                     }
-                  }
-                  else {
-                     break;
-                  }
-               }
-
-               LOG.info("[" + original.getQueueName() + "] completed segment (" + index + " of " + blockSize + ")");
-               connection.close();
-            }
-         }
-         catch (Exception e) {
-            LOG.warn("Caught unexpected exception: {}", e);
-         }
-         finally {
-            LOG.debug(getName() + ": is stopping");
-            try {
-               connection.close();
-            }
-            catch (Throwable e) {
-            }
-         }
-      }
-   }
-
-   public class ConsumerThread extends Thread {
-
-      private final String uri;
-      private final ActiveMQQueue dest;
-      private int blockSize = 0;
-      private final int PARALLEL = 1;
-      private boolean failed;
-
-      public ConsumerThread(String uri, ActiveMQQueue dest, int total) {
-         this.uri = uri;
-         this.dest = dest;
-         this.blockSize = total / PARALLEL;
-      }
-
-      public boolean isFailed() {
-         return failed;
-      }
-
-      @Override
-      public void run() {
-         Connection connection = null;
-         try {
-
-            for (int index = 0; index < PARALLEL; index++) {
-
-               ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(uri);
-
-               connection = factory.createConnection();
-               Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-               MessageConsumer consumer = session.createConsumer(dest);
-               connection.start();
-               int count = 0;
-
-               while (count < blockSize) {
-
-                  Object msg1 = consumer.receive(10000);
-                  if (msg1 != null) {
-                     if (msg1 instanceof ActiveMQTextMessage) {
-                        if (count % 100 == 0) {
-                           LOG.info("Consuming -> " + ((ActiveMQTextMessage) msg1).getDestination() + " count=" + count);
-                        }
-
-                        count++;
-                     }
-                     else {
-                        LOG.info("Skipping unknown msg type " + msg1);
-                     }
-                  }
-                  else {
-                     failed = true;
-                     break;
-                  }
-               }
-
-               LOG.info("[" + dest.getQueueName() + "] completed segment (" + index + " of " + blockSize + ")");
-               connection.close();
-            }
-         }
-         catch (Exception e) {
-            LOG.warn("Caught unexpected exception: {}", e);
-         }
-         finally {
-            LOG.debug(getName() + ": is stopping");
-            try {
-               connection.close();
-            }
-            catch (Throwable e) {
-            }
-         }
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4485LowLimitLevelDBTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4485LowLimitLevelDBTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4485LowLimitLevelDBTest.java
deleted file mode 100644
index efaf484..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4485LowLimitLevelDBTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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;
-
-import java.io.File;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.leveldb.LevelDBStore;
-
-public class AMQ4485LowLimitLevelDBTest extends AMQ4485LowLimitTest {
-
-   public AMQ4485LowLimitLevelDBTest() {
-      super();
-      numBrokers = 2;
-   }
-
-   @Override
-   protected BrokerService createBroker(int brokerid, boolean addToNetwork) throws Exception {
-      BrokerService broker = super.createBroker(brokerid, addToNetwork);
-
-      LevelDBStore levelDBStore = new LevelDBStore();
-      levelDBStore.setDirectory(new File(broker.getBrokerDataDirectory(), "levelDB"));
-      broker.setPersistenceAdapter(levelDBStore);
-      return broker;
-   }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4485LowLimitTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4485LowLimitTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4485LowLimitTest.java
deleted file mode 100644
index 4c48c2c..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4485LowLimitTest.java
+++ /dev/null
@@ -1,473 +0,0 @@
-/**
- * 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;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.QueueConnection;
-import javax.jms.QueueReceiver;
-import javax.jms.QueueSession;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.management.ObjectName;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.JmsMultipleBrokersTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.QueueViewMBean;
-import org.apache.activemq.broker.region.RegionBroker;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQMessage;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.BrokerInfo;
-import org.apache.activemq.network.DiscoveryNetworkConnector;
-import org.apache.activemq.network.NetworkConnector;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.util.TimeUtils;
-import org.apache.activemq.util.Wait;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ4485LowLimitTest extends JmsMultipleBrokersTestSupport {
-
-   static final String payload = new String(new byte[10 * 1024]);
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ4485LowLimitTest.class);
-   final int portBase = 61600;
-   int numBrokers = 8;
-   final int numProducers = 30;
-   final int numMessages = 1000;
-   final int consumerSleepTime = 40;
-   StringBuilder brokersUrl = new StringBuilder();
-   HashMap<ActiveMQQueue, AtomicInteger> accumulators = new HashMap<>();
-   private ArrayList<Throwable> exceptions = new ArrayList<>();
-
-   protected void buildUrlList() throws Exception {
-      for (int i = 0; i < numBrokers; i++) {
-         brokersUrl.append("tcp://localhost:" + (portBase + i));
-         if (i != numBrokers - 1) {
-            brokersUrl.append(',');
-         }
-      }
-   }
-
-   protected BrokerService createBroker(int brokerid) throws Exception {
-      return createBroker(brokerid, true);
-   }
-
-   protected BrokerService createBroker(int brokerid, boolean addToNetwork) throws Exception {
-
-      BrokerService broker = new BrokerService();
-      broker.setPersistent(true);
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.getManagementContext().setCreateConnector(false);
-
-      broker.setUseJmx(true);
-      broker.setBrokerName("B" + brokerid);
-      broker.addConnector(new URI("tcp://localhost:" + (portBase + brokerid)));
-
-      if (addToNetwork) {
-         addNetworkConnector(broker);
-      }
-      broker.setSchedulePeriodForDestinationPurge(0);
-      broker.getSystemUsage().getMemoryUsage().setLimit(256 * 1024 * 1024L);
-
-      PolicyMap policyMap = new PolicyMap();
-      PolicyEntry policyEntry = new PolicyEntry();
-      policyEntry.setExpireMessagesPeriod(0);
-      policyEntry.setQueuePrefetch(1000);
-      policyEntry.setMemoryLimit(2 * 1024 * 1024L);
-      policyEntry.setProducerFlowControl(false);
-      policyEntry.setEnableAudit(true);
-      policyEntry.setUseCache(true);
-      policyMap.put(new ActiveMQQueue("GW.>"), policyEntry);
-
-      PolicyEntry inPolicyEntry = new PolicyEntry();
-      inPolicyEntry.setExpireMessagesPeriod(0);
-      inPolicyEntry.setQueuePrefetch(1000);
-      inPolicyEntry.setMemoryLimit(5 * 1024 * 1024L);
-      inPolicyEntry.setProducerFlowControl(true);
-      inPolicyEntry.setEnableAudit(true);
-      inPolicyEntry.setUseCache(true);
-      policyMap.put(new ActiveMQQueue("IN"), inPolicyEntry);
-
-      broker.setDestinationPolicy(policyMap);
-
-      KahaDBPersistenceAdapter kahaDBPersistenceAdapter = (KahaDBPersistenceAdapter) broker.getPersistenceAdapter();
-      kahaDBPersistenceAdapter.setConcurrentStoreAndDispatchQueues(true);
-
-      brokers.put(broker.getBrokerName(), new BrokerItem(broker));
-      return broker;
-   }
-
-   private void addNetworkConnector(BrokerService broker) throws Exception {
-      StringBuilder networkConnectorUrl = new StringBuilder("static:(").append(brokersUrl.toString());
-      networkConnectorUrl.append(')');
-
-      for (int i = 0; i < 2; i++) {
-         NetworkConnector nc = new DiscoveryNetworkConnector(new URI(networkConnectorUrl.toString()));
-         nc.setName("Bridge-" + i);
-         nc.setNetworkTTL(1);
-         nc.setDecreaseNetworkConsumerPriority(true);
-         nc.setDynamicOnly(true);
-         nc.setPrefetchSize(100);
-         nc.setDynamicallyIncludedDestinations(Arrays.asList(new ActiveMQDestination[]{new ActiveMQQueue("GW.*")}));
-         broker.addNetworkConnector(nc);
-      }
-   }
-
-   // used to explore contention with concurrentStoreandDispatch - sync commit and task queue reversing
-   // order of cursor add and sequence assignment
-   public void x_testInterleavedSend() throws Exception {
-
-      BrokerService b = createBroker(0, false);
-      b.start();
-
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:" + (portBase + 0));
-      connectionFactory.setWatchTopicAdvisories(false);
-
-      QueueConnection c1 = connectionFactory.createQueueConnection();
-      QueueConnection c2 = connectionFactory.createQueueConnection();
-      QueueConnection c3 = connectionFactory.createQueueConnection();
-
-      c1.start();
-      c2.start();
-      c3.start();
-
-      ActiveMQQueue dest = new ActiveMQQueue("IN");
-      final Session s1 = c1.createQueueSession(true, Session.SESSION_TRANSACTED);
-      final TextMessage txMessage = s1.createTextMessage("TX");
-      final TextMessage noTxMessage = s1.createTextMessage("NO_TX");
-
-      final MessageProducer txProducer = s1.createProducer(dest);
-      final MessageProducer nonTxProducer = c2.createQueueSession(false, Session.AUTO_ACKNOWLEDGE).createProducer(dest);
-
-      txProducer.send(txMessage);
-
-      ExecutorService executorService = Executors.newFixedThreadPool(2);
-      executorService.execute(new Runnable() {
-         @Override
-         public void run() {
-            try {
-               s1.commit();
-            }
-            catch (JMSException e) {
-               e.printStackTrace();
-            }
-         }
-      });
-
-      executorService.execute(new Runnable() {
-         @Override
-         public void run() {
-            try {
-               nonTxProducer.send(noTxMessage);
-            }
-            catch (JMSException e) {
-               e.printStackTrace();
-            }
-         }
-      });
-
-      executorService.shutdown();
-      executorService.awaitTermination(10, TimeUnit.MINUTES);
-
-   }
-
-   public void testBrokers() throws Exception {
-
-      buildUrlList();
-
-      for (int i = 0; i < numBrokers; i++) {
-         createBroker(i);
-      }
-
-      startAllBrokers();
-      waitForBridgeFormation(numBrokers - 1);
-
-      verifyPeerBrokerInfos(numBrokers - 1);
-
-      final List<ConsumerState> consumerStates = startAllGWConsumers(numBrokers);
-
-      startAllGWFanoutConsumers(numBrokers);
-
-      LOG.info("Waiting for percolation of consumers..");
-      TimeUnit.SECONDS.sleep(5);
-
-      LOG.info("Produce mesages..");
-      long startTime = System.currentTimeMillis();
-
-      // produce
-      produce(numMessages);
-
-      assertTrue("Got all sent", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            for (ConsumerState tally : consumerStates) {
-               final int expected = numMessages * (tally.destination.isComposite() ? tally.destination.getCompositeDestinations().length : 1);
-               LOG.info("Tally for: " + tally.brokerName + ", dest: " + tally.destination + " - " + tally.accumulator.get());
-               if (tally.accumulator.get() != expected) {
-                  LOG.info("Tally for: " + tally.brokerName + ", dest: " + tally.destination + " - " + tally.accumulator.get() + " != " + expected + ", " + tally.expected);
-                  if (tally.accumulator.get() > expected - 50) {
-                     dumpQueueStat(null);
-                  }
-                  if (tally.expected.size() == 1) {
-                     startConsumer(tally.brokerName, tally.destination);
-                  }
-                  return false;
-               }
-               LOG.info("got tally on " + tally.brokerName);
-            }
-            return true;
-         }
-      }, 1000 * 60 * 1000L, 20 * 1000));
-
-      assertTrue("No exceptions:" + exceptions, exceptions.isEmpty());
-
-      LOG.info("done");
-      long duration = System.currentTimeMillis() - startTime;
-      LOG.info("Duration:" + TimeUtils.printDuration(duration));
-
-      assertEquals("nothing in the dlq's", 0, dumpQueueStat(new ActiveMQQueue("ActiveMQ.DLQ")));
-
-   }
-
-   private void startConsumer(String brokerName, ActiveMQDestination destination) throws Exception {
-      int id = Integer.parseInt(brokerName.substring(1));
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:" + (portBase + id));
-      connectionFactory.setWatchTopicAdvisories(false);
-      QueueConnection queueConnection = connectionFactory.createQueueConnection();
-      queueConnection.start();
-
-      queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE).createConsumer(destination);
-      queueConnection.close();
-   }
-
-   private long dumpQueueStat(ActiveMQDestination destination) throws Exception {
-      long sumTotal = 0;
-      Collection<BrokerItem> brokerList = brokers.values();
-      for (Iterator<BrokerItem> i = brokerList.iterator(); i.hasNext(); ) {
-         BrokerService brokerService = i.next().broker;
-         for (ObjectName objectName : brokerService.getAdminView().getQueues()) {
-            if (destination != null && objectName.toString().contains(destination.getPhysicalName())) {
-               QueueViewMBean qViewMBean = (QueueViewMBean) brokerService.getManagementContext().newProxyInstance(objectName, QueueViewMBean.class, false);
-               LOG.info(brokerService.getBrokerName() + ", " + qViewMBean.getName() + ", Enqueue:" + qViewMBean.getEnqueueCount() + ", Size: " + qViewMBean.getQueueSize());
-               sumTotal += qViewMBean.getQueueSize();
-            }
-         }
-      }
-      return sumTotal;
-   }
-
-   private void startAllGWFanoutConsumers(int nBrokers) throws Exception {
-
-      StringBuffer compositeDest = new StringBuffer();
-      for (int k = 0; k < nBrokers; k++) {
-         compositeDest.append("GW." + k);
-         if (k + 1 != nBrokers) {
-            compositeDest.append(',');
-         }
-      }
-      ActiveMQQueue compositeQ = new ActiveMQQueue(compositeDest.toString());
-
-      for (int id = 0; id < nBrokers; id++) {
-         ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("failover:(tcp://localhost:" + (portBase + id) + ")");
-         connectionFactory.setWatchTopicAdvisories(false);
-
-         QueueConnection queueConnection = connectionFactory.createQueueConnection();
-         queueConnection.start();
-
-         final QueueSession queueSession = queueConnection.createQueueSession(true, Session.SESSION_TRANSACTED);
-
-         final MessageProducer producer = queueSession.createProducer(compositeQ);
-         queueSession.createReceiver(new ActiveMQQueue("IN")).setMessageListener(new MessageListener() {
-            @Override
-            public void onMessage(Message message) {
-               try {
-                  producer.send(message);
-                  queueSession.commit();
-               }
-               catch (Exception e) {
-                  LOG.error("Failed to fanout to GW: " + message, e);
-               }
-
-            }
-         });
-      }
-   }
-
-   private List<ConsumerState> startAllGWConsumers(int nBrokers) throws Exception {
-      List<ConsumerState> consumerStates = new LinkedList<>();
-      for (int id = 0; id < nBrokers; id++) {
-         ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("failover:(tcp://localhost:" + (portBase + id) + ")");
-         connectionFactory.setWatchTopicAdvisories(false);
-
-         QueueConnection queueConnection = connectionFactory.createQueueConnection();
-         queueConnection.start();
-
-         final QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
-
-         ActiveMQQueue destination = new ActiveMQQueue("GW." + id);
-         QueueReceiver queueReceiver = queueSession.createReceiver(destination);
-
-         final ConsumerState consumerState = new ConsumerState();
-         consumerState.brokerName = ((ActiveMQConnection) queueConnection).getBrokerName();
-         consumerState.receiver = queueReceiver;
-         consumerState.destination = destination;
-         for (int j = 0; j < numMessages * (consumerState.destination.isComposite() ? consumerState.destination.getCompositeDestinations().length : 1); j++) {
-            consumerState.expected.add(j);
-         }
-
-         if (!accumulators.containsKey(destination)) {
-            accumulators.put(destination, new AtomicInteger(0));
-         }
-         consumerState.accumulator = accumulators.get(destination);
-
-         queueReceiver.setMessageListener(new MessageListener() {
-            @Override
-            public void onMessage(Message message) {
-               try {
-                  if (consumerSleepTime > 0) {
-                     TimeUnit.MILLISECONDS.sleep(consumerSleepTime);
-                  }
-               }
-               catch (InterruptedException e) {
-                  e.printStackTrace();
-               }
-               try {
-                  consumerState.accumulator.incrementAndGet();
-                  try {
-                     consumerState.expected.remove(((ActiveMQMessage) message).getProperty("NUM"));
-                  }
-                  catch (IOException e) {
-                     e.printStackTrace();
-                  }
-                  //queueSession.commit();
-               }
-               catch (Exception e) {
-                  LOG.error("Failed to commit slow receipt of " + message, e);
-               }
-            }
-         });
-
-         consumerStates.add(consumerState);
-
-      }
-      return consumerStates;
-   }
-
-   private void produce(final int numMessages) throws Exception {
-      ExecutorService executorService = Executors.newFixedThreadPool(numProducers);
-      final AtomicInteger toSend = new AtomicInteger(numMessages);
-      for (int i = 1; i <= numProducers; i++) {
-         final int id = i % numBrokers;
-         executorService.execute(new Runnable() {
-            @Override
-            public void run() {
-               try {
-                  ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("failover:(tcp://localhost:" + (portBase + id) + ")");
-                  connectionFactory.setWatchTopicAdvisories(false);
-                  QueueConnection queueConnection = connectionFactory.createQueueConnection();
-                  queueConnection.start();
-                  QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
-                  MessageProducer producer = queueSession.createProducer(null);
-                  int val = 0;
-                  while ((val = toSend.decrementAndGet()) >= 0) {
-
-                     int id = numMessages - val - 1;
-
-                     ActiveMQQueue compositeQ = new ActiveMQQueue("IN");
-                     Message textMessage = queueSession.createTextMessage(((ActiveMQConnection) queueConnection).getBrokerName() + "->" + id + " payload:" + payload);
-                     textMessage.setIntProperty("NUM", id);
-                     producer.send(compositeQ, textMessage);
-                  }
-                  queueConnection.close();
-
-               }
-               catch (Throwable throwable) {
-                  throwable.printStackTrace();
-                  exceptions.add(throwable);
-               }
-            }
-         });
-      }
-   }
-
-   private void verifyPeerBrokerInfo(BrokerItem brokerItem, final int max) throws Exception {
-      final BrokerService broker = brokerItem.broker;
-      final RegionBroker regionBroker = (RegionBroker) broker.getRegionBroker();
-      Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            LOG.info("verify infos " + broker.getBrokerName() + ", len: " + regionBroker.getPeerBrokerInfos().length);
-            return max == regionBroker.getPeerBrokerInfos().length;
-         }
-      });
-      LOG.info("verify infos " + broker.getBrokerName() + ", len: " + regionBroker.getPeerBrokerInfos().length);
-      List<String> missing = new ArrayList<>();
-      for (int i = 0; i < max; i++) {
-         missing.add("B" + i);
-      }
-      if (max != regionBroker.getPeerBrokerInfos().length) {
-         for (BrokerInfo info : regionBroker.getPeerBrokerInfos()) {
-            LOG.info(info.getBrokerName());
-            missing.remove(info.getBrokerName());
-         }
-         LOG.info("Broker infos off.." + missing);
-      }
-      assertEquals(broker.getBrokerName(), max, regionBroker.getPeerBrokerInfos().length);
-   }
-
-   private void verifyPeerBrokerInfos(final int max) throws Exception {
-      Collection<BrokerItem> brokerList = brokers.values();
-      for (Iterator<BrokerItem> i = brokerList.iterator(); i.hasNext(); ) {
-         verifyPeerBrokerInfo(i.next(), max);
-      }
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      super.tearDown();
-   }
-
-   class ConsumerState {
-
-      AtomicInteger accumulator;
-      String brokerName;
-      QueueReceiver receiver;
-      ActiveMQDestination destination;
-      ConcurrentLinkedQueue<Integer> expected = new ConcurrentLinkedQueue<>();
-   }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4485NetworkOfXBrokersWithNDestsFanoutTransactionTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4485NetworkOfXBrokersWithNDestsFanoutTransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4485NetworkOfXBrokersWithNDestsFanoutTransactionTest.java
deleted file mode 100644
index 5ddb14f..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4485NetworkOfXBrokersWithNDestsFanoutTransactionTest.java
+++ /dev/null
@@ -1,358 +0,0 @@
-/**
- * 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;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Vector;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.QueueConnection;
-import javax.jms.QueueReceiver;
-import javax.jms.QueueSession;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.JmsMultipleBrokersTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.RegionBroker;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQMessage;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.BrokerInfo;
-import org.apache.activemq.network.DiscoveryNetworkConnector;
-import org.apache.activemq.network.NetworkConnector;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.util.TimeUtils;
-import org.apache.activemq.util.Wait;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ4485NetworkOfXBrokersWithNDestsFanoutTransactionTest extends JmsMultipleBrokersTestSupport {
-
-   static final String payload = new String(new byte[10 * 1024]);
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ4485NetworkOfXBrokersWithNDestsFanoutTransactionTest.class);
-   final int portBase = 61600;
-   final int numBrokers = 4;
-   final int numProducers = 10;
-   final int numMessages = 800;
-   final int consumerSleepTime = 20;
-   StringBuilder brokersUrl = new StringBuilder();
-   HashMap<ActiveMQQueue, AtomicInteger> accumulators = new HashMap<>();
-   private ArrayList<Throwable> exceptions = new ArrayList<>();
-
-   protected void buildUrlList() throws Exception {
-      for (int i = 0; i < numBrokers; i++) {
-         brokersUrl.append("tcp://localhost:" + (portBase + i));
-         if (i != numBrokers - 1) {
-            brokersUrl.append(',');
-         }
-      }
-   }
-
-   protected BrokerService createBroker(int brokerid) throws Exception {
-      BrokerService broker = new BrokerService();
-      broker.setPersistent(true);
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.getManagementContext().setCreateConnector(false);
-
-      broker.setUseJmx(true);
-      broker.setBrokerName("B" + brokerid);
-      broker.addConnector(new URI("tcp://localhost:" + (portBase + brokerid)));
-
-      addNetworkConnector(broker);
-      broker.setSchedulePeriodForDestinationPurge(0);
-      broker.getSystemUsage().setSendFailIfNoSpace(true);
-      broker.getSystemUsage().getMemoryUsage().setLimit(512 * 1024 * 1024);
-
-      PolicyMap policyMap = new PolicyMap();
-      PolicyEntry policyEntry = new PolicyEntry();
-      policyEntry.setExpireMessagesPeriod(0);
-      policyEntry.setQueuePrefetch(1000);
-      policyEntry.setMemoryLimit(1024 * 1024L);
-      policyEntry.setOptimizedDispatch(false);
-      policyEntry.setProducerFlowControl(false);
-      policyEntry.setEnableAudit(true);
-      policyEntry.setUseCache(true);
-      policyMap.put(new ActiveMQQueue("GW.>"), policyEntry);
-      broker.setDestinationPolicy(policyMap);
-
-      KahaDBPersistenceAdapter kahaDBPersistenceAdapter = (KahaDBPersistenceAdapter) broker.getPersistenceAdapter();
-      kahaDBPersistenceAdapter.setConcurrentStoreAndDispatchQueues(false);
-
-      brokers.put(broker.getBrokerName(), new BrokerItem(broker));
-      return broker;
-   }
-
-   private void addNetworkConnector(BrokerService broker) throws Exception {
-      StringBuilder networkConnectorUrl = new StringBuilder("static:(").append(brokersUrl.toString());
-      networkConnectorUrl.append(')');
-
-      for (int i = 0; i < 2; i++) {
-         NetworkConnector nc = new DiscoveryNetworkConnector(new URI(networkConnectorUrl.toString()));
-         nc.setName("Bridge-" + i);
-         nc.setNetworkTTL(1);
-         nc.setDecreaseNetworkConsumerPriority(true);
-         nc.setDynamicOnly(true);
-         nc.setPrefetchSize(100);
-         nc.setDynamicallyIncludedDestinations(Arrays.asList(new ActiveMQDestination[]{new ActiveMQQueue("GW.*")}));
-         broker.addNetworkConnector(nc);
-      }
-   }
-
-   public void testBrokers() throws Exception {
-
-      buildUrlList();
-
-      for (int i = 0; i < numBrokers; i++) {
-         createBroker(i);
-      }
-
-      startAllBrokers();
-      waitForBridgeFormation(numBrokers - 1);
-
-      verifyPeerBrokerInfos(numBrokers - 1);
-
-      final List<ConsumerState> consumerStates = startAllGWConsumers(numBrokers);
-
-      startAllGWFanoutConsumers(numBrokers);
-
-      LOG.info("Waiting for percolation of consumers..");
-      TimeUnit.SECONDS.sleep(5);
-
-      LOG.info("Produce mesages..");
-      long startTime = System.currentTimeMillis();
-
-      // produce
-      produce(numMessages);
-
-      assertTrue("Got all sent", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            for (ConsumerState tally : consumerStates) {
-               final int expected = numMessages * (tally.destination.isComposite() ? tally.destination.getCompositeDestinations().length : 1);
-               LOG.info("Tally for: " + tally.brokerName + ", dest: " + tally.destination + " - " + tally.accumulator.get());
-               if (tally.accumulator.get() != expected) {
-                  LOG.info("Tally for: " + tally.brokerName + ", dest: " + tally.destination + " - " + tally.accumulator.get() + " != " + expected + ", " + tally.expected);
-                  return false;
-               }
-               LOG.info("got tally on " + tally.brokerName);
-            }
-            return true;
-         }
-      }, 1000 * 60 * 1000L));
-
-      assertTrue("No exceptions:" + exceptions, exceptions.isEmpty());
-
-      LOG.info("done");
-      long duration = System.currentTimeMillis() - startTime;
-      LOG.info("Duration:" + TimeUtils.printDuration(duration));
-   }
-
-   private void startAllGWFanoutConsumers(int nBrokers) throws Exception {
-
-      StringBuffer compositeDest = new StringBuffer();
-      for (int k = 0; k < nBrokers; k++) {
-         compositeDest.append("GW." + k);
-         if (k + 1 != nBrokers) {
-            compositeDest.append(',');
-         }
-      }
-      ActiveMQQueue compositeQ = new ActiveMQQueue(compositeDest.toString());
-
-      for (int id = 0; id < nBrokers; id++) {
-         ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("failover:(tcp://localhost:" + (portBase + id) + ")");
-         connectionFactory.setWatchTopicAdvisories(false);
-
-         QueueConnection queueConnection = connectionFactory.createQueueConnection();
-         queueConnection.start();
-
-         final QueueSession queueSession = queueConnection.createQueueSession(true, Session.SESSION_TRANSACTED);
-
-         final MessageProducer producer = queueSession.createProducer(compositeQ);
-         queueSession.createReceiver(new ActiveMQQueue("IN")).setMessageListener(new MessageListener() {
-            @Override
-            public void onMessage(Message message) {
-               try {
-                  producer.send(message);
-                  queueSession.commit();
-               }
-               catch (Exception e) {
-                  LOG.error("Failed to fanout to GW: " + message, e);
-               }
-
-            }
-         });
-      }
-   }
-
-   private List<ConsumerState> startAllGWConsumers(int nBrokers) throws Exception {
-      List<ConsumerState> consumerStates = new LinkedList<>();
-      for (int id = 0; id < nBrokers; id++) {
-         ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("failover:(tcp://localhost:" + (portBase + id) + ")");
-         connectionFactory.setWatchTopicAdvisories(false);
-
-         QueueConnection queueConnection = connectionFactory.createQueueConnection();
-         queueConnection.start();
-
-         final QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
-
-         ActiveMQQueue destination = new ActiveMQQueue("GW." + id);
-         QueueReceiver queueReceiver = queueSession.createReceiver(destination);
-
-         final ConsumerState consumerState = new ConsumerState();
-         consumerState.brokerName = ((ActiveMQConnection) queueConnection).getBrokerName();
-         consumerState.receiver = queueReceiver;
-         consumerState.destination = destination;
-         for (int j = 0; j < numMessages * (consumerState.destination.isComposite() ? consumerState.destination.getCompositeDestinations().length : 1); j++) {
-            consumerState.expected.add(j);
-         }
-
-         if (!accumulators.containsKey(destination)) {
-            accumulators.put(destination, new AtomicInteger(0));
-         }
-         consumerState.accumulator = accumulators.get(destination);
-
-         queueReceiver.setMessageListener(new MessageListener() {
-            @Override
-            public void onMessage(Message message) {
-               try {
-                  if (consumerSleepTime > 0) {
-                     TimeUnit.MILLISECONDS.sleep(consumerSleepTime);
-                  }
-               }
-               catch (InterruptedException e) {
-                  e.printStackTrace();
-               }
-               try {
-                  consumerState.accumulator.incrementAndGet();
-                  try {
-                     consumerState.expected.remove(((ActiveMQMessage) message).getProperty("NUM"));
-                  }
-                  catch (IOException e) {
-                     e.printStackTrace();
-                  }
-               }
-               catch (Exception e) {
-                  LOG.error("Failed to commit slow receipt of " + message, e);
-               }
-            }
-         });
-
-         consumerStates.add(consumerState);
-
-      }
-      return consumerStates;
-   }
-
-   private void produce(int numMessages) throws Exception {
-      ExecutorService executorService = Executors.newFixedThreadPool(numProducers);
-      final AtomicInteger toSend = new AtomicInteger(numMessages);
-      for (int i = 1; i <= numProducers; i++) {
-         final int id = i % numBrokers;
-         executorService.execute(new Runnable() {
-            @Override
-            public void run() {
-               try {
-                  ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("failover:(tcp://localhost:" + (portBase + id) + ")");
-                  connectionFactory.setWatchTopicAdvisories(false);
-                  QueueConnection queueConnection = connectionFactory.createQueueConnection();
-                  queueConnection.start();
-                  QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
-                  MessageProducer producer = queueSession.createProducer(null);
-                  int val = 0;
-                  while ((val = toSend.decrementAndGet()) >= 0) {
-
-                     ActiveMQQueue compositeQ = new ActiveMQQueue("IN");
-                     LOG.info("Send to: " + ((ActiveMQConnection) queueConnection).getBrokerName() + ", " + val + ", dest:" + compositeQ);
-                     Message textMessage = queueSession.createTextMessage(((ActiveMQConnection) queueConnection).getBrokerName() + "->" + val + " payload:" + payload);
-                     textMessage.setIntProperty("NUM", val);
-                     producer.send(compositeQ, textMessage);
-                  }
-                  queueConnection.close();
-
-               }
-               catch (Throwable throwable) {
-                  throwable.printStackTrace();
-                  exceptions.add(throwable);
-               }
-            }
-         });
-      }
-   }
-
-   private void verifyPeerBrokerInfo(BrokerItem brokerItem, final int max) throws Exception {
-      final BrokerService broker = brokerItem.broker;
-      final RegionBroker regionBroker = (RegionBroker) broker.getRegionBroker();
-      Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            LOG.info("verify infos " + broker.getBrokerName() + ", len: " + regionBroker.getPeerBrokerInfos().length);
-            return max == regionBroker.getPeerBrokerInfos().length;
-         }
-      });
-      LOG.info("verify infos " + broker.getBrokerName() + ", len: " + regionBroker.getPeerBrokerInfos().length);
-      List<String> missing = new ArrayList<>();
-      for (int i = 0; i < max; i++) {
-         missing.add("B" + i);
-      }
-      if (max != regionBroker.getPeerBrokerInfos().length) {
-         for (BrokerInfo info : regionBroker.getPeerBrokerInfos()) {
-            LOG.info(info.getBrokerName());
-            missing.remove(info.getBrokerName());
-         }
-         LOG.info("Broker infos off.." + missing);
-      }
-      assertEquals(broker.getBrokerName(), max, regionBroker.getPeerBrokerInfos().length);
-   }
-
-   private void verifyPeerBrokerInfos(final int max) throws Exception {
-      Collection<BrokerItem> brokerList = brokers.values();
-      for (Iterator<BrokerItem> i = brokerList.iterator(); i.hasNext(); ) {
-         verifyPeerBrokerInfo(i.next(), max);
-      }
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      super.tearDown();
-   }
-
-   class ConsumerState {
-
-      AtomicInteger accumulator;
-      String brokerName;
-      QueueReceiver receiver;
-      ActiveMQDestination destination;
-      Vector<Integer> expected = new Vector<>();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4485Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4485Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4485Test.java
deleted file mode 100644
index 777d582..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4485Test.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/**
- * 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;
-
-import java.util.HashSet;
-import java.util.Set;
-import java.util.Vector;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerPlugin;
-import org.apache.activemq.broker.BrokerPluginSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.ProducerBrokerExchange;
-import org.apache.activemq.broker.TransactionBroker;
-import org.apache.activemq.broker.jmx.DestinationViewMBean;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQBytesMessage;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.Message;
-import org.apache.activemq.command.MessageId;
-import org.apache.activemq.transaction.Synchronization;
-import org.apache.activemq.util.Wait;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ4485Test extends TestCase {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ4485Test.class);
-   BrokerService broker;
-   ActiveMQConnectionFactory factory;
-   final int messageCount = 20;
-   int memoryLimit = 40 * 1024;
-   final ActiveMQQueue destination = new ActiveMQQueue("QUEUE." + this.getClass().getName());
-   final Vector<Throwable> exceptions = new Vector<>();
-   final CountDownLatch slowSendResume = new CountDownLatch(1);
-
-   protected void configureBroker(long memoryLimit) throws Exception {
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.setAdvisorySupport(false);
-
-      PolicyEntry policy = new PolicyEntry();
-      policy.setExpireMessagesPeriod(0);
-      policy.setMemoryLimit(memoryLimit);
-      policy.setProducerFlowControl(false);
-      PolicyMap pMap = new PolicyMap();
-      pMap.setDefaultEntry(policy);
-      broker.setDestinationPolicy(pMap);
-
-      broker.setPlugins(new BrokerPlugin[]{new BrokerPluginSupport() {
-         @Override
-         public void send(ProducerBrokerExchange producerExchange, final Message messageSend) throws Exception {
-            if (messageSend.isInTransaction() && messageSend.getProperty("NUM") != null) {
-               final Integer num = (Integer) messageSend.getProperty("NUM");
-               if (true) {
-                  TransactionBroker transactionBroker = (TransactionBroker) broker.getBroker().getAdaptor(TransactionBroker.class);
-                  transactionBroker.getTransaction(producerExchange.getConnectionContext(), messageSend.getTransactionId(), false).addSynchronization(new Synchronization() {
-                                                                                                                                                         @Override
-                                                                                                                                                         public void afterCommit() throws Exception {
-                                                                                                                                                            LOG.error("AfterCommit, NUM:" + num + ", " + messageSend.getMessageId() + ", tx: " + messageSend.getTransactionId());
-                                                                                                                                                            if (num == 5) {
-                                                                                                                                                               // we want to add to cursor after usage is exhausted by message 20 and when
-                                                                                                                                                               // all other messages have been processed
-                                                                                                                                                               LOG.error("Pausing on latch in afterCommit for: " + num + ", " + messageSend.getMessageId());
-                                                                                                                                                               slowSendResume.await(20, TimeUnit.SECONDS);
-                                                                                                                                                               LOG.error("resuming on latch afterCommit for: " + num + ", " + messageSend.getMessageId());
-                                                                                                                                                            }
-                                                                                                                                                            else if (messageCount + 1 == num) {
-                                                                                                                                                               LOG.error("releasing latch. " + num + ", " + messageSend.getMessageId());
-                                                                                                                                                               slowSendResume.countDown();
-                                                                                                                                                               // for message X, we need to delay so message 5 can setBatch
-                                                                                                                                                               TimeUnit.SECONDS.sleep(5);
-                                                                                                                                                               LOG.error("resuming afterCommit for: " + num + ", " + messageSend.getMessageId());
-                                                                                                                                                            }
-                                                                                                                                                         }
-                                                                                                                                                      });
-               }
-            }
-            super.send(producerExchange, messageSend);
-         }
-      }});
-
-   }
-
-   public void testOutOfOrderTransactionCompletionOnMemoryLimit() throws Exception {
-
-      Set<Integer> expected = new HashSet<>();
-      final Vector<Session> sessionVector = new Vector<>();
-      ExecutorService executorService = Executors.newCachedThreadPool();
-      for (int i = 1; i <= messageCount; i++) {
-         sessionVector.add(send(i, 1, true));
-         expected.add(i);
-      }
-
-      // get parallel commit so that the sync writes are batched
-      for (int i = 0; i < messageCount; i++) {
-         final int id = i;
-         executorService.submit(new Runnable() {
-            @Override
-            public void run() {
-               try {
-                  sessionVector.get(id).commit();
-               }
-               catch (Exception fail) {
-                  exceptions.add(fail);
-               }
-            }
-         });
-      }
-
-      final DestinationViewMBean queueViewMBean = (DestinationViewMBean) broker.getManagementContext().newProxyInstance(broker.getAdminView().getQueues()[0], DestinationViewMBean.class, false);
-
-      // not sure how many messages will get enqueued
-      TimeUnit.SECONDS.sleep(3);
-      if (false)
-         assertTrue("all " + messageCount + " on the q", Wait.waitFor(new Wait.Condition() {
-            @Override
-            public boolean isSatisified() throws Exception {
-               LOG.info("enqueueCount: " + queueViewMBean.getEnqueueCount());
-               return messageCount == queueViewMBean.getEnqueueCount();
-            }
-         }));
-
-      LOG.info("Big send to blow available destination usage before slow send resumes");
-      send(messageCount + 1, 35 * 1024, true).commit();
-
-      // consume and verify all received
-      Connection cosumerConnection = factory.createConnection();
-      cosumerConnection.start();
-      MessageConsumer consumer = cosumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE).createConsumer(destination);
-      for (int i = 1; i <= messageCount + 1; i++) {
-         BytesMessage bytesMessage = (BytesMessage) consumer.receive(10000);
-         assertNotNull("Got message: " + i + ", " + expected, bytesMessage);
-         MessageId mqMessageId = ((ActiveMQBytesMessage) bytesMessage).getMessageId();
-         LOG.info("got: " + expected + ", " + mqMessageId + ", NUM=" + ((ActiveMQBytesMessage) bytesMessage).getProperty("NUM"));
-         expected.remove(((ActiveMQBytesMessage) bytesMessage).getProperty("NUM"));
-      }
-   }
-
-   private Session send(int id, int messageSize, boolean transacted) throws Exception {
-      Connection connection = factory.createConnection();
-      connection.start();
-      Session session = connection.createSession(transacted, transacted ? Session.SESSION_TRANSACTED : Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = session.createProducer(destination);
-      BytesMessage bytesMessage = session.createBytesMessage();
-      bytesMessage.writeBytes(new byte[messageSize]);
-      bytesMessage.setIntProperty("NUM", id);
-      producer.send(bytesMessage);
-      LOG.info("Sent:" + bytesMessage.getJMSMessageID() + " session tx: " + ((ActiveMQBytesMessage) bytesMessage).getTransactionId());
-      return session;
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      super.setUp();
-      broker = new BrokerService();
-      broker.setBrokerName("thisOne");
-      configureBroker(memoryLimit);
-      broker.start();
-      factory = new ActiveMQConnectionFactory("vm://thisOne?jms.alwaysSyncSend=true");
-      factory.setWatchTopicAdvisories(false);
-
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      super.tearDown();
-      if (broker != null) {
-         broker.stop();
-         broker = null;
-      }
-   }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4487Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4487Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4487Test.java
deleted file mode 100644
index 7d3ee41..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4487Test.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.Enumeration;
-
-import javax.jms.Connection;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.QueueBrowser;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ4487Test {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ4487Test.class);
-
-   private final String destinationName = "TEST.QUEUE";
-   private BrokerService broker;
-   private ActiveMQConnectionFactory factory;
-
-   @Before
-   public void startBroker() throws Exception {
-      broker = new BrokerService();
-      broker.deleteAllMessages();
-      broker.setUseJmx(false);
-      broker.setAdvisorySupport(false);
-
-      PolicyEntry policy = new PolicyEntry();
-      policy.setQueue(">");
-      policy.setMaxProducersToAudit(75);
-      PolicyMap pMap = new PolicyMap();
-      pMap.setDefaultEntry(policy);
-      broker.setDestinationPolicy(pMap);
-
-      broker.start();
-      broker.waitUntilStarted();
-      factory = new ActiveMQConnectionFactory("vm://localhost");
-   }
-
-   @After
-   public void stopBroker() throws Exception {
-      broker.stop();
-      broker.waitUntilStopped();
-   }
-
-   private void sendMessages(int messageToSend) throws Exception {
-      String data = "";
-      for (int i = 0; i < 1024 * 2; i++) {
-         data += "x";
-      }
-
-      Connection connection = factory.createConnection();
-      connection.start();
-
-      for (int i = 0; i < messageToSend; i++) {
-         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         Queue queue = session.createQueue(destinationName);
-         MessageProducer producer = session.createProducer(queue);
-         producer.send(session.createTextMessage(data));
-         session.close();
-      }
-
-      connection.close();
-   }
-
-   @Test
-   public void testBrowsingWithLessThanMaxAuditDepth() throws Exception {
-      doTestBrowsing(75);
-   }
-
-   @Test
-   public void testBrowsingWithMoreThanMaxAuditDepth() throws Exception {
-      doTestBrowsing(300);
-   }
-
-   @SuppressWarnings("rawtypes")
-   private void doTestBrowsing(int messagesToSend) throws Exception {
-
-      Connection connection = factory.createConnection();
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Queue queue = session.createQueue(destinationName);
-
-      sendMessages(messagesToSend);
-
-      QueueBrowser browser = session.createBrowser(queue);
-      Enumeration enumeration = browser.getEnumeration();
-      int received = 0;
-      while (enumeration.hasMoreElements()) {
-         Message m = (Message) enumeration.nextElement();
-         assertNotNull(m);
-
-         if (LOG.isDebugEnabled()) {
-            LOG.debug("Browsed Message: {}", m.getJMSMessageID());
-         }
-
-         received++;
-         if (received > messagesToSend) {
-            break;
-         }
-      }
-
-      browser.close();
-
-      assertEquals(messagesToSend, received);
-   }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4504Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4504Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4504Test.java
deleted file mode 100644
index a89aca2..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4504Test.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * 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;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTextMessage;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertNotNull;
-
-public class AMQ4504Test {
-
-   BrokerService brokerService;
-
-   @Before
-   public void setup() throws Exception {
-      brokerService = new BrokerService();
-      brokerService.setPersistent(false);
-      brokerService.start();
-   }
-
-   @After
-   public void stop() throws Exception {
-      brokerService.stop();
-   }
-
-   @Test
-   public void testCompositeDestConsumer() throws Exception {
-
-      final int numDests = 20;
-      final int numMessages = 200;
-      StringBuffer stringBuffer = new StringBuffer();
-      for (int i = 0; i < numDests; i++) {
-         if (stringBuffer.length() != 0) {
-            stringBuffer.append(',');
-         }
-         stringBuffer.append("ST." + i);
-      }
-      stringBuffer.append("?consumer.prefetchSize=100");
-      ActiveMQQueue activeMQQueue = new ActiveMQQueue(stringBuffer.toString());
-      ConnectionFactory factory = new ActiveMQConnectionFactory(brokerService.getVmConnectorURI());
-      Connection connection = factory.createConnection();
-      connection.start();
-      MessageProducer producer = connection.createSession(false, Session.AUTO_ACKNOWLEDGE).createProducer(activeMQQueue);
-      for (int i = 0; i < numMessages; i++) {
-         producer.send(new ActiveMQTextMessage());
-      }
-
-      MessageConsumer consumer = connection.createSession(false, Session.AUTO_ACKNOWLEDGE).createConsumer(activeMQQueue);
-      try {
-         for (int i = 0; i < numMessages * numDests; i++) {
-            assertNotNull("received:" + i, consumer.receive(4000));
-         }
-      }
-      finally {
-         connection.close();
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4513Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4513Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4513Test.java
deleted file mode 100644
index ceac82f..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4513Test.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.Random;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.DeadLetterStrategy;
-import org.apache.activemq.broker.region.policy.IndividualDeadLetterStrategy;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AMQ4513Test {
-
-   private BrokerService brokerService;
-   private String connectionUri;
-
-   @Before
-   public void setup() throws Exception {
-      brokerService = new BrokerService();
-
-      connectionUri = brokerService.addConnector("tcp://localhost:0").getPublishableConnectString();
-
-      // Configure Dead Letter Strategy
-      DeadLetterStrategy strategy = new IndividualDeadLetterStrategy();
-      ((IndividualDeadLetterStrategy) strategy).setUseQueueForQueueMessages(true);
-      ((IndividualDeadLetterStrategy) strategy).setQueuePrefix("DLQ.");
-      strategy.setProcessNonPersistent(false);
-      strategy.setProcessExpired(false);
-
-      // Add policy and individual DLQ strategy
-      PolicyEntry policy = new PolicyEntry();
-      policy.setTimeBeforeDispatchStarts(3000);
-      policy.setDeadLetterStrategy(strategy);
-
-      PolicyMap pMap = new PolicyMap();
-      pMap.setDefaultEntry(policy);
-
-      brokerService.setDestinationPolicy(pMap);
-
-      brokerService.setPersistent(false);
-      brokerService.start();
-   }
-
-   @After
-   public void stop() throws Exception {
-      brokerService.stop();
-   }
-
-   @Test(timeout = 360000)
-   public void test() throws Exception {
-
-      final ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(connectionUri);
-
-      ExecutorService service = Executors.newFixedThreadPool(25);
-
-      final Random ripple = new Random(System.currentTimeMillis());
-
-      for (int i = 0; i < 1000; ++i) {
-         service.execute(new Runnable() {
-            @Override
-            public void run() {
-               try {
-                  ActiveMQConnection connection = (ActiveMQConnection) cf.createConnection();
-                  Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-                  Destination destination = session.createTemporaryQueue();
-                  session.createProducer(destination);
-                  connection.close();
-                  TimeUnit.MILLISECONDS.sleep(ripple.nextInt(20));
-               }
-               catch (Exception e) {
-               }
-            }
-         });
-
-         service.execute(new Runnable() {
-            @Override
-            public void run() {
-               try {
-                  ActiveMQConnection connection = (ActiveMQConnection) cf.createConnection();
-                  Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-                  Destination destination = session.createTemporaryQueue();
-                  MessageProducer producer = session.createProducer(destination);
-                  producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-                  producer.setTimeToLive(400);
-                  producer.send(session.createTextMessage());
-                  producer.send(session.createTextMessage());
-                  TimeUnit.MILLISECONDS.sleep(500);
-                  connection.close();
-               }
-               catch (Exception e) {
-               }
-            }
-         });
-
-         service.execute(new Runnable() {
-            @Override
-            public void run() {
-               try {
-                  ActiveMQConnection connection = (ActiveMQConnection) cf.createConnection();
-                  Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-                  Destination destination = session.createTemporaryQueue();
-                  session.createProducer(destination);
-                  connection.close();
-                  TimeUnit.MILLISECONDS.sleep(ripple.nextInt(20));
-               }
-               catch (Exception e) {
-               }
-            }
-         });
-      }
-
-      service.shutdown();
-      assertTrue(service.awaitTermination(5, TimeUnit.MINUTES));
-   }
-}


[57/60] [abbrv] activemq-artemis git commit: more refactorings on producers

Posted by cl...@apache.org.
more refactorings on producers


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/dfb047b6
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/dfb047b6
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/dfb047b6

Branch: refs/heads/refactor-openwire
Commit: dfb047b62dcb58de6466fb29da5444e0ba140de1
Parents: e7f743b
Author: Clebert Suconic <cl...@apache.org>
Authored: Thu Feb 25 18:10:18 2016 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:45:29 2016 -0400

----------------------------------------------------------------------
 .../protocol/openwire/OpenWireConnection.java   | 190 +++++++++----------
 .../core/protocol/openwire/OpenWireUtil.java    |  23 +--
 .../artemis/core/server/ActiveMQServer.java     |   4 +
 .../core/server/impl/ActiveMQServerImpl.java    |  71 +++++++
 .../core/server/impl/ServerSessionImpl.java     |  56 +-----
 .../InvestigationOpenwireTest.java              |  17 +-
 6 files changed, 181 insertions(+), 180 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dfb047b6/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
index dc2a8a6..6839259 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
@@ -51,7 +51,9 @@ import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQSingleConsumerB
 import org.apache.activemq.artemis.core.remoting.FailureListener;
 import org.apache.activemq.artemis.core.security.CheckType;
 import org.apache.activemq.artemis.core.security.SecurityAuth;
+import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
+import org.apache.activemq.artemis.core.server.BindingQueryResult;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.ServerConsumer;
 import org.apache.activemq.artemis.core.server.SlowConsumerDetectionListener;
@@ -146,6 +148,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
 
    private String defaultSocketURIString;
 
+   // TODO-NOW: check on why there are two connections created for every createConnection on the client.
    public OpenWireConnection(Connection connection,
                              Executor executor,
                              OpenWireProtocolManager openWireProtocolManager,
@@ -267,13 +270,25 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
 
          }
       }
-      catch (IOException e) {
+      catch (Exception e) {
+         ActiveMQServerLogger.LOGGER.debug(e);
 
-         // TODO-NOW: send errors
-         ActiveMQServerLogger.LOGGER.error("error decoding", e);
-      }
-      catch (Throwable t) {
-         ActiveMQServerLogger.LOGGER.error("error decoding", t);
+         Response resp;
+         if (e instanceof ActiveMQSecurityException) {
+            resp = new ExceptionResponse(new JMSSecurityException(e.getMessage()));
+         }
+         else if (e instanceof ActiveMQNonExistentQueueException) {
+            resp = new ExceptionResponse(new InvalidDestinationException(e.getMessage()));
+         }
+         else {
+            resp = new ExceptionResponse(e);
+         }
+         try {
+            dispatch(resp);
+         }
+         catch (IOException e2) {
+            ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e2);
+         }
       }
    }
 
@@ -861,6 +876,22 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
       }
    }
 
+   /**
+    * Checks to see if this destination exists.  If it does not throw an invalid destination exception.
+    *
+    * @param destination
+    */
+   private void validateDestination(ActiveMQDestination destination) throws Exception {
+      if (destination.isQueue()) {
+         SimpleString physicalName = OpenWireUtil.toCoreAddress(destination);
+         BindingQueryResult result = protocolManager.getServer().bindingQuery(physicalName);
+         if (!result.isExists() && !result.isAutoCreateJmsQueues()) {
+            throw ActiveMQMessageBundle.BUNDLE.noSuchQueue(physicalName);
+         }
+      }
+   }
+
+
    // This will listen for commands throught the protocolmanager
    public class CommandProcessor implements CommandVisitor {
 
@@ -892,69 +923,40 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
 
       @Override
       public Response processAddProducer(ProducerInfo info) throws Exception {
-         Response resp = null;
-         try {
-            SessionId sessionId = info.getProducerId().getParentId();
-            ConnectionId connectionId = sessionId.getParentId();
-            ConnectionState cs = getState();
-            if (cs == null) {
-               throw new IllegalStateException("Cannot add a producer to a connection that had not been registered: " + connectionId);
-            }
-            SessionState ss = cs.getSessionState(sessionId);
-            if (ss == null) {
-               throw new IllegalStateException("Cannot add a producer to a session that had not been registered: " + sessionId);
-            }
-            // Avoid replaying dup commands
-            if (!ss.getProducerIds().contains(info.getProducerId())) {
+         SessionId sessionId = info.getProducerId().getParentId();
+         ConnectionState cs = getState();
 
-               AMQSession amqSession = sessions.get(sessionId);
-               if (amqSession == null) {
-                  throw new IllegalStateException("Session not exist! : " + sessionId);
-               }
+         if (cs == null) {
+            throw new IllegalStateException("Cannot add a producer to a connection that had not been registered: " + sessionId.getParentId());
+         }
 
-               ActiveMQDestination destination = info.getDestination();
-               if (destination != null && !AdvisorySupport.isAdvisoryTopic(destination)) {
-                  if (destination.isQueue()) {
-                     OpenWireUtil.validateDestination(destination, amqSession);
-                  }
-                  DestinationInfo destInfo = new DestinationInfo(getContext().getConnectionId(), DestinationInfo.ADD_OPERATION_TYPE, destination);
-                  OpenWireConnection.this.addDestination(destInfo);
-               }
+         SessionState ss = cs.getSessionState(sessionId);
+         if (ss == null) {
+            throw new IllegalStateException("Cannot add a producer to a session that had not been registered: " + sessionId);
+         }
 
-               ss.addProducer(info);
+         // Avoid replaying dup commands
+         if (!ss.getProducerIds().contains(info.getProducerId())) {
+            ActiveMQDestination destination = info.getDestination();
 
+            if (destination != null && !AdvisorySupport.isAdvisoryTopic(destination)) {
+               if (destination.isQueue()) {
+                  OpenWireConnection.this.validateDestination(destination);
+               }
+               DestinationInfo destInfo = new DestinationInfo(getContext().getConnectionId(), DestinationInfo.ADD_OPERATION_TYPE, destination);
+               OpenWireConnection.this.addDestination(destInfo);
             }
+
+            ss.addProducer(info);
+
          }
-         catch (Exception e) {
-            if (e instanceof ActiveMQSecurityException) {
-               resp = new ExceptionResponse(new JMSSecurityException(e.getMessage()));
-            }
-            else if (e instanceof ActiveMQNonExistentQueueException) {
-               resp = new ExceptionResponse(new InvalidDestinationException(e.getMessage()));
-            }
-            else {
-               resp = new ExceptionResponse(e);
-            }
-         }
-         return resp;
+         return null;
       }
 
       @Override
-      public Response processAddConsumer(ConsumerInfo info) {
-         Response resp = null;
-         try {
-            addConsumer(info);
-         }
-         catch (Exception e) {
-            e.printStackTrace();
-            if (e instanceof ActiveMQSecurityException) {
-               resp = new ExceptionResponse(new JMSSecurityException(e.getMessage()));
-            }
-            else {
-               resp = new ExceptionResponse(e);
-            }
-         }
-         return resp;
+      public Response processAddConsumer(ConsumerInfo info) throws Exception {
+         addConsumer(info);
+         return null;
       }
 
       @Override
@@ -1146,50 +1148,40 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
       }
 
       @Override
-      public Response processMessage(Message messageSend) {
-         Response resp = null;
-         try {
-            ProducerId producerId = messageSend.getProducerId();
-            AMQProducerBrokerExchange producerExchange = getProducerBrokerExchange(producerId);
-            final AMQConnectionContext pcontext = producerExchange.getConnectionContext();
-            final ProducerInfo producerInfo = producerExchange.getProducerState().getInfo();
-            boolean sendProducerAck = !messageSend.isResponseRequired() && producerInfo.getWindowSize() > 0 && !pcontext.isInRecoveryMode();
-
-            AMQSession session = getSession(producerId.getParentId());
-
-            SendingResult result = session.send(producerExchange, messageSend, sendProducerAck);
-            if (result.isBlockNextSend()) {
-               if (!context.isNetworkConnection() && result.isSendFailIfNoSpace()) {
-                  // TODO see logging
-                  throw new ResourceAllocationException("Usage Manager Memory Limit reached. Stopping producer (" + producerId + ") to prevent flooding " + result.getBlockingAddress() + "." + " See http://activemq.apache.org/producer-flow-control.html for more info");
-               }
-
-               if (producerInfo.getWindowSize() > 0 || messageSend.isResponseRequired()) {
-                  //in that case don't send the response
-                  //this will force the client to wait until
-                  //the response is got.
-                  context.setDontSendReponse(true);
-               }
-               else {
-                  //hang the connection until the space is available
-                  session.blockingWaitForSpace(producerExchange, result);
-               }
+      public Response processMessage(Message messageSend) throws Exception {
+         ProducerId producerId = messageSend.getProducerId();
+         AMQProducerBrokerExchange producerExchange = getProducerBrokerExchange(producerId);
+         final AMQConnectionContext pcontext = producerExchange.getConnectionContext();
+         final ProducerInfo producerInfo = producerExchange.getProducerState().getInfo();
+         boolean sendProducerAck = !messageSend.isResponseRequired() && producerInfo.getWindowSize() > 0 && !pcontext.isInRecoveryMode();
+
+         AMQSession session = getSession(producerId.getParentId());
+
+         SendingResult result = session.send(producerExchange, messageSend, sendProducerAck);
+         if (result.isBlockNextSend()) {
+            if (!context.isNetworkConnection() && result.isSendFailIfNoSpace()) {
+               // TODO see logging
+               throw new ResourceAllocationException("Usage Manager Memory Limit reached. Stopping producer (" + producerId + ") to prevent flooding " + result.getBlockingAddress() + "." + " See http://activemq.apache.org/producer-flow-control.html for more info");
             }
-            else if (sendProducerAck) {
-               // TODO-now: send through OperationContext
-               ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), messageSend.getSize());
-               OpenWireConnection.this.dispatchAsync(ack);
-            }
-         }
-         catch (Throwable e) {
-            if (e instanceof ActiveMQSecurityException) {
-               resp = new ExceptionResponse(new JMSSecurityException(e.getMessage()));
+
+            if (producerInfo.getWindowSize() > 0 || messageSend.isResponseRequired()) {
+               //in that case don't send the response
+               //this will force the client to wait until
+               //the response is got.
+               context.setDontSendReponse(true);
             }
             else {
-               resp = new ExceptionResponse(e);
+               //hang the connection until the space is available
+               session.blockingWaitForSpace(producerExchange, result);
             }
          }
-         return resp;
+         else if (sendProducerAck) {
+            // TODO-now: send through OperationContext
+            ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), messageSend.getSize());
+            OpenWireConnection.this.dispatchAsync(ack);
+         }
+
+         return null;
       }
 
       @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dfb047b6/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireUtil.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireUtil.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireUtil.java
index d684761..4513eb3 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireUtil.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireUtil.java
@@ -18,16 +18,12 @@ package org.apache.activemq.artemis.core.protocol.openwire;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
+import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQServerSession;
-import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQSession;
-import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
-import org.apache.activemq.artemis.core.server.BindingQueryResult;
 import org.apache.activemq.command.ActiveMQQueue;
 import org.apache.activemq.command.ActiveMQTopic;
 import org.apache.activemq.util.ByteSequence;
-import org.apache.activemq.artemis.api.core.SimpleString;
 
 public class OpenWireUtil {
 
@@ -64,23 +60,6 @@ public class OpenWireUtil {
       }
    }
 
-   /**
-    * Checks to see if this destination exists.  If it does not throw an invalid destination exception.
-    *
-    * @param destination
-    * @param amqSession
-    */
-   public static void validateDestination(ActiveMQDestination destination, AMQSession amqSession) throws Exception {
-      if (destination.isQueue()) {
-         AMQServerSession coreSession = amqSession.getCoreSession();
-         SimpleString physicalName = OpenWireUtil.toCoreAddress(destination);
-         BindingQueryResult result = coreSession.executeBindingQuery(physicalName);
-         if (!result.isExists() && !result.isAutoCreateJmsQueues()) {
-            throw ActiveMQMessageBundle.BUNDLE.noSuchQueue(physicalName);
-         }
-      }
-   }
-
    /*
     *This util converts amq wildcards to compatible core wildcards
     *The conversion is like this:

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dfb047b6/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java
index e3c1b2a..64633bb 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java
@@ -243,6 +243,10 @@ public interface ActiveMQServer extends ActiveMQComponent {
 
    Queue locateQueue(SimpleString queueName);
 
+   BindingQueryResult bindingQuery(SimpleString address) throws Exception;
+
+   QueueQueryResult queueQuery(SimpleString name) throws Exception;
+
    void destroyQueue(SimpleString queueName) throws Exception;
 
    void destroyQueue(SimpleString queueName, SecurityAuth session) throws Exception;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dfb047b6/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
index 7554127..13a1283 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
@@ -45,6 +45,7 @@ import java.util.concurrent.TimeUnit;
 import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
 import org.apache.activemq.artemis.api.core.Pair;
 import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.api.core.management.ResourceNames;
 import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl;
 import org.apache.activemq.artemis.core.config.BridgeConfiguration;
 import org.apache.activemq.artemis.core.config.Configuration;
@@ -76,6 +77,8 @@ import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageM
 import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl;
 import org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager;
 import org.apache.activemq.artemis.core.postoffice.Binding;
+import org.apache.activemq.artemis.core.postoffice.BindingType;
+import org.apache.activemq.artemis.core.postoffice.Bindings;
 import org.apache.activemq.artemis.core.postoffice.PostOffice;
 import org.apache.activemq.artemis.core.postoffice.QueueBinding;
 import org.apache.activemq.artemis.core.postoffice.impl.DivertBinding;
@@ -97,6 +100,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.Bindable;
+import org.apache.activemq.artemis.core.server.BindingQueryResult;
 import org.apache.activemq.artemis.core.server.Divert;
 import org.apache.activemq.artemis.core.server.JournalType;
 import org.apache.activemq.artemis.core.server.LargeServerMessage;
@@ -105,6 +109,7 @@ import org.apache.activemq.artemis.core.server.NodeManager;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.core.server.QueueCreator;
 import org.apache.activemq.artemis.core.server.QueueFactory;
+import org.apache.activemq.artemis.core.server.QueueQueryResult;
 import org.apache.activemq.artemis.core.server.SecuritySettingPlugin;
 import org.apache.activemq.artemis.core.server.ServerSession;
 import org.apache.activemq.artemis.core.server.ServerSessionFactory;
@@ -545,6 +550,72 @@ public class ActiveMQServerImpl implements ActiveMQServer {
    }
 
    @Override
+   public BindingQueryResult bindingQuery(SimpleString address) throws Exception {
+      if (address == null) {
+         throw ActiveMQMessageBundle.BUNDLE.addressIsNull();
+      }
+
+      boolean autoCreateJmsQueues = address.toString().startsWith(ResourceNames.JMS_QUEUE) && getAddressSettingsRepository().getMatch(address.toString()).isAutoCreateJmsQueues();
+
+      List<SimpleString> names = new ArrayList<>();
+
+      // make an exception for the management address (see HORNETQ-29)
+      ManagementService managementService = getManagementService();
+      if (managementService != null) {
+         if (address.equals(managementService.getManagementAddress())) {
+            return new BindingQueryResult(true, names, autoCreateJmsQueues);
+         }
+      }
+
+      Bindings bindings = getPostOffice().getMatchingBindings(address);
+
+      for (Binding binding : bindings.getBindings()) {
+         if (binding.getType() == BindingType.LOCAL_QUEUE || binding.getType() == BindingType.REMOTE_QUEUE) {
+            names.add(binding.getUniqueName());
+         }
+      }
+
+      return new BindingQueryResult(!names.isEmpty(), names, autoCreateJmsQueues);
+   }
+
+   @Override
+   public QueueQueryResult queueQuery(SimpleString name) {
+      if (name == null) {
+         throw ActiveMQMessageBundle.BUNDLE.queueNameIsNull();
+      }
+
+      boolean autoCreateJmsQueues = name.toString().startsWith(ResourceNames.JMS_QUEUE) && getAddressSettingsRepository().getMatch(name.toString()).isAutoCreateJmsQueues();
+
+      QueueQueryResult response;
+
+      Binding binding = getPostOffice().getBinding(name);
+
+      SimpleString managementAddress = getManagementService() != null ? getManagementService().getManagementAddress() : null;
+
+      if (binding != null && binding.getType() == BindingType.LOCAL_QUEUE) {
+         Queue queue = (Queue) binding.getBindable();
+
+         Filter filter = queue.getFilter();
+
+         SimpleString filterString = filter == null ? null : filter.getFilterString();
+
+         response = new QueueQueryResult(name, binding.getAddress(), queue.isDurable(), queue.isTemporary(), filterString, queue.getConsumerCount(), queue.getMessageCount(), autoCreateJmsQueues);
+      }
+      // make an exception for the management address (see HORNETQ-29)
+      else if (name.equals(managementAddress)) {
+         response = new QueueQueryResult(name, managementAddress, true, false, null, -1, -1, autoCreateJmsQueues);
+      }
+      else if (autoCreateJmsQueues) {
+         response = new QueueQueryResult(name, name, true, false, null, 0, 0, true, false);
+      }
+      else {
+         response = new QueueQueryResult(null, null, false, false, null, 0, 0, false, false);
+      }
+
+      return response;
+   }
+
+   @Override
    public void threadDump() {
       StringWriter str = new StringWriter();
       PrintWriter out = new PrintWriter(str);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dfb047b6/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
index d628bde..77705fa 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
@@ -50,7 +50,6 @@ import org.apache.activemq.artemis.core.persistence.OperationContext;
 import org.apache.activemq.artemis.core.persistence.StorageManager;
 import org.apache.activemq.artemis.core.postoffice.Binding;
 import org.apache.activemq.artemis.core.postoffice.BindingType;
-import org.apache.activemq.artemis.core.postoffice.Bindings;
 import org.apache.activemq.artemis.core.postoffice.PostOffice;
 import org.apache.activemq.artemis.core.postoffice.QueueBinding;
 import org.apache.activemq.artemis.core.remoting.CloseListener;
@@ -623,63 +622,12 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
 
    @Override
    public QueueQueryResult executeQueueQuery(final SimpleString name) throws Exception {
-      if (name == null) {
-         throw ActiveMQMessageBundle.BUNDLE.queueNameIsNull();
-      }
-
-      boolean autoCreateJmsQueues = name.toString().startsWith(ResourceNames.JMS_QUEUE) && server.getAddressSettingsRepository().getMatch(name.toString()).isAutoCreateJmsQueues();
-
-      QueueQueryResult response;
-
-      Binding binding = postOffice.getBinding(name);
-
-      if (binding != null && binding.getType() == BindingType.LOCAL_QUEUE) {
-         Queue queue = (Queue) binding.getBindable();
-
-         Filter filter = queue.getFilter();
-
-         SimpleString filterString = filter == null ? null : filter.getFilterString();
-
-         response = new QueueQueryResult(name, binding.getAddress(), queue.isDurable(), queue.isTemporary(), filterString, queue.getConsumerCount(), queue.getMessageCount(), autoCreateJmsQueues);
-      }
-      // make an exception for the management address (see HORNETQ-29)
-      else if (name.equals(managementAddress)) {
-         response = new QueueQueryResult(name, managementAddress, true, false, null, -1, -1, autoCreateJmsQueues);
-      }
-      else if (autoCreateJmsQueues) {
-         response = new QueueQueryResult(name, name, true, false, null, 0, 0, true, false);
-      }
-      else {
-         response = new QueueQueryResult(null, null, false, false, null, 0, 0, false, false);
-      }
-
-      return response;
+      return server.queueQuery(name);
    }
 
    @Override
    public BindingQueryResult executeBindingQuery(final SimpleString address) throws Exception {
-      if (address == null) {
-         throw ActiveMQMessageBundle.BUNDLE.addressIsNull();
-      }
-
-      boolean autoCreateJmsQueues = address.toString().startsWith(ResourceNames.JMS_QUEUE) && server.getAddressSettingsRepository().getMatch(address.toString()).isAutoCreateJmsQueues();
-
-      List<SimpleString> names = new ArrayList<>();
-
-      // make an exception for the management address (see HORNETQ-29)
-      if (address.equals(managementAddress)) {
-         return new BindingQueryResult(true, names, autoCreateJmsQueues);
-      }
-
-      Bindings bindings = postOffice.getMatchingBindings(address);
-
-      for (Binding binding : bindings.getBindings()) {
-         if (binding.getType() == BindingType.LOCAL_QUEUE || binding.getType() == BindingType.REMOTE_QUEUE) {
-            names.add(binding.getUniqueName());
-         }
-      }
-
-      return new BindingQueryResult(!names.isEmpty(), names, autoCreateJmsQueues);
+      return server.bindingQuery(address);
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dfb047b6/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/investigations/InvestigationOpenwireTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/investigations/InvestigationOpenwireTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/investigations/InvestigationOpenwireTest.java
index 3614b9a..914a8e1 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/investigations/InvestigationOpenwireTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/investigations/InvestigationOpenwireTest.java
@@ -17,15 +17,22 @@
 
 package org.apache.activemq.artemis.tests.integration.openwire.investigations;
 
-import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest;
-import org.junit.Assert;
-import org.junit.Test;
-
-import javax.jms.*;
+import javax.jms.Connection;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.jms.XAConnection;
+import javax.jms.XASession;
 import javax.transaction.xa.XAResource;
 import java.util.Collection;
 import java.util.LinkedList;
 
+import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest;
+import org.junit.Assert;
+import org.junit.Test;
+
 public class InvestigationOpenwireTest extends BasicOpenWireTest {
 
    @Test


[42/60] [abbrv] activemq-artemis git commit: included more tests fixed some test issues

Posted by cl...@apache.org.
included more tests
fixed some test issues


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/eb1cdf8d
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/eb1cdf8d
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/eb1cdf8d

Branch: refs/heads/refactor-openwire
Commit: eb1cdf8d8eabecbd8959bed2ad24bee1ddd00ee2
Parents: 77345c7
Author: Howard Gao <ho...@gmail.com>
Authored: Wed Feb 3 22:47:21 2016 +0800
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:44:21 2016 -0400

----------------------------------------------------------------------
 tests/activemq5-unit-tests/pom.xml                              | 5 +++--
 .../org/apache/activemq/transport/tcp/TcpTransportFactory.java  | 4 ++++
 .../java/org/apache/activemq/EmbeddedBrokerTestSupport.java     | 4 +++-
 .../test/java/org/apache/activemq/ExclusiveConsumerTest.java    | 1 +
 .../java/org/apache/activemq/ReconnectWithSameClientIDTest.java | 2 +-
 .../test/java/org/apache/activemq/TransactionContextTest.java   | 4 +++-
 .../java/org/apache/activemq/test/JmsTopicSendReceiveTest.java  | 2 ++
 .../org/apache/activemq/transport/tcp/TransportUriTest.java     | 1 +
 8 files changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/eb1cdf8d/tests/activemq5-unit-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/pom.xml b/tests/activemq5-unit-tests/pom.xml
index 0f7c9ac..2782627 100644
--- a/tests/activemq5-unit-tests/pom.xml
+++ b/tests/activemq5-unit-tests/pom.xml
@@ -416,11 +416,13 @@
             <configuration>
                <skipTests>${skipActiveMQ5Tests}</skipTests>
                <includes>
-                  <!-- include this first three packages -->
+                  <!-- included packages -->
                   <include>**/org/apache/activemq/*Test.java</include>
                   <include>**/org/apache/activemq/command/*Test.java</include>
                   <include>**/org/apache/activemq/openwire/*Test.java</include>
                   <include>**/org/apache/activemq/transport/tcp/*Test.java</include>
+                  <include>**/org/apache/activemq/transport/failover/*Test.java</include>
+                  <include>**/org/apache/activemq/transport/*Test.java</include>
                   <!-- tests that are known to pass-->
                   <include>**/org/apache/activemq/blob/BlobTransferPolicyUriTest.java</include>
                </includes>
@@ -430,7 +432,6 @@
                   <exclude>**/org/apache/activemq/ProducerFlowControlTest.java</exclude>
                   <!-- exclude tests that are on client side only -->
                   <exclude>**/org/apache/activemq/transport/tcp/TransportConnectorInvalidSocketOptionsTest.java</exclude>
-                  <exclude>**/org/apache/activemq/transport/tcp/TransportUriTest.java</exclude>
                </excludes>
             </configuration>
          </plugin>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/eb1cdf8d/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
index 0843d3a..b3ac85f 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
@@ -67,6 +67,10 @@ public class TcpTransportFactory extends TransportFactory {
             System.out.println("bound: " + brokerId);
          }
       }
+      //remove unused invm parameters
+      params.remove("broker.persistent");
+      params.remove("broker.useJmx");
+      params.remove("marshal");
       URI location2 = URISupport.createRemainingURI(location, params);
       return super.doConnect(location2);
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/eb1cdf8d/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/EmbeddedBrokerTestSupport.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/EmbeddedBrokerTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/EmbeddedBrokerTestSupport.java
index b8dea70..1e6a227 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/EmbeddedBrokerTestSupport.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/EmbeddedBrokerTestSupport.java
@@ -46,13 +46,14 @@ public abstract class EmbeddedBrokerTestSupport extends CombinationTestSupport {
    protected boolean useTopic;
    protected ActiveMQDestination destination;
    protected JmsTemplate template;
+   protected boolean disableWrapper = false;
 
    public TemporaryFolder temporaryFolder;
 
    public String CLUSTER_PASSWORD = "OPENWIRECLUSTER";
 
    protected void setUp() throws Exception {
-      BrokerService.disableWrapper = true;
+      BrokerService.disableWrapper = disableWrapper;
       File tmpRoot = new File("./target/tmp");
       tmpRoot.mkdirs();
       temporaryFolder = new TemporaryFolder(tmpRoot);
@@ -78,6 +79,7 @@ public abstract class EmbeddedBrokerTestSupport extends CombinationTestSupport {
       if (artemisBroker != null) {
          try {
             artemisBroker.stop();
+            artemisBroker = null;
          }
          catch (Exception e) {
          }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/eb1cdf8d/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerTest.java
index 0287a77..b2c1d8a 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ExclusiveConsumerTest.java
@@ -26,6 +26,7 @@ import javax.jms.Session;
 
 import junit.framework.TestCase;
 
+import org.apache.activemq.artemiswrapper.ArtemisBrokerHelper;
 import org.apache.activemq.command.ActiveMQQueue;
 
 public class ExclusiveConsumerTest extends TestCase {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/eb1cdf8d/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ReconnectWithSameClientIDTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ReconnectWithSameClientIDTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ReconnectWithSameClientIDTest.java
index c6f60f8..adda445 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ReconnectWithSameClientIDTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ReconnectWithSameClientIDTest.java
@@ -96,7 +96,7 @@ public class ReconnectWithSameClientIDTest extends EmbeddedBrokerTestSupport {
 
    @Override
    protected ConnectionFactory createConnectionFactory() throws Exception {
-      return new ActiveMQConnectionFactory((useFailover ? "failover:" : "") + broker.getTransportConnectors().get(0).getPublishableConnectString());
+      return new ActiveMQConnectionFactory((useFailover ? "failover:" : "") + newURI("localhost", 0));
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/eb1cdf8d/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TransactionContextTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TransactionContextTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TransactionContextTest.java
index 8d239e7..beab88e 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TransactionContextTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TransactionContextTest.java
@@ -42,7 +42,9 @@ public class TransactionContextTest {
 
    @After
    public void tearDown() throws Exception {
-      connection.close();
+      if (connection != null) {
+         connection.close();
+      }
    }
 
    @Test

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/eb1cdf8d/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveTest.java
index 1cfea7b..28ac25e 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveTest.java
@@ -23,6 +23,7 @@ import javax.jms.MessageConsumer;
 import javax.jms.Session;
 import javax.jms.Topic;
 
+import org.apache.activemq.artemiswrapper.ArtemisBrokerHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -90,6 +91,7 @@ public class JmsTopicSendReceiveTest extends JmsSendReceiveTestSupport {
       /** TODO we should be able to shut down properly */
       session.close();
       connection.close();
+      ArtemisBrokerHelper.stopArtemisBroker();
    }
 
    /**

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/eb1cdf8d/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java
index 9d3c347..ce9aff9 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java
@@ -165,6 +165,7 @@ public class TransportUriTest extends EmbeddedBrokerTestSupport {
 
    @Override
    protected void setUp() throws Exception {
+      disableWrapper = true;
       bindAddress = "tcp://localhost:61616";
       super.setUp();
    }


[27/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/QueueDuplicatesFromStoreTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/QueueDuplicatesFromStoreTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/QueueDuplicatesFromStoreTest.java
index 97cd6f6..9729793 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/QueueDuplicatesFromStoreTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/QueueDuplicatesFromStoreTest.java
@@ -32,6 +32,7 @@ import junit.framework.TestCase;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.broker.ConnectionContext;
 import org.apache.activemq.broker.ProducerBrokerExchange;
+import org.apache.activemq.broker.region.SubscriptionStatistics;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ActiveMQQueue;
 import org.apache.activemq.command.ActiveMQTextMessage;
@@ -53,12 +54,13 @@ import org.slf4j.LoggerFactory;
 /**
  * @author gtully
  * @see https://issues.apache.org/activemq/browse/AMQ-2020
- */
+ **/
 public class QueueDuplicatesFromStoreTest extends TestCase {
+   private static final Logger LOG = LoggerFactory
+           .getLogger(QueueDuplicatesFromStoreTest.class);
 
-   private static final Logger LOG = LoggerFactory.getLogger(QueueDuplicatesFromStoreTest.class);
-
-   ActiveMQQueue destination = new ActiveMQQueue("queue-" + QueueDuplicatesFromStoreTest.class.getSimpleName());
+   ActiveMQQueue destination = new ActiveMQQueue("queue-"
+           + QueueDuplicatesFromStoreTest.class.getSimpleName());
    BrokerService brokerService;
 
    final static String mesageIdRoot = "11111:22222:";
@@ -89,7 +91,7 @@ public class QueueDuplicatesFromStoreTest extends TestCase {
    }
 
    public void testNoDuplicateAfterCacheFullAndAckedWithLargeAuditDepth() throws Exception {
-      doTestNoDuplicateAfterCacheFullAndAcked(1024 * 10);
+      doTestNoDuplicateAfterCacheFullAndAcked(1024*10);
    }
 
    public void testNoDuplicateAfterCacheFullAndAckedWithSmallAuditDepth() throws Exception {
@@ -97,13 +99,15 @@ public class QueueDuplicatesFromStoreTest extends TestCase {
    }
 
    public void doTestNoDuplicateAfterCacheFullAndAcked(final int auditDepth) throws Exception {
-      final PersistenceAdapter persistenceAdapter = brokerService.getPersistenceAdapter();
-      final MessageStore queueMessageStore = persistenceAdapter.createQueueMessageStore(destination);
+      final PersistenceAdapter persistenceAdapter =  brokerService.getPersistenceAdapter();
+      final MessageStore queueMessageStore =
+              persistenceAdapter.createQueueMessageStore(destination);
       final ConnectionContext contextNotInTx = new ConnectionContext();
       final ConsumerInfo consumerInfo = new ConsumerInfo();
       final DestinationStatistics destinationStatistics = new DestinationStatistics();
       consumerInfo.setExclusive(true);
-      final Queue queue = new Queue(brokerService, destination, queueMessageStore, destinationStatistics, brokerService.getTaskRunnerFactory());
+      final Queue queue = new Queue(brokerService, destination,
+              queueMessageStore, destinationStatistics, brokerService.getTaskRunnerFactory());
 
       // a workaround for this issue
       // queue.setUseCache(false);
@@ -134,34 +138,38 @@ public class QueueDuplicatesFromStoreTest extends TestCase {
       // pull from store in small windows
       Subscription subscription = new Subscription() {
 
+         private SubscriptionStatistics subscriptionStatistics = new SubscriptionStatistics();
+
          @Override
          public void add(MessageReference node) throws Exception {
             if (enqueueCounter.get() != node.getMessageId().getProducerSequenceId()) {
-               errors.add("Not in sequence at: " + enqueueCounter.get() + ", received: " + node.getMessageId().getProducerSequenceId());
+               errors.add("Not in sequence at: " + enqueueCounter.get() + ", received: "
+                       + node.getMessageId().getProducerSequenceId());
             }
-            assertEquals("is in order", enqueueCounter.get(), node.getMessageId().getProducerSequenceId());
+            assertEquals("is in order", enqueueCounter.get(), node
+                    .getMessageId().getProducerSequenceId());
             receivedLatch.countDown();
             enqueueCounter.incrementAndGet();
             node.decrementReferenceCount();
          }
 
          @Override
-         public void add(ConnectionContext context, Destination destination) throws Exception {
+         public void add(ConnectionContext context, Destination destination)
+                 throws Exception {
          }
 
          @Override
          public int countBeforeFull() {
             if (isFull()) {
                return 0;
-            }
-            else {
+            } else {
                return fullWindow - (int) (enqueueCounter.get() - ackedCount.get());
             }
          }
 
          @Override
          public void destroy() {
-         }
+         };
 
          @Override
          public void gc() {
@@ -253,7 +261,8 @@ public class QueueDuplicatesFromStoreTest extends TestCase {
          }
 
          @Override
-         public boolean matches(MessageReference node, MessageEvaluationContext context) throws IOException {
+         public boolean matches(MessageReference node,
+                                MessageEvaluationContext context) throws IOException {
             return true;
          }
 
@@ -263,11 +272,13 @@ public class QueueDuplicatesFromStoreTest extends TestCase {
          }
 
          @Override
-         public void processMessageDispatchNotification(MessageDispatchNotification mdn) throws Exception {
+         public void processMessageDispatchNotification(
+                 MessageDispatchNotification mdn) throws Exception {
          }
 
          @Override
-         public Response pullMessage(ConnectionContext context, MessagePull pull) throws Exception {
+         public Response pullMessage(ConnectionContext context,
+                                     MessagePull pull) throws Exception {
             return null;
          }
 
@@ -277,7 +288,8 @@ public class QueueDuplicatesFromStoreTest extends TestCase {
          }
 
          @Override
-         public List<MessageReference> remove(ConnectionContext context, Destination destination) throws Exception {
+         public List<MessageReference> remove(ConnectionContext context,
+                                              Destination destination) throws Exception {
             return null;
          }
 
@@ -286,7 +298,9 @@ public class QueueDuplicatesFromStoreTest extends TestCase {
          }
 
          @Override
-         public void setSelector(String selector) throws InvalidSelectorException, UnsupportedOperationException {
+         public void setSelector(String selector)
+                 throws InvalidSelectorException,
+                 UnsupportedOperationException {
          }
 
          @Override
@@ -294,7 +308,8 @@ public class QueueDuplicatesFromStoreTest extends TestCase {
          }
 
          @Override
-         public boolean addRecoveredMessage(ConnectionContext context, MessageReference message) throws Exception {
+         public boolean addRecoveredMessage(ConnectionContext context,
+                                            MessageReference message) throws Exception {
             return false;
          }
 
@@ -304,16 +319,18 @@ public class QueueDuplicatesFromStoreTest extends TestCase {
          }
 
          @Override
-         public void acknowledge(ConnectionContext context, MessageAck ack) throws Exception {
+         public void acknowledge(ConnectionContext context, MessageAck ack)
+                 throws Exception {
          }
 
          @Override
-         public int getCursorMemoryHighWaterMark() {
+         public int getCursorMemoryHighWaterMark(){
             return 0;
          }
 
          @Override
-         public void setCursorMemoryHighWaterMark(int cursorMemoryHighWaterMark) {
+         public void setCursorMemoryHighWaterMark(
+                 int cursorMemoryHighWaterMark) {
          }
 
          @Override
@@ -336,14 +353,24 @@ public class QueueDuplicatesFromStoreTest extends TestCase {
          }
 
          @Override
-         public void incrementConsumedCount() {
+         public void incrementConsumedCount(){
 
          }
 
          @Override
-         public void resetConsumedCount() {
+         public void resetConsumedCount(){
 
          }
+
+         @Override
+         public SubscriptionStatistics getSubscriptionStatistics() {
+            return subscriptionStatistics;
+         }
+
+         @Override
+         public long getInFlightMessageSize() {
+            return subscriptionStatistics.getInflightMessageSize().getTotalSize();
+         }
       };
 
       queue.addSubscription(contextNotInTx, subscription);
@@ -356,9 +383,12 @@ public class QueueDuplicatesFromStoreTest extends TestCase {
                for (int j = 0; j < ackBatchSize; j++, removeIndex++) {
                   ackedCount.incrementAndGet();
                   MessageAck ack = new MessageAck();
-                  ack.setLastMessageId(new MessageId(mesageIdRoot + removeIndex));
+                  ack.setLastMessageId(new MessageId(mesageIdRoot
+                          + removeIndex));
                   ack.setMessageCount(1);
-                  queue.removeMessage(contextNotInTx, subscription, new IndirectMessageReference(getMessage(removeIndex)), ack);
+                  queue.removeMessage(contextNotInTx, subscription,
+                          new IndirectMessageReference(
+                                  getMessage(removeIndex)), ack);
                   queue.wakeup();
 
                }
@@ -373,7 +403,8 @@ public class QueueDuplicatesFromStoreTest extends TestCase {
 
       assertTrue("There are no errors: " + errors, errors.isEmpty());
       assertEquals(count, enqueueCounter.get());
-      assertEquals("store count is correct", count - removeIndex, queueMessageStore.getMessageCount());
+      assertEquals("store count is correct", count - removeIndex,
+              queueMessageStore.getMessageCount());
    }
 
    private Message getMessage(int i) throws Exception {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/SubscriptionAddRemoveQueueTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/SubscriptionAddRemoveQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/SubscriptionAddRemoveQueueTest.java
index b38a965..c9d0339 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/SubscriptionAddRemoveQueueTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/SubscriptionAddRemoveQueueTest.java
@@ -61,7 +61,6 @@ import org.apache.activemq.filter.MessageEvaluationContext;
 import org.apache.activemq.state.ProducerState;
 import org.apache.activemq.store.MessageStore;
 import org.apache.activemq.thread.TaskRunnerFactory;
-
 import junit.framework.TestCase;
 
 public class SubscriptionAddRemoveQueueTest extends TestCase {
@@ -177,16 +176,20 @@ public class SubscriptionAddRemoveQueueTest extends TestCase {
 
    public class SimpleImmediateDispatchSubscription implements Subscription, LockOwner {
 
-      List<MessageReference> dispatched = Collections.synchronizedList(new ArrayList<MessageReference>());
+      private SubscriptionStatistics subscriptionStatistics = new SubscriptionStatistics();
+      List<MessageReference> dispatched =
+              Collections.synchronizedList(new ArrayList<MessageReference>());
+
 
       @Override
-      public void acknowledge(ConnectionContext context, MessageAck ack) throws Exception {
+      public void acknowledge(ConnectionContext context, MessageAck ack)
+              throws Exception {
       }
 
       @Override
       public void add(MessageReference node) throws Exception {
          // immediate dispatch
-         QueueMessageReference qmr = (QueueMessageReference) node;
+         QueueMessageReference  qmr = (QueueMessageReference)node;
          qmr.lock(this);
          dispatched.add(qmr);
       }
@@ -400,5 +403,15 @@ public class SubscriptionAddRemoveQueueTest extends TestCase {
          return 10;
       }
 
+      @Override
+      public SubscriptionStatistics getSubscriptionStatistics() {
+         return subscriptionStatistics;
+      }
+
+      @Override
+      public long getInFlightMessageSize() {
+         return subscriptionStatistics.getInflightMessageSize().getTotalSize();
+      }
+
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/NegativeQueueTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/NegativeQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/NegativeQueueTest.java
deleted file mode 100644
index ab388f0..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/NegativeQueueTest.java
+++ /dev/null
@@ -1,432 +0,0 @@
-/**
- * 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.broker.region.cursors;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.AutoFailTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.QueueViewMBean;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.broker.region.policy.StorePendingQueueMessageStoragePolicy;
-import org.apache.activemq.usage.MemoryUsage;
-import org.apache.activemq.usage.StoreUsage;
-import org.apache.activemq.usage.SystemUsage;
-import org.apache.activemq.usage.TempUsage;
-import org.apache.activemq.util.Wait;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Modified CursorSupport Unit test to reproduce the negative queue issue.
- *
- * Keys to reproducing:
- * 1) Consecutive queues with listener on first sending to second queue
- * 2) Push each queue to the memory limit
- * This seems to help reproduce the issue more consistently, but
- * we have seen times in our production environment where the
- * negative queue can occur without. Our memory limits are
- * very high in production and it still happens in varying
- * frequency.
- * 3) Prefetch
- * Lowering the prefetch down to 10 and below seems to help
- * reduce occurrences.
- * 4) # of consumers per queue
- * The issue occurs less with fewer consumers
- *
- * Things that do not affect reproduction:
- * 1) Spring - we use spring in our production applications, but this test case works
- * with or without it.
- * 2) transacted
- */
-public class NegativeQueueTest extends AutoFailTestSupport {
-
-   private static final Logger LOG = LoggerFactory.getLogger(NegativeQueueTest.class);
-
-   public static SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd,hh:mm:ss:SSS");
-
-   private static final String QUEUE_1_NAME = "conn.test.queue.1";
-   private static final String QUEUE_2_NAME = "conn.test.queue.2";
-
-   private static final long QUEUE_MEMORY_LIMIT = 2097152;
-   private static final long MEMORY_USAGE = 400000000;
-   private static final long TEMP_USAGE = 200000000;
-   private static final long STORE_USAGE = 1000000000;
-   // ensure we exceed the cache 70%
-   private static final int MESSAGE_COUNT = 2100;
-
-   protected static final boolean TRANSACTED = true;
-   protected static final boolean DEBUG = true;
-   protected static int NUM_CONSUMERS = 20;
-   protected static int PREFETCH_SIZE = 1000;
-
-   protected BrokerService broker;
-   protected String bindAddress = "tcp://localhost:0";
-
-   public void testWithDefaultPrefetch() throws Exception {
-      PREFETCH_SIZE = 1000;
-      NUM_CONSUMERS = 20;
-      blastAndConsume();
-   }
-
-   public void x_testWithDefaultPrefetchFiveConsumers() throws Exception {
-      PREFETCH_SIZE = 1000;
-      NUM_CONSUMERS = 5;
-      blastAndConsume();
-   }
-
-   public void x_testWithDefaultPrefetchTwoConsumers() throws Exception {
-      PREFETCH_SIZE = 1000;
-      NUM_CONSUMERS = 2;
-      blastAndConsume();
-   }
-
-   public void testWithDefaultPrefetchOneConsumer() throws Exception {
-      PREFETCH_SIZE = 1000;
-      NUM_CONSUMERS = 1;
-      blastAndConsume();
-   }
-
-   public void testWithMediumPrefetch() throws Exception {
-      PREFETCH_SIZE = 50;
-      NUM_CONSUMERS = 20;
-      blastAndConsume();
-   }
-
-   public void x_testWithSmallPrefetch() throws Exception {
-      PREFETCH_SIZE = 10;
-      NUM_CONSUMERS = 20;
-      blastAndConsume();
-   }
-
-   public void testWithNoPrefetch() throws Exception {
-      PREFETCH_SIZE = 1;
-      NUM_CONSUMERS = 20;
-      blastAndConsume();
-   }
-
-   public void blastAndConsume() throws Exception {
-      LOG.info(getName());
-      ConnectionFactory factory = createConnectionFactory();
-
-      //get proxy queues for statistics lookups
-      Connection proxyConnection = factory.createConnection();
-      proxyConnection.start();
-      Session proxySession = proxyConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      final QueueViewMBean proxyQueue1 = getProxyToQueueViewMBean(proxySession.createQueue(QUEUE_1_NAME));
-      final QueueViewMBean proxyQueue2 = getProxyToQueueViewMBean(proxySession.createQueue(QUEUE_2_NAME));
-
-      // LOAD THE QUEUE
-      Connection producerConnection = factory.createConnection();
-      producerConnection.start();
-      Session session = producerConnection.createSession(TRANSACTED, Session.AUTO_ACKNOWLEDGE);
-      Destination queue = session.createQueue(QUEUE_1_NAME);
-      MessageProducer producer = session.createProducer(queue);
-      List<TextMessage> senderList = new ArrayList<>();
-      for (int i = 0; i < MESSAGE_COUNT; i++) {
-         TextMessage msg = session.createTextMessage(i + " " + formatter.format(new Date()));
-         senderList.add(msg);
-         producer.send(msg);
-         if (TRANSACTED)
-            session.commit();
-         if (DEBUG && i % 100 == 0) {
-            int index = (i / 100) + 1;
-            System.out.print(index - ((index / 10) * 10));
-         }
-      }
-
-      //get access to the Queue info
-      if (DEBUG) {
-         System.out.println("");
-         System.out.println("Queue1 Size = " + proxyQueue1.getQueueSize());
-         System.out.println("Queue1 Memory % Used = " + proxyQueue1.getMemoryPercentUsage());
-         System.out.println("Queue1 Memory Available = " + proxyQueue1.getMemoryLimit());
-      }
-
-      // FLUSH THE QUEUE
-      final CountDownLatch latch1 = new CountDownLatch(1);
-      final CountDownLatch latch2 = new CountDownLatch(1);
-      Connection[] consumerConnections1 = new Connection[NUM_CONSUMERS];
-      List<Message> consumerList1 = new ArrayList<>();
-      Connection[] consumerConnections2 = new Connection[NUM_CONSUMERS];
-      Connection[] producerConnections2 = new Connection[NUM_CONSUMERS];
-      List<Message> consumerList2 = new ArrayList<>();
-
-      for (int ix = 0; ix < NUM_CONSUMERS; ix++) {
-         producerConnections2[ix] = factory.createConnection();
-         producerConnections2[ix].start();
-         consumerConnections1[ix] = getConsumerConnection(factory);
-         Session consumerSession = consumerConnections1[ix].createSession(TRANSACTED, Session.AUTO_ACKNOWLEDGE);
-         MessageConsumer consumer = consumerSession.createConsumer(session.createQueue(QUEUE_1_NAME));
-         consumer.setMessageListener(new SessionAwareMessageListener(producerConnections2[ix], consumerSession, QUEUE_2_NAME, latch1, consumerList1));
-      }
-
-      latch1.await(200000, TimeUnit.MILLISECONDS);
-      if (DEBUG) {
-         System.out.println("");
-         System.out.println("Queue2 Size = " + proxyQueue2.getQueueSize());
-         System.out.println("Queue2 Memory % Used = " + proxyQueue2.getMemoryPercentUsage());
-         System.out.println("Queue2 Memory Available = " + proxyQueue2.getMemoryLimit());
-      }
-
-      for (int ix = 0; ix < NUM_CONSUMERS; ix++) {
-         consumerConnections2[ix] = getConsumerConnection(factory);
-         Session consumerSession = consumerConnections2[ix].createSession(TRANSACTED, Session.AUTO_ACKNOWLEDGE);
-         MessageConsumer consumer = consumerSession.createConsumer(session.createQueue(QUEUE_2_NAME));
-         consumer.setMessageListener(new SessionAwareMessageListener(consumerSession, latch2, consumerList2));
-      }
-
-      boolean success = Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            boolean done = latch2.await(10, TimeUnit.SECONDS);
-            if (DEBUG) {
-               System.out.println("");
-               System.out.println("Queue1 Size = " + proxyQueue1.getQueueSize());
-               System.out.println("Queue1 Memory % Used = " + proxyQueue1.getMemoryPercentUsage());
-               System.out.println("Queue2 Size = " + proxyQueue2.getQueueSize());
-               System.out.println("Queue2 Memory % Used = " + proxyQueue2.getMemoryPercentUsage());
-               System.out.println("Queue2 Memory Available = " + proxyQueue2.getMemoryLimit());
-            }
-            return done;
-         }
-      }, 300 * 1000);
-      if (!success) {
-         dumpAllThreads("blocked waiting on 2");
-      }
-      assertTrue("got all expected messages on 2", success);
-
-      producerConnection.close();
-      for (int ix = 0; ix < NUM_CONSUMERS; ix++) {
-         consumerConnections1[ix].close();
-         consumerConnections2[ix].close();
-         producerConnections2[ix].close();
-      }
-
-      //let the consumer statistics on queue2 have time to update
-      Thread.sleep(500);
-
-      if (DEBUG) {
-         System.out.println("");
-         System.out.println("Queue1 Size = " + proxyQueue1.getQueueSize());
-         System.out.println("Queue1 Memory % Used = " + proxyQueue1.getMemoryPercentUsage());
-         System.out.println("Queue2 Size = " + proxyQueue2.getQueueSize());
-         System.out.println("Queue2 Memory % Used = " + proxyQueue2.getMemoryPercentUsage());
-      }
-
-      Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return 0 == proxyQueue1.getQueueSize();
-         }
-      });
-      assertEquals("Queue1 has gone negative,", 0, proxyQueue1.getQueueSize());
-
-      Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return 0 == proxyQueue2.getQueueSize();
-         }
-      });
-      assertEquals("Queue2 has gone negative,", 0, proxyQueue2.getQueueSize());
-      proxyConnection.close();
-
-   }
-
-   private QueueViewMBean getProxyToQueueViewMBean(Queue queue) throws MalformedObjectNameException, JMSException {
-      final String prefix = "org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=";
-
-      ObjectName queueViewMBeanName = new ObjectName(prefix + queue.getQueueName());
-      QueueViewMBean proxy = (QueueViewMBean) broker.getManagementContext().newProxyInstance(queueViewMBeanName, QueueViewMBean.class, true);
-
-      return proxy;
-   }
-
-   protected Connection getConsumerConnection(ConnectionFactory fac) throws JMSException {
-      Connection connection = fac.createConnection();
-      connection.start();
-      return connection;
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      if (broker == null) {
-         broker = createBroker();
-      }
-      super.setUp();
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      super.tearDown();
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-      }
-   }
-
-   protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
-      ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(bindAddress);
-      Properties props = new Properties();
-      props.setProperty("prefetchPolicy.durableTopicPrefetch", "" + PREFETCH_SIZE);
-      props.setProperty("prefetchPolicy.optimizeDurableTopicPrefetch", "" + PREFETCH_SIZE);
-      props.setProperty("prefetchPolicy.queuePrefetch", "" + PREFETCH_SIZE);
-      cf.setProperties(props);
-      return cf;
-   }
-
-   protected BrokerService createBroker() throws Exception {
-      BrokerService answer = new BrokerService();
-      configureBroker(answer);
-      answer.start();
-      answer.waitUntilStarted();
-      bindAddress = answer.getTransportConnectors().get(0).getConnectUri().toString();
-      return answer;
-   }
-
-   protected void configureBroker(BrokerService answer) throws Exception {
-      PolicyEntry policy = new PolicyEntry();
-      policy.setMemoryLimit(QUEUE_MEMORY_LIMIT);
-      policy.setPendingQueuePolicy(new StorePendingQueueMessageStoragePolicy());
-
-      // disable the cache to be sure setBatch is the problem
-      // will get lots of duplicates
-      // real problem is sync between cursor and store add - leads to out or order messages
-      // in the cursor so setBatch can break.
-      // policy.setUseCache(false);
-
-      PolicyMap pMap = new PolicyMap();
-      pMap.setDefaultEntry(policy);
-      answer.setDestinationPolicy(pMap);
-      answer.setDeleteAllMessagesOnStartup(true);
-      answer.addConnector("tcp://localhost:0");
-
-      MemoryUsage memoryUsage = new MemoryUsage();
-      memoryUsage.setLimit(MEMORY_USAGE);
-      memoryUsage.setPercentUsageMinDelta(20);
-
-      TempUsage tempUsage = new TempUsage();
-      tempUsage.setLimit(TEMP_USAGE);
-
-      StoreUsage storeUsage = new StoreUsage();
-      storeUsage.setLimit(STORE_USAGE);
-
-      SystemUsage systemUsage = new SystemUsage();
-      systemUsage.setMemoryUsage(memoryUsage);
-      systemUsage.setTempUsage(tempUsage);
-      systemUsage.setStoreUsage(storeUsage);
-      answer.setSystemUsage(systemUsage);
-   }
-
-   /**
-    * Message listener that is given the Session for transacted consumers
-    */
-   class SessionAwareMessageListener implements MessageListener {
-
-      private final List<Message> consumerList;
-      private final CountDownLatch latch;
-      private final Session consumerSession;
-      private Session producerSession;
-      private MessageProducer producer;
-
-      public SessionAwareMessageListener(Session consumerSession, CountDownLatch latch, List<Message> consumerList) {
-         this(null, consumerSession, null, latch, consumerList);
-      }
-
-      public SessionAwareMessageListener(Connection producerConnection,
-                                         Session consumerSession,
-                                         String outQueueName,
-                                         CountDownLatch latch,
-                                         List<Message> consumerList) {
-         this.consumerList = consumerList;
-         this.latch = latch;
-         this.consumerSession = consumerSession;
-
-         if (producerConnection != null) {
-            try {
-               producerSession = producerConnection.createSession(TRANSACTED, Session.AUTO_ACKNOWLEDGE);
-               Destination queue = producerSession.createQueue(outQueueName);
-               producer = producerSession.createProducer(queue);
-            }
-            catch (JMSException e) {
-               e.printStackTrace();
-            }
-         }
-      }
-
-      @Override
-      public void onMessage(Message msg) {
-         try {
-            if (producer == null) {
-               // sleep to act as a slow consumer
-               // which will force a mix of direct and polled dispatching
-               // using the cursor on the broker
-               Thread.sleep(50);
-            }
-            else {
-               producer.send(msg);
-               if (TRANSACTED)
-                  producerSession.commit();
-            }
-         }
-         catch (Exception e) {
-            e.printStackTrace();
-         }
-
-         synchronized (consumerList) {
-            consumerList.add(msg);
-            if (DEBUG && consumerList.size() % 100 == 0) {
-               int index = consumerList.size() / 100;
-               System.out.print(index - ((index / 10) * 10));
-            }
-            if (consumerList.size() == MESSAGE_COUNT) {
-               latch.countDown();
-            }
-         }
-         if (TRANSACTED) {
-            try {
-               consumerSession.commit();
-            }
-            catch (JMSException e) {
-               e.printStackTrace();
-            }
-         }
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/CompositeQueueTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/CompositeQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/CompositeQueueTest.java
deleted file mode 100644
index 2d8adb5..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/CompositeQueueTest.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/**
- * 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.broker.virtual;
-
-import java.net.URI;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.spring.ConsumerBean;
-import org.apache.activemq.xbean.XBeanBrokerFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- *
- *
- */
-public class CompositeQueueTest extends EmbeddedBrokerTestSupport {
-
-   private static final Logger LOG = LoggerFactory.getLogger(CompositeQueueTest.class);
-
-   protected int total = 10;
-   protected Connection connection;
-   public String messageSelector1, messageSelector2 = null;
-
-   public void testVirtualTopicCreation() throws Exception {
-      if (connection == null) {
-         connection = createConnection();
-      }
-      connection.start();
-
-      ConsumerBean messageList1 = new ConsumerBean();
-      ConsumerBean messageList2 = new ConsumerBean();
-      messageList1.setVerbose(true);
-      messageList2.setVerbose(true);
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      Destination producerDestination = getProducerDestination();
-      Destination destination1 = getConsumer1Dsetination();
-      Destination destination2 = getConsumer2Dsetination();
-
-      LOG.info("Sending to: " + producerDestination);
-      LOG.info("Consuming from: " + destination1 + " and " + destination2);
-
-      MessageConsumer c1 = session.createConsumer(destination1, messageSelector1);
-      MessageConsumer c2 = session.createConsumer(destination2, messageSelector2);
-
-      c1.setMessageListener(messageList1);
-      c2.setMessageListener(messageList2);
-
-      // create topic producer
-      MessageProducer producer = session.createProducer(producerDestination);
-      assertNotNull(producer);
-
-      for (int i = 0; i < total; i++) {
-         producer.send(createMessage(session, i));
-      }
-
-      assertMessagesArrived(messageList1, messageList2);
-   }
-
-   protected void assertMessagesArrived(ConsumerBean messageList1, ConsumerBean messageList2) {
-      messageList1.assertMessagesArrived(total);
-      messageList2.assertMessagesArrived(total);
-   }
-
-   protected TextMessage createMessage(Session session, int i) throws JMSException {
-      TextMessage textMessage = session.createTextMessage("message: " + i);
-      if (i % 2 != 0) {
-         textMessage.setStringProperty("odd", "yes");
-      }
-      else {
-         textMessage.setStringProperty("odd", "no");
-      }
-      textMessage.setIntProperty("i", i);
-      return textMessage;
-   }
-
-   protected Destination getConsumer1Dsetination() {
-      return new ActiveMQQueue("FOO");
-   }
-
-   protected Destination getConsumer2Dsetination() {
-      return new ActiveMQTopic("BAR");
-   }
-
-   protected Destination getProducerDestination() {
-      return new ActiveMQQueue("MY.QUEUE");
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      if (connection != null) {
-         connection.close();
-      }
-      super.tearDown();
-   }
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      XBeanBrokerFactory factory = new XBeanBrokerFactory();
-      BrokerService answer = factory.createBroker(new URI(getBrokerConfigUri()));
-      return answer;
-   }
-
-   protected String getBrokerConfigUri() {
-      return "org/apache/activemq/broker/virtual/composite-queue.xml";
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/CompositeTopicTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/CompositeTopicTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/CompositeTopicTest.java
deleted file mode 100644
index 9ada103..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/CompositeTopicTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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.broker.virtual;
-
-import javax.jms.Destination;
-
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-
-/**
- *
- *
- */
-public class CompositeTopicTest extends CompositeQueueTest {
-
-   @Override
-   protected Destination getConsumer1Dsetination() {
-      return new ActiveMQQueue("FOO");
-   }
-
-   @Override
-   protected Destination getConsumer2Dsetination() {
-      return new ActiveMQTopic("BAR");
-   }
-
-   @Override
-   protected Destination getProducerDestination() {
-      return new ActiveMQTopic("MY.TOPIC");
-   }
-
-   @Override
-   protected String getBrokerConfigUri() {
-      return "org/apache/activemq/broker/virtual/composite-topic.xml";
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/DestinationInterceptorDurableSubTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/DestinationInterceptorDurableSubTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/DestinationInterceptorDurableSubTest.java
deleted file mode 100644
index 39e9d2a..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/DestinationInterceptorDurableSubTest.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/**
- * 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.broker.virtual;
-
-import java.io.IOException;
-import java.net.URI;
-
-import javax.jms.Connection;
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.jms.TopicSubscriber;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXServiceURL;
-
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-
-import org.apache.activemq.broker.Broker;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.ConnectionContext;
-import org.apache.activemq.broker.ProducerBrokerExchange;
-import org.apache.activemq.broker.region.Destination;
-import org.apache.activemq.broker.region.DestinationFilter;
-import org.apache.activemq.broker.region.DestinationInterceptor;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.Message;
-import org.apache.activemq.xbean.XBeanBrokerFactory;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Test for AMQ-4571.
- * checks that durable subscription is fully unregistered
- * when using nested destination interceptors.
- */
-public class DestinationInterceptorDurableSubTest extends EmbeddedBrokerTestSupport {
-
-   private static final transient Logger LOG = LoggerFactory.getLogger(DestinationInterceptorDurableSubTest.class);
-   private MBeanServerConnection mbsc = null;
-   public static final String JMX_CONTEXT_BASE_NAME = "org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Topic,destinationName=";
-
-   /**
-    * Tests AMQ-4571.
-    *
-    * @throws Exception
-    */
-   public void testVirtualTopicRemoval() throws Exception {
-
-      LOG.debug("Running testVirtualTopicRemoval()");
-      String clientId1 = "myId1";
-      String clientId2 = "myId2";
-
-      Connection conn = null;
-      Session session = null;
-
-      try {
-         assertTrue(broker.isStarted());
-
-         // create durable sub 1
-         conn = createConnection();
-         conn.setClientID(clientId1);
-         conn.start();
-         session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         // Topic topic = session.createTopic(destination.getPhysicalName());
-         TopicSubscriber sub1 = session.createDurableSubscriber((Topic) destination, clientId1);
-
-         // create durable sub 2
-         TopicSubscriber sub2 = session.createDurableSubscriber((Topic) destination, clientId2);
-
-         // verify two subs registered in JMX
-         assertSubscriptionCount(destination.getPhysicalName(), 2);
-         assertTrue(isSubRegisteredInJmx(destination.getPhysicalName(), clientId1));
-         assertTrue(isSubRegisteredInJmx(destination.getPhysicalName(), clientId2));
-
-         // delete sub 1
-         sub1.close();
-         session.unsubscribe(clientId1);
-
-         // verify only one sub registered in JMX
-         assertSubscriptionCount(destination.getPhysicalName(), 1);
-         assertFalse(isSubRegisteredInJmx(destination.getPhysicalName(), clientId1));
-         assertTrue(isSubRegisteredInJmx(destination.getPhysicalName(), clientId2));
-
-         // delete sub 2
-         sub2.close();
-         session.unsubscribe(clientId2);
-
-         // verify no sub registered in JMX
-         assertSubscriptionCount(destination.getPhysicalName(), 0);
-         assertFalse(isSubRegisteredInJmx(destination.getPhysicalName(), clientId1));
-         assertFalse(isSubRegisteredInJmx(destination.getPhysicalName(), clientId2));
-      }
-      finally {
-         session.close();
-         conn.close();
-      }
-   }
-
-   /**
-    * Connects to broker using JMX
-    *
-    * @return The JMX connection
-    * @throws IOException in case of any errors
-    */
-   protected MBeanServerConnection connectJMXBroker() throws IOException {
-      // connect to broker via JMX
-      JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://:1299/jmxrmi");
-      JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
-      MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
-      LOG.debug("JMX connection established");
-      return mbsc;
-   }
-
-   /**
-    * Asserts that the Subscriptions JMX attribute of a topic has the expected
-    * count.
-    *
-    * @param topicName     name of the topic destination
-    * @param expectedCount expected number of subscriptions
-    * @return
-    */
-   protected boolean assertSubscriptionCount(String topicName, int expectedCount) {
-      try {
-         if (mbsc == null) {
-            mbsc = connectJMXBroker();
-         }
-         // query broker queue size
-         ObjectName[] tmp = (ObjectName[]) mbsc.getAttribute(new ObjectName(JMX_CONTEXT_BASE_NAME + topicName), "Subscriptions");
-         assertEquals(expectedCount, tmp.length);
-      }
-      catch (Exception ex) {
-         LOG.error(ex.getMessage());
-         return false;
-      }
-      return true;
-   }
-
-   /**
-    * Checks if a subscriptions for topic topicName with subName is registered in JMX
-    *
-    * @param topicName physical name of topic destination (excluding prefix 'topic://')
-    * @param subName   name of the durable subscription
-    * @return true if registered, false otherwise
-    */
-   protected boolean isSubRegisteredInJmx(String topicName, String subName) {
-
-      try {
-         if (mbsc == null) {
-            mbsc = connectJMXBroker();
-         }
-
-         // A durable sub is registered under the Subscriptions JMX attribute of the topic and
-         // as its own ObjectInstance under the topic's Consumer namespace.
-         // AMQ-4571 only removed the latter not the former on unsubscribe(), so we need
-         // to check against both.
-         ObjectName[] names = (ObjectName[]) mbsc.getAttribute(new ObjectName(JMX_CONTEXT_BASE_NAME + topicName), "Subscriptions");
-         ObjectInstance instance = mbsc.getObjectInstance(new ObjectName(JMX_CONTEXT_BASE_NAME +
-                                                                                             topicName +
-                                                                                             ",endpoint=Consumer,clientId=myId1,consumerId=Durable(myId1_" +
-                                                                                             subName +
-                                                                                             ")"));
-
-         if (instance == null)
-            return false;
-
-         for (int i = 0; i < names.length; i++) {
-            if (names[i].toString().contains(subName))
-               return true;
-         }
-      }
-      catch (InstanceNotFoundException ine) {
-         //this may be expected so log at info level
-         LOG.info(ine.toString());
-         return false;
-      }
-      catch (Exception ex) {
-         LOG.error(ex.toString());
-         return false;
-      }
-      return false;
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      super.tearDown();
-   }
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      XBeanBrokerFactory factory = new XBeanBrokerFactory();
-      BrokerService answer = factory.createBroker(new URI(getBrokerConfigUri()));
-
-      // lets disable persistence as we are a test
-      answer.setPersistent(false);
-      useTopic = true;
-      return answer;
-   }
-
-   protected String getBrokerConfigUri() {
-      return "org/apache/activemq/broker/virtual/virtual-topics-and-interceptor.xml";
-   }
-
-   /**
-    * Simple but custom topic interceptor.
-    * To be used for testing nested interceptors in conjunction with
-    * virtual topic interceptor.
-    */
-   public static class SimpleDestinationInterceptor implements DestinationInterceptor {
-
-      private final Logger LOG = LoggerFactory.getLogger(SimpleDestinationInterceptor.class);
-      private BrokerService broker;
-
-      public SimpleDestinationInterceptor() {
-      }
-
-      /* (non-Javadoc)
-       * @see org.apache.activemq.broker.BrokerServiceAware#setBrokerService(org.apache.activemq.broker.BrokerService)
-       */
-      public void setBrokerService(BrokerService brokerService) {
-         LOG.info("setBrokerService()");
-         this.broker = brokerService;
-      }
-
-      /* (non-Javadoc)
-       * @see org.apache.activemq.broker.region.DestinationInterceptor#intercept(org.apache.activemq.broker.region.Destination)
-       */
-      @Override
-      public Destination intercept(final Destination destination) {
-         LOG.info("intercept({})", destination.getName());
-
-         if (!destination.getActiveMQDestination().getPhysicalName().startsWith("ActiveMQ")) {
-            return new DestinationFilter(destination) {
-               @Override
-               public void send(ProducerBrokerExchange context, Message message) throws Exception {
-                  // Send message to Destination
-                  if (LOG.isDebugEnabled()) {
-                     LOG.debug("SimpleDestinationInterceptor: Sending message to destination:" + this.getActiveMQDestination().getPhysicalName());
-                  }
-                  // message.setDestination(destination.getActiveMQDestination());
-                  super.send(context, message);
-               }
-            };
-         }
-         return destination;
-      }
-
-      /* (non-Javadoc)
-       * @see org.apache.activemq.broker.region.DestinationInterceptor#remove(org.apache.activemq.broker.region.Destination)
-       */
-      @Override
-      public void remove(Destination destination) {
-         LOG.info("remove({})", destination.getName());
-         this.broker = null;
-      }
-
-      /* (non-Javadoc)
-       * @see org.apache.activemq.broker.region.DestinationInterceptor#create(org.apache.activemq.broker.Broker, org.apache.activemq.broker.ConnectionContext, org.apache.activemq.command.ActiveMQDestination)
-       */
-      @Override
-      public void create(Broker broker, ConnectionContext context, ActiveMQDestination destination) throws Exception {
-         LOG.info("create(" + broker.getBrokerName() + ", " + context.toString() + ", " + destination.getPhysicalName());
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/FilteredQueueTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/FilteredQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/FilteredQueueTest.java
deleted file mode 100644
index e91ae4b..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/FilteredQueueTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * 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.broker.virtual;
-
-import org.apache.activemq.spring.ConsumerBean;
-
-/**
- *
- */
-public class FilteredQueueTest extends CompositeQueueTest {
-
-   @Override
-   protected String getBrokerConfigUri() {
-      return "org/apache/activemq/broker/virtual/filtered-queue.xml";
-   }
-
-   @Override
-   protected void assertMessagesArrived(ConsumerBean messageList1, ConsumerBean messageList2) {
-      messageList1.assertMessagesArrived(total / 2);
-      messageList2.assertMessagesArrived(1);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/MirroredQueueCorrectMemoryUsageTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/MirroredQueueCorrectMemoryUsageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/MirroredQueueCorrectMemoryUsageTest.java
deleted file mode 100644
index 5ca00b7..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/MirroredQueueCorrectMemoryUsageTest.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/**
- * 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.broker.virtual;
-
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.DestinationInterceptor;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.broker.region.virtual.MirroredQueue;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.usage.MemoryUsage;
-import org.apache.activemq.usage.StoreUsage;
-import org.apache.activemq.usage.SystemUsage;
-import org.apache.activemq.usage.TempUsage;
-import org.apache.activemq.util.IOHelper;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.util.Assert;
-
-/**
- * This test will determine that the producer flow control does not kick in.
- * The original MirroredQueue implementation was causing the queue to update
- * the topic memory usage instead of the queue memory usage.
- * The reason is that the message memory usage instance will not be updated
- * unless it is null.  This was the case when the message was initially sent
- * to the topic but then it was non-null when it was being sent to the queue.
- * When the region destination was set, the associated memory usage was not
- * updated to the passed queue destination and thus the memory usage of the
- * topic was being updated instead.
- *
- * @author Claudio Corsi
- */
-public class MirroredQueueCorrectMemoryUsageTest extends EmbeddedBrokerTestSupport {
-
-   private static final Logger logger = LoggerFactory.getLogger(MirroredQueueCorrectMemoryUsageTest.class);
-
-   private static final long ONE_MB = 0x0100000;
-   private static final long TEN_MB = ONE_MB * 10;
-   private static final long TWENTY_MB = TEN_MB * 2;
-
-   private static final String CREATED_STATIC_FOR_PERSISTENT = "created.static.for.persistent";
-
-   @Override
-   protected boolean isPersistent() {
-      return true;
-   }
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      // Create the broker service instance....
-      BrokerService broker = super.createBroker();
-      // Create and add the mirrored queue destination interceptor ....
-      DestinationInterceptor[] destinationInterceptors = new DestinationInterceptor[1];
-      MirroredQueue mq = new MirroredQueue();
-      mq.setCopyMessage(true);
-      mq.setPrefix("");
-      mq.setPostfix(".qmirror");
-      destinationInterceptors[0] = mq;
-      broker.setDestinationInterceptors(destinationInterceptors);
-      // Create the destination policy for the topics and queues
-      PolicyMap policyMap = new PolicyMap();
-      List<PolicyEntry> entries = new LinkedList<>();
-      // Create Topic policy entry
-      PolicyEntry policyEntry = new PolicyEntry();
-      super.useTopic = true;
-      ActiveMQDestination destination = super.createDestination(">");
-      Assert.isTrue(destination.isTopic(), "Created destination was not a topic");
-      policyEntry.setDestination(destination);
-      policyEntry.setProducerFlowControl(true);
-      policyEntry.setMemoryLimit(ONE_MB); // x10
-      entries.add(policyEntry);
-      // Create Queue policy entry
-      policyEntry = new PolicyEntry();
-      super.useTopic = false;
-      destination = super.createDestination(CREATED_STATIC_FOR_PERSISTENT);
-      Assert.isTrue(destination.isQueue(), "Created destination was not a queue");
-      policyEntry.setDestination(destination);
-      policyEntry.setProducerFlowControl(true);
-      policyEntry.setMemoryLimit(TEN_MB);
-      entries.add(policyEntry);
-      policyMap.setPolicyEntries(entries);
-      broker.setDestinationPolicy(policyMap);
-      // Set destinations
-      broker.setDestinations(new ActiveMQDestination[]{destination});
-      // Set system usage
-      SystemUsage memoryManager = new SystemUsage();
-      MemoryUsage memoryUsage = new MemoryUsage();
-      memoryUsage.setLimit(TEN_MB);
-      memoryManager.setMemoryUsage(memoryUsage);
-      StoreUsage storeUsage = new StoreUsage();
-      storeUsage.setLimit(TWENTY_MB);
-      memoryManager.setStoreUsage(storeUsage);
-      TempUsage tempDiskUsage = new TempUsage();
-      tempDiskUsage.setLimit(TEN_MB);
-      memoryManager.setTempUsage(tempDiskUsage);
-      broker.setSystemUsage(memoryManager);
-      // Set the persistent adapter
-      KahaDBPersistenceAdapter persistenceAdapter = new KahaDBPersistenceAdapter();
-      persistenceAdapter.setJournalMaxFileLength((int) TEN_MB);
-      // Delete all current messages...
-      IOHelper.deleteFile(persistenceAdapter.getDirectory());
-      broker.setPersistenceAdapter(persistenceAdapter);
-      return broker;
-   }
-
-   @Override
-   @Before
-   protected void setUp() throws Exception {
-      super.setUp();
-   }
-
-   @Override
-   @After
-   protected void tearDown() throws Exception {
-      super.tearDown();
-   }
-
-   @Test(timeout = 40000)
-   public void testNoMemoryUsageIncreaseForTopic() throws Exception {
-      Connection connection = super.createConnection();
-      connection.start();
-      Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-      Destination destination = session.createQueue(CREATED_STATIC_FOR_PERSISTENT);
-      MessageProducer producer = session.createProducer(destination);
-      producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-      char[] m = new char[1024];
-      Arrays.fill(m, 'x');
-      // create some messages that have 1k each
-      for (int i = 1; i < 12000; i++) {
-         producer.send(session.createTextMessage(new String(m)));
-         logger.debug("Sent message: " + i);
-      }
-      producer.close();
-      session.close();
-      connection.stop();
-      connection.close();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/MirroredQueueTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/MirroredQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/MirroredQueueTest.java
deleted file mode 100644
index 127f04c..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/MirroredQueueTest.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/**
- * 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.broker.virtual;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TemporaryQueue;
-
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.RegionBroker;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.spring.ConsumerBean;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- *
- */
-public class MirroredQueueTest extends EmbeddedBrokerTestSupport {
-
-   private static final transient Logger LOG = LoggerFactory.getLogger(MirroredQueueTest.class);
-   private Connection connection;
-
-   public void testSendingToQueueIsMirrored() throws Exception {
-      if (connection == null) {
-         connection = createConnection();
-      }
-      connection.start();
-
-      ConsumerBean messageList = new ConsumerBean();
-      messageList.setVerbose(true);
-
-      Destination consumeDestination = createConsumeDestination();
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      LOG.info("Consuming from: " + consumeDestination);
-
-      MessageConsumer c1 = session.createConsumer(consumeDestination);
-      c1.setMessageListener(messageList);
-
-      // create topic producer
-      ActiveMQQueue sendDestination = new ActiveMQQueue(getQueueName());
-      LOG.info("Sending to: " + sendDestination);
-
-      MessageProducer producer = session.createProducer(sendDestination);
-      assertNotNull(producer);
-
-      int total = 10;
-      for (int i = 0; i < total; i++) {
-         producer.send(session.createTextMessage("message: " + i));
-      }
-
-      ///Thread.sleep(1000000);
-
-      messageList.assertMessagesArrived(total);
-
-      LOG.info("Received: " + messageList);
-   }
-
-   public void testTempMirroredQueuesClearDown() throws Exception {
-      if (connection == null) {
-         connection = createConnection();
-      }
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      TemporaryQueue tempQueue = session.createTemporaryQueue();
-      RegionBroker rb = (RegionBroker) broker.getBroker().getAdaptor(RegionBroker.class);
-      assertTrue(rb.getDestinationMap().size() == 5);
-      tempQueue.delete();
-      assertTrue(rb.getDestinationMap().size() == 4);
-   }
-
-   protected Destination createConsumeDestination() {
-      return new ActiveMQTopic("VirtualTopic.Mirror." + getQueueName());
-   }
-
-   protected String getQueueName() {
-      return "My.Queue";
-   }
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      BrokerService answer = new BrokerService();
-      answer.setUseMirroredQueues(true);
-      answer.setPersistent(isPersistent());
-      answer.addConnector(bindAddress);
-      return answer;
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      if (connection != null) {
-         connection.close();
-      }
-      super.tearDown();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/MirroredQueueUsingVirtualTopicQueueTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/MirroredQueueUsingVirtualTopicQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/MirroredQueueUsingVirtualTopicQueueTest.java
deleted file mode 100644
index 6acaad1..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/MirroredQueueUsingVirtualTopicQueueTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * 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.broker.virtual;
-
-import javax.jms.Destination;
-
-import org.apache.activemq.command.ActiveMQQueue;
-
-/**
- *
- *
- */
-public class MirroredQueueUsingVirtualTopicQueueTest extends MirroredQueueTest {
-
-   @Override
-   protected Destination createConsumeDestination() {
-      String queueName = "Consumer.A.VirtualTopic.Mirror." + getQueueName();
-      return new ActiveMQQueue(queueName);
-   }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualDestPerfTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualDestPerfTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualDestPerfTest.java
deleted file mode 100644
index 85e14c7..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/virtual/VirtualDestPerfTest.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/**
- * 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.broker.virtual;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.management.ObjectName;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.QueueViewMBean;
-import org.apache.activemq.broker.region.DestinationInterceptor;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.broker.region.virtual.CompositeTopic;
-import org.apache.activemq.broker.region.virtual.VirtualDestination;
-import org.apache.activemq.broker.region.virtual.VirtualDestinationInterceptor;
-import org.apache.activemq.command.ActiveMQBytesMessage;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.util.ByteSequence;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class VirtualDestPerfTest {
-
-   private static final Logger LOG = LoggerFactory.getLogger(VirtualDestPerfTest.class);
-   public int messageSize = 5 * 1024;
-   public int messageCount = 10000;
-   ActiveMQTopic target = new ActiveMQTopic("target");
-   BrokerService brokerService;
-   ActiveMQConnectionFactory connectionFactory;
-
-   @Test
-   @Ignore("comparison test - 'new' no wait on future with async send broker side is always on")
-   public void testAsyncSendBurstToFillCache() throws Exception {
-      startBroker(4, true, true);
-      connectionFactory.setUseAsyncSend(true);
-
-      // a burst of messages to fill the cache
-      messageCount = 22000;
-      messageSize = 10 * 1024;
-
-      LinkedHashMap<Integer, Long> results = new LinkedHashMap<>();
-
-      final ActiveMQQueue queue = new ActiveMQQueue("targetQ");
-      for (Integer numThreads : new Integer[]{1, 2}) {
-         ExecutorService executor = Executors.newFixedThreadPool(numThreads);
-         final AtomicLong numMessagesToSend = new AtomicLong(messageCount);
-         purge();
-         long startTime = System.currentTimeMillis();
-         for (int i = 0; i < numThreads; i++) {
-            executor.execute(new Runnable() {
-               @Override
-               public void run() {
-                  try {
-                     produceMessages(numMessagesToSend, queue);
-                  }
-                  catch (Exception e) {
-                     e.printStackTrace();
-                  }
-               }
-            });
-         }
-         executor.shutdown();
-         executor.awaitTermination(5, TimeUnit.MINUTES);
-         long endTime = System.currentTimeMillis();
-         long seconds = (endTime - startTime) / 1000;
-         LOG.info("For numThreads {} duration {}", numThreads.intValue(), seconds);
-         results.put(numThreads, seconds);
-         LOG.info("Broker got {} messages", brokerService.getAdminView().getTotalEnqueueCount());
-      }
-
-      brokerService.stop();
-      brokerService.waitUntilStopped();
-      LOG.info("Results: {}", results);
-   }
-
-   private void purge() throws Exception {
-      ObjectName[] queues = brokerService.getAdminView().getQueues();
-      if (queues.length == 1) {
-         QueueViewMBean queueViewMBean = (QueueViewMBean) brokerService.getManagementContext().newProxyInstance(queues[0], QueueViewMBean.class, false);
-         queueViewMBean.purge();
-      }
-   }
-
-   @Test
-   @Ignore("comparison test - takes too long and really needs a peek at the graph")
-   public void testPerf() throws Exception {
-      LinkedHashMap<Integer, Long> resultsT = new LinkedHashMap<>();
-      LinkedHashMap<Integer, Long> resultsF = new LinkedHashMap<>();
-
-      for (int i = 2; i < 11; i++) {
-         for (Boolean concurrent : new Boolean[]{true, false}) {
-            startBroker(i, concurrent, false);
-
-            long startTime = System.currentTimeMillis();
-            produceMessages(new AtomicLong(messageCount), target);
-            long endTime = System.currentTimeMillis();
-            long seconds = (endTime - startTime) / 1000;
-            LOG.info("For routes {} duration {}", i, seconds);
-            if (concurrent) {
-               resultsT.put(i, seconds);
-            }
-            else {
-               resultsF.put(i, seconds);
-            }
-            brokerService.stop();
-            brokerService.waitUntilStopped();
-         }
-      }
-      LOG.info("results T{} F{}", resultsT, resultsF);
-      LOG.info("http://www.chartgo.com/samples.do?chart=line&border=1&show3d=0&width=600&height=500&roundedge=1&transparency=1&legend=1&title=Send:10k::Concurrent-v-Serial&xtitle=routes&ytitle=Duration(seconds)&chrtbkgndcolor=white&threshold=0.0&lang=en" + "&xaxis1=" + toStr(resultsT.keySet()) + "&yaxis1=" + toStr(resultsT.values()) + "&group1=concurrent" + "&xaxis2=" + toStr(resultsF.keySet()) + "&yaxis2=" + toStr(resultsF.values()) + "&group2=serial" + "&from=linejsp");
-   }
-
-   private String toStr(Collection set) {
-      return set.toString().replace(",", "%0D%0A").replace("[", "").replace("]", "").replace(" ", "");
-   }
-
-   protected void produceMessages(AtomicLong messageCount, ActiveMQDestination destination) throws Exception {
-      final ByteSequence payLoad = new ByteSequence(new byte[messageSize]);
-      Connection connection = connectionFactory.createConnection();
-      MessageProducer messageProducer = connection.createSession(false, Session.AUTO_ACKNOWLEDGE).createProducer(destination);
-      messageProducer.setDeliveryMode(DeliveryMode.PERSISTENT);
-      ActiveMQBytesMessage message = new ActiveMQBytesMessage();
-      message.setContent(payLoad);
-      while (messageCount.decrementAndGet() >= 0) {
-         messageProducer.send(message);
-      }
-      connection.close();
-   }
-
-   private void startBroker(int fanoutCount,
-                            boolean concurrentSend,
-                            boolean concurrentStoreAndDispatchQueues) throws Exception {
-      brokerService = new BrokerService();
-      brokerService.setDeleteAllMessagesOnStartup(true);
-      brokerService.setUseVirtualTopics(true);
-      brokerService.addConnector("tcp://0.0.0.0:0");
-      brokerService.setAdvisorySupport(false);
-      PolicyMap destPolicyMap = new PolicyMap();
-      PolicyEntry defaultEntry = new PolicyEntry();
-      defaultEntry.setExpireMessagesPeriod(0);
-      defaultEntry.setOptimizedDispatch(true);
-      defaultEntry.setCursorMemoryHighWaterMark(110);
-      destPolicyMap.setDefaultEntry(defaultEntry);
-      brokerService.setDestinationPolicy(destPolicyMap);
-
-      CompositeTopic route = new CompositeTopic();
-      route.setName("target");
-      route.setForwardOnly(true);
-      route.setConcurrentSend(concurrentSend);
-      Collection<ActiveMQQueue> routes = new ArrayList<>();
-      for (int i = 0; i < fanoutCount; i++) {
-         routes.add(new ActiveMQQueue("route." + i));
-      }
-      route.setForwardTo(routes);
-      VirtualDestinationInterceptor interceptor = new VirtualDestinationInterceptor();
-      interceptor.setVirtualDestinations(new VirtualDestination[]{route});
-      brokerService.setDestinationInterceptors(new DestinationInterceptor[]{interceptor});
-      brokerService.start();
-
-      connectionFactory = new ActiveMQConnectionFactory(brokerService.getTransportConnectors().get(0).getPublishableConnectString());
-      connectionFactory.setWatchTopicAdvisories(false);
-      if (brokerService.getPersistenceAdapter() instanceof KahaDBPersistenceAdapter) {
-
-         //with parallel sends and no consumers, concurrentStoreAnd dispatch, which uses a single thread by default
-         // will stop/impeed write batching. The num threads will need tweaking when consumers are in the mix but may introduce
-         // order issues
-         ((KahaDBPersistenceAdapter) brokerService.getPersistenceAdapter()).setConcurrentStoreAndDispatchQueues(concurrentStoreAndDispatchQueues);
-      }
-   }
-}


[30/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
index ffdfc6e..d34f943 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
@@ -16,22 +16,25 @@
  */
 package org.apache.activemq.broker;
 
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.net.ServerSocket;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.WeakHashMap;
-
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.activemq.ActiveMQConnectionMetaData;
 import org.apache.activemq.Service;
@@ -44,6 +47,8 @@ import org.apache.activemq.broker.region.policy.PolicyMap;
 import org.apache.activemq.broker.scheduler.JobSchedulerStore;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.BrokerId;
+import org.apache.activemq.network.ConnectionFilter;
+import org.apache.activemq.network.DiscoveryNetworkConnector;
 import org.apache.activemq.network.NetworkConnector;
 import org.apache.activemq.network.jms.JmsConnector;
 import org.apache.activemq.proxy.ProxyConnector;
@@ -57,6 +62,7 @@ import org.apache.activemq.usage.SystemUsage;
 import org.apache.activemq.util.IOExceptionHandler;
 import org.apache.activemq.util.IOHelper;
 import org.apache.activemq.util.ServiceStopper;
+import org.junit.rules.TemporaryFolder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -68,10 +74,12 @@ import org.slf4j.LoggerFactory;
 public class BrokerService implements Service {
 
    public static final String DEFAULT_PORT = "61616";
+   public static final AtomicInteger RANDOM_PORT_BASE = new AtomicInteger(51616);
    public static final String DEFAULT_BROKER_NAME = "localhost";
    public static final String BROKER_VERSION;
    public static final int DEFAULT_MAX_FILE_LENGTH = 1024 * 1024 * 32;
    public static final long DEFAULT_START_TIMEOUT = 600000L;
+   public static boolean disableWrapper = false;
 
    public String SERVER_SIDE_KEYSTORE;
    public String KEYSTORE_PASSWORD;
@@ -99,6 +107,11 @@ public class BrokerService implements Service {
    private PolicyMap destinationPolicy;
    private SystemUsage systemUsage;
 
+   private boolean isClustered = true;
+   private final List<NetworkConnector> networkConnectors = new CopyOnWriteArrayList<NetworkConnector>();
+
+   private TemporaryFolder tmpfolder;
+
    public static WeakHashMap<Broker, Exception> map = new WeakHashMap<>();
 
    static {
@@ -131,6 +144,10 @@ public class BrokerService implements Service {
 
    @Override
    public void start() throws Exception {
+      File targetTmp = new File("./target/tmp");
+      targetTmp.mkdirs();
+      tmpfolder = new TemporaryFolder(targetTmp);
+      tmpfolder.create();
       Exception e = new Exception();
       e.fillInStackTrace();
       startBroker(startAsync);
@@ -188,10 +205,10 @@ public class BrokerService implements Service {
       LOG.info("Apache ActiveMQ Artemis{} ({}, {}) is shutting down", new Object[]{getBrokerVersion(), getBrokerName(), brokerId});
 
       if (broker != null) {
-         System.out.println("______________________stopping broker: " + broker.getClass().getName());
          broker.stop();
          broker = null;
       }
+      tmpfolder.delete();
       LOG.info("Apache ActiveMQ Artemis {} ({}, {}) is shutdown", new Object[]{getBrokerVersion(), getBrokerName(), brokerId});
    }
 
@@ -200,7 +217,7 @@ public class BrokerService implements Service {
 
    public Broker getBroker() throws Exception {
       if (broker == null) {
-         broker = createBroker();
+         broker = createBroker(tmpfolder.getRoot());
       }
       return broker;
    }
@@ -220,13 +237,14 @@ public class BrokerService implements Service {
       this.brokerName = str.trim();
    }
 
-   protected Broker createBroker() throws Exception {
-      broker = createBrokerWrapper();
+   protected Broker createBroker(File temporaryFile) throws Exception {
+      new Exception("file=" + temporaryFile.getAbsolutePath()).printStackTrace();
+      broker = createBrokerWrapper(temporaryFile);
       return broker;
    }
 
-   private Broker createBrokerWrapper() {
-      return new ArtemisBrokerWrapper(this);
+   private Broker createBrokerWrapper(File temporaryFile) {
+      return new ArtemisBrokerWrapper(this, temporaryFile);
    }
 
    public void makeSureDestinationExists(ActiveMQDestination activemqDestination) throws Exception {
@@ -382,10 +400,6 @@ public class BrokerService implements Service {
    public void setKeepDurableSubsActive(boolean keepDurableSubsActive) {
    }
 
-   public NetworkConnector addNetworkConnector(String discoveryAddress) throws Exception {
-      return null;
-   }
-
    public TransportConnector getConnectorByName(String connectorName) {
       return null;
    }
@@ -407,8 +421,17 @@ public class BrokerService implements Service {
    public void setSchedulerDirectoryFile(File schedulerDirectory) {
    }
 
+   public NetworkConnector addNetworkConnector(String discoveryAddress) throws Exception {
+      return addNetworkConnector(new URI(discoveryAddress));
+   }
+
+   public NetworkConnector addNetworkConnector(URI discoveryAddress) throws Exception {
+      NetworkConnector connector = new DiscoveryNetworkConnector(discoveryAddress);
+      return addNetworkConnector(connector);
+   }
+
    public List<NetworkConnector> getNetworkConnectors() {
-      return new ArrayList<>();
+      return this.networkConnectors;
    }
 
    public void setSchedulerSupport(boolean schedulerSupport) {
@@ -471,6 +494,30 @@ public class BrokerService implements Service {
    }
 
    public NetworkConnector addNetworkConnector(NetworkConnector connector) throws Exception {
+      connector.setBrokerService(this);
+
+      System.out.println("------------------------ this broker uri: " + this.getConnectURI());
+      connector.setLocalUri(this.getConnectURI());
+      // Set a connection filter so that the connector does not establish loop
+      // back connections.
+      connector.setConnectionFilter(new ConnectionFilter() {
+         @Override
+         public boolean connectTo(URI location) {
+            List<TransportConnector> transportConnectors = getTransportConnectors();
+            for (Iterator<TransportConnector> iter = transportConnectors.iterator(); iter.hasNext();) {
+               try {
+                  TransportConnector tc = iter.next();
+                  if (location.equals(tc.getConnectUri())) {
+                     return false;
+                  }
+               } catch (Throwable e) {
+               }
+            }
+            return true;
+         }
+      });
+
+      networkConnectors.add(connector);
       return connector;
    }
 
@@ -486,19 +533,63 @@ public class BrokerService implements Service {
 
    public TransportConnector addConnector(URI bindAddress) throws Exception {
       Integer port = bindAddress.getPort();
+      String host = bindAddress.getHost();
       FakeTransportConnector connector = null;
-      if (port != 0) {
-         connector = new FakeTransportConnector(bindAddress);
-         this.transportConnectors.add(connector);
-         this.extraConnectors.add(port);
+
+      host = (host == null || host.length() == 0) ? "localhost" : host;
+      if ("0.0.0.0".equals(host)) {
+         host = "localhost";
       }
-      else {
-         connector = new FakeTransportConnector(new URI(this.getDefaultUri()));
-         this.transportConnectors.add(connector);
+
+      if (port == 0) {
+         //In actual impl in amq5, after connector has been added the socket
+         //is bound already. This means in case of 0 port uri, the random
+         //port is available after this call. With artemis wrapper however
+         //the real binding happens during broker start. To work around this
+         //we use manually calculated port for that.
+         port = getPseudoRandomPort();
+
       }
+
+      System.out.println("Now host is: " + host);
+      bindAddress = new URI(bindAddress.getScheme(), bindAddress.getUserInfo(),
+              host, port, bindAddress.getPath(), bindAddress.getQuery(), bindAddress.getFragment());
+
+      connector = new FakeTransportConnector(bindAddress);
+      this.transportConnectors.add(connector);
+      this.extraConnectors.add(port);
+
       return connector;
    }
 
+   private int getPseudoRandomPort() {
+      int port = RANDOM_PORT_BASE.getAndIncrement();
+      while (!checkPort(port)) {
+         port = RANDOM_PORT_BASE.getAndIncrement();
+      }
+      return port;
+   }
+
+   private static boolean checkPort(final int port) {
+      ServerSocket ssocket = null;
+      try {
+         ssocket = new ServerSocket(port);
+      }
+      catch (Exception e) {
+         return false;
+      }
+      finally {
+         if (ssocket != null) {
+            try {
+               ssocket.close();
+            }
+            catch (IOException e) {
+            }
+         }
+      }
+      return true;
+   }
+
    public void setCacheTempDestinations(boolean cacheTempDestinations) {
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerBase.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerBase.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerBase.java
index 5c052a6..fb3c242 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerBase.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerBase.java
@@ -17,7 +17,6 @@
 package org.apache.activemq.broker.artemiswrapper;
 
 import java.io.File;
-import java.io.IOException;
 import java.net.URI;
 import java.util.HashMap;
 import java.util.Map;
@@ -65,7 +64,6 @@ import org.apache.activemq.command.TransactionId;
 import org.apache.activemq.store.PListStore;
 import org.apache.activemq.thread.Scheduler;
 import org.apache.activemq.usage.Usage;
-import org.junit.rules.TemporaryFolder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -83,20 +81,19 @@ public abstract class ArtemisBrokerBase implements Broker {
    protected volatile boolean stopped;
    protected BrokerId brokerId = new BrokerId("Artemis Broker");
    protected BrokerService bservice;
-   protected TemporaryFolder temporaryFolder = new TemporaryFolder();
-   protected String testDir;
+
+   protected final File temporaryFolder;
+   protected final String testDir;
    protected boolean realStore = false;
 
    protected ActiveMQServer server;
 
    protected boolean enableSecurity = false;
 
-   public ArtemisBrokerBase() {
-      try {
-         this.temporaryFolder.create();
-      }
-      catch (IOException e) {
-      }
+   public ArtemisBrokerBase(File temporaryFolder) {
+      this.temporaryFolder = temporaryFolder;
+      this.testDir = temporaryFolder.getAbsolutePath();
+
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
index 61d6250..3ad6072 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.broker.artemiswrapper;
 
+import java.io.File;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -46,20 +47,16 @@ public class ArtemisBrokerWrapper extends ArtemisBrokerBase {
    protected final Map<String, SimpleString> testQueues = new HashMap<>();
    protected JMSServerManagerImpl jmsServer;
 
-   public ArtemisBrokerWrapper(BrokerService brokerService) {
+   public ArtemisBrokerWrapper(BrokerService brokerService, File temporaryFolder) {
+      super(temporaryFolder);
       this.bservice = brokerService;
    }
 
    @Override
    public void start() throws Exception {
-      testDir = temporaryFolder.getRoot().getAbsolutePath();
       clearDataRecreateServerDirs();
       server = createServer(realStore, true);
       server.getConfiguration().getAcceptorConfigurations().clear();
-      HashMap<String, Object> params = new HashMap<>();
-      params.put(TransportConstants.PORT_PROP_NAME, "61616");
-      params.put(TransportConstants.PROTOCOLS_PROP_NAME, "OPENWIRE,CORE");
-      TransportConfiguration transportConfiguration = new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, params);
 
       Configuration serverConfig = server.getConfiguration();
 
@@ -82,9 +79,11 @@ public class ArtemisBrokerWrapper extends ArtemisBrokerBase {
       commonSettings.setDeadLetterAddress(dla);
       commonSettings.setAutoCreateJmsQueues(true);
 
-      serverConfig.getAcceptorConfigurations().add(transportConfiguration);
+      HashMap<String, Object> params = new HashMap<String, Object>();
+      if (bservice.extraConnectors.size() == 0) {
+         serverConfig.addAcceptorConfiguration("home", "tcp://localhost:61616?protocols=OPENWIRE,CORE");
+      }
       if (this.bservice.enableSsl()) {
-         params = new HashMap<>();
          params.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
          params.put(TransportConstants.PORT_PROP_NAME, 61611);
          params.put(TransportConstants.PROTOCOLS_PROP_NAME, "OPENWIRE");
@@ -102,14 +101,7 @@ public class ArtemisBrokerWrapper extends ArtemisBrokerBase {
       }
 
       for (Integer port : bservice.extraConnectors) {
-         if (port.intValue() != 61616) {
-            //extra port
-            params = new HashMap<>();
-            params.put(TransportConstants.PORT_PROP_NAME, port.intValue());
-            params.put(TransportConstants.PROTOCOLS_PROP_NAME, "OPENWIRE");
-            TransportConfiguration extraTransportConfiguration = new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, params);
-            serverConfig.getAcceptorConfigurations().add(extraTransportConfiguration);
-         }
+         serverConfig.addAcceptorConfiguration("homePort" + port, "tcp://localhost:" + port + "?protocols=OPENWIRE,CORE");
       }
 
       serverConfig.setSecurityEnabled(enableSecurity);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/OpenwireArtemisBaseTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/OpenwireArtemisBaseTest.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/OpenwireArtemisBaseTest.java
new file mode 100644
index 0000000..be9cf06
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/OpenwireArtemisBaseTest.java
@@ -0,0 +1,266 @@
+/**
+ * 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.broker.artemiswrapper;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
+import org.apache.activemq.artemis.api.jms.management.JMSQueueControl;
+import org.apache.activemq.artemis.api.jms.management.JMSServerControl;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
+import org.apache.activemq.artemis.core.server.JournalType;
+import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.activemq.broker.BrokerService;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.rules.TemporaryFolder;
+import org.junit.rules.TestName;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerInvocationHandler;
+import javax.management.ObjectName;
+
+public class OpenwireArtemisBaseTest {
+
+   @Rule
+   public TemporaryFolder temporaryFolder;
+   @Rule
+   public TestName name = new TestName();
+
+   public OpenwireArtemisBaseTest() {
+      File tmpRoot = new File("./target/tmp");
+      tmpRoot.mkdirs();
+      temporaryFolder = new TemporaryFolder(tmpRoot);
+      //The wrapper stuff will automatically create a default
+      //server on a normal connection factory, which will
+      //cause problems with clustering tests, which starts
+      //all servers explicitly. Setting this to true
+      //can prevent the auto-creation from happening.
+      BrokerService.disableWrapper = true;
+   }
+
+
+   public String getTmp() {
+      return getTmpFile().getAbsolutePath();
+   }
+
+   public File getTmpFile() {
+      return temporaryFolder.getRoot();
+   }
+
+   protected String getJournalDir(int serverID, boolean backup) {
+      return getTmp() + "/journal_" + serverID + "_" + backup;
+   }
+
+   protected String getBindingsDir(int serverID, boolean backup) {
+      return getTmp() + "/binding_" + serverID + "_" + backup;
+   }
+
+   protected String getPageDir(int serverID, boolean backup) {
+      return getTmp() + "/paging_" + serverID + "_" + backup;
+   }
+
+   protected String getLargeMessagesDir(int serverID, boolean backup) {
+      return getTmp() + "/paging_" + serverID + "_" + backup;
+   }
+
+   public String CLUSTER_PASSWORD = "OPENWIRECLUSTER";
+
+   protected Configuration createConfig(final int serverID) throws Exception {
+      return createConfig("localhost", serverID);
+   }
+
+   protected Configuration createConfig(final String hostAddress, final int serverID, final int port) throws Exception {
+      ConfigurationImpl configuration = new ConfigurationImpl().setJMXManagementEnabled(false).
+         setSecurityEnabled(false).setJournalMinFiles(2).setJournalFileSize(1000 * 1024).setJournalType(JournalType.NIO).
+         setJournalDirectory(getJournalDir(serverID, false)).
+         setBindingsDirectory(getBindingsDir(serverID, false)).
+         setPagingDirectory(getPageDir(serverID, false)).
+         setLargeMessagesDirectory(getLargeMessagesDir(serverID, false)).
+         setJournalCompactMinFiles(0).
+         setJournalCompactPercentage(0).
+         setClusterPassword(CLUSTER_PASSWORD);
+
+      configuration.addAddressesSetting("#", new AddressSettings().setAutoCreateJmsQueues(true).setAutoDeleteJmsQueues(true));
+
+      configuration.addAcceptorConfiguration("netty", newURIwithPort(hostAddress, port));
+      configuration.addConnectorConfiguration("netty-connector", newURIwithPort(hostAddress, port));
+
+      return configuration;
+   }
+
+   protected Configuration createConfig(final String hostAddress, final int serverID) throws Exception {
+      ConfigurationImpl configuration = new ConfigurationImpl().setJMXManagementEnabled(false).
+              setSecurityEnabled(false).setJournalMinFiles(2).setJournalFileSize(1000 * 1024).setJournalType(JournalType.NIO).
+              setJournalDirectory(getJournalDir(serverID, false)).
+              setBindingsDirectory(getBindingsDir(serverID, false)).
+              setPagingDirectory(getPageDir(serverID, false)).
+              setLargeMessagesDirectory(getLargeMessagesDir(serverID, false)).
+              setJournalCompactMinFiles(0).
+              setJournalCompactPercentage(0).
+              setClusterPassword(CLUSTER_PASSWORD);
+
+      configuration.addAddressesSetting("#", new AddressSettings().setAutoCreateJmsQueues(true).setAutoDeleteJmsQueues(true));
+
+      configuration.addAcceptorConfiguration("netty", newURI(hostAddress, serverID));
+      configuration.addConnectorConfiguration("netty-connector", newURI(hostAddress, serverID));
+
+      return configuration;
+   }
+
+   //extraAcceptor takes form: "?name=value&name1=value ..."
+   protected Configuration createConfig(final int serverID, String extraAcceptorParams) throws Exception {
+      ConfigurationImpl configuration = new ConfigurationImpl().setJMXManagementEnabled(false).
+              setSecurityEnabled(false).setJournalMinFiles(2).setJournalFileSize(100 * 1024).setJournalType(JournalType.NIO).
+              setJournalDirectory(getJournalDir(serverID, false)).
+              setBindingsDirectory(getBindingsDir(serverID, false)).
+              setPagingDirectory(getPageDir(serverID, false)).
+              setLargeMessagesDirectory(getLargeMessagesDir(serverID, false)).
+              setJournalCompactMinFiles(0).
+              setJournalCompactPercentage(0).
+              setClusterPassword(CLUSTER_PASSWORD);
+
+      configuration.addAddressesSetting("#", new AddressSettings().setAutoCreateJmsQueues(true).setAutoDeleteJmsQueues(true));
+
+      String fullAcceptorUri = newURI(serverID) + extraAcceptorParams;
+      configuration.addAcceptorConfiguration("netty", fullAcceptorUri);
+
+      configuration.addConnectorConfiguration("netty-connector", newURI(serverID));
+      return configuration;
+   }
+
+   public void deployClusterConfiguration(Configuration config, Integer ... targetIDs) throws Exception {
+      StringBuffer stringBuffer = new StringBuffer();
+      String separator = "";
+      for (int x : targetIDs) {
+         stringBuffer.append(separator + newURI(x));
+         separator = ",";
+      }
+
+      String ccURI = "static://(" + stringBuffer.toString() + ")?connectorName=netty-connector;retryInterval=500;messageLoadBalancingType=STRICT;maxHops=1";
+
+      config.addClusterConfiguration("clusterCC", ccURI);
+   }
+
+   protected static String newURI(int serverID) {
+      return newURI("localhost", serverID);
+   }
+
+   protected static String newURI(String localhostAddress, int serverID) {
+      return "tcp://" + localhostAddress + ":" + (61616 + serverID);
+   }
+
+   protected static String newURIwithPort(String localhostAddress, int port) {
+      return "tcp://" + localhostAddress + ":" + port;
+   }
+
+   public static JMSServerControl createJMSServerControl(final MBeanServer mbeanServer) throws Exception {
+      return (JMSServerControl) createProxy(ObjectNameBuilder.DEFAULT.getJMSServerObjectName(), JMSServerControl.class, mbeanServer);
+   }
+
+   public static JMSQueueControl createJMSQueueControl(final String name,
+                                                       final MBeanServer mbeanServer) throws Exception {
+      return (JMSQueueControl) createProxy(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(name), JMSQueueControl.class, mbeanServer);
+   }
+
+   private static Object createProxy(final ObjectName objectName,
+                                     final Class mbeanInterface,
+                                     final MBeanServer mbeanServer) {
+      return MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName, mbeanInterface, false);
+   }
+
+   protected void shutDownClusterServers(EmbeddedJMS[] servers) throws Exception {
+      for (int i = 0; i < servers.length; i++) {
+         try {
+            servers[i].stop();
+         }
+         catch (Throwable t) {
+            t.printStackTrace();
+         }
+      }
+   }
+
+   protected void shutDownNonClusterServers(EmbeddedJMS[] servers) throws Exception {
+      shutDownClusterServers(servers);
+   }
+
+   protected void setUpNonClusterServers(EmbeddedJMS[] servers) throws Exception {
+
+      Configuration[] serverCfgs = new Configuration[servers.length];
+      for (int i = 0; i < servers.length; i++) {
+         serverCfgs[i] = createConfig(i);
+      }
+
+      for (int i = 0; i < servers.length; i++) {
+         servers[i] = new EmbeddedJMS().setConfiguration(serverCfgs[i]).setJmsConfiguration(new JMSConfigurationImpl());
+      }
+
+      for (int i = 0; i < servers.length; i++) {
+         servers[i].start();
+      }
+   }
+
+   protected void setUpClusterServers(EmbeddedJMS[] servers) throws Exception {
+
+      Configuration[] serverCfgs = new Configuration[servers.length];
+      for (int i = 0; i < servers.length; i++) {
+         serverCfgs[i] = createConfig(i);
+      }
+
+      for (int i = 0; i < servers.length; i++) {
+         deployClusterConfiguration(serverCfgs[i], getTargets(servers.length, i));
+      }
+
+      for (int i = 0; i < servers.length; i++) {
+         servers[i] = new EmbeddedJMS().setConfiguration(serverCfgs[i]).setJmsConfiguration(new JMSConfigurationImpl());
+      }
+
+      for (int i = 0; i < servers.length; i++) {
+         servers[i].start();
+      }
+
+      for (int i = 0; i < servers.length; i++) {
+         Assert.assertTrue(servers[i].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, servers.length));
+      }
+   }
+
+   private Integer[] getTargets(int total, int self)
+   {
+      int lenTargets = total - self;
+      List<Integer> targets = new ArrayList<>();
+      for (int i = 0; i < lenTargets; i++) {
+         if (i != self) {
+            targets.add(i);
+         }
+      }
+      return targets.toArray(new Integer[0]);
+   }
+
+   public EmbeddedJMS createBroker() throws Exception {
+      Configuration config0 = createConfig(0);
+      EmbeddedJMS newbroker = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
+      return newbroker;
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
index 34babf8..0843d3a 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
@@ -20,6 +20,7 @@ import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.UnknownHostException;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -29,6 +30,7 @@ import javax.net.SocketFactory;
 import org.apache.activemq.TransportLoggerSupport;
 import org.apache.activemq.artemiswrapper.ArtemisBrokerHelper;
 import org.apache.activemq.broker.BrokerRegistry;
+import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.openwire.OpenWireFormat;
 import org.apache.activemq.transport.*;
 import org.apache.activemq.util.IOExceptionSupport;
@@ -54,11 +56,10 @@ public class TcpTransportFactory extends TransportFactory {
       //here check broker, if no broker, we start one
       Map<String, String> params = URISupport.parseParameters(location);
       String brokerId = params.remove("invmBrokerId");
-      params.clear();
-      location = URISupport.createRemainingURI(location, params);
-      if (brokerService == null) {
+      URI location1 = URISupport.createRemainingURI(location, Collections.EMPTY_MAP);
+      if (brokerService == null && !BrokerService.disableWrapper) {
 
-         ArtemisBrokerHelper.startArtemisBroker(location);
+         ArtemisBrokerHelper.startArtemisBroker(location1);
          brokerService = location.toString();
 
          if (brokerId != null) {
@@ -66,7 +67,8 @@ public class TcpTransportFactory extends TransportFactory {
             System.out.println("bound: " + brokerId);
          }
       }
-      return super.doConnect(location);
+      URI location2 = URISupport.createRemainingURI(location, params);
+      return super.doConnect(location2);
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQInputStreamTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQInputStreamTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQInputStreamTest.java
deleted file mode 100644
index fd06de9..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQInputStreamTest.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * 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;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import javax.jms.Queue;
-import javax.jms.Session;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated
-public class ActiveMQInputStreamTest extends TestCase {
-
-   private static final Logger LOG = LoggerFactory.getLogger(ActiveMQInputStreamTest.class);
-
-   private static final String BROKER_URL = "tcp://localhost:0";
-   private static final String DESTINATION = "destination";
-   private static final int STREAM_LENGTH = 64 * 1024 + 0; // change 0 to 1 to make it not crash
-
-   private BrokerService broker;
-   private String connectionUri;
-
-   @Override
-   public void setUp() throws Exception {
-      broker = new BrokerService();
-      broker.setUseJmx(false);
-      broker.setPersistent(false);
-      broker.setDestinations(new ActiveMQDestination[]{ActiveMQDestination.createDestination(DESTINATION, ActiveMQDestination.QUEUE_TYPE),});
-      broker.addConnector(BROKER_URL);
-      broker.start();
-      broker.waitUntilStarted();
-
-      //some internal api we don't implement
-      connectionUri = broker.getDefaultUri();
-   }
-
-   @Override
-   public void tearDown() throws Exception {
-      broker.stop();
-      broker.waitUntilStopped();
-   }
-
-   public void testInputStreamSetSyncSendOption() throws Exception {
-
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(connectionUri);
-      ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Queue destination = session.createQueue(DESTINATION + "?producer.alwaysSyncSend=true");
-
-      OutputStream out = null;
-      try {
-         out = connection.createOutputStream(destination);
-
-         assertTrue(((ActiveMQOutputStream) out).isAlwaysSyncSend());
-
-         LOG.debug("writing...");
-         for (int i = 0; i < STREAM_LENGTH; ++i) {
-            out.write(0);
-         }
-         LOG.debug("wrote " + STREAM_LENGTH + " bytes");
-      }
-      finally {
-         if (out != null) {
-            out.close();
-         }
-      }
-
-      InputStream in = null;
-      try {
-         in = connection.createInputStream(destination);
-         LOG.debug("reading...");
-         int count = 0;
-         while (-1 != in.read()) {
-            ++count;
-         }
-         LOG.debug("read " + count + " bytes");
-      }
-      finally {
-         if (in != null) {
-            in.close();
-         }
-      }
-
-      connection.close();
-   }
-
-   public void testInputStreamMatchesDefaultChuckSize() throws Exception {
-
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(connectionUri);
-      ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Queue destination = session.createQueue(DESTINATION);
-
-      OutputStream out = null;
-      try {
-         out = connection.createOutputStream(destination);
-         LOG.debug("writing...");
-         for (int i = 0; i < STREAM_LENGTH; ++i) {
-            out.write(0);
-         }
-         LOG.debug("wrote " + STREAM_LENGTH + " bytes");
-      }
-      finally {
-         if (out != null) {
-            out.close();
-         }
-      }
-
-      InputStream in = null;
-      try {
-         in = connection.createInputStream(destination);
-         LOG.debug("reading...");
-         int count = 0;
-         while (-1 != in.read()) {
-            ++count;
-         }
-         LOG.debug("read " + count + " bytes");
-      }
-      finally {
-         if (in != null) {
-            in.close();
-         }
-      }
-
-      connection.close();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/AutoFailTestSupport.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/AutoFailTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/AutoFailTestSupport.java
new file mode 100644
index 0000000..f47620f
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/AutoFailTestSupport.java
@@ -0,0 +1,159 @@
+/**
+ * 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;
+
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import junit.framework.TestCase;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Enforces a test case to run for only an allotted time to prevent them from
+ * hanging and breaking the whole testing.
+ *
+ *
+ */
+
+public abstract class AutoFailTestSupport extends TestCase {
+    public static final int EXIT_SUCCESS = 0;
+    public static final int EXIT_ERROR = 1;
+    private static final Logger LOG = LoggerFactory.getLogger(AutoFailTestSupport.class);
+
+    private long maxTestTime = 5 * 60 * 1000; // 5 mins by default
+    private Thread autoFailThread;
+
+    private boolean verbose = true;
+    private boolean useAutoFail; // Disable auto fail by default
+    private AtomicBoolean isTestSuccess;
+
+    protected void setUp() throws Exception {
+        // Runs the auto fail thread before performing any setup
+        if (isAutoFail()) {
+            startAutoFailThread();
+        }
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+
+        // Stops the auto fail thread only after performing any clean up
+        stopAutoFailThread();
+    }
+
+    /**
+     * Manually start the auto fail thread. To start it automatically, just set
+     * the auto fail to true before calling any setup methods. As a rule, this
+     * method is used only when you are not sure, if the setUp and tearDown
+     * method is propagated correctly.
+     */
+    public void startAutoFailThread() {
+        setAutoFail(true);
+        isTestSuccess = new AtomicBoolean(false);
+        autoFailThread = new Thread(new Runnable() {
+            public void run() {
+                try {
+                    // Wait for test to finish succesfully
+                    Thread.sleep(getMaxTestTime());
+                } catch (InterruptedException e) {
+                    // This usually means the test was successful
+                } finally {
+                    // Check if the test was able to tear down succesfully,
+                    // which usually means, it has finished its run.
+                    if (!isTestSuccess.get()) {
+                        LOG.error("Test case has exceeded the maximum allotted time to run of: " + getMaxTestTime() + " ms.");
+                        dumpAllThreads(getName());
+                        if (System.getProperty("org.apache.activemq.AutoFailTestSupport.disableSystemExit") == null) {
+                            System.exit(EXIT_ERROR);
+                        } else {
+                            LOG.error("No system.exit as it kills surefire - forkedProcessTimeoutInSeconds (surefire.timeout) will kick in eventually see pom.xml surefire plugin config");
+                        }
+                    }
+                }
+            }
+        }, "AutoFailThread");
+
+        if (verbose) {
+            LOG.info("Starting auto fail thread...");
+        }
+
+        LOG.info("Starting auto fail thread...");
+        autoFailThread.start();
+    }
+
+    /**
+     * Manually stops the auto fail thread. As a rule, this method is used only
+     * when you are not sure, if the setUp and tearDown method is propagated
+     * correctly.
+     */
+    public void stopAutoFailThread() {
+        if (isAutoFail() && autoFailThread != null && autoFailThread.isAlive()) {
+            isTestSuccess.set(true);
+
+            if (verbose) {
+                LOG.info("Stopping auto fail thread...");
+            }
+
+            LOG.info("Stopping auto fail thread...");
+            autoFailThread.interrupt();
+        }
+    }
+
+    /**
+     * Sets the auto fail value. As a rule, this should be used only before any
+     * setup methods is called to automatically enable the auto fail thread in
+     * the setup method of the test case.
+     *
+     * @param val
+     */
+    public void setAutoFail(boolean val) {
+        this.useAutoFail = val;
+    }
+
+    public boolean isAutoFail() {
+        return this.useAutoFail;
+    }
+
+    /**
+     * The assigned value will only be reflected when the auto fail thread has
+     * started its run. Value is in milliseconds.
+     *
+     * @param val
+     */
+    public void setMaxTestTime(long val) {
+        this.maxTestTime = val;
+    }
+
+    public long getMaxTestTime() {
+        return this.maxTestTime;
+    }
+
+
+    public static void dumpAllThreads(String prefix) {
+        Map<Thread, StackTraceElement[]> stacks = Thread.getAllStackTraces();
+        for (Entry<Thread, StackTraceElement[]> stackEntry : stacks.entrySet()) {
+            System.err.println(prefix + " " + stackEntry.getKey());
+            for(StackTraceElement element : stackEntry.getValue()) {
+                System.err.println("     " + element);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ConnectionCleanupTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ConnectionCleanupTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ConnectionCleanupTest.java
index 5e5b993..b8397e2 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ConnectionCleanupTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ConnectionCleanupTest.java
@@ -52,22 +52,50 @@ public class ConnectionCleanupTest extends TestCase {
 
       try {
          connection.setClientID("test");
-         // fail("Should have received JMSException");
+         fail("Should have received JMSException");
       }
       catch (JMSException e) {
       }
 
-      connection.cleanup();
+      connection.doCleanup(true);
       connection.setClientID("test");
 
       connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 
       try {
          connection.setClientID("test");
-         // fail("Should have received JMSException");
+         fail("Should have received JMSException");
       }
       catch (JMSException e) {
       }
    }
 
+   public void testChangeClientIDDenied() throws JMSException {
+
+      connection.setClientID("test");
+      connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      try {
+         connection.setClientID("test");
+         fail("Should have received JMSException");
+      } catch (JMSException e) {
+      }
+
+      connection.cleanup();
+
+      try {
+         connection.setClientID("test");
+         fail("Should have received JMSException");
+      } catch (JMSException e) {
+      }
+
+      connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      try {
+         connection.setClientID("test");
+         fail("Should have received JMSException");
+      } catch (JMSException e) {
+      }
+   }
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/EmbeddedBrokerTestSupport.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/EmbeddedBrokerTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/EmbeddedBrokerTestSupport.java
index fa58ebe..b8dea70 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/EmbeddedBrokerTestSupport.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/EmbeddedBrokerTestSupport.java
@@ -16,15 +16,23 @@
  */
 package org.apache.activemq;
 
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
+import org.apache.activemq.artemis.core.server.JournalType;
+import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ActiveMQQueue;
 import org.apache.activemq.command.ActiveMQTopic;
+import org.junit.rules.TemporaryFolder;
 import org.springframework.jms.core.JmsTemplate;
 
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
 import javax.jms.Destination;
+import java.io.File;
 
 /**
  * A useful base class which creates and closes an embedded broker
@@ -32,17 +40,26 @@ import javax.jms.Destination;
 public abstract class EmbeddedBrokerTestSupport extends CombinationTestSupport {
 
    protected BrokerService broker;
-   // protected String bindAddress = "tcp://localhost:61616";
-   protected String bindAddress = "vm://localhost";
+   protected EmbeddedJMS artemisBroker;
+   protected String bindAddress = "tcp://localhost:61616";
    protected ConnectionFactory connectionFactory;
    protected boolean useTopic;
    protected ActiveMQDestination destination;
    protected JmsTemplate template;
 
-   @Override
+   public TemporaryFolder temporaryFolder;
+
+   public String CLUSTER_PASSWORD = "OPENWIRECLUSTER";
+
    protected void setUp() throws Exception {
-      if (broker == null) {
-         broker = createBroker();
+      BrokerService.disableWrapper = true;
+      File tmpRoot = new File("./target/tmp");
+      tmpRoot.mkdirs();
+      temporaryFolder = new TemporaryFolder(tmpRoot);
+      temporaryFolder.create();
+
+      if (artemisBroker == null) {
+         artemisBroker = createArtemisBroker();
       }
       startBroker();
 
@@ -58,13 +75,42 @@ public abstract class EmbeddedBrokerTestSupport extends CombinationTestSupport {
 
    @Override
    protected void tearDown() throws Exception {
-      if (broker != null) {
+      if (artemisBroker != null) {
          try {
-            broker.stop();
+            artemisBroker.stop();
          }
          catch (Exception e) {
          }
       }
+      temporaryFolder.delete();
+   }
+
+   public String getTmp() {
+      return getTmpFile().getAbsolutePath();
+   }
+
+   public File getTmpFile() {
+      return temporaryFolder.getRoot();
+   }
+
+   protected String getJournalDir(int serverID, boolean backup) {
+      return getTmp() + "/journal_" + serverID + "_" + backup;
+   }
+
+   protected String getBindingsDir(int serverID, boolean backup) {
+      return getTmp() + "/binding_" + serverID + "_" + backup;
+   }
+
+   protected String getPageDir(int serverID, boolean backup) {
+      return getTmp() + "/paging_" + serverID + "_" + backup;
+   }
+
+   protected String getLargeMessagesDir(int serverID, boolean backup) {
+      return getTmp() + "/paging_" + serverID + "_" + backup;
+   }
+
+   protected static String newURI(String localhostAddress, int serverID) {
+      return "tcp://" + localhostAddress + ":" + (61616 + serverID);
    }
 
    /**
@@ -114,20 +160,44 @@ public abstract class EmbeddedBrokerTestSupport extends CombinationTestSupport {
       return new ActiveMQConnectionFactory(bindAddress);
    }
 
-   /**
-    * Factory method to create a new broker
-    *
-    * @throws Exception
-    */
+
+   public EmbeddedJMS createArtemisBroker() throws Exception {
+      Configuration config0 = createConfig("localhost", 0);
+      EmbeddedJMS newbroker = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
+      return newbroker;
+   }
+
+   protected Configuration createConfig(final String hostAddress, final int serverID) throws Exception {
+      ConfigurationImpl configuration = new ConfigurationImpl().setJMXManagementEnabled(false).
+              setSecurityEnabled(false).setJournalMinFiles(2).setJournalFileSize(1000 * 1024).setJournalType(JournalType.NIO).
+              setJournalDirectory(getJournalDir(serverID, false)).
+              setBindingsDirectory(getBindingsDir(serverID, false)).
+              setPagingDirectory(getPageDir(serverID, false)).
+              setLargeMessagesDirectory(getLargeMessagesDir(serverID, false)).
+              setJournalCompactMinFiles(0).
+              setJournalCompactPercentage(0).
+              setClusterPassword(CLUSTER_PASSWORD);
+
+      configuration.addAddressesSetting("#", new AddressSettings().setAutoCreateJmsQueues(true).setAutoDeleteJmsQueues(true));
+
+      configuration.addAcceptorConfiguration("netty", newURI(hostAddress, serverID));
+      configuration.addConnectorConfiguration("netty-connector", newURI(hostAddress, serverID));
+
+      return configuration;
+   }
+
+   //we keep this because some other tests uses it.
+   //we'll delete this when those tests are dealt with.
    protected BrokerService createBroker() throws Exception {
       BrokerService answer = new BrokerService();
       answer.setPersistent(isPersistent());
+      answer.getManagementContext().setCreateConnector(false);
       answer.addConnector(bindAddress);
       return answer;
    }
 
    protected void startBroker() throws Exception {
-      broker.start();
+      artemisBroker.start();
    }
 
    /**

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueTransactionTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueTransactionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueTransactionTest.java
new file mode 100755
index 0000000..b7c2e94
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueTransactionTest.java
@@ -0,0 +1,234 @@
+/**
+ * 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;
+
+import javax.jms.Destination;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.QueueBrowser;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import java.util.ArrayList;
+import java.util.Enumeration;
+
+import org.apache.activemq.test.JmsResourceProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ */
+public class JmsQueueTransactionTest extends JmsTransactionTestSupport {
+    private static final Logger LOG = LoggerFactory.getLogger(JmsQueueTransactionTest.class);
+
+    /**
+     * @see org.apache.activemq.JmsTransactionTestSupport#getJmsResourceProvider()
+     */
+    protected JmsResourceProvider getJmsResourceProvider() {
+        JmsResourceProvider p = new JmsResourceProvider();
+        p.setTopic(false);
+        return p;
+    }
+
+    /**
+     * Tests if the the connection gets reset, the messages will still be
+     * received.
+     *
+     * @throws Exception
+     */
+    public void testReceiveTwoThenCloseConnection() throws Exception {
+        Message[] outbound = new Message[] {session.createTextMessage("First Message"), session.createTextMessage("Second Message")};
+
+        // lets consume any outstanding messages from previous test runs
+        beginTx();
+        while (consumer.receive(1000) != null) {
+        }
+        commitTx();
+
+        beginTx();
+        producer.send(outbound[0]);
+        producer.send(outbound[1]);
+        commitTx();
+
+        LOG.info("Sent 0: " + outbound[0]);
+        LOG.info("Sent 1: " + outbound[1]);
+
+        ArrayList<Message> messages = new ArrayList<Message>();
+        beginTx();
+        Message message = consumer.receive(2000);
+        assertEquals(outbound[0], message);
+
+        message = consumer.receive(2000);
+        assertNotNull(message);
+        assertEquals(outbound[1], message);
+
+        // Close and reopen connection.
+        reconnect();
+
+        // Consume again.. the previous message should
+        // get redelivered.
+        beginTx();
+        message = consumer.receive(2000);
+        assertNotNull("Should have re-received the first message again!", message);
+        messages.add(message);
+        assertEquals(outbound[0], message);
+
+        message = consumer.receive(5000);
+        assertNotNull("Should have re-received the second message again!", message);
+        messages.add(message);
+        assertEquals(outbound[1], message);
+        commitTx();
+
+        Message inbound[] = new Message[messages.size()];
+        messages.toArray(inbound);
+
+        assertTextMessagesEqual("Rollback did not work", outbound, inbound);
+    }
+
+    /**
+     * Tests sending and receiving messages with two sessions(one for producing
+     * and another for consuming).
+     *
+     * @throws Exception
+     */
+    public void testSendReceiveInSeperateSessionTest() throws Exception {
+        session.close();
+        int batchCount = 10;
+
+        for (int i = 0; i < batchCount; i++) {
+            // Session that sends messages
+            {
+                Session session = resourceProvider.createSession(connection);
+                this.session = session;
+                MessageProducer producer = resourceProvider.createProducer(session, destination);
+                // consumer = resourceProvider.createConsumer(session,
+                // destination);
+                beginTx();
+                producer.send(session.createTextMessage("Test Message: " + i));
+                commitTx();
+                session.close();
+            }
+
+            // Session that consumes messages
+            {
+                Session session = resourceProvider.createSession(connection);
+                this.session = session;
+                MessageConsumer consumer = resourceProvider.createConsumer(session, destination);
+
+                beginTx();
+                TextMessage message = (TextMessage)consumer.receive(1000 * 5);
+                assertNotNull("Received only " + i + " messages in batch ", message);
+                assertEquals("Test Message: " + i, message.getText());
+
+                commitTx();
+                session.close();
+            }
+        }
+    }
+
+    /**
+     * Tests the queue browser. Browses the messages then the consumer tries to
+     * receive them. The messages should still be in the queue even when it was
+     * browsed.
+     *
+     * @throws Exception
+     */
+    public void testReceiveBrowseReceive() throws Exception {
+        Message[] outbound = new Message[] {session.createTextMessage("First Message"), session.createTextMessage("Second Message"), session.createTextMessage("Third Message")};
+
+        // lets consume any outstanding messages from previous test runs
+        beginTx();
+        while (consumer.receive(1000) != null) {
+        }
+        commitTx();
+
+        beginTx();
+        producer.send(outbound[0]);
+        producer.send(outbound[1]);
+        producer.send(outbound[2]);
+        commitTx();
+
+        // Get the first.
+        beginTx();
+        assertEquals(outbound[0], consumer.receive(1000));
+        consumer.close();
+        commitTx();
+
+        beginTx();
+        QueueBrowser browser = session.createBrowser((Queue)destination);
+        Enumeration enumeration = browser.getEnumeration();
+
+        // browse the second
+        assertTrue("should have received the second message", enumeration.hasMoreElements());
+        assertEquals(outbound[1], (Message)enumeration.nextElement());
+
+        // browse the third.
+        assertTrue("Should have received the third message", enumeration.hasMoreElements());
+        assertEquals(outbound[2], (Message)enumeration.nextElement());
+
+        LOG.info("Check for more...");
+        // There should be no more.
+        boolean tooMany = false;
+        while (enumeration.hasMoreElements()) {
+            LOG.info("Got extra message: " + ((TextMessage)enumeration.nextElement()).getText());
+            tooMany = true;
+        }
+        assertFalse(tooMany);
+        LOG.info("close browser...");
+        browser.close();
+
+        LOG.info("reopen and consume...");
+        // Re-open the consumer.
+        consumer = resourceProvider.createConsumer(session, destination);
+        // Receive the second.
+        assertEquals(outbound[1], consumer.receive(1000));
+        // Receive the third.
+        assertEquals(outbound[2], consumer.receive(1000));
+        consumer.close();
+
+        commitTx();
+    }
+
+    public void testCloseConsumer() throws Exception {
+        Destination dest = session.createQueue(getSubject() + "?consumer.prefetchSize=0");
+        producer = session.createProducer(dest);
+        beginTx();
+        producer.send(session.createTextMessage("message 1"));
+        producer.send(session.createTextMessage("message 2"));
+        commitTx();
+
+        beginTx();
+        consumer = session.createConsumer(dest);
+        Message message1 = consumer.receive(1000);
+        String text1 = ((TextMessage)message1).getText();
+        assertNotNull(message1);
+        assertEquals("message 1", text1);
+
+        consumer.close();
+
+        consumer = session.createConsumer(dest);
+
+        Message message2 = consumer.receive(1000);
+        String text2 = ((TextMessage)message2).getText();
+        assertNotNull(message2);
+        assertEquals("message 2", text2);
+        commitTx();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java
new file mode 100755
index 0000000..dfcf302
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTransactionTestSupport.java
@@ -0,0 +1,721 @@
+/**
+ * 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;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.activemq.broker.BrokerFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.test.JmsResourceProvider;
+import org.apache.activemq.test.TestSupport;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ */
+public abstract class JmsTransactionTestSupport extends TestSupport implements MessageListener {
+
+    private static final Logger LOG = LoggerFactory.getLogger(JmsTransactionTestSupport.class);
+    private static final int MESSAGE_COUNT = 5;
+    private static final String MESSAGE_TEXT = "message";
+
+    protected ConnectionFactory connectionFactory;
+    protected Connection connection;
+    protected Session session;
+    protected MessageConsumer consumer;
+    protected MessageProducer producer;
+    protected JmsResourceProvider resourceProvider;
+    protected Destination destination;
+    protected int batchCount = 10;
+    protected int batchSize = 20;
+    protected BrokerService broker;
+
+    // for message listener test
+    private final List<Message> unackMessages = new ArrayList<Message>(MESSAGE_COUNT);
+    private final List<Message> ackMessages = new ArrayList<Message>(MESSAGE_COUNT);
+    private boolean resendPhase;
+
+    public JmsTransactionTestSupport() {
+        super();
+    }
+
+    public JmsTransactionTestSupport(String name) {
+        super(name);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see junit.framework.TestCase#setUp()
+     */
+    @Override
+    protected void setUp() throws Exception {
+        broker = createBroker();
+        broker.start();
+        broker.waitUntilStarted();
+
+        resourceProvider = getJmsResourceProvider();
+        topic = resourceProvider.isTopic();
+        // We will be using transacted sessions.
+        setSessionTransacted();
+        connectionFactory = newConnectionFactory();
+        reconnect();
+    }
+
+    protected void setSessionTransacted() {
+        resourceProvider.setTransacted(true);
+    }
+
+    protected ConnectionFactory newConnectionFactory() throws Exception {
+        return resourceProvider.createConnectionFactory();
+    }
+
+    protected void beginTx() throws Exception {
+        //no-op for local tx
+    }
+
+    protected void commitTx() throws Exception {
+        session.commit();
+    }
+
+    protected void rollbackTx() throws Exception {
+        session.rollback();
+    }
+
+    /**
+     */
+    protected BrokerService createBroker() throws Exception, URISyntaxException {
+        return BrokerFactory.createBroker(new URI("broker://()/localhost?persistent=false"));
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see junit.framework.TestCase#tearDown()
+     */
+    @Override
+    protected void tearDown() throws Exception {
+        LOG.info("Closing down connection");
+
+        try {
+            session.close();
+            session = null;
+            connection.close();
+            connection = null;
+        } catch (Exception e) {
+            LOG.info("Caught exception while closing resources.");
+        }
+
+        try {
+            broker.stop();
+            broker.waitUntilStopped();
+            broker = null;
+        } catch (Exception e) {
+            LOG.info("Caught exception while shutting down the Broker", e);
+        }
+
+        LOG.info("Connection closed.");
+    }
+
+    protected abstract JmsResourceProvider getJmsResourceProvider();
+
+    /**
+     * Sends a batch of messages and validates that the messages are received.
+     *
+     * @throws Exception
+     */
+    public void testSendReceiveTransactedBatches() throws Exception {
+
+        TextMessage message = session.createTextMessage("Batch Message");
+        for (int j = 0; j < batchCount; j++) {
+            LOG.info("Producing bacth " + j + " of " + batchSize + " messages");
+
+            beginTx();
+            for (int i = 0; i < batchSize; i++) {
+                producer.send(message);
+            }
+            messageSent();
+            commitTx();
+            LOG.info("Consuming bacth " + j + " of " + batchSize + " messages");
+
+            beginTx();
+            for (int i = 0; i < batchSize; i++) {
+                message = (TextMessage)consumer.receive(1000 * 5);
+                assertNotNull("Received only " + i + " messages in batch " + j, message);
+                assertEquals("Batch Message", message.getText());
+            }
+
+            commitTx();
+        }
+    }
+
+    protected void messageSent() throws Exception {
+    }
+
+    /**
+     * Sends a batch of messages and validates that the rollbacked message was
+     * not consumed.
+     *
+     * @throws Exception
+     */
+    public void testSendRollback() throws Exception {
+        Message[] outbound = new Message[] {session.createTextMessage("First Message"), session.createTextMessage("Second Message")};
+
+        // sends a message
+        beginTx();
+        producer.send(outbound[0]);
+        commitTx();
+
+        // sends a message that gets rollbacked
+        beginTx();
+        producer.send(session.createTextMessage("I'm going to get rolled back."));
+        rollbackTx();
+
+        // sends a message
+        beginTx();
+        producer.send(outbound[1]);
+        commitTx();
+
+        // receives the first message
+        beginTx();
+        ArrayList<Message> messages = new ArrayList<Message>();
+        LOG.info("About to consume message 1");
+        Message message = consumer.receive(1000);
+        messages.add(message);
+        LOG.info("Received: " + message);
+
+        // receives the second message
+        LOG.info("About to consume message 2");
+        message = consumer.receive(4000);
+        messages.add(message);
+        LOG.info("Received: " + message);
+
+        // validates that the rollbacked was not consumed
+        commitTx();
+        Message inbound[] = new Message[messages.size()];
+        messages.toArray(inbound);
+        assertTextMessagesEqual("Rollback did not work.", outbound, inbound);
+    }
+
+    /**
+     * spec section 3.6 acking a message with automation acks has no effect.
+     * @throws Exception
+     */
+    public void testAckMessageInTx() throws Exception {
+        Message[] outbound = new Message[] {session.createTextMessage("First Message")};
+
+        // sends a message
+        beginTx();
+        producer.send(outbound[0]);
+        outbound[0].acknowledge();
+        commitTx();
+        outbound[0].acknowledge();
+
+        // receives the first message
+        beginTx();
+        ArrayList<Message> messages = new ArrayList<Message>();
+        LOG.info("About to consume message 1");
+        Message message = consumer.receive(1000);
+        messages.add(message);
+        LOG.info("Received: " + message);
+
+        // validates that the rollbacked was not consumed
+        commitTx();
+        Message inbound[] = new Message[messages.size()];
+        messages.toArray(inbound);
+        assertTextMessagesEqual("Message not delivered.", outbound, inbound);
+    }
+
+    /**
+     * Sends a batch of messages and validates that the message sent before
+     * session close is not consumed.
+     *
+     * This test only works with local transactions, not xa.
+     * @throws Exception
+     */
+    public void testSendSessionClose() throws Exception {
+        Message[] outbound = new Message[] {session.createTextMessage("First Message"), session.createTextMessage("Second Message")};
+
+        // sends a message
+        beginTx();
+        producer.send(outbound[0]);
+        commitTx();
+
+        // sends a message that gets rollbacked
+        beginTx();
+        producer.send(session.createTextMessage("I'm going to get rolled back."));
+        consumer.close();
+
+        reconnectSession();
+
+        // sends a message
+        producer.send(outbound[1]);
+        commitTx();
+
+        // receives the first message
+        ArrayList<Message> messages = new ArrayList<Message>();
+        LOG.info("About to consume message 1");
+        beginTx();
+        Message message = consumer.receive(1000);
+        messages.add(message);
+        LOG.info("Received: " + message);
+
+        // receives the second message
+        LOG.info("About to consume message 2");
+        message = consumer.receive(4000);
+        messages.add(message);
+        LOG.info("Received: " + message);
+
+        // validates that the rollbacked was not consumed
+        commitTx();
+        Message inbound[] = new Message[messages.size()];
+        messages.toArray(inbound);
+        assertTextMessagesEqual("Rollback did not work.", outbound, inbound);
+    }
+
+    /**
+     * Sends a batch of messages and validates that the message sent before
+     * session close is not consumed.
+     *
+     * @throws Exception
+     */
+    public void testSendSessionAndConnectionClose() throws Exception {
+        Message[] outbound = new Message[] {session.createTextMessage("First Message"), session.createTextMessage("Second Message")};
+
+        // sends a message
+        beginTx();
+        producer.send(outbound[0]);
+        commitTx();
+
+        // sends a message that gets rollbacked
+        beginTx();
+        producer.send(session.createTextMessage("I'm going to get rolled back."));
+        consumer.close();
+        session.close();
+
+        reconnect();
+
+        // sends a message
+        beginTx();
+        producer.send(outbound[1]);
+        commitTx();
+
+        // receives the first message
+        ArrayList<Message> messages = new ArrayList<Message>();
+        LOG.info("About to consume message 1");
+        beginTx();
+        Message message = consumer.receive(1000);
+        messages.add(message);
+        LOG.info("Received: " + message);
+
+        // receives the second message
+        LOG.info("About to consume message 2");
+        message = consumer.receive(4000);
+        messages.add(message);
+        LOG.info("Received: " + message);
+
+        // validates that the rollbacked was not consumed
+        commitTx();
+        Message inbound[] = new Message[messages.size()];
+        messages.toArray(inbound);
+        assertTextMessagesEqual("Rollback did not work.", outbound, inbound);
+    }
+
+    /**
+     * Sends a batch of messages and validates that the rollbacked message was
+     * redelivered.
+     *
+     * @throws Exception
+     */
+    public void testReceiveRollback() throws Exception {
+        Message[] outbound = new Message[] {session.createTextMessage("First Message"), session.createTextMessage("Second Message")};
+
+        // lets consume any outstanding messages from prev test runs
+        beginTx();
+            while (consumer.receive(1000) != null) {
+        }
+        commitTx();
+
+        // sent both messages
+        beginTx();
+        producer.send(outbound[0]);
+        producer.send(outbound[1]);
+        commitTx();
+
+        LOG.info("Sent 0: " + outbound[0]);
+        LOG.info("Sent 1: " + outbound[1]);
+
+        ArrayList<Message> messages = new ArrayList<Message>();
+        beginTx();
+        Message message = consumer.receive(1000);
+        messages.add(message);
+        assertEquals(outbound[0], message);
+        commitTx();
+
+        // rollback so we can get that last message again.
+        beginTx();
+        message = consumer.receive(1000);
+        assertNotNull(message);
+        assertEquals(outbound[1], message);
+        rollbackTx();
+
+        // Consume again.. the prev message should
+        // get redelivered.
+        beginTx();
+        message = consumer.receive(5000);
+        assertNotNull("Should have re-received the message again!", message);
+        messages.add(message);
+        commitTx();
+
+        Message inbound[] = new Message[messages.size()];
+        messages.toArray(inbound);
+        assertTextMessagesEqual("Rollback did not work", outbound, inbound);
+    }
+
+    /**
+     * Sends a batch of messages and validates that the rollbacked message was
+     * redelivered.
+     *
+     * @throws Exception
+     */
+    public void testReceiveTwoThenRollback() throws Exception {
+        Message[] outbound = new Message[] {session.createTextMessage("First Message"), session.createTextMessage("Second Message")};
+
+        // lets consume any outstanding messages from prev test runs
+        beginTx();
+        while (consumer.receive(1000) != null) {
+        }
+        commitTx();
+
+        //
+        beginTx();
+        producer.send(outbound[0]);
+        producer.send(outbound[1]);
+        commitTx();
+
+        LOG.info("Sent 0: " + outbound[0]);
+        LOG.info("Sent 1: " + outbound[1]);
+
+        ArrayList<Message> messages = new ArrayList<Message>();
+        beginTx();
+        Message message = consumer.receive(1000);
+        assertEquals(outbound[0], message);
+
+        message = consumer.receive(1000);
+        assertNotNull(message);
+        assertEquals(outbound[1], message);
+        rollbackTx();
+
+        // Consume again.. the prev message should
+        // get redelivered.
+        beginTx();
+        message = consumer.receive(5000);
+        assertNotNull("Should have re-received the first message again!", message);
+        messages.add(message);
+        assertEquals(outbound[0], message);
+        message = consumer.receive(5000);
+        assertNotNull("Should have re-received the second message again!", message);
+        messages.add(message);
+        assertEquals(outbound[1], message);
+
+        assertNull(consumer.receiveNoWait());
+        commitTx();
+
+        Message inbound[] = new Message[messages.size()];
+        messages.toArray(inbound);
+        assertTextMessagesEqual("Rollback did not work", outbound, inbound);
+    }
+
+    /**
+     * Sends a batch of messages and validates that the rollbacked message was
+     * not consumed.
+     *
+     * @throws Exception
+     */
+    public void testSendReceiveWithPrefetchOne() throws Exception {
+        setPrefetchToOne();
+        Message[] outbound = new Message[] {session.createTextMessage("First Message"), session.createTextMessage("Second Message"), session.createTextMessage("Third Message"),
+                                            session.createTextMessage("Fourth Message")};
+
+        beginTx();
+        for (int i = 0; i < outbound.length; i++) {
+            // sends a message
+            producer.send(outbound[i]);
+        }
+        commitTx();
+
+        // receives the first message
+        beginTx();
+        for (int i = 0; i < outbound.length; i++) {
+            LOG.info("About to consume message 1");
+            Message message = consumer.receive(1000);
+            assertNotNull(message);
+            LOG.info("Received: " + message);
+        }
+
+        // validates that the rollbacked was not consumed
+        commitTx();
+    }
+
+    /**
+     * Perform the test that validates if the rollbacked message was redelivered
+     * multiple times.
+     *
+     * @throws Exception
+     */
+    public void testReceiveTwoThenRollbackManyTimes() throws Exception {
+        for (int i = 0; i < 5; i++) {
+            testReceiveTwoThenRollback();
+        }
+    }
+
+    /**
+     * Sends a batch of messages and validates that the rollbacked message was
+     * not consumed. This test differs by setting the message prefetch to one.
+     *
+     * @throws Exception
+     */
+    public void testSendRollbackWithPrefetchOfOne() throws Exception {
+        setPrefetchToOne();
+        testSendRollback();
+    }
+
+    /**
+     * Sends a batch of messages and and validates that the rollbacked message
+     * was redelivered. This test differs by setting the message prefetch to
+     * one.
+     *
+     * @throws Exception
+     */
+    public void testReceiveRollbackWithPrefetchOfOne() throws Exception {
+        setPrefetchToOne();
+        testReceiveRollback();
+    }
+
+    /**
+     * Tests if the messages can still be received if the consumer is closed
+     * (session is not closed).
+     *
+     * @throws Exception see http://jira.codehaus.org/browse/AMQ-143
+     */
+    public void testCloseConsumerBeforeCommit() throws Exception {
+        TextMessage[] outbound = new TextMessage[] {session.createTextMessage("First Message"), session.createTextMessage("Second Message")};
+
+        // lets consume any outstanding messages from prev test runs
+        beginTx();
+        while (consumer.receiveNoWait() != null) {
+        }
+
+        commitTx();
+
+        // sends the messages
+        beginTx();
+        producer.send(outbound[0]);
+        producer.send(outbound[1]);
+        commitTx();
+        LOG.info("Sent 0: " + outbound[0]);
+        LOG.info("Sent 1: " + outbound[1]);
+
+        beginTx();
+        TextMessage message = (TextMessage)consumer.receive(1000);
+        assertEquals(outbound[0].getText(), message.getText());
+        // Close the consumer before the commit. This should not cause the
+        // received message
+        // to rollback.
+        consumer.close();
+        commitTx();
+
+        // Create a new consumer
+        consumer = resourceProvider.createConsumer(session, destination);
+        LOG.info("Created consumer: " + consumer);
+
+        beginTx();
+        message = (TextMessage)consumer.receive(1000);
+        assertEquals(outbound[1].getText(), message.getText());
+        commitTx();
+    }
+
+    public void testChangeMutableObjectInObjectMessageThenRollback() throws Exception {
+        ArrayList<String> list = new ArrayList<String>();
+        list.add("First");
+        Message outbound = session.createObjectMessage(list);
+        outbound.setStringProperty("foo", "abc");
+
+        beginTx();
+        producer.send(outbound);
+        commitTx();
+
+        LOG.info("About to consume message 1");
+        beginTx();
+        Message message = consumer.receive(5000);
+
+        List<String> body = assertReceivedObjectMessageWithListBody(message);
+
+        // now lets try mutate it
+        try {
+            message.setStringProperty("foo", "def");
+            fail("Cannot change properties of the object!");
+        } catch (JMSException e) {
+            LOG.info("Caught expected exception: " + e, e);
+        }
+        body.clear();
+        body.add("This should never be seen!");
+        rollbackTx();
+
+        beginTx();
+        message = consumer.receive(5000);
+        List<String> secondBody = assertReceivedObjectMessageWithListBody(message);
+        assertNotSame("Second call should return a different body", secondBody, body);
+        commitTx();
+    }
+
+    @SuppressWarnings("unchecked")
+    protected List<String> assertReceivedObjectMessageWithListBody(Message message) throws JMSException {
+        assertNotNull("Should have received a message!", message);
+        assertEquals("foo header", "abc", message.getStringProperty("foo"));
+
+        assertTrue("Should be an object message but was: " + message, message instanceof ObjectMessage);
+        ObjectMessage objectMessage = (ObjectMessage)message;
+        List<String> body = (List<String>)objectMessage.getObject();
+        LOG.info("Received body: " + body);
+
+        assertEquals("Size of list should be 1", 1, body.size());
+        assertEquals("element 0 of list", "First", body.get(0));
+        return body;
+    }
+
+    /**
+     * Recreates the connection.
+     *
+     * @throws javax.jms.JMSException
+     */
+    protected void reconnect() throws Exception {
+
+        if (connection != null) {
+            // Close the prev connection.
+            connection.close();
+        }
+        session = null;
+        connection = resourceProvider.createConnection(connectionFactory);
+        reconnectSession();
+        connection.start();
+    }
+
+    /**
+     * Recreates the connection.
+     *
+     * @throws javax.jms.JMSException
+     */
+    protected void reconnectSession() throws JMSException {
+        if (session != null) {
+            session.close();
+        }
+
+        session = resourceProvider.createSession(connection);
+        destination = resourceProvider.createDestination(session, getSubject());
+        producer = resourceProvider.createProducer(session, destination);
+        consumer = resourceProvider.createConsumer(session, destination);
+    }
+
+    /**
+     * Sets the prefeftch policy to one.
+     */
+    protected void setPrefetchToOne() {
+        ActiveMQPrefetchPolicy prefetchPolicy = getPrefetchPolicy();
+        prefetchPolicy.setQueuePrefetch(1);
+        prefetchPolicy.setTopicPrefetch(1);
+        prefetchPolicy.setDurableTopicPrefetch(1);
+        prefetchPolicy.setOptimizeDurableTopicPrefetch(1);
+    }
+
+    protected ActiveMQPrefetchPolicy getPrefetchPolicy() {
+        return ((ActiveMQConnection)connection).getPrefetchPolicy();
+    }
+
+    //This test won't work with xa tx so no beginTx() has been added.
+    public void testMessageListener() throws Exception {
+        // send messages
+        for (int i = 0; i < MESSAGE_COUNT; i++) {
+            producer.send(session.createTextMessage(MESSAGE_TEXT + i));
+        }
+        commitTx();
+        consumer.setMessageListener(this);
+        // wait receive
+        waitReceiveUnack();
+        assertEquals(unackMessages.size(), MESSAGE_COUNT);
+        // resend phase
+        waitReceiveAck();
+        assertEquals(ackMessages.size(), MESSAGE_COUNT);
+        // should no longer re-receive
+        consumer.setMessageListener(null);
+        assertNull(consumer.receive(500));
+        reconnect();
+    }
+
+    @Override
+    public void onMessage(Message message) {
+        if (!resendPhase) {
+            unackMessages.add(message);
+            if (unackMessages.size() == MESSAGE_COUNT) {
+                try {
+                    rollbackTx();
+                    resendPhase = true;
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        } else {
+            ackMessages.add(message);
+            if (ackMessages.size() == MESSAGE_COUNT) {
+                try {
+                    commitTx();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    private void waitReceiveUnack() throws Exception {
+        for (int i = 0; i < 100 && !resendPhase; i++) {
+            Thread.sleep(100);
+        }
+        assertTrue(resendPhase);
+    }
+
+    private void waitReceiveAck() throws Exception {
+        for (int i = 0; i < 100 && ackMessages.size() < MESSAGE_COUNT; i++) {
+            Thread.sleep(100);
+        }
+        assertFalse(ackMessages.size() < MESSAGE_COUNT);
+    }
+}


[12/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MemoryUsageBlockResumeTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MemoryUsageBlockResumeTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MemoryUsageBlockResumeTest.java
deleted file mode 100644
index 7e46df4..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MemoryUsageBlockResumeTest.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/**
- * 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;
-
-import java.io.File;
-import java.util.Vector;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQPrefetchPolicy;
-import org.apache.activemq.TestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.runners.BlockJUnit4ClassRunner;
-import org.junit.runner.RunWith;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@RunWith(BlockJUnit4ClassRunner.class)
-public class MemoryUsageBlockResumeTest extends TestSupport implements Thread.UncaughtExceptionHandler {
-
-   public int deliveryMode = DeliveryMode.PERSISTENT;
-
-   private static final Logger LOG = LoggerFactory.getLogger(MemoryUsageBlockResumeTest.class);
-   private static byte[] buf = new byte[4 * 1024];
-   private static byte[] bigBuf = new byte[48 * 1024];
-
-   private BrokerService broker;
-   AtomicInteger messagesSent = new AtomicInteger(0);
-   AtomicInteger messagesConsumed = new AtomicInteger(0);
-
-   protected long messageReceiveTimeout = 10000L;
-
-   Destination destination = new ActiveMQQueue("FooTwo");
-   Destination bigDestination = new ActiveMQQueue("FooTwoBig");
-
-   private String connectionUri;
-   private final Vector<Throwable> exceptions = new Vector<>();
-
-   @Test(timeout = 60 * 1000)
-   public void testBlockByOtherResumeNoException() throws Exception {
-
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri);
-
-      // ensure more than on message can be pending when full
-      factory.setProducerWindowSize(48 * 1024);
-      // ensure messages are spooled to disk for this consumer
-      ActiveMQPrefetchPolicy prefetch = new ActiveMQPrefetchPolicy();
-      prefetch.setTopicPrefetch(10);
-      factory.setPrefetchPolicy(prefetch);
-      Connection consumerConnection = factory.createConnection();
-      consumerConnection.start();
-
-      Session consumerSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer consumer = consumerSession.createConsumer(bigDestination);
-
-      final Connection producerConnection = factory.createConnection();
-      producerConnection.start();
-
-      final int fillWithBigCount = 10;
-      Session session = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = session.createProducer(null);
-      producer.setDeliveryMode(deliveryMode);
-      for (int idx = 0; idx < fillWithBigCount; ++idx) {
-         Message message = session.createTextMessage(new String(bigBuf) + idx);
-         producer.send(bigDestination, message);
-         messagesSent.incrementAndGet();
-         LOG.info("After big: " + idx + ", System Memory Usage " + broker.getSystemUsage().getMemoryUsage().getPercentUsage());
-      }
-
-      // will block on pfc
-      final int toSend = 20;
-      Thread producingThread = new Thread("Producing thread") {
-         @Override
-         public void run() {
-            try {
-               Session session = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-               MessageProducer producer = session.createProducer(destination);
-               producer.setDeliveryMode(deliveryMode);
-               for (int idx = 0; idx < toSend; ++idx) {
-                  Message message = session.createTextMessage(new String(buf) + idx);
-                  producer.send(destination, message);
-                  messagesSent.incrementAndGet();
-                  LOG.info("After little:" + idx + ", System Memory Usage " + broker.getSystemUsage().getMemoryUsage().getPercentUsage());
-               }
-            }
-            catch (Throwable ex) {
-               ex.printStackTrace();
-            }
-         }
-      };
-      producingThread.start();
-
-      Thread producingThreadTwo = new Thread("Producing thread") {
-         @Override
-         public void run() {
-            try {
-               Session session = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-               MessageProducer producer = session.createProducer(destination);
-               producer.setDeliveryMode(deliveryMode);
-               for (int idx = 0; idx < toSend; ++idx) {
-                  Message message = session.createTextMessage(new String(buf) + idx);
-                  producer.send(destination, message);
-                  messagesSent.incrementAndGet();
-                  LOG.info("After little:" + idx + ", System Memory Usage " + broker.getSystemUsage().getMemoryUsage().getPercentUsage());
-               }
-            }
-            catch (Throwable ex) {
-               ex.printStackTrace();
-            }
-         }
-      };
-      producingThreadTwo.start();
-
-      assertTrue("producer has sent x in a reasonable time", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            LOG.info("Checking for : X sent, System Memory Usage " + broker.getSystemUsage().getMemoryUsage().getPercentUsage() + ", sent:  " + messagesSent);
-            return messagesSent.get() > 20;
-         }
-      }));
-
-      LOG.info("Consuming from big q to allow delivery to smaller q from pending");
-      int count = 0;
-
-      Message m = null;
-
-      for (; count < 10; count++) {
-         assertTrue((m = consumer.receive(messageReceiveTimeout)) != null);
-         LOG.info("Received Message (" + count + "):" + m + ", System Memory Usage " + broker.getSystemUsage().getMemoryUsage().getPercentUsage());
-         messagesConsumed.incrementAndGet();
-      }
-      consumer.close();
-
-      producingThread.join();
-      producingThreadTwo.join();
-
-      assertEquals("Incorrect number of Messages Sent: " + messagesSent.get(), messagesSent.get(), fillWithBigCount + toSend * 2);
-
-      // consume all little messages
-      consumer = consumerSession.createConsumer(destination);
-      for (count = 0; count < toSend * 2; count++) {
-         assertTrue((m = consumer.receive(messageReceiveTimeout)) != null);
-         LOG.info("Received Message (" + count + "):" + m + ", System Memory Usage " + broker.getSystemUsage().getMemoryUsage().getPercentUsage());
-         messagesConsumed.incrementAndGet();
-      }
-
-      assertEquals("Incorrect number of Messages consumed: " + messagesConsumed.get(), messagesSent.get(), messagesConsumed.get());
-
-      //assertTrue("no exceptions: " + exceptions, exceptions.isEmpty());
-   }
-
-   @Override
-   @Before
-   public void setUp() throws Exception {
-
-      Thread.setDefaultUncaughtExceptionHandler(this);
-      broker = new BrokerService();
-      broker.setDataDirectory("target" + File.separator + "activemq-data");
-      broker.setPersistent(true);
-      broker.setUseJmx(false);
-      broker.setAdvisorySupport(false);
-      broker.setDeleteAllMessagesOnStartup(true);
-
-      setDefaultPersistenceAdapter(broker);
-      broker.getSystemUsage().getMemoryUsage().setLimit((30 * 16 * 1024));
-
-      PolicyEntry defaultPolicy = new PolicyEntry();
-      defaultPolicy.setOptimizedDispatch(true);
-      PolicyMap policyMap = new PolicyMap();
-      policyMap.setDefaultEntry(defaultPolicy);
-      broker.setDestinationPolicy(policyMap);
-
-      broker.addConnector("tcp://localhost:0");
-      broker.start();
-
-      connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
-   }
-
-   @Override
-   @After
-   public void tearDown() throws Exception {
-      if (broker != null) {
-         broker.stop();
-      }
-   }
-
-   @Override
-   public void uncaughtException(Thread t, Throwable e) {
-      LOG.error("Unexpected Unhandeled ex on: " + t, e);
-      exceptions.add(e);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MemoryUsageBrokerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MemoryUsageBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MemoryUsageBrokerTest.java
deleted file mode 100644
index 4653ea6..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MemoryUsageBrokerTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * 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;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.BrokerTestSupport;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.store.kahadb.KahaDBStore;
-import org.apache.activemq.util.IOHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.jms.*;
-import java.io.File;
-
-public class MemoryUsageBrokerTest extends BrokerTestSupport {
-
-   private static final Logger LOG = LoggerFactory.getLogger(MemoryUsageBrokerTest.class);
-
-   @Override
-   protected void setUp() throws Exception {
-      this.setAutoFail(true);
-      super.setUp();
-   }
-
-   @Override
-   protected PolicyEntry getDefaultPolicy() {
-      PolicyEntry policy = super.getDefaultPolicy();
-      // Disable PFC and assign a large memory limit that's larger than the default broker memory limit for queues
-      policy.setProducerFlowControl(false);
-      policy.setQueue(">");
-      policy.setMemoryLimit(128 * 1024 * 1024);
-      return policy;
-   }
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      BrokerService broker = new BrokerService();
-      KahaDBStore kaha = new KahaDBStore();
-      File directory = new File("target/activemq-data/kahadb");
-      IOHelper.deleteChildren(directory);
-      kaha.setDirectory(directory);
-      kaha.deleteAllMessages();
-      broker.setPersistenceAdapter(kaha);
-      return broker;
-   }
-
-   protected ConnectionFactory createConnectionFactory() {
-      return new ActiveMQConnectionFactory(broker.getVmConnectorURI());
-   }
-
-   protected Connection createJmsConnection() throws JMSException {
-      return createConnectionFactory().createConnection();
-   }
-
-   public void testMemoryUsage() throws Exception {
-      Connection conn = createJmsConnection();
-      Session session = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
-      Queue queue = session.createQueue("queue.a.b");
-      MessageProducer producer = session.createProducer(queue);
-      for (int i = 0; i < 100000; i++) {
-         BytesMessage bm = session.createBytesMessage();
-         bm.writeBytes(new byte[1024]);
-         producer.send(bm);
-         if ((i + 1) % 100 == 0) {
-            session.commit();
-            int memoryUsagePercent = broker.getSystemUsage().getMemoryUsage().getPercentUsage();
-            LOG.info((i + 1) + " messages have been sent; broker memory usage " + memoryUsagePercent + "%");
-            assertTrue("Used more than available broker memory", memoryUsagePercent <= 100);
-         }
-      }
-      session.commit();
-      producer.close();
-      session.close();
-      conn.close();
-   }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MemoryUsageCleanupTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MemoryUsageCleanupTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MemoryUsageCleanupTest.java
deleted file mode 100644
index e89c93f..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MemoryUsageCleanupTest.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.util.Random;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.Broker;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.broker.region.policy.SharedDeadLetterStrategy;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class MemoryUsageCleanupTest {
-
-   private static final Logger LOG = LoggerFactory.getLogger(MemoryUsageCleanupTest.class);
-   private static final String QUEUE_NAME = MemoryUsageCleanupTest.class.getName() + "Queue";
-
-   private final String str = new String("QAa0bcLdUK2eHfJgTP8XhiFj61DOklNm9nBoI5pGqYVrs3CtSuMZvwWx4yE7zR");
-
-   private BrokerService broker;
-   private String connectionUri;
-   private ExecutorService pool;
-   private String queueName;
-   private Random r = new Random();
-
-   @Before
-   public void setUp() throws Exception {
-
-      broker = new BrokerService();
-      broker.setDataDirectory("target" + File.separator + "activemq-data");
-      broker.setPersistent(true);
-      broker.setUseJmx(true);
-      broker.setDedicatedTaskRunner(false);
-      broker.setAdvisorySupport(false);
-      broker.setDeleteAllMessagesOnStartup(true);
-
-      SharedDeadLetterStrategy strategy = new SharedDeadLetterStrategy();
-      strategy.setProcessExpired(false);
-      strategy.setProcessNonPersistent(false);
-
-      PolicyEntry defaultPolicy = new PolicyEntry();
-      defaultPolicy.setQueue(">");
-      defaultPolicy.setOptimizedDispatch(true);
-      defaultPolicy.setDeadLetterStrategy(strategy);
-      defaultPolicy.setMemoryLimit(300000000);
-
-      PolicyMap policyMap = new PolicyMap();
-      policyMap.setDefaultEntry(defaultPolicy);
-
-      broker.setDestinationPolicy(policyMap);
-
-      broker.getSystemUsage().getMemoryUsage().setLimit(300000000L);
-
-      broker.addConnector("tcp://localhost:0").setName("Default");
-      broker.start();
-      broker.waitUntilStarted();
-
-      connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
-      pool = Executors.newFixedThreadPool(10);
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-      }
-
-      if (pool != null) {
-         pool.shutdown();
-      }
-   }
-
-   @Test
-   public void testIt() throws Exception {
-
-      final int startPercentage = broker.getAdminView().getMemoryPercentUsage();
-      LOG.info("MemoryUsage at test start = " + startPercentage);
-
-      for (int i = 0; i < 2; i++) {
-         LOG.info("Started the test iteration: " + i + " using queueName = " + queueName);
-         queueName = QUEUE_NAME + i;
-         final CountDownLatch latch = new CountDownLatch(11);
-
-         pool.execute(new Runnable() {
-            @Override
-            public void run() {
-               receiveAndDiscard100messages(latch);
-            }
-         });
-
-         for (int j = 0; j < 10; j++) {
-            pool.execute(new Runnable() {
-               @Override
-               public void run() {
-                  send10000messages(latch);
-               }
-            });
-         }
-
-         LOG.info("Waiting on the send / receive latch");
-         latch.await(5, TimeUnit.MINUTES);
-         LOG.info("Resumed");
-
-         destroyQueue();
-         TimeUnit.SECONDS.sleep(2);
-      }
-
-      LOG.info("MemoryUsage before awaiting temp store cleanup = " + broker.getAdminView().getMemoryPercentUsage());
-
-      assertTrue("MemoryUsage should return to: " + startPercentage +
-                    "% but was " + broker.getAdminView().getMemoryPercentUsage() + "%", Wait.waitFor(new Wait.Condition() {
-
-         @Override
-         public boolean isSatisified() throws Exception {
-            return broker.getAdminView().getMemoryPercentUsage() <= startPercentage + 1;
-         }
-      }));
-
-      int endPercentage = broker.getAdminView().getMemoryPercentUsage();
-      LOG.info("MemoryUsage at test end = " + endPercentage);
-   }
-
-   public void destroyQueue() {
-      try {
-         Broker broker = this.broker.getBroker();
-         if (!broker.isStopped()) {
-            LOG.info("Removing: " + queueName);
-            broker.removeDestination(this.broker.getAdminConnectionContext(), new ActiveMQQueue(queueName), 10);
-         }
-      }
-      catch (Exception e) {
-         LOG.warn("Got an error while removing the test queue", e);
-      }
-   }
-
-   private void send10000messages(CountDownLatch latch) {
-      ActiveMQConnection activeMQConnection = null;
-      try {
-         activeMQConnection = createConnection(null);
-         Session session = activeMQConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageProducer producer = session.createProducer(session.createQueue(queueName));
-         producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-         activeMQConnection.start();
-         for (int i = 0; i < 10000; i++) {
-            TextMessage textMessage = session.createTextMessage();
-            textMessage.setText(generateBody(1000));
-            textMessage.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
-            producer.send(textMessage);
-            try {
-               Thread.sleep(10);
-            }
-            catch (InterruptedException e) {
-            }
-         }
-         producer.close();
-      }
-      catch (JMSException e) {
-         LOG.warn("Got an error while sending the messages", e);
-      }
-      finally {
-         if (activeMQConnection != null) {
-            try {
-               activeMQConnection.close();
-            }
-            catch (JMSException e) {
-            }
-         }
-      }
-      latch.countDown();
-   }
-
-   private void receiveAndDiscard100messages(CountDownLatch latch) {
-      ActiveMQConnection activeMQConnection = null;
-      try {
-         activeMQConnection = createConnection(null);
-         Session session = activeMQConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageConsumer messageConsumer = session.createConsumer(session.createQueue(queueName));
-         activeMQConnection.start();
-         for (int i = 0; i < 100; i++) {
-            messageConsumer.receive();
-         }
-         messageConsumer.close();
-         LOG.info("Created and disconnected");
-      }
-      catch (JMSException e) {
-         LOG.warn("Got an error while receiving the messages", e);
-      }
-      finally {
-         if (activeMQConnection != null) {
-            try {
-               activeMQConnection.close();
-            }
-            catch (JMSException e) {
-            }
-         }
-      }
-      latch.countDown();
-   }
-
-   private ActiveMQConnection createConnection(String id) throws JMSException {
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri);
-      if (id != null) {
-         factory.setClientID(id);
-      }
-
-      ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
-      return connection;
-   }
-
-   private String generateBody(int length) {
-
-      StringBuilder sb = new StringBuilder();
-      int te = 0;
-      for (int i = 1; i <= length; i++) {
-         te = r.nextInt(62);
-         sb.append(str.charAt(te));
-      }
-      return sb.toString();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MessageExpirationReaperTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MessageExpirationReaperTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MessageExpirationReaperTest.java
deleted file mode 100644
index 3cdd0d6..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MessageExpirationReaperTest.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-
-import javax.jms.*;
-import javax.management.ObjectName;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.DestinationViewMBean;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test to determine if expired messages are being reaped if there is
- * no active consumer connected to the broker.
- */
-public class MessageExpirationReaperTest {
-
-   private BrokerService broker;
-   private ConnectionFactory factory;
-   private ActiveMQConnection connection;
-   private final String destinationName = "TEST.Q";
-   private final String brokerUrl = "tcp://localhost:0";
-   private final String brokerName = "testBroker";
-   private String connectionUri;
-
-   @Before
-   public void init() throws Exception {
-      createBroker();
-
-      connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
-
-      factory = createConnectionFactory();
-      connection = (ActiveMQConnection) factory.createConnection();
-      connection.setClientID("test-connection");
-      connection.start();
-   }
-
-   @After
-   public void cleanUp() throws Exception {
-      connection.close();
-      broker.stop();
-   }
-
-   protected void createBroker() throws Exception {
-      broker = new BrokerService();
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.setBrokerName(brokerName);
-      broker.addConnector(brokerUrl);
-
-      PolicyMap policyMap = new PolicyMap();
-      PolicyEntry defaultEntry = new PolicyEntry();
-      defaultEntry.setExpireMessagesPeriod(500);
-      policyMap.setDefaultEntry(defaultEntry);
-      broker.setDestinationPolicy(policyMap);
-
-      broker.start();
-   }
-
-   protected ConnectionFactory createConnectionFactory() throws Exception {
-      return new ActiveMQConnectionFactory(connectionUri);
-   }
-
-   protected Session createSession() throws Exception {
-      return connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-   }
-
-   @Test
-   public void testExpiredMessageReaping() throws Exception {
-
-      Session producerSession = createSession();
-      ActiveMQDestination destination = (ActiveMQDestination) producerSession.createQueue(destinationName);
-      MessageProducer producer = producerSession.createProducer(destination);
-      producer.setTimeToLive(1000);
-
-      final int count = 3;
-      // Send some messages with an expiration
-      for (int i = 0; i < count; i++) {
-         TextMessage message = producerSession.createTextMessage("" + i);
-         producer.send(message);
-      }
-
-      // Let the messages expire
-      Thread.sleep(2000);
-
-      DestinationViewMBean view = createView(destination);
-
-      assertEquals("Incorrect inflight count: " + view.getInFlightCount(), 0, view.getInFlightCount());
-      assertEquals("Incorrect queue size count", 0, view.getQueueSize());
-      assertEquals("Incorrect expired size count", view.getEnqueueCount(), view.getExpiredCount());
-
-      // Send more messages with an expiration
-      for (int i = 0; i < count; i++) {
-         TextMessage message = producerSession.createTextMessage("" + i);
-         producer.send(message);
-      }
-
-      // Let the messages expire
-      Thread.sleep(2000);
-
-      // Simply browse the queue
-      Session browserSession = createSession();
-      QueueBrowser browser = browserSession.createBrowser((Queue) destination);
-      assertFalse("no message in the browser", browser.getEnumeration().hasMoreElements());
-
-      // The messages expire and should be reaped because of the presence of
-      // the queue browser
-      assertEquals("Wrong inFlightCount: " + view.getInFlightCount(), 0, view.getInFlightCount());
-   }
-
-   @Test
-   public void testExpiredMessagesOnTopic() throws Exception {
-      Session session = createSession();
-
-      // use a zero prefetch so messages don't go inflight
-      ActiveMQTopic destination = new ActiveMQTopic(destinationName + "?consumer.prefetchSize=0");
-
-      MessageProducer producer = session.createProducer(destination);
-
-      // should have a durable sub because it's a little tricky to get messages to expire in
-      // non-durable subs.. with durable subs, we can just expire in the topic using the expire
-      // period.. also.. durable sub has to be "inactive" for the expire checker to actually
-      // expire the messages
-      MessageConsumer consumer = session.createDurableSubscriber(destination, "test-durable");
-
-      producer.setTimeToLive(500);
-
-      final int count = 3;
-      // Send some messages with an expiration
-      for (int i = 0; i < count; i++) {
-         TextMessage message = session.createTextMessage("" + i);
-         producer.send(message);
-      }
-
-      DestinationViewMBean view = createView(destination);
-      // not expired yet...
-      assertEquals("Incorrect enqueue count", 3, view.getEnqueueCount());
-
-      // close consumer so topic thinks consumer is inactive
-      consumer.close();
-
-      // Let the messages reach an expiry time
-      Thread.sleep(2000);
-
-      assertEquals("Incorrect inflight count: " + view.getInFlightCount(), 0, view.getInFlightCount());
-      assertEquals("Incorrect queue size count", 0, view.getQueueSize());
-      assertEquals("Incorrect expired size count", view.getEnqueueCount(), view.getExpiredCount());
-   }
-
-   protected DestinationViewMBean createView(ActiveMQDestination destination) throws Exception {
-      String domain = "org.apache.activemq";
-      ObjectName name;
-      if (destination.isQueue()) {
-         name = new ObjectName(domain + ":type=Broker,brokerName=" + brokerName + ",destinationType=Queue,destinationName=" + destinationName);
-      }
-      else {
-         name = new ObjectName(domain + ":type=Broker,brokerName=" + brokerName + ",destinationType=Topic,destinationName=" + destinationName);
-      }
-      return (DestinationViewMBean) broker.getManagementContext().newProxyInstance(name, DestinationViewMBean.class, true);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MessageSender.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MessageSender.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MessageSender.java
deleted file mode 100644
index e7d22b1..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MessageSender.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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;
-
-import javax.jms.Connection;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Session;
-
-public class MessageSender {
-
-   private MessageProducer producer;
-   private Session session;
-
-   public MessageSender(String queueName,
-                        Connection connection,
-                        boolean useTransactedSession,
-                        boolean topic) throws Exception {
-      session = useTransactedSession ? connection.createSession(true, Session.SESSION_TRANSACTED) : connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      producer = session.createProducer(topic ? session.createTopic(queueName) : session.createQueue(queueName));
-   }
-
-   public void send(String payload) throws Exception {
-      ObjectMessage message = session.createObjectMessage();
-      message.setObject(payload);
-      producer.send(message);
-      if (session.getTransacted()) {
-         session.commit();
-      }
-   }
-
-   public MessageProducer getProducer() {
-      return producer;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MissingDataFileTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MissingDataFileTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MissingDataFileTest.java
deleted file mode 100644
index b278dc9..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/MissingDataFileTest.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/**
- * 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;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.ObjectMessage;
-import javax.jms.Session;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.usage.SystemUsage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/*
- * Try and replicate:
- * Caused by: java.io.IOException: Could not locate data file data--188
- *  at org.apache.activemq.kaha.impl.async.AsyncDataManager.getDataFile(AsyncDataManager.java:302)
- *  at org.apache.activemq.kaha.impl.async.AsyncDataManager.read(AsyncDataManager.java:614)
- *  at org.apache.activemq.store.amq.AMQPersistenceAdapter.readCommand(AMQPersistenceAdapter.java:523)
- */
-
-public class MissingDataFileTest extends TestCase {
-
-   private static final Logger LOG = LoggerFactory.getLogger(MissingDataFileTest.class);
-
-   private static int counter = 500;
-
-   private static int hectorToHaloCtr;
-   private static int xenaToHaloCtr;
-   private static int troyToHaloCtr;
-
-   private static int haloToHectorCtr;
-   private static int haloToXenaCtr;
-   private static int haloToTroyCtr;
-
-   private final String hectorToHalo = "hectorToHalo";
-   private final String xenaToHalo = "xenaToHalo";
-   private final String troyToHalo = "troyToHalo";
-
-   private final String haloToHector = "haloToHector";
-   private final String haloToXena = "haloToXena";
-   private final String haloToTroy = "haloToTroy";
-
-   private BrokerService broker;
-
-   private Connection hectorConnection;
-   private Connection xenaConnection;
-   private Connection troyConnection;
-   private Connection haloConnection;
-
-   private final Object lock = new Object();
-   final boolean useTopic = false;
-   final boolean useSleep = true;
-
-   protected static final String payload = new String(new byte[500]);
-
-   public Connection createConnection() throws JMSException {
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
-      return factory.createConnection();
-   }
-
-   public Session createSession(Connection connection, boolean transacted) throws JMSException {
-      return connection.createSession(transacted, Session.AUTO_ACKNOWLEDGE);
-   }
-
-   public void startBroker() throws Exception {
-      broker = new BrokerService();
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.setPersistent(true);
-      broker.setUseJmx(true);
-      broker.addConnector("tcp://localhost:61616").setName("Default");
-
-      SystemUsage systemUsage;
-      systemUsage = new SystemUsage();
-      systemUsage.getMemoryUsage().setLimit(10 * 1024 * 1024); // Just a few messags
-      broker.setSystemUsage(systemUsage);
-
-      KahaDBPersistenceAdapter kahaDBPersistenceAdapter = new KahaDBPersistenceAdapter();
-      kahaDBPersistenceAdapter.setJournalMaxFileLength(16 * 1024);
-      kahaDBPersistenceAdapter.setCleanupInterval(500);
-      broker.setPersistenceAdapter(kahaDBPersistenceAdapter);
-
-      broker.start();
-      LOG.info("Starting broker..");
-   }
-
-   @Override
-   public void tearDown() throws Exception {
-      hectorConnection.close();
-      xenaConnection.close();
-      troyConnection.close();
-      haloConnection.close();
-      broker.stop();
-   }
-
-   public void testForNoDataFoundError() throws Exception {
-
-      startBroker();
-      hectorConnection = createConnection();
-      Thread hectorThread = buildProducer(hectorConnection, hectorToHalo, false, useTopic);
-      Receiver hHectorReceiver = new Receiver() {
-         @Override
-         public void receive(String s) throws Exception {
-            haloToHectorCtr++;
-            if (haloToHectorCtr >= counter) {
-               synchronized (lock) {
-                  lock.notifyAll();
-               }
-            }
-            possiblySleep(haloToHectorCtr);
-         }
-      };
-      buildReceiver(hectorConnection, haloToHector, false, hHectorReceiver, useTopic);
-
-      troyConnection = createConnection();
-      Thread troyThread = buildProducer(troyConnection, troyToHalo);
-      Receiver hTroyReceiver = new Receiver() {
-         @Override
-         public void receive(String s) throws Exception {
-            haloToTroyCtr++;
-            if (haloToTroyCtr >= counter) {
-               synchronized (lock) {
-                  lock.notifyAll();
-               }
-            }
-            possiblySleep(haloToTroyCtr);
-         }
-      };
-      buildReceiver(hectorConnection, haloToTroy, false, hTroyReceiver, false);
-
-      xenaConnection = createConnection();
-      Thread xenaThread = buildProducer(xenaConnection, xenaToHalo);
-      Receiver hXenaReceiver = new Receiver() {
-         @Override
-         public void receive(String s) throws Exception {
-            haloToXenaCtr++;
-            if (haloToXenaCtr >= counter) {
-               synchronized (lock) {
-                  lock.notifyAll();
-               }
-            }
-            possiblySleep(haloToXenaCtr);
-         }
-      };
-      buildReceiver(xenaConnection, haloToXena, false, hXenaReceiver, false);
-
-      haloConnection = createConnection();
-      final MessageSender hectorSender = buildTransactionalProducer(haloToHector, haloConnection, false);
-      final MessageSender troySender = buildTransactionalProducer(haloToTroy, haloConnection, false);
-      final MessageSender xenaSender = buildTransactionalProducer(haloToXena, haloConnection, false);
-      Receiver hectorReceiver = new Receiver() {
-         @Override
-         public void receive(String s) throws Exception {
-            hectorToHaloCtr++;
-            troySender.send(payload);
-            if (hectorToHaloCtr >= counter) {
-               synchronized (lock) {
-                  lock.notifyAll();
-               }
-               possiblySleep(hectorToHaloCtr);
-            }
-         }
-      };
-      Receiver xenaReceiver = new Receiver() {
-         @Override
-         public void receive(String s) throws Exception {
-            xenaToHaloCtr++;
-            hectorSender.send(payload);
-            if (xenaToHaloCtr >= counter) {
-               synchronized (lock) {
-                  lock.notifyAll();
-               }
-            }
-            possiblySleep(xenaToHaloCtr);
-         }
-      };
-      Receiver troyReceiver = new Receiver() {
-         @Override
-         public void receive(String s) throws Exception {
-            troyToHaloCtr++;
-            xenaSender.send(payload);
-            if (troyToHaloCtr >= counter) {
-               synchronized (lock) {
-                  lock.notifyAll();
-               }
-            }
-         }
-      };
-      buildReceiver(haloConnection, hectorToHalo, true, hectorReceiver, false);
-      buildReceiver(haloConnection, xenaToHalo, true, xenaReceiver, false);
-      buildReceiver(haloConnection, troyToHalo, true, troyReceiver, false);
-
-      haloConnection.start();
-
-      troyConnection.start();
-      troyThread.start();
-
-      xenaConnection.start();
-      xenaThread.start();
-
-      hectorConnection.start();
-      hectorThread.start();
-      waitForMessagesToBeDelivered();
-      // number of messages received should match messages sent
-      assertEquals(hectorToHaloCtr, counter);
-      LOG.info("hectorToHalo received " + hectorToHaloCtr + " messages");
-      assertEquals(xenaToHaloCtr, counter);
-      LOG.info("xenaToHalo received " + xenaToHaloCtr + " messages");
-      assertEquals(troyToHaloCtr, counter);
-      LOG.info("troyToHalo received " + troyToHaloCtr + " messages");
-      assertEquals(haloToHectorCtr, counter);
-      LOG.info("haloToHector received " + haloToHectorCtr + " messages");
-      assertEquals(haloToXenaCtr, counter);
-      LOG.info("haloToXena received " + haloToXenaCtr + " messages");
-      assertEquals(haloToTroyCtr, counter);
-      LOG.info("haloToTroy received " + haloToTroyCtr + " messages");
-
-   }
-
-   protected void possiblySleep(int count) throws InterruptedException {
-      if (useSleep) {
-         if (count % 100 == 0) {
-            Thread.sleep(5000);
-         }
-      }
-
-   }
-
-   protected void waitForMessagesToBeDelivered() {
-      // let's give the listeners enough time to read all messages
-      long maxWaitTime = counter * 1000;
-      long waitTime = maxWaitTime;
-      long start = (maxWaitTime <= 0) ? 0 : System.currentTimeMillis();
-
-      synchronized (lock) {
-         boolean hasMessages = true;
-         while (hasMessages && waitTime >= 0) {
-            try {
-               lock.wait(200);
-            }
-            catch (InterruptedException e) {
-               LOG.error(e.toString());
-            }
-            // check if all messages have been received
-            hasMessages = hectorToHaloCtr < counter || xenaToHaloCtr < counter || troyToHaloCtr < counter || haloToHectorCtr < counter || haloToXenaCtr < counter || haloToTroyCtr < counter;
-            waitTime = maxWaitTime - (System.currentTimeMillis() - start);
-         }
-      }
-   }
-
-   public MessageSender buildTransactionalProducer(String queueName,
-                                                   Connection connection,
-                                                   boolean isTopic) throws Exception {
-
-      return new MessageSender(queueName, connection, true, isTopic);
-   }
-
-   public Thread buildProducer(Connection connection, final String queueName) throws Exception {
-      return buildProducer(connection, queueName, false, false);
-   }
-
-   public Thread buildProducer(Connection connection,
-                               final String queueName,
-                               boolean transacted,
-                               boolean isTopic) throws Exception {
-      final MessageSender producer = new MessageSender(queueName, connection, transacted, isTopic);
-      Thread thread = new Thread() {
-         @Override
-         public synchronized void run() {
-            for (int i = 0; i < counter; i++) {
-               try {
-                  producer.send(payload);
-               }
-               catch (Exception e) {
-                  throw new RuntimeException("on " + queueName + " send", e);
-               }
-            }
-         }
-      };
-      return thread;
-   }
-
-   public void buildReceiver(Connection connection,
-                             final String queueName,
-                             boolean transacted,
-                             final Receiver receiver,
-                             boolean isTopic) throws Exception {
-      final Session session = transacted ? connection.createSession(true, Session.SESSION_TRANSACTED) : connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer inputMessageConsumer = session.createConsumer(isTopic ? session.createTopic(queueName) : session.createQueue(queueName));
-      MessageListener messageListener = new MessageListener() {
-
-         @Override
-         public void onMessage(Message message) {
-            try {
-               ObjectMessage objectMessage = (ObjectMessage) message;
-               String s = (String) objectMessage.getObject();
-               receiver.receive(s);
-               if (session.getTransacted()) {
-                  session.commit();
-               }
-
-            }
-            catch (Exception e) {
-               e.printStackTrace();
-            }
-         }
-      };
-      inputMessageConsumer.setMessageListener(messageListener);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/OptimizeAcknowledgeWithExpiredMsgsTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/OptimizeAcknowledgeWithExpiredMsgsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/OptimizeAcknowledgeWithExpiredMsgsTest.java
deleted file mode 100644
index 4bc92ad..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/OptimizeAcknowledgeWithExpiredMsgsTest.java
+++ /dev/null
@@ -1,309 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Test for AMQ-3965.
- * A consumer may be stalled in case it uses optimizeAcknowledge and receives
- * a number of messages that expire before being dispatched to application code.
- * See for more details.
- */
-public class OptimizeAcknowledgeWithExpiredMsgsTest {
-
-   private final static Logger LOG = LoggerFactory.getLogger(OptimizeAcknowledgeWithExpiredMsgsTest.class);
-
-   private BrokerService broker = null;
-
-   private String connectionUri;
-
-   /**
-    * Creates a broker instance but does not start it.
-    *
-    * @param brokerUri  - transport uri of broker
-    * @param brokerName - name for the broker
-    * @return a BrokerService instance with transport uri and broker name set
-    * @throws Exception
-    */
-   protected BrokerService createBroker() throws Exception {
-      BrokerService broker = new BrokerService();
-      broker.setPersistent(false);
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.setUseJmx(false);
-      connectionUri = broker.addConnector("tcp://localhost:0").getPublishableConnectString();
-      return broker;
-   }
-
-   @Before
-   public void setUp() throws Exception {
-      broker = createBroker();
-      broker.start();
-      broker.waitUntilStarted();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-         broker = null;
-      }
-   }
-
-   /**
-    * Tests for AMQ-3965
-    * Creates connection into broker using optimzeAcknowledge and prefetch=100
-    * Creates producer and consumer. Producer sends 45 msgs that will expire
-    * at consumer (but before being dispatched to app code).
-    * Producer then sends 60 msgs without expiry.
-    *
-    * Consumer receives msgs using a MessageListener and increments a counter.
-    * Main thread sleeps for 5 seconds and checks the counter value.
-    * If counter != 60 msgs (the number of msgs that should get dispatched
-    * to consumer) the test fails.
-    */
-   @Test
-   public void testOptimizedAckWithExpiredMsgs() throws Exception {
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(connectionUri + "?jms.optimizeAcknowledge=true&jms.prefetchPolicy.all=100");
-
-      // Create JMS resources
-      Connection connection = connectionFactory.createConnection();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Destination destination = session.createQueue("TEST.FOO");
-
-      // ***** Consumer code *****
-      MessageConsumer consumer = session.createConsumer(destination);
-
-      final MyMessageListener listener = new MyMessageListener();
-      connection.setExceptionListener(listener);
-
-      // ***** Producer Code *****
-      MessageProducer producer = session.createProducer(destination);
-      producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
-      String text = "Hello world! From: " + Thread.currentThread().getName() + " : " + this.hashCode();
-      TextMessage message;
-
-      // Produce msgs that will expire quickly
-      for (int i = 0; i < 45; i++) {
-         message = session.createTextMessage(text);
-         producer.send(message, 1, 1, 100);
-         LOG.trace("Sent message: " + message.getJMSMessageID() +
-                      " with expiry 10 msec");
-      }
-      // Produce msgs that don't expire
-      for (int i = 0; i < 60; i++) {
-         message = session.createTextMessage(text);
-         producer.send(message, 1, 1, 60000);
-         // producer.send(message);
-         LOG.trace("Sent message: " + message.getJMSMessageID() +
-                      " with expiry 30 sec");
-      }
-      consumer.setMessageListener(listener);
-
-      sleep(1000);  // let the batch of 45 expire.
-
-      connection.start();
-
-      assertTrue("Should receive all expected messages, counter at " + listener.getCounter(), Wait.waitFor(new Wait.Condition() {
-
-         @Override
-         public boolean isSatisified() throws Exception {
-            return listener.getCounter() == 60;
-         }
-      }));
-
-      LOG.info("Received all expected messages with counter at: " + listener.getCounter());
-
-      // Cleanup
-      producer.close();
-      consumer.close();
-      session.close();
-      connection.close();
-   }
-
-   @Test
-   public void testOptimizedAckWithExpiredMsgsSync() throws Exception {
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(connectionUri + "?jms.optimizeAcknowledge=true&jms.prefetchPolicy.all=100");
-
-      // Create JMS resources
-      Connection connection = connectionFactory.createConnection();
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Destination destination = session.createQueue("TEST.FOO");
-
-      // ***** Consumer code *****
-      MessageConsumer consumer = session.createConsumer(destination);
-
-      // ***** Producer Code *****
-      MessageProducer producer = session.createProducer(destination);
-      producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
-      String text = "Hello world! From: " + Thread.currentThread().getName() + " : " + this.hashCode();
-      TextMessage message;
-
-      // Produce msgs that will expire quickly
-      for (int i = 0; i < 45; i++) {
-         message = session.createTextMessage(text);
-         producer.send(message, 1, 1, 10);
-         LOG.trace("Sent message: " + message.getJMSMessageID() +
-                      " with expiry 10 msec");
-      }
-      // Produce msgs that don't expire
-      for (int i = 0; i < 60; i++) {
-         message = session.createTextMessage(text);
-         producer.send(message, 1, 1, 30000);
-         // producer.send(message);
-         LOG.trace("Sent message: " + message.getJMSMessageID() +
-                      " with expiry 30 sec");
-      }
-      sleep(200);
-
-      int counter = 1;
-      for (; counter <= 60; ++counter) {
-         assertNotNull(consumer.receive(2000));
-         LOG.info("counter at " + counter);
-      }
-      LOG.info("Received all expected messages with counter at: " + counter);
-
-      // Cleanup
-      producer.close();
-      consumer.close();
-      session.close();
-      connection.close();
-   }
-
-   @Test
-   public void testOptimizedAckWithExpiredMsgsSync2() throws Exception {
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(connectionUri + "?jms.optimizeAcknowledge=true&jms.prefetchPolicy.all=100");
-
-      // Create JMS resources
-      Connection connection = connectionFactory.createConnection();
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Destination destination = session.createQueue("TEST.FOO");
-
-      // ***** Consumer code *****
-      MessageConsumer consumer = session.createConsumer(destination);
-
-      // ***** Producer Code *****
-      MessageProducer producer = session.createProducer(destination);
-      producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
-      String text = "Hello world! From: " + Thread.currentThread().getName() + " : " + this.hashCode();
-      TextMessage message;
-
-      // Produce msgs that don't expire
-      for (int i = 0; i < 56; i++) {
-         message = session.createTextMessage(text);
-         producer.send(message, 1, 1, 30000);
-         // producer.send(message);
-         LOG.trace("Sent message: " + message.getJMSMessageID() +
-                      " with expiry 30 sec");
-      }
-      // Produce msgs that will expire quickly
-      for (int i = 0; i < 44; i++) {
-         message = session.createTextMessage(text);
-         producer.send(message, 1, 1, 10);
-         LOG.trace("Sent message: " + message.getJMSMessageID() +
-                      " with expiry 10 msec");
-      }
-      // Produce some moremsgs that don't expire
-      for (int i = 0; i < 4; i++) {
-         message = session.createTextMessage(text);
-         producer.send(message, 1, 1, 30000);
-         // producer.send(message);
-         LOG.trace("Sent message: " + message.getJMSMessageID() +
-                      " with expiry 30 sec");
-      }
-
-      sleep(200);
-
-      int counter = 1;
-      for (; counter <= 60; ++counter) {
-         assertNotNull(consumer.receive(2000));
-         LOG.info("counter at " + counter);
-      }
-      LOG.info("Received all expected messages with counter at: " + counter);
-
-      // Cleanup
-      producer.close();
-      consumer.close();
-      session.close();
-      connection.close();
-   }
-
-   private void sleep(int milliSecondTime) {
-      try {
-         Thread.sleep(milliSecondTime);
-      }
-      catch (InterruptedException igonred) {
-      }
-   }
-
-   /**
-    * Standard JMS MessageListener
-    */
-   private class MyMessageListener implements MessageListener, ExceptionListener {
-
-      private AtomicInteger counter = new AtomicInteger(0);
-
-      @Override
-      public void onMessage(final Message message) {
-         try {
-            LOG.trace("Got Message " + message.getJMSMessageID());
-            LOG.info("counter at " + counter.incrementAndGet());
-         }
-         catch (final Exception e) {
-         }
-      }
-
-      public int getCounter() {
-         return counter.get();
-      }
-
-      @Override
-      public synchronized void onException(JMSException ex) {
-         LOG.error("JMS Exception occurred.  Shutting down client.");
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/OutOfOrderTestCase.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/OutOfOrderTestCase.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/OutOfOrderTestCase.java
deleted file mode 100644
index 2b84862..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/OutOfOrderTestCase.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * 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;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class OutOfOrderTestCase extends TestCase {
-
-   private static final Logger log = LoggerFactory.getLogger(OutOfOrderTestCase.class);
-
-   private static final String BROKER_URL = "tcp://localhost:0";
-   private static final int PREFETCH = 10;
-   private static final String CONNECTION_URL_OPTIONS = "?jms.prefetchPolicy.all=" + PREFETCH;
-
-   private static final String DESTINATION = "QUEUE?consumer.exclusive=true";
-
-   private BrokerService brokerService;
-   private Session session;
-   private Connection connection;
-   private String connectionUri;
-
-   private int seq = 0;
-
-   @Override
-   public void setUp() throws Exception {
-      brokerService = new BrokerService();
-      brokerService.setUseJmx(true);
-      brokerService.addConnector(BROKER_URL);
-      brokerService.deleteAllMessages();
-      brokerService.start();
-      brokerService.waitUntilStarted();
-
-      connectionUri = brokerService.getTransportConnectors().get(0).getPublishableConnectString();
-
-      ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(connectionUri + CONNECTION_URL_OPTIONS);
-      connection = connectionFactory.createConnection();
-      connection.start();
-      session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      session.close();
-      connection.close();
-      brokerService.stop();
-   }
-
-   public void testOrder() throws Exception {
-
-      log.info("Producing messages 0-29 . . .");
-      Destination destination = session.createQueue(DESTINATION);
-      final MessageProducer messageProducer = session.createProducer(destination);
-      try {
-         for (int i = 0; i < 30; ++i) {
-            final Message message = session.createTextMessage(createMessageText(i));
-            message.setStringProperty("JMSXGroupID", "FOO");
-
-            messageProducer.send(message);
-            log.info("sent " + toString(message));
-         }
-      }
-      finally {
-         messageProducer.close();
-      }
-
-      log.info("Consuming messages 0-9 . . .");
-      consumeBatch();
-
-      log.info("Consuming messages 10-19 . . .");
-      consumeBatch();
-
-      log.info("Consuming messages 20-29 . . .");
-      consumeBatch();
-   }
-
-   protected void consumeBatch() throws Exception {
-      Destination destination = session.createQueue(DESTINATION);
-      final MessageConsumer messageConsumer = session.createConsumer(destination);
-      try {
-         for (int i = 0; i < 10; ++i) {
-            final Message message = messageConsumer.receive(1000L);
-            log.info("received " + toString(message));
-            assertEquals("Message out of order", createMessageText(seq++), ((TextMessage) message).getText());
-            message.acknowledge();
-         }
-      }
-      finally {
-         messageConsumer.close();
-      }
-   }
-
-   private String toString(final Message message) throws JMSException {
-      String ret = "received message '" + ((TextMessage) message).getText() + "' - " + message.getJMSMessageID();
-      if (message.getJMSRedelivered())
-         ret += " (redelivered)";
-      return ret;
-
-   }
-
-   private static String createMessageText(final int index) {
-      return "message #" + index;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/QueueWorkerPrefetchTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/QueueWorkerPrefetchTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/QueueWorkerPrefetchTest.java
deleted file mode 100644
index 95057b9..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/QueueWorkerPrefetchTest.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/**
- * 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;
-
-import java.io.Serializable;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.AtomicReference;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.Session;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQPrefetchPolicy;
-import org.apache.activemq.broker.BrokerService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Test case demonstrating situation where messages are not delivered to
- * consumers.
- */
-public class QueueWorkerPrefetchTest extends TestCase implements MessageListener {
-
-   private static final Logger LOG = LoggerFactory.getLogger(QueueWorkerPrefetchTest.class);
-   private static final int BATCH_SIZE = 10;
-   private static final long WAIT_TIMEOUT = 1000 * 10;
-
-   /**
-    * The connection URL.
-    */
-   private static final String BROKER_BIND_ADDRESS = "tcp://localhost:0";
-
-   /**
-    * The queue prefetch size to use. A value greater than 1 seems to make
-    * things work.
-    */
-   private static final int QUEUE_PREFETCH_SIZE = 1;
-
-   /**
-    * The number of workers to use. A single worker with a prefetch of 1 works.
-    */
-   private static final int NUM_WORKERS = 2;
-
-   /**
-    * Embedded JMS broker.
-    */
-   private BrokerService broker;
-
-   /**
-    * The master's producer object for creating work items.
-    */
-   private MessageProducer workItemProducer;
-
-   /**
-    * The master's consumer object for consuming ack messages from workers.
-    */
-   private MessageConsumer masterItemConsumer;
-
-   /**
-    * The number of acks received by the master.
-    */
-   private final AtomicLong acksReceived = new AtomicLong(0);
-
-   private final AtomicReference<CountDownLatch> latch = new AtomicReference<>();
-
-   private String connectionUri;
-
-   /**
-    * Messages sent to the work-item queue.
-    */
-   private static class WorkMessage implements Serializable {
-
-      private static final long serialVersionUID = 1L;
-      private final int id;
-
-      public WorkMessage(int id) {
-         this.id = id;
-      }
-
-      @Override
-      public String toString() {
-         return "Work: " + id;
-      }
-   }
-
-   /**
-    * The worker process. Consume messages from the work-item queue, possibly
-    * creating more messages to submit to the work-item queue. For each work
-    * item, send an ack to the master.
-    */
-   private static class Worker implements MessageListener {
-
-      /**
-       * Counter shared between workers to decided when new work-item messages
-       * are created.
-       */
-      private static AtomicInteger counter = new AtomicInteger(0);
-
-      /**
-       * Session to use.
-       */
-      private Session session;
-
-      /**
-       * Producer for sending ack messages to the master.
-       */
-      private MessageProducer masterItemProducer;
-
-      /**
-       * Producer for sending new work items to the work-items queue.
-       */
-      private MessageProducer workItemProducer;
-
-      public Worker(Session session) throws JMSException {
-         this.session = session;
-         masterItemProducer = session.createProducer(session.createQueue("master-item"));
-         Queue workItemQueue = session.createQueue("work-item");
-         workItemProducer = session.createProducer(workItemQueue);
-         MessageConsumer workItemConsumer = session.createConsumer(workItemQueue);
-         workItemConsumer.setMessageListener(this);
-      }
-
-      @Override
-      public void onMessage(javax.jms.Message message) {
-         try {
-            WorkMessage work = (WorkMessage) ((ObjectMessage) message).getObject();
-
-            long c = counter.incrementAndGet();
-
-            // Don't create a new work item for every BATCH_SIZE message. */
-            if (c % BATCH_SIZE != 0) {
-               // Send new work item to work-item queue.
-               workItemProducer.send(session.createObjectMessage(new WorkMessage(work.id + 1)));
-            }
-
-            // Send ack to master.
-            masterItemProducer.send(session.createObjectMessage(work));
-         }
-         catch (JMSException e) {
-            throw new IllegalStateException("Something has gone wrong", e);
-         }
-      }
-
-      /**
-       * Close of JMS resources used by worker.
-       */
-      public void close() throws JMSException {
-         masterItemProducer.close();
-         workItemProducer.close();
-         session.close();
-      }
-   }
-
-   /**
-    * Master message handler. Process ack messages.
-    */
-   @Override
-   public void onMessage(javax.jms.Message message) {
-      long acks = acksReceived.incrementAndGet();
-      latch.get().countDown();
-      if (acks % 1 == 0) {
-         LOG.info("Master now has ack count of: " + acksReceived);
-      }
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      // Create the message broker.
-      super.setUp();
-      broker = new BrokerService();
-      broker.setPersistent(false);
-      broker.setUseJmx(true);
-      broker.addConnector(BROKER_BIND_ADDRESS);
-      broker.start();
-      broker.waitUntilStarted();
-
-      connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      // Shut down the message broker.
-      broker.deleteAllMessages();
-      broker.stop();
-      super.tearDown();
-   }
-
-   public void testActiveMQ() throws Exception {
-      // Create the connection to the broker.
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(connectionUri);
-      ActiveMQPrefetchPolicy prefetchPolicy = new ActiveMQPrefetchPolicy();
-      prefetchPolicy.setQueuePrefetch(QUEUE_PREFETCH_SIZE);
-      connectionFactory.setPrefetchPolicy(prefetchPolicy);
-      Connection connection = connectionFactory.createConnection();
-      connection.start();
-
-      Session masterSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      workItemProducer = masterSession.createProducer(masterSession.createQueue("work-item"));
-      masterItemConsumer = masterSession.createConsumer(masterSession.createQueue("master-item"));
-      masterItemConsumer.setMessageListener(this);
-
-      // Create the workers.
-      Worker[] workers = new Worker[NUM_WORKERS];
-      for (int i = 0; i < NUM_WORKERS; i++) {
-         workers[i] = new Worker(connection.createSession(false, Session.AUTO_ACKNOWLEDGE));
-      }
-
-      // Send a message to the work queue, and wait for the BATCH_SIZE acks
-      // from the workers.
-      acksReceived.set(0);
-      latch.set(new CountDownLatch(BATCH_SIZE));
-      workItemProducer.send(masterSession.createObjectMessage(new WorkMessage(1)));
-
-      if (!latch.get().await(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)) {
-         fail("First batch only received " + acksReceived + " messages");
-      }
-
-      LOG.info("First batch received");
-
-      // Send another message to the work queue, and wait for the next 1000 acks. It is
-      // at this point where the workers never get notified of this message, as they
-      // have a large pending queue. Creating a new worker at this point however will
-      // receive this new message.
-      acksReceived.set(0);
-      latch.set(new CountDownLatch(BATCH_SIZE));
-      workItemProducer.send(masterSession.createObjectMessage(new WorkMessage(1)));
-
-      if (!latch.get().await(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)) {
-         fail("Second batch only received " + acksReceived + " messages");
-      }
-
-      LOG.info("Second batch received");
-
-      // Cleanup all JMS resources.
-      for (int i = 0; i < NUM_WORKERS; i++) {
-         workers[i].close();
-      }
-      masterSession.close();
-      connection.close();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/RawRollbackSharedConsumerTests.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/RawRollbackSharedConsumerTests.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/RawRollbackSharedConsumerTests.java
deleted file mode 100644
index 549922d..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/RawRollbackSharedConsumerTests.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class RawRollbackSharedConsumerTests {
-
-   private static ConnectionFactory connectionFactory;
-   private static Destination queue;
-   private static BrokerService broker;
-
-   @BeforeClass
-   public static void clean() throws Exception {
-      broker = new BrokerService();
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.setUseJmx(true);
-      broker.start();
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
-      connectionFactory.setBrokerURL("vm://localhost?async=false");
-      RawRollbackSharedConsumerTests.connectionFactory = connectionFactory;
-      queue = new ActiveMQQueue("queue");
-   }
-
-   @AfterClass
-   public static void close() throws Exception {
-      broker.stop();
-   }
-
-   @Before
-   public void clearData() throws Exception {
-      getMessages(false); // drain queue
-      convertAndSend("foo");
-      convertAndSend("bar");
-   }
-
-   @After
-   public void checkPostConditions() throws Exception {
-
-      Thread.sleep(1000L);
-      List<String> list = getMessages(false);
-      assertEquals(2, list.size());
-
-   }
-
-   @Test
-   public void testReceiveMessages() throws Exception {
-
-      List<String> list = getMessages(true);
-      assertEquals(2, list.size());
-      assertTrue(list.contains("foo"));
-
-   }
-
-   private void convertAndSend(String msg) throws Exception {
-      Connection connection = connectionFactory.createConnection();
-      connection.start();
-      Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = session.createProducer(queue);
-      producer.send(session.createTextMessage(msg));
-      producer.close();
-      session.commit();
-      session.close();
-      connection.close();
-   }
-
-   private List<String> getMessages(boolean rollback) throws Exception {
-      Connection connection = connectionFactory.createConnection();
-      connection.start();
-      Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
-      String next = "";
-      List<String> msgs = new ArrayList<>();
-      MessageConsumer consumer = session.createConsumer(queue);
-      while (next != null) {
-         next = receiveAndConvert(consumer);
-         if (next != null)
-            msgs.add(next);
-      }
-      consumer.close();
-      if (rollback) {
-         session.rollback();
-      }
-      else {
-         session.commit();
-      }
-      session.close();
-      connection.close();
-      return msgs;
-   }
-
-   private String receiveAndConvert(MessageConsumer consumer) throws Exception {
-      Message message = consumer.receive(100L);
-      if (message == null) {
-         return null;
-      }
-      return ((TextMessage) message).getText();
-   }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/RawRollbackTests.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/RawRollbackTests.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/RawRollbackTests.java
deleted file mode 100644
index 74437b7..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/RawRollbackTests.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class RawRollbackTests {
-
-   private static ConnectionFactory connectionFactory;
-   private static Destination queue;
-   private static BrokerService broker;
-
-   @BeforeClass
-   public static void clean() throws Exception {
-      broker = new BrokerService();
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.setUseJmx(true);
-      broker.start();
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
-      connectionFactory.setBrokerURL("vm://localhost?async=false&waitForStart=5000&jms.prefetchPolicy.all=0");
-      RawRollbackTests.connectionFactory = connectionFactory;
-      queue = new ActiveMQQueue("queue");
-   }
-
-   @AfterClass
-   public static void close() throws Exception {
-      broker.stop();
-   }
-
-   @Before
-   public void clearData() throws Exception {
-      getMessages(false); // drain queue
-      convertAndSend("foo");
-      convertAndSend("bar");
-   }
-
-   @After
-   public void checkPostConditions() throws Exception {
-
-      Thread.sleep(1000L);
-      List<String> list = getMessages(false);
-      assertEquals(2, list.size());
-
-   }
-
-   @Test
-   public void testReceiveMessages() throws Exception {
-
-      List<String> list = getMessages(true);
-      assertEquals(2, list.size());
-      assertTrue(list.contains("foo"));
-
-   }
-
-   private void convertAndSend(String msg) throws Exception {
-      Connection connection = connectionFactory.createConnection();
-      connection.start();
-      Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = session.createProducer(queue);
-      producer.send(session.createTextMessage(msg));
-      producer.close();
-      session.commit();
-      session.close();
-      connection.close();
-   }
-
-   private List<String> getMessages(boolean rollback) throws Exception {
-      Connection connection = connectionFactory.createConnection();
-      connection.start();
-      Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
-      String next = "";
-      List<String> msgs = new ArrayList<>();
-      while (next != null) {
-         next = receiveAndConvert(session);
-         if (next != null)
-            msgs.add(next);
-      }
-      if (rollback) {
-         session.rollback();
-      }
-      else {
-         session.commit();
-      }
-      session.close();
-      connection.close();
-      return msgs;
-   }
-
-   private String receiveAndConvert(Session session) throws Exception {
-      MessageConsumer consumer = session.createConsumer(queue);
-      Message message = consumer.receive(100L);
-      consumer.close();
-      if (message == null) {
-         return null;
-      }
-      return ((TextMessage) message).getText();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/Receiver.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/Receiver.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/Receiver.java
deleted file mode 100644
index e6d1d40..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/Receiver.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * 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;
-
-public interface Receiver {
-
-   void receive(String s) throws Exception;
-}


[19/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4083Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4083Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4083Test.java
deleted file mode 100644
index 882105b..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4083Test.java
+++ /dev/null
@@ -1,520 +0,0 @@
-/**
- * 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;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.management.ObjectName;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQPrefetchPolicy;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.QueueViewMBean;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class AMQ4083Test {
-
-   private static final transient Logger LOG = LoggerFactory.getLogger(AMQ3992Test.class);
-   private static BrokerService brokerService;
-   private static String BROKER_ADDRESS = "tcp://localhost:0";
-   private static String TEST_QUEUE = "testQueue";
-   private static ActiveMQQueue queue = new ActiveMQQueue(TEST_QUEUE);
-
-   private final int messageCount = 100;
-
-   private String connectionUri;
-   private String[] data;
-
-   @Before
-   public void setUp() throws Exception {
-      brokerService = new BrokerService();
-      brokerService.setPersistent(false);
-      brokerService.setUseJmx(true);
-      brokerService.setDeleteAllMessagesOnStartup(true);
-      connectionUri = brokerService.addConnector(BROKER_ADDRESS).getPublishableConnectString();
-      brokerService.start();
-      brokerService.waitUntilStarted();
-
-      data = new String[messageCount];
-
-      for (int i = 0; i < messageCount; i++) {
-         data[i] = "Text for message: " + i + " at " + new Date();
-      }
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      brokerService.stop();
-      brokerService.waitUntilStopped();
-   }
-
-   @Test
-   public void testExpiredMsgsBeforeNonExpired() throws Exception {
-
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri);
-      ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
-      connection.getPrefetchPolicy().setQueuePrefetch(400);
-
-      Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
-      connection.start();
-
-      MessageProducer producer = session.createProducer(queue);
-      MessageConsumer consumer = session.createConsumer(queue);
-
-      // send a batch that expires in a short time.
-      for (int i = 0; i < 100; i++) {
-         producer.send(session.createTextMessage(), DeliveryMode.PERSISTENT, 4, 4000);
-      }
-
-      // and send one that doesn't expire to we can ack it.
-      producer.send(session.createTextMessage());
-
-      // wait long enough so the first batch times out.
-      TimeUnit.SECONDS.sleep(5);
-
-      final QueueViewMBean queueView = getProxyToQueueViewMBean();
-
-      assertEquals(101, queueView.getInFlightCount());
-
-      consumer.setMessageListener(new MessageListener() {
-         @Override
-         public void onMessage(Message message) {
-            try {
-               message.acknowledge();
-            }
-            catch (JMSException e) {
-            }
-         }
-      });
-
-      TimeUnit.SECONDS.sleep(5);
-
-      assertEquals(0, queueView.getInFlightCount());
-
-      for (int i = 0; i < 200; i++) {
-         producer.send(session.createTextMessage());
-      }
-
-      assertTrue("Inflight count should reach zero, currently: " + queueView.getInFlightCount(), Wait.waitFor(new Wait.Condition() {
-
-         @Override
-         public boolean isSatisified() throws Exception {
-            return queueView.getInFlightCount() == 0;
-         }
-      }));
-
-      LOG.info("Dequeued Count: {}", queueView.getDequeueCount());
-      LOG.info("Dispatch Count: {}", queueView.getDispatchCount());
-      LOG.info("Enqueue Count: {}", queueView.getEnqueueCount());
-      LOG.info("Expired Count: {}", queueView.getExpiredCount());
-      LOG.info("InFlight Count: {}", queueView.getInFlightCount());
-   }
-
-   @Test
-   public void testExpiredMsgsBeforeNonExpiredWithTX() throws Exception {
-
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri);
-      ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
-      connection.getPrefetchPolicy().setQueuePrefetch(400);
-
-      final Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-
-      connection.start();
-
-      MessageProducer producer = session.createProducer(queue);
-      MessageConsumer consumer = session.createConsumer(queue);
-
-      // send a batch that expires in a short time.
-      for (int i = 0; i < 100; i++) {
-         producer.send(session.createTextMessage(), DeliveryMode.PERSISTENT, 4, 4000);
-      }
-
-      // and send one that doesn't expire to we can ack it.
-      producer.send(session.createTextMessage());
-      session.commit();
-
-      // wait long enough so the first batch times out.
-      TimeUnit.SECONDS.sleep(5);
-
-      final QueueViewMBean queueView = getProxyToQueueViewMBean();
-
-      assertEquals(101, queueView.getInFlightCount());
-
-      consumer.setMessageListener(new MessageListener() {
-         @Override
-         public void onMessage(Message message) {
-            try {
-               session.commit();
-            }
-            catch (JMSException e) {
-            }
-         }
-      });
-
-      TimeUnit.SECONDS.sleep(5);
-
-      assertEquals(0, queueView.getInFlightCount());
-
-      for (int i = 0; i < 200; i++) {
-         producer.send(session.createTextMessage());
-      }
-      session.commit();
-
-      assertTrue("Inflight count should reach zero, currently: " + queueView.getInFlightCount(), Wait.waitFor(new Wait.Condition() {
-
-         @Override
-         public boolean isSatisified() throws Exception {
-            return queueView.getInFlightCount() == 0;
-         }
-      }));
-
-      LOG.info("Dequeued Count: {}", queueView.getDequeueCount());
-      LOG.info("Dispatch Count: {}", queueView.getDispatchCount());
-      LOG.info("Enqueue Count: {}", queueView.getEnqueueCount());
-      LOG.info("Expired Count: {}", queueView.getExpiredCount());
-      LOG.info("InFlight Count: {}", queueView.getInFlightCount());
-   }
-
-   @Test
-   public void testExpiredMsgsInterleavedWithNonExpired() throws Exception {
-
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri);
-      ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
-      connection.getPrefetchPolicy().setQueuePrefetch(400);
-
-      Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
-      connection.start();
-
-      MessageProducer producer = session.createProducer(queue);
-      MessageConsumer consumer = session.createConsumer(queue);
-
-      // send a batch that expires in a short time.
-      for (int i = 0; i < 200; i++) {
-
-         if ((i % 2) == 0) {
-            producer.send(session.createTextMessage(), DeliveryMode.PERSISTENT, 4, 4000);
-         }
-         else {
-            producer.send(session.createTextMessage());
-         }
-      }
-
-      // wait long enough so the first batch times out.
-      TimeUnit.SECONDS.sleep(5);
-
-      final QueueViewMBean queueView = getProxyToQueueViewMBean();
-
-      assertEquals(200, queueView.getInFlightCount());
-
-      consumer.setMessageListener(new MessageListener() {
-
-         @Override
-         public void onMessage(Message message) {
-            try {
-               LOG.debug("Acking message: {}", message);
-               message.acknowledge();
-            }
-            catch (JMSException e) {
-            }
-         }
-      });
-
-      TimeUnit.SECONDS.sleep(5);
-
-      assertTrue("Inflight count should reach zero, currently: " + queueView.getInFlightCount(), Wait.waitFor(new Wait.Condition() {
-
-         @Override
-         public boolean isSatisified() throws Exception {
-            return queueView.getInFlightCount() == 0;
-         }
-      }));
-
-      for (int i = 0; i < 200; i++) {
-         producer.send(session.createTextMessage());
-      }
-
-      assertTrue("Inflight count should reach zero, currently: " + queueView.getInFlightCount(), Wait.waitFor(new Wait.Condition() {
-
-         @Override
-         public boolean isSatisified() throws Exception {
-            return queueView.getInFlightCount() == 0;
-         }
-      }));
-
-      LOG.info("Dequeued Count: {}", queueView.getDequeueCount());
-      LOG.info("Dispatch Count: {}", queueView.getDispatchCount());
-      LOG.info("Enqueue Count: {}", queueView.getEnqueueCount());
-      LOG.info("Expired Count: {}", queueView.getExpiredCount());
-      LOG.info("InFlight Count: {}", queueView.getInFlightCount());
-   }
-
-   @Test
-   public void testExpiredMsgsInterleavedWithNonExpiredCumulativeAck() throws Exception {
-
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri);
-      ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
-      connection.getPrefetchPolicy().setQueuePrefetch(400);
-
-      Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
-      connection.start();
-
-      MessageProducer producer = session.createProducer(queue);
-      MessageConsumer consumer = session.createConsumer(queue);
-
-      // send a batch that expires in a short time.
-      for (int i = 0; i < 200; i++) {
-
-         if ((i % 2) == 0) {
-            producer.send(session.createTextMessage(), DeliveryMode.PERSISTENT, 4, 4000);
-         }
-         else {
-            producer.send(session.createTextMessage());
-         }
-      }
-
-      // wait long enough so the first batch times out.
-      TimeUnit.SECONDS.sleep(5);
-
-      final QueueViewMBean queueView = getProxyToQueueViewMBean();
-
-      assertEquals(200, queueView.getInFlightCount());
-
-      final AtomicInteger msgCount = new AtomicInteger();
-
-      consumer.setMessageListener(new MessageListener() {
-
-         @Override
-         public void onMessage(Message message) {
-            try {
-               if (msgCount.incrementAndGet() == 100) {
-                  LOG.debug("Acking message: {}", message);
-                  message.acknowledge();
-               }
-            }
-            catch (JMSException e) {
-            }
-         }
-      });
-
-      TimeUnit.SECONDS.sleep(5);
-
-      assertTrue("Inflight count should reach zero, currently: " + queueView.getInFlightCount(), Wait.waitFor(new Wait.Condition() {
-
-         @Override
-         public boolean isSatisified() throws Exception {
-            return queueView.getInFlightCount() == 0;
-         }
-      }));
-
-      // Now we just ack each and see if our counters come out right in the end.
-      consumer.setMessageListener(new MessageListener() {
-
-         @Override
-         public void onMessage(Message message) {
-            try {
-               LOG.debug("Acking message: {}", message);
-               message.acknowledge();
-            }
-            catch (JMSException e) {
-            }
-         }
-      });
-
-      for (int i = 0; i < 200; i++) {
-         producer.send(session.createTextMessage());
-      }
-
-      assertTrue("Inflight count should reach zero, currently: " + queueView.getInFlightCount(), Wait.waitFor(new Wait.Condition() {
-
-         @Override
-         public boolean isSatisified() throws Exception {
-            return queueView.getInFlightCount() == 0;
-         }
-      }));
-
-      LOG.info("Dequeued Count: {}", queueView.getDequeueCount());
-      LOG.info("Dispatch Count: {}", queueView.getDispatchCount());
-      LOG.info("Enqueue Count: {}", queueView.getEnqueueCount());
-      LOG.info("Expired Count: {}", queueView.getExpiredCount());
-      LOG.info("InFlight Count: {}", queueView.getInFlightCount());
-   }
-
-   @Test
-   public void testExpiredBatchBetweenNonExpiredMessages() throws Exception {
-
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri);
-      ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
-      connection.getPrefetchPolicy().setQueuePrefetch(400);
-
-      Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
-      connection.start();
-
-      MessageProducer producer = session.createProducer(queue);
-      MessageConsumer consumer = session.createConsumer(queue);
-
-      // Send one that doesn't expire so we can ack it.
-      producer.send(session.createTextMessage());
-
-      // send a batch that expires in a short time.
-      for (int i = 0; i < 100; i++) {
-         producer.send(session.createTextMessage(), DeliveryMode.PERSISTENT, 4, 4000);
-      }
-
-      // and send one that doesn't expire so we can ack it.
-      producer.send(session.createTextMessage());
-
-      // wait long enough so the first batch times out.
-      TimeUnit.SECONDS.sleep(5);
-
-      final QueueViewMBean queueView = getProxyToQueueViewMBean();
-
-      assertEquals(102, queueView.getInFlightCount());
-
-      consumer.setMessageListener(new MessageListener() {
-
-         @Override
-         public void onMessage(Message message) {
-            try {
-               message.acknowledge();
-            }
-            catch (JMSException e) {
-            }
-         }
-      });
-
-      TimeUnit.SECONDS.sleep(5);
-
-      assertTrue("Inflight count should reach zero, currently: " + queueView.getInFlightCount(), Wait.waitFor(new Wait.Condition() {
-
-         @Override
-         public boolean isSatisified() throws Exception {
-            return queueView.getInFlightCount() == 0;
-         }
-      }));
-
-      for (int i = 0; i < 200; i++) {
-         producer.send(session.createTextMessage());
-      }
-
-      assertTrue("Inflight count should reach zero, currently: " + queueView.getInFlightCount(), Wait.waitFor(new Wait.Condition() {
-
-         @Override
-         public boolean isSatisified() throws Exception {
-            return queueView.getInFlightCount() == 0;
-         }
-      }));
-
-      LOG.info("Dequeued Count: {}", queueView.getDequeueCount());
-      LOG.info("Dispatch Count: {}", queueView.getDispatchCount());
-      LOG.info("Enqueue Count: {}", queueView.getEnqueueCount());
-      LOG.info("Expired Count: {}", queueView.getExpiredCount());
-      LOG.info("InFlight Count: {}", queueView.getInFlightCount());
-   }
-
-   @Test
-   public void testConsumeExpiredQueueAndDlq() throws Exception {
-
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri);
-      Connection connection = factory.createConnection();
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      MessageProducer producerNormal = session.createProducer(queue);
-      MessageProducer producerExpire = session.createProducer(queue);
-      producerExpire.setTimeToLive(500);
-
-      MessageConsumer dlqConsumer = session.createConsumer(session.createQueue("ActiveMQ.DLQ"));
-      connection.start();
-
-      Connection consumerConnection = factory.createConnection();
-      ActiveMQPrefetchPolicy prefetchPolicy = new ActiveMQPrefetchPolicy();
-      prefetchPolicy.setAll(10);
-      ((ActiveMQConnection) consumerConnection).setPrefetchPolicy(prefetchPolicy);
-      Session consumerSession = consumerConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-      MessageConsumer consumer = consumerSession.createConsumer(queue);
-      consumerConnection.start();
-
-      String msgBody = new String(new byte[20 * 1024]);
-      for (int i = 0; i < data.length; i++) {
-         Message message = session.createTextMessage(msgBody);
-         producerExpire.send(queue, message);
-      }
-
-      for (int i = 0; i < data.length; i++) {
-         Message message = session.createTextMessage(msgBody);
-         producerNormal.send(queue, message);
-      }
-
-      ArrayList<Message> messages = new ArrayList<>();
-      Message received;
-      while ((received = consumer.receive(1000)) != null) {
-         messages.add(received);
-         if (messages.size() == 1) {
-            TimeUnit.SECONDS.sleep(1);
-         }
-         received.acknowledge();
-      }
-
-      assertEquals("got messages", messageCount + 1, messages.size());
-
-      ArrayList<Message> dlqMessages = new ArrayList<>();
-      while ((received = dlqConsumer.receive(1000)) != null) {
-         dlqMessages.add(received);
-      }
-
-      assertEquals("got dlq messages", data.length - 1, dlqMessages.size());
-
-      final QueueViewMBean queueView = getProxyToQueueViewMBean();
-
-      LOG.info("Dequeued Count: {}", queueView.getDequeueCount());
-      LOG.info("Dispatch Count: {}", queueView.getDispatchCount());
-      LOG.info("Enqueue Count: {}", queueView.getEnqueueCount());
-      LOG.info("Expired Count: {}", queueView.getExpiredCount());
-      LOG.info("InFlight Count: {}", queueView.getInFlightCount());
-   }
-
-   private QueueViewMBean getProxyToQueueViewMBean() throws Exception {
-      final ObjectName queueViewMBeanName = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + queue.getQueueName());
-      final QueueViewMBean proxy = (QueueViewMBean) brokerService.getManagementContext().newProxyInstance(queueViewMBeanName, QueueViewMBean.class, true);
-      return proxy;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4092Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4092Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4092Test.java
deleted file mode 100644
index e894b70..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4092Test.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/**
- * 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;
-
-import java.util.HashMap;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ4092Test extends TestCase {
-
-   private static final Logger log = LoggerFactory.getLogger(AMQ4092Test.class);
-
-   static final String QUEUE_NAME = "TEST";
-
-   // increase limits to expedite failure
-   static final int NUM_TO_SEND_PER_PRODUCER = 1000; // 10000
-   static final int NUM_PRODUCERS = 5; // 40
-
-   static final ActiveMQQueue[] DESTINATIONS = new ActiveMQQueue[]{new ActiveMQQueue("A"), new ActiveMQQueue("B")
-      // A/B seems to be sufficient for concurrentStoreAndDispatch=true
-   };
-
-   static final boolean debug = false;
-
-   private BrokerService brokerService;
-
-   private ActiveMQQueue destination;
-   private HashMap<Thread, Throwable> exceptions = new HashMap<>();
-   private ExceptionListener exceptionListener = new ExceptionListener() {
-      @Override
-      public void onException(JMSException exception) {
-         exception.printStackTrace();
-         exceptions.put(Thread.currentThread(), exception);
-      }
-   };
-
-   @Override
-   protected void setUp() throws Exception {
-      brokerService = new BrokerService();
-      brokerService.setDeleteAllMessagesOnStartup(true);
-      ((KahaDBPersistenceAdapter) brokerService.getPersistenceAdapter()).setConcurrentStoreAndDispatchQueues(false);
-      brokerService.addConnector("tcp://localhost:0");
-      brokerService.start();
-      destination = new ActiveMQQueue();
-      destination.setCompositeDestinations(DESTINATIONS);
-      Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
-         @Override
-         public void uncaughtException(Thread t, Throwable e) {
-            exceptions.put(t, e);
-         }
-      });
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      // Stop any running threads.
-      brokerService.stop();
-   }
-
-   public void testConcurrentGroups() throws Exception {
-      ExecutorService executorService = Executors.newCachedThreadPool();
-      executorService.submit(new TestConsumer());
-      for (int i = 0; i < NUM_PRODUCERS; i++) {
-         executorService.submit(new TestProducer());
-      }
-      executorService.shutdown();
-      executorService.awaitTermination(5, TimeUnit.MINUTES);
-      assertTrue("no exceptions: " + exceptions, exceptions.isEmpty());
-   }
-
-   class TestProducer implements Runnable {
-
-      public void produceMessages() throws Exception {
-         ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerService.getTransportConnectors().get(0).getConnectUri().toString());
-         connectionFactory.setExceptionListener(exceptionListener);
-         connectionFactory.setUseAsyncSend(true);
-         Connection connection = connectionFactory.createConnection();
-         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageProducer producer = session.createProducer(destination);
-         producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-
-         String name = new String(new byte[2 * 1024]);
-         for (int i = 1; i <= NUM_TO_SEND_PER_PRODUCER; i++) {
-
-            TextMessage message = session.createTextMessage(name + "_" + i);
-            for (int j = 0; j < 100; j++) {
-               message.setStringProperty("Prop" + j, "" + j);
-            }
-            message.setStringProperty("JMSXGroupID", Thread.currentThread().getName() + i);
-            message.setIntProperty("JMSXGroupSeq", 1);
-            producer.send(message);
-         }
-
-         producer.close();
-         session.close();
-         connection.close();
-      }
-
-      @Override
-      public void run() {
-         try {
-            produceMessages();
-         }
-         catch (Exception e) {
-            e.printStackTrace();
-            exceptions.put(Thread.currentThread(), e);
-         }
-      }
-   }
-
-   class TestConsumer implements Runnable {
-
-      private CountDownLatch finishLatch = new CountDownLatch(1);
-
-      public void consume() throws Exception {
-         ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerService.getTransportConnectors().get(0).getConnectUri().toString());
-
-         connectionFactory.setExceptionListener(exceptionListener);
-         final int totalMessageCount = NUM_TO_SEND_PER_PRODUCER * DESTINATIONS.length * NUM_PRODUCERS;
-         final AtomicInteger counter = new AtomicInteger();
-         final MessageListener listener = new MessageListener() {
-            @Override
-            public void onMessage(Message message) {
-
-               if (debug) {
-                  try {
-                     log.info(((TextMessage) message).getText());
-                  }
-                  catch (JMSException e) {
-                     e.printStackTrace();
-                  }
-               }
-
-               boolean first = false;
-               try {
-                  first = message.getBooleanProperty("JMSXGroupFirstForConsumer");
-               }
-               catch (JMSException e) {
-                  e.printStackTrace();
-                  exceptions.put(Thread.currentThread(), e);
-               }
-               assertTrue("Always is first message", first);
-               if (counter.incrementAndGet() == totalMessageCount) {
-                  log.info("Got all:" + counter.get());
-                  finishLatch.countDown();
-
-               }
-            }
-         };
-
-         int consumerCount = DESTINATIONS.length * 100;
-         Connection[] connections = new Connection[consumerCount];
-
-         Session[] sessions = new Session[consumerCount];
-         MessageConsumer[] consumers = new MessageConsumer[consumerCount];
-
-         for (int i = 0; i < consumerCount; i++) {
-            connections[i] = connectionFactory.createConnection();
-            connections[i].start();
-
-            sessions[i] = connections[i].createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-            consumers[i] = sessions[i].createConsumer(DESTINATIONS[i % DESTINATIONS.length], null);
-            consumers[i].setMessageListener(listener);
-         }
-
-         log.info("received " + counter.get() + " messages");
-
-         assertTrue("got all messages in time", finishLatch.await(4, TimeUnit.MINUTES));
-
-         log.info("received " + counter.get() + " messages");
-
-         for (MessageConsumer consumer : consumers) {
-            consumer.close();
-         }
-
-         for (Session session : sessions) {
-            session.close();
-         }
-
-         for (Connection connection : connections) {
-            connection.close();
-         }
-      }
-
-      @Override
-      public void run() {
-         try {
-            consume();
-         }
-         catch (Exception e) {
-            e.printStackTrace();
-            exceptions.put(Thread.currentThread(), e);
-         }
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4116Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4116Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4116Test.java
deleted file mode 100644
index b87fd1b..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4116Test.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * 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;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.Destination;
-import org.apache.activemq.command.ActiveMQMessage;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.junit.Assert;
-
-public class AMQ4116Test extends EmbeddedBrokerTestSupport {
-
-   private final String tcpAddr = "tcp://localhost:0";
-   private String connectionUri;
-
-   /**
-    * In this test, a message is produced and consumed from the test queue.
-    * Memory usage on the test queue should be reset to 0. The memory that was
-    * consumed is then sent to a second queue. Memory usage on the original
-    * test queue should remain 0, but actually increased when the second
-    * enqueue occurs.
-    */
-   public void testVMTransport() throws Exception {
-      runTest(connectionFactory);
-   }
-
-   /**
-    * This is an analog to the previous test, but occurs over TCP and passes.
-    */
-   public void testTCPTransport() throws Exception {
-      runTest(new ActiveMQConnectionFactory(connectionUri));
-   }
-
-   private void runTest(ConnectionFactory connFactory) throws Exception {
-      // Verify that test queue is empty and not using any memory.
-      Destination physicalDestination = broker.getDestination(destination);
-      Assert.assertEquals(0, physicalDestination.getMemoryUsage().getUsage());
-
-      // Enqueue a single message and verify that the test queue is using
-      // memory.
-      Connection conn = connFactory.createConnection();
-      conn.start();
-      Session session = conn.createSession(true, Session.SESSION_TRANSACTED);
-      MessageProducer producer = session.createProducer(destination);
-
-      producer.send(new ActiveMQMessage());
-
-      // Commit, which ensures message is in queue and memory usage updated.
-      session.commit();
-      Assert.assertTrue(physicalDestination.getMemoryUsage().getUsage() > 0);
-
-      // Consume the message and verify that the test queue is no longer using
-      // any memory.
-      MessageConsumer consumer = session.createConsumer(destination);
-      Message received = consumer.receive();
-      Assert.assertNotNull(received);
-
-      // Commit, which ensures message is removed from queue and memory usage
-      // updated.
-      session.commit();
-      Assert.assertEquals(0, physicalDestination.getMemoryUsage().getUsage());
-
-      // Resend the message to a different queue and verify that the original
-      // test queue is still not using any memory.
-      ActiveMQQueue secondDestination = new ActiveMQQueue(AMQ4116Test.class + ".second");
-      MessageProducer secondPproducer = session.createProducer(secondDestination);
-
-      secondPproducer.send(received);
-
-      // Commit, which ensures message is in queue and memory usage updated.
-      // NOTE: This assertion fails due to bug.
-      session.commit();
-      Assert.assertEquals(0, physicalDestination.getMemoryUsage().getUsage());
-
-      conn.stop();
-   }
-
-   /**
-    * Create an embedded broker that has both TCP and VM connectors.
-    */
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      BrokerService broker = super.createBroker();
-      connectionUri = broker.addConnector(tcpAddr).getPublishableConnectString();
-      return broker;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4126Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4126Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4126Test.java
deleted file mode 100644
index d47c7c8..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4126Test.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/**
- * 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;
-
-import java.net.Socket;
-import java.net.URI;
-
-import javax.management.ObjectName;
-import javax.net.SocketFactory;
-import javax.net.ssl.SSLSocketFactory;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQSslConnectionFactory;
-import org.apache.activemq.broker.BrokerFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.transport.stomp.Stomp;
-import org.apache.activemq.transport.stomp.StompConnection;
-import org.apache.activemq.transport.stomp.StompFrame;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- *
- */
-public class AMQ4126Test {
-
-   protected BrokerService broker;
-
-   protected String java_security_auth_login_config = "java.security.auth.login.config";
-   protected String xbean = "xbean:";
-   protected String confBase = "src/test/resources/org/apache/activemq/bugs/amq4126";
-   protected String certBase = "src/test/resources/org/apache/activemq/security";
-   protected String JaasStompSSLBroker_xml = "JaasStompSSLBroker.xml";
-   protected StompConnection stompConnection = new StompConnection();
-   private final static String destinationName = "TEST.QUEUE";
-   protected String oldLoginConf = null;
-
-   @Before
-   public void before() throws Exception {
-      if (System.getProperty(java_security_auth_login_config) != null) {
-         oldLoginConf = System.getProperty(java_security_auth_login_config);
-      }
-      System.setProperty(java_security_auth_login_config, confBase + "/login.config");
-      broker = BrokerFactory.createBroker(xbean + confBase + "/" + JaasStompSSLBroker_xml);
-
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.setUseJmx(true);
-      broker.start();
-      broker.waitUntilStarted();
-   }
-
-   @After
-   public void after() throws Exception {
-      broker.stop();
-
-      if (oldLoginConf != null) {
-         System.setProperty(java_security_auth_login_config, oldLoginConf);
-      }
-   }
-
-   public Socket createSocket(String host, int port) throws Exception {
-      System.setProperty("javax.net.ssl.trustStore", certBase + "/broker1.ks");
-      System.setProperty("javax.net.ssl.trustStorePassword", "password");
-      System.setProperty("javax.net.ssl.trustStoreType", "jks");
-      System.setProperty("javax.net.ssl.keyStore", certBase + "/client.ks");
-      System.setProperty("javax.net.ssl.keyStorePassword", "password");
-      System.setProperty("javax.net.ssl.keyStoreType", "jks");
-
-      SocketFactory factory = SSLSocketFactory.getDefault();
-      return factory.createSocket(host, port);
-   }
-
-   public void stompConnectTo(String connectorName, String extraHeaders) throws Exception {
-      String host = broker.getConnectorByName(connectorName).getConnectUri().getHost();
-      int port = broker.getConnectorByName(connectorName).getConnectUri().getPort();
-      stompConnection.open(createSocket(host, port));
-      String extra = extraHeaders != null ? extraHeaders : "\n";
-      stompConnection.sendFrame("CONNECT\n" + extra + "\n" + Stomp.NULL);
-
-      StompFrame f = stompConnection.receive();
-      TestCase.assertEquals(f.getBody(), "CONNECTED", f.getAction());
-      stompConnection.close();
-   }
-
-   @Test
-   public void testStompSSLWithUsernameAndPassword() throws Exception {
-      stompConnectTo("stomp+ssl", "login:system\n" + "passcode:manager\n");
-   }
-
-   @Test
-   public void testStompSSLWithCertificate() throws Exception {
-      stompConnectTo("stomp+ssl", null);
-   }
-
-   @Test
-   public void testStompNIOSSLWithUsernameAndPassword() throws Exception {
-      stompConnectTo("stomp+nio+ssl", "login:system\n" + "passcode:manager\n");
-   }
-
-   @Test
-   public void testStompNIOSSLWithCertificate() throws Exception {
-      stompConnectTo("stomp+nio+ssl", null);
-   }
-
-   public void openwireConnectTo(String connectorName, String username, String password) throws Exception {
-      URI brokerURI = broker.getConnectorByName(connectorName).getConnectUri();
-      String uri = "ssl://" + brokerURI.getHost() + ":" + brokerURI.getPort();
-      ActiveMQSslConnectionFactory cf = new ActiveMQSslConnectionFactory(uri);
-      cf.setTrustStore("org/apache/activemq/security/broker1.ks");
-      cf.setTrustStorePassword("password");
-      cf.setKeyStore("org/apache/activemq/security/client.ks");
-      cf.setKeyStorePassword("password");
-      ActiveMQConnection connection = null;
-      if (username != null || password != null) {
-         connection = (ActiveMQConnection) cf.createConnection(username, password);
-      }
-      else {
-         connection = (ActiveMQConnection) cf.createConnection();
-      }
-      TestCase.assertNotNull(connection);
-      connection.start();
-      connection.stop();
-   }
-
-   @Test
-   public void testOpenwireSSLWithUsernameAndPassword() throws Exception {
-      openwireConnectTo("openwire+ssl", "system", "manager");
-   }
-
-   @Test
-   public void testOpenwireSSLWithCertificate() throws Exception {
-      openwireConnectTo("openwire+ssl", null, null);
-   }
-
-   @Test
-   public void testOpenwireNIOSSLWithUsernameAndPassword() throws Exception {
-      openwireConnectTo("openwire+nio+ssl", "system", "mmanager");
-   }
-
-   @Test
-   public void testOpenwireNIOSSLWithCertificate() throws Exception {
-      openwireConnectTo("openwire+nio+ssl", null, null);
-   }
-
-   @Test
-   public void testJmx() throws Exception {
-      TestCase.assertFalse(findDestination(destinationName));
-      broker.getAdminView().addQueue(destinationName);
-      TestCase.assertTrue(findDestination(destinationName));
-      broker.getAdminView().removeQueue(destinationName);
-      TestCase.assertFalse(findDestination(destinationName));
-   }
-
-   private boolean findDestination(String name) throws Exception {
-      ObjectName[] destinations = broker.getAdminView().getQueues();
-      for (ObjectName destination : destinations) {
-         if (destination.toString().contains(name)) {
-            return true;
-         }
-      }
-      return false;
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4133Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4133Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4133Test.java
deleted file mode 100644
index 123413f..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4133Test.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * 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;
-
-import java.net.Socket;
-
-import javax.net.SocketFactory;
-import javax.net.ssl.SSLSocketFactory;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.broker.BrokerFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.transport.stomp.Stomp;
-import org.apache.activemq.transport.stomp.StompConnection;
-import org.apache.activemq.transport.stomp.StompFrame;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AMQ4133Test {
-
-   protected String java_security_auth_login_config = "java.security.auth.login.config";
-   protected String xbean = "xbean:";
-   protected String confBase = "src/test/resources/org/apache/activemq/bugs/amq4126";
-   protected String certBase = "src/test/resources/org/apache/activemq/security";
-   protected String activemqXml = "InconsistentConnectorPropertiesBehaviour.xml";
-   protected BrokerService broker;
-
-   protected String oldLoginConf = null;
-
-   @Before
-   public void before() throws Exception {
-      if (System.getProperty(java_security_auth_login_config) != null) {
-         oldLoginConf = System.getProperty(java_security_auth_login_config);
-      }
-      System.setProperty(java_security_auth_login_config, confBase + "/" + "login.config");
-      broker = BrokerFactory.createBroker(xbean + confBase + "/" + activemqXml);
-
-      broker.start();
-      broker.waitUntilStarted();
-   }
-
-   @After
-   public void after() throws Exception {
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-      }
-   }
-
-   @Test
-   public void stompSSLTransportNeedClientAuthTrue() throws Exception {
-      stompConnectTo("localhost", broker.getConnectorByName("stomp+ssl").getConnectUri().getPort());
-   }
-
-   @Test
-   public void stompSSLNeedClientAuthTrue() throws Exception {
-      stompConnectTo("localhost", broker.getConnectorByName("stomp+ssl+special").getConnectUri().getPort());
-   }
-
-   @Test
-   public void stompNIOSSLTransportNeedClientAuthTrue() throws Exception {
-      stompConnectTo("localhost", broker.getConnectorByName("stomp+nio+ssl").getConnectUri().getPort());
-   }
-
-   @Test
-   public void stompNIOSSLNeedClientAuthTrue() throws Exception {
-      stompConnectTo("localhost", broker.getConnectorByName("stomp+nio+ssl+special").getConnectUri().getPort());
-   }
-
-   public Socket createSocket(String host, int port) throws Exception {
-      System.setProperty("javax.net.ssl.trustStore", certBase + "/" + "broker1.ks");
-      System.setProperty("javax.net.ssl.trustStorePassword", "password");
-      System.setProperty("javax.net.ssl.trustStoreType", "jks");
-      System.setProperty("javax.net.ssl.keyStore", certBase + "/" + "client.ks");
-      System.setProperty("javax.net.ssl.keyStorePassword", "password");
-      System.setProperty("javax.net.ssl.keyStoreType", "jks");
-
-      SocketFactory factory = SSLSocketFactory.getDefault();
-      return factory.createSocket(host, port);
-   }
-
-   public void stompConnectTo(String host, int port) throws Exception {
-      StompConnection stompConnection = new StompConnection();
-      stompConnection.open(createSocket(host, port));
-      stompConnection.sendFrame("CONNECT\n" + "\n" + Stomp.NULL);
-      StompFrame f = stompConnection.receive();
-      TestCase.assertEquals(f.getBody(), "CONNECTED", f.getAction());
-      stompConnection.close();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4147Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4147Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4147Test.java
deleted file mode 100644
index d0096f1..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4147Test.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/**
- * 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;
-
-import java.net.URI;
-import java.util.concurrent.Semaphore;
-
-import javax.jms.Message;
-import javax.jms.MessageListener;
-
-import org.apache.activemq.JmsMultipleBrokersTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.Destination;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.network.DemandForwardingBridgeSupport;
-import org.apache.activemq.util.MessageIdList;
-import org.apache.activemq.util.Wait;
-
-/**
- * This test demonstrates a bug in {@link DemandForwardingBridgeSupport} when
- * bridges are VM-to-VM. Specifically, memory usage from the local broker is
- * manipulated by the remote broker.
- */
-public class AMQ4147Test extends JmsMultipleBrokersTestSupport {
-
-   /**
-    * This test demonstrates the bug: namely, when a message is bridged over
-    * the VMTransport, its memory usage continues to refer to the originating
-    * broker. As a result, memory usage is never accounted for on the remote
-    * broker, and the local broker's memory usage is only decreased once the
-    * message is consumed on the remote broker.
-    */
-   public void testVMTransportRemoteMemoryUsage() throws Exception {
-      BrokerService broker1 = createBroker(new URI("broker:(vm://broker1)/broker1?persistent=false"));
-
-      BrokerService broker2 = createBroker(new URI("broker:(vm://broker2)/broker2?persistent=false"));
-
-      startAllBrokers();
-
-      // Forward messages from broker1 to broker2 over the VM transport.
-      bridgeBrokers("broker1", "broker2").start();
-
-      // Verify that broker1 and broker2's test queues have no memory usage.
-      ActiveMQDestination testQueue = createDestination(AMQ4147Test.class.getSimpleName() + ".queue", false);
-      final Destination broker1TestQueue = broker1.getDestination(testQueue);
-      final Destination broker2TestQueue = broker2.getDestination(testQueue);
-
-      assertEquals(0, broker1TestQueue.getMemoryUsage().getUsage());
-      assertEquals(0, broker2TestQueue.getMemoryUsage().getUsage());
-
-      // Produce a message to broker1's test queue and verify that broker1's
-      // memory usage has increased, but broker2 still has no memory usage.
-      sendMessages("broker1", testQueue, 1);
-      assertTrue(broker1TestQueue.getMemoryUsage().getUsage() > 0);
-      assertEquals(0, broker2TestQueue.getMemoryUsage().getUsage());
-
-      // Create a consumer on broker2 that is synchronized to allow detection
-      // of "in flight" messages to the consumer.
-      MessageIdList broker2Messages = getBrokerMessages("broker2");
-      final Semaphore consumerReady = new Semaphore(0);
-      final Semaphore consumerProceed = new Semaphore(0);
-
-      broker2Messages.setParent(new MessageListener() {
-         @Override
-         public void onMessage(Message message) {
-            consumerReady.release();
-            try {
-               consumerProceed.acquire();
-            }
-            catch (InterruptedException ex) {
-               Thread.currentThread().interrupt();
-            }
-         }
-      });
-
-      createConsumer("broker2", testQueue);
-
-      // Verify that when broker2's consumer receives the message, the memory
-      // usage has moved broker1 to broker2. The first assertion is expected
-      // to fail due to the bug; the try/finally ensures the consumer is
-      // released prior to failure so that the broker can shut down.
-      consumerReady.acquire();
-
-      try {
-         assertTrue("Memory Usage Should be Zero: ", Wait.waitFor(new Wait.Condition() {
-            @Override
-            public boolean isSatisified() throws Exception {
-               return broker1TestQueue.getMemoryUsage().getUsage() == 0;
-            }
-         }));
-         assertTrue(broker2TestQueue.getMemoryUsage().getUsage() > 0);
-      }
-      finally {
-         // Consume the message and verify that there is no more memory
-         // usage.
-         consumerProceed.release();
-      }
-
-      assertTrue("Memory Usage Should be Zero: ", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return broker1TestQueue.getMemoryUsage().getUsage() == 0;
-         }
-      }));
-      assertTrue("Memory Usage Should be Zero: ", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return broker2TestQueue.getMemoryUsage().getUsage() == 0;
-         }
-      }));
-   }
-
-   /**
-    * This test demonstrates that the bug is VMTransport-specific and does not
-    * occur when bridges occur using other protocols.
-    */
-   public void testTcpTransportRemoteMemoryUsage() throws Exception {
-      BrokerService broker1 = createBroker(new URI("broker:(vm://broker1)/broker1?persistent=false"));
-
-      BrokerService broker2 = createBroker(new URI("broker:(tcp://localhost:61616)/broker2?persistent=false"));
-
-      startAllBrokers();
-
-      // Forward messages from broker1 to broker2 over the TCP transport.
-      bridgeBrokers("broker1", "broker2").start();
-
-      // Verify that broker1 and broker2's test queues have no memory usage.
-      ActiveMQDestination testQueue = createDestination(AMQ4147Test.class.getSimpleName() + ".queue", false);
-      final Destination broker1TestQueue = broker1.getDestination(testQueue);
-      final Destination broker2TestQueue = broker2.getDestination(testQueue);
-
-      assertEquals(0, broker1TestQueue.getMemoryUsage().getUsage());
-      assertEquals(0, broker2TestQueue.getMemoryUsage().getUsage());
-
-      // Produce a message to broker1's test queue and verify that broker1's
-      // memory usage has increased, but broker2 still has no memory usage.
-      sendMessages("broker1", testQueue, 1);
-      assertTrue(broker1TestQueue.getMemoryUsage().getUsage() > 0);
-      assertEquals(0, broker2TestQueue.getMemoryUsage().getUsage());
-
-      // Create a consumer on broker2 that is synchronized to allow detection
-      // of "in flight" messages to the consumer.
-      MessageIdList broker2Messages = getBrokerMessages("broker2");
-      final Semaphore consumerReady = new Semaphore(0);
-      final Semaphore consumerProceed = new Semaphore(0);
-
-      broker2Messages.setParent(new MessageListener() {
-         @Override
-         public void onMessage(Message message) {
-            consumerReady.release();
-            try {
-               consumerProceed.acquire();
-            }
-            catch (InterruptedException ex) {
-               Thread.currentThread().interrupt();
-            }
-         }
-      });
-
-      createConsumer("broker2", testQueue);
-
-      // Verify that when broker2's consumer receives the message, the memory
-      // usage has moved broker1 to broker2.
-      consumerReady.acquire();
-
-      try {
-         assertTrue("Memory Usage Should be Zero: ", Wait.waitFor(new Wait.Condition() {
-            @Override
-            public boolean isSatisified() throws Exception {
-               return broker1TestQueue.getMemoryUsage().getUsage() == 0;
-            }
-         }));
-         assertTrue(broker2TestQueue.getMemoryUsage().getUsage() > 0);
-      }
-      finally {
-         // Consume the message and verify that there is no more memory
-         // usage.
-         consumerProceed.release();
-      }
-
-      // Pause to allow ACK to be processed.
-      assertTrue("Memory Usage Should be Zero: ", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return broker1TestQueue.getMemoryUsage().getUsage() == 0;
-         }
-      }));
-      assertTrue("Memory Usage Should be Zero: ", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return broker2TestQueue.getMemoryUsage().getUsage() == 0;
-         }
-      }));
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4148Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4148Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4148Test.java
deleted file mode 100644
index 8558f48..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4148Test.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * 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;
-
-import java.net.URI;
-import java.util.Arrays;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.activemq.JmsMultipleBrokersTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.Destination;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.network.DemandForwardingBridgeSupport;
-import org.apache.activemq.network.NetworkConnector;
-import org.apache.activemq.util.Wait;
-import org.junit.Assert;
-
-/**
- * This test demonstrates a bug in {@link DemandForwardingBridgeSupport} whereby
- * a static subscription from broker1 to broker2 is forwarded to broker3 even
- * though the network TTL is 1. This results in duplicate subscriptions on
- * broker3.
- */
-public class AMQ4148Test extends JmsMultipleBrokersTestSupport {
-
-   public void test() throws Exception {
-      // Create a hub-and-spoke network where each hub-spoke pair share
-      // messages on a test queue.
-      BrokerService hub = createBroker(new URI("broker:(vm://hub)/hub?persistent=false"));
-
-      final BrokerService[] spokes = new BrokerService[4];
-      for (int i = 0; i < spokes.length; i++) {
-         spokes[i] = createBroker(new URI("broker:(vm://spoke" + i + ")/spoke" + i + "?persistent=false"));
-
-      }
-      startAllBrokers();
-
-      ActiveMQDestination testQueue = createDestination(AMQ4148Test.class.getSimpleName() + ".queue", false);
-
-      NetworkConnector[] ncs = new NetworkConnector[spokes.length];
-      for (int i = 0; i < spokes.length; i++) {
-         NetworkConnector nc = bridgeBrokers("hub", "spoke" + i);
-         nc.setNetworkTTL(1);
-         nc.setDuplex(true);
-         nc.setConduitSubscriptions(false);
-         nc.setStaticallyIncludedDestinations(Arrays.asList(testQueue));
-         nc.start();
-
-         ncs[i] = nc;
-      }
-
-      waitForBridgeFormation();
-
-      // Pause to allow subscriptions to be created.
-      TimeUnit.SECONDS.sleep(5);
-
-      // Verify that the hub has a subscription from each spoke, but that each
-      // spoke has a single subscription from the hub (since the network TTL is 1).
-      final Destination hubTestQueue = hub.getDestination(testQueue);
-      assertTrue("Expecting {" + spokes.length + "} consumer but was {" + hubTestQueue.getConsumers().size() + "}", Wait.waitFor(new Wait.Condition() {
-
-                    @Override
-                    public boolean isSatisified() throws Exception {
-                       return spokes.length == hubTestQueue.getConsumers().size();
-                    }
-                 }));
-
-      // Now check each spoke has exactly one consumer on the Queue.
-      for (int i = 0; i < 4; i++) {
-         Destination spokeTestQueue = spokes[i].getDestination(testQueue);
-         Assert.assertEquals(1, spokeTestQueue.getConsumers().size());
-      }
-
-      for (NetworkConnector nc : ncs) {
-         nc.stop();
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4157Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4157Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4157Test.java
deleted file mode 100644
index f932a49..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4157Test.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Vector;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-
-import javax.jms.BytesMessage;
-import javax.jms.DeliveryMode;
-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.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ConnectionControl;
-import org.junit.After;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ4157Test {
-
-   static final Logger LOG = LoggerFactory.getLogger(AMQ4157Test.class);
-   private BrokerService broker;
-   private ActiveMQConnectionFactory connectionFactory;
-   private final Destination destination = new ActiveMQQueue("Test");
-   private final String payloadString = new String(new byte[8 * 1024]);
-   private final boolean useBytesMessage = true;
-   private final int parallelProducer = 20;
-   private final int parallelConsumer = 100;
-
-   private final Vector<Exception> exceptions = new Vector<>();
-   long toSend = 1000;
-
-   @Test
-   public void testPublishCountsWithRollbackConsumer() throws Exception {
-
-      startBroker(true);
-
-      final AtomicLong sharedCount = new AtomicLong(toSend);
-      ExecutorService executorService = Executors.newCachedThreadPool();
-
-      for (int i = 0; i < parallelConsumer; i++) {
-         executorService.execute(new Runnable() {
-            @Override
-            public void run() {
-               try {
-                  consumeOneAndRollback();
-               }
-               catch (Exception e) {
-                  exceptions.add(e);
-               }
-            }
-         });
-      }
-
-      for (int i = 0; i < parallelProducer; i++) {
-         executorService.execute(new Runnable() {
-            @Override
-            public void run() {
-               try {
-                  publishMessages(sharedCount, 0);
-               }
-               catch (Exception e) {
-                  exceptions.add(e);
-               }
-            }
-         });
-      }
-
-      executorService.shutdown();
-      executorService.awaitTermination(30, TimeUnit.MINUTES);
-      assertTrue("Producers done in time", executorService.isTerminated());
-      assertTrue("No exceptions: " + exceptions, exceptions.isEmpty());
-
-      restartBroker(500);
-
-      LOG.info("Attempting consume of {} messages", toSend);
-
-      consumeMessages(toSend);
-   }
-
-   private void consumeOneAndRollback() throws Exception {
-      ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection();
-      connection.start();
-      Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-      MessageConsumer consumer = session.createConsumer(destination);
-      Message message = null;
-      while (message == null) {
-         message = consumer.receive(1000);
-      }
-      session.rollback();
-      connection.close();
-   }
-
-   private void consumeMessages(long count) throws Exception {
-      ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection();
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer consumer = session.createConsumer(destination);
-      for (int i = 0; i < count; i++) {
-         assertNotNull("got message " + i, consumer.receive(20000));
-      }
-      assertNull("none left over", consumer.receive(2000));
-   }
-
-   private void restartBroker(int restartDelay) throws Exception {
-      stopBroker();
-      TimeUnit.MILLISECONDS.sleep(restartDelay);
-      startBroker(false);
-   }
-
-   @After
-   public void stopBroker() throws Exception {
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-      }
-   }
-
-   private void publishMessages(AtomicLong count, int expiry) throws Exception {
-      ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection();
-      connection.setWatchTopicAdvisories(false);
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      MessageProducer producer = session.createProducer(destination);
-      while ((count.getAndDecrement()) > 0) {
-         Message message = null;
-         if (useBytesMessage) {
-            message = session.createBytesMessage();
-            ((BytesMessage) message).writeBytes(payloadString.getBytes());
-         }
-         else {
-            message = session.createTextMessage(payloadString);
-         }
-         producer.send(message, DeliveryMode.PERSISTENT, 5, expiry);
-      }
-      connection.syncSendPacket(new ConnectionControl());
-      connection.close();
-   }
-
-   public void startBroker(boolean deleteAllMessages) throws Exception {
-      broker = new BrokerService();
-      broker.setDeleteAllMessagesOnStartup(deleteAllMessages);
-      broker.addConnector("tcp://0.0.0.0:0");
-      broker.start();
-
-      String options = "?jms.redeliveryPolicy.maximumRedeliveries=-1&jms.prefetchPolicy.all=1000&jms.watchTopicAdvisories=false&jms.useAsyncSend=true&jms.alwaysSessionAsync=false&jms.dispatchAsync=false&socketBufferSize=131072&ioBufferSize=16384&wireFormat.tightEncodingEnabled=false&wireFormat.cacheSize=8192";
-      connectionFactory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getConnectUri() + options);
-   }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4160Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4160Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4160Test.java
deleted file mode 100644
index 0cd8e0b..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4160Test.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/**
- * 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;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.management.ObjectName;
-
-import org.apache.activemq.JmsMultipleBrokersTestSupport;
-import org.apache.activemq.broker.Broker;
-import org.apache.activemq.broker.BrokerFilter;
-import org.apache.activemq.broker.BrokerPlugin;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.ConnectionContext;
-import org.apache.activemq.command.ConnectionInfo;
-import org.apache.activemq.command.DiscoveryEvent;
-import org.apache.activemq.network.DiscoveryNetworkConnector;
-import org.apache.activemq.network.NetworkBridge;
-import org.apache.activemq.network.NetworkBridgeListener;
-import org.apache.activemq.network.NetworkConnector;
-import org.apache.activemq.thread.TaskRunnerFactory;
-import org.apache.activemq.transport.Transport;
-import org.apache.activemq.transport.discovery.DiscoveryAgent;
-import org.apache.activemq.transport.discovery.DiscoveryListener;
-import org.apache.activemq.transport.discovery.simple.SimpleDiscoveryAgent;
-import org.junit.Assert;
-
-/**
- * This test demonstrates a number of race conditions in
- * {@link DiscoveryNetworkConnector} that can result in an active bridge no
- * longer being reported as active and vice-versa, an inactive bridge still
- * being reported as active.
- */
-public class AMQ4160Test extends JmsMultipleBrokersTestSupport {
-
-   final long MAX_TEST_TIME = TimeUnit.MINUTES.toMillis(2);
-
-   /**
-    * Since these tests involve wait conditions, protect against indefinite
-    * waits (due to unanticipated issues).
-    */
-   @Override
-   public void setUp() throws Exception {
-      setAutoFail(true);
-      setMaxTestTime(MAX_TEST_TIME);
-      super.setUp();
-   }
-
-   /**
-    * This test demonstrates how concurrent attempts to establish a bridge to
-    * the same remote broker are allowed to occur. Connection uniqueness will
-    * cause whichever bridge creation attempt is second to fail. However, this
-    * failure erases the entry in
-    * {@link DiscoveryNetworkConnector#activeBridges()} that represents the
-    * successful first bridge creation attempt.
-    */
-   public void testLostActiveBridge() throws Exception {
-      final long ATTEMPT_TO_CREATE_DELAY = TimeUnit.SECONDS.toMillis(15);
-
-      // Start two brokers with a bridge from broker1 to broker2.
-      BrokerService broker1 = createBroker(new URI("broker:(vm://broker1)/broker1?persistent=false"));
-      final BrokerService broker2 = createBroker(new URI("broker:(vm://broker2)/broker2?persistent=false"));
-
-      // Allow the concurrent local bridge connections to be made even though
-      // they are duplicated; this prevents both of the bridge attempts from
-      // failing in the case that the local and remote bridges are established
-      // out-of-order.
-      BrokerPlugin ignoreAddConnectionPlugin = new BrokerPlugin() {
-         @Override
-         public Broker installPlugin(Broker broker) throws Exception {
-            return new BrokerFilter(broker) {
-               @Override
-               public void addConnection(ConnectionContext context, ConnectionInfo info) throws Exception {
-                  // ignore
-               }
-            };
-         }
-      };
-
-      broker1.setPlugins(new BrokerPlugin[]{ignoreAddConnectionPlugin});
-
-      startAllBrokers();
-
-      // Start a bridge from broker1 to broker2. The discovery agent attempts
-      // to create the bridge concurrently with two threads, and the
-      // synchronization in createBridge ensures that pre-patch both threads
-      // actually attempt to start bridges. Post-patch, only one thread is
-      // allowed to start the bridge.
-      final CountDownLatch attemptLatch = new CountDownLatch(2);
-      final CountDownLatch createLatch = new CountDownLatch(2);
-
-      DiscoveryNetworkConnector nc = new DiscoveryNetworkConnector() {
-         @Override
-         public void onServiceAdd(DiscoveryEvent event) {
-            // Pre-and-post patch, two threads attempt to establish a bridge
-            // to the same remote broker.
-            attemptLatch.countDown();
-            super.onServiceAdd(event);
-         }
-
-         @Override
-         protected NetworkBridge createBridge(Transport localTransport,
-                                              Transport remoteTransport,
-                                              final DiscoveryEvent event) {
-            // Pre-patch, the two threads are allowed to create the bridge.
-            // Post-patch, only the first thread is allowed. Wait a
-            // reasonable delay once both attempts are detected to allow
-            // the two bridge creations to occur concurrently (pre-patch).
-            // Post-patch, the wait will timeout and allow the first (and
-            // only) bridge creation to occur.
-            try {
-               attemptLatch.await();
-               createLatch.countDown();
-               createLatch.await(ATTEMPT_TO_CREATE_DELAY, TimeUnit.MILLISECONDS);
-               return super.createBridge(localTransport, remoteTransport, event);
-            }
-            catch (InterruptedException e) {
-               Thread.interrupted();
-               return null;
-            }
-         }
-      };
-
-      nc.setDiscoveryAgent(new DiscoveryAgent() {
-         TaskRunnerFactory taskRunner = new TaskRunnerFactory();
-         DiscoveryListener listener;
-
-         @Override
-         public void start() throws Exception {
-            taskRunner.init();
-            taskRunner.execute(new Runnable() {
-               @Override
-               public void run() {
-                  listener.onServiceAdd(new DiscoveryEvent(broker2.getVmConnectorURI().toString()));
-               }
-            });
-            taskRunner.execute(new Runnable() {
-               @Override
-               public void run() {
-                  listener.onServiceAdd(new DiscoveryEvent(broker2.getVmConnectorURI().toString()));
-               }
-            });
-         }
-
-         @Override
-         public void stop() throws Exception {
-            taskRunner.shutdown();
-         }
-
-         @Override
-         public void setDiscoveryListener(DiscoveryListener listener) {
-            this.listener = listener;
-         }
-
-         @Override
-         public void registerService(String name) throws IOException {
-         }
-
-         @Override
-         public void serviceFailed(DiscoveryEvent event) throws IOException {
-            listener.onServiceRemove(event);
-         }
-      });
-
-      broker1.addNetworkConnector(nc);
-      nc.start();
-
-      // Wait for the bridge to be formed by the first attempt.
-      waitForBridge(broker1.getBrokerName(), broker2.getBrokerName(), MAX_TEST_TIME, TimeUnit.MILLISECONDS);
-
-      // Pre-patch, the second bridge creation attempt fails and removes the
-      // first (successful) bridge creation attempt from the
-      // list of active bridges. Post-patch, the second bridge creation
-      // attempt is prevented, so the first bridge creation attempt
-      // remains "active". This assertion is expected to fail pre-patch and
-      // pass post-patch.
-      Assert.assertFalse(nc.activeBridges().isEmpty());
-   }
-
-   /**
-    * This test demonstrates a race condition where a failed bridge can be
-    * removed from the list of active bridges in
-    * {@link DiscoveryNetworkConnector} before it has been added. Eventually,
-    * the failed bridge is added, but never removed, which causes subsequent
-    * bridge creation attempts to be ignored. The result is a network connector
-    * that thinks it has an active bridge, when in fact it doesn't.
-    */
-   public void testInactiveBridgStillActive() throws Exception {
-      // Start two brokers with a bridge from broker1 to broker2.
-      BrokerService broker1 = createBroker(new URI("broker:(vm://broker1)/broker1?persistent=false"));
-      final BrokerService broker2 = createBroker(new URI("broker:(vm://broker2)/broker2?persistent=false"));
-
-      // Force bridge failure by having broker1 disallow connections.
-      BrokerPlugin disallowAddConnectionPlugin = new BrokerPlugin() {
-         @Override
-         public Broker installPlugin(Broker broker) throws Exception {
-            return new BrokerFilter(broker) {
-               @Override
-               public void addConnection(ConnectionContext context, ConnectionInfo info) throws Exception {
-                  throw new Exception("Test exception to force bridge failure");
-               }
-            };
-         }
-      };
-
-      broker1.setPlugins(new BrokerPlugin[]{disallowAddConnectionPlugin});
-
-      startAllBrokers();
-
-      // Start a bridge from broker1 to broker2. The bridge delays returning
-      // from start until after the bridge failure has been processed;
-      // this leaves the first bridge creation attempt recorded as active,
-      // even though it failed.
-      final SimpleDiscoveryAgent da = new SimpleDiscoveryAgent();
-      da.setServices(new URI[]{broker2.getVmConnectorURI()});
-
-      final CountDownLatch attemptLatch = new CountDownLatch(3);
-      final CountDownLatch removedLatch = new CountDownLatch(1);
-
-      DiscoveryNetworkConnector nc = new DiscoveryNetworkConnector() {
-         @Override
-         public void onServiceAdd(DiscoveryEvent event) {
-            attemptLatch.countDown();
-            super.onServiceAdd(event);
-         }
-
-         @Override
-         public void onServiceRemove(DiscoveryEvent event) {
-            super.onServiceRemove(event);
-            removedLatch.countDown();
-         }
-
-         @Override
-         protected NetworkBridge createBridge(Transport localTransport,
-                                              Transport remoteTransport,
-                                              final DiscoveryEvent event) {
-            final NetworkBridge next = super.createBridge(localTransport, remoteTransport, event);
-            return new NetworkBridge() {
-
-               @Override
-               public void start() throws Exception {
-                  next.start();
-                  // Delay returning until the failed service has been
-                  // removed.
-                  removedLatch.await();
-               }
-
-               @Override
-               public void stop() throws Exception {
-                  next.stop();
-               }
-
-               @Override
-               public void serviceRemoteException(Throwable error) {
-                  next.serviceRemoteException(error);
-               }
-
-               @Override
-               public void serviceLocalException(Throwable error) {
-                  next.serviceLocalException(error);
-               }
-
-               @Override
-               public void setNetworkBridgeListener(NetworkBridgeListener listener) {
-                  next.setNetworkBridgeListener(listener);
-               }
-
-               @Override
-               public String getRemoteAddress() {
-                  return next.getRemoteAddress();
-               }
-
-               @Override
-               public String getRemoteBrokerName() {
-                  return next.getRemoteBrokerName();
-               }
-
-               @Override
-               public String getRemoteBrokerId() {
-                  return next.getRemoteBrokerId();
-               }
-
-               @Override
-               public String getLocalAddress() {
-                  return next.getLocalAddress();
-               }
-
-               @Override
-               public String getLocalBrokerName() {
-                  return next.getLocalBrokerName();
-               }
-
-               @Override
-               public long getEnqueueCounter() {
-                  return next.getEnqueueCounter();
-               }
-
-               @Override
-               public long getDequeueCounter() {
-                  return next.getDequeueCounter();
-               }
-
-               @Override
-               public void setMbeanObjectName(ObjectName objectName) {
-                  next.setMbeanObjectName(objectName);
-               }
-
-               @Override
-               public ObjectName getMbeanObjectName() {
-                  return next.getMbeanObjectName();
-               }
-
-               @Override
-               public void resetStats() {
-                  next.resetStats();
-               }
-            };
-         }
-      };
-      nc.setDiscoveryAgent(da);
-
-      broker1.addNetworkConnector(nc);
-      nc.start();
-
-      // All bridge attempts should fail, so the attempt latch should get
-      // triggered. However, because of the race condition, the first attempt
-      // is considered successful and causes further attempts to stop.
-      // Therefore, this wait will time out and cause the test to fail.
-      Assert.assertTrue(attemptLatch.await(30, TimeUnit.SECONDS));
-   }
-
-   /**
-    * This test verifies that when a network connector is restarted, any
-    * bridges that were active at the time of the stop are allowed to be
-    * re-established (i.e., the "active events" data structure in
-    * {@link DiscoveryNetworkConnector} is reset.
-    */
-   public void testAllowAttemptsAfterRestart() throws Exception {
-      final long STOP_DELAY = TimeUnit.SECONDS.toMillis(10);
-
-      // Start two brokers with a bridge from broker1 to broker2.
-      BrokerService broker1 = createBroker(new URI("broker:(vm://broker1)/broker1?persistent=false"));
-      final BrokerService broker2 = createBroker(new URI("broker:(vm://broker2)/broker2?persistent=false"));
-
-      startAllBrokers();
-
-      // Start a bridge from broker1 to broker2.
-      NetworkConnector nc = bridgeBrokers(broker1.getBrokerName(), broker2.getBrokerName());
-      nc.start();
-
-      waitForBridge(broker1.getBrokerName(), broker2.getBrokerName(), MAX_TEST_TIME, TimeUnit.MILLISECONDS);
-
-      // Restart the network connector and verify that the bridge is
-      // re-established. The pause between start/stop is to account for the
-      // asynchronous closure.
-      nc.stop();
-      Thread.sleep(STOP_DELAY);
-      nc.start();
-
-      waitForBridge(broker1.getBrokerName(), broker2.getBrokerName(), MAX_TEST_TIME, TimeUnit.MILLISECONDS);
-   }
-}


[29/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/LargeStreamletTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/LargeStreamletTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/LargeStreamletTest.java
deleted file mode 100644
index 37899e8..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/LargeStreamletTest.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/**
- * 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;
-
-/**
- * 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.
- */
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Random;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.jms.Destination;
-import javax.jms.Session;
-
-import junit.framework.TestCase;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author rnewson
- */
-public final class LargeStreamletTest extends TestCase {
-
-   private static final Logger LOG = LoggerFactory.getLogger(LargeStreamletTest.class);
-   private static final String BROKER_URL = "vm://localhost?broker.persistent=false";
-   private static final int BUFFER_SIZE = 1 * 1024;
-   private static final int MESSAGE_COUNT = 10 * 1024;
-
-   protected Exception writerException;
-   protected Exception readerException;
-
-   private final AtomicInteger totalRead = new AtomicInteger();
-   private final AtomicInteger totalWritten = new AtomicInteger();
-   private final AtomicBoolean stopThreads = new AtomicBoolean(false);
-
-   public void testStreamlets() throws Exception {
-      final ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(BROKER_URL);
-
-      final ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
-      connection.start();
-      try {
-         final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         try {
-            final Destination destination = session.createQueue("wibble");
-            final Thread readerThread = new Thread(new Runnable() {
-
-               @Override
-               public void run() {
-                  totalRead.set(0);
-                  try {
-                     final InputStream inputStream = connection.createInputStream(destination);
-                     try {
-                        int read;
-                        final byte[] buf = new byte[BUFFER_SIZE];
-                        while (!stopThreads.get() && (read = inputStream.read(buf)) != -1) {
-                           totalRead.addAndGet(read);
-                        }
-                     }
-                     finally {
-                        inputStream.close();
-                     }
-                  }
-                  catch (Exception e) {
-                     readerException = e;
-                     e.printStackTrace();
-                  }
-                  finally {
-                     LOG.info(totalRead + " total bytes read.");
-                  }
-               }
-            });
-
-            final Thread writerThread = new Thread(new Runnable() {
-               private final Random random = new Random();
-
-               @Override
-               public void run() {
-                  totalWritten.set(0);
-                  int count = MESSAGE_COUNT;
-                  try {
-                     final OutputStream outputStream = connection.createOutputStream(destination);
-                     try {
-                        final byte[] buf = new byte[BUFFER_SIZE];
-                        random.nextBytes(buf);
-                        while (count > 0 && !stopThreads.get()) {
-                           outputStream.write(buf);
-                           totalWritten.addAndGet(buf.length);
-                           count--;
-                        }
-                     }
-                     finally {
-                        outputStream.close();
-                     }
-                  }
-                  catch (Exception e) {
-                     writerException = e;
-                     e.printStackTrace();
-                  }
-                  finally {
-                     LOG.info(totalWritten + " total bytes written.");
-                  }
-               }
-            });
-
-            readerThread.start();
-            writerThread.start();
-
-            // Wait till reader is has finished receiving all the messages
-            // or he has stopped
-            // receiving messages.
-            Thread.sleep(1000);
-            int lastRead = totalRead.get();
-            while (readerThread.isAlive()) {
-               readerThread.join(1000);
-               // No progress?? then stop waiting..
-               if (lastRead == totalRead.get()) {
-                  break;
-               }
-               lastRead = totalRead.get();
-            }
-
-            stopThreads.set(true);
-
-            assertTrue("Should not have received a reader exception", readerException == null);
-            assertTrue("Should not have received a writer exception", writerException == null);
-
-            assertEquals("Not all messages accounted for", totalWritten.get(), totalRead.get());
-
-         }
-         finally {
-            session.close();
-         }
-      }
-      finally {
-         connection.close();
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/AMQ4351Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/AMQ4351Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/AMQ4351Test.java
deleted file mode 100644
index 1e2448a..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/AMQ4351Test.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/**
- * 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.broker;
-
-import junit.framework.Test;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.store.jdbc.JDBCPersistenceAdapter;
-import org.apache.derby.jdbc.EmbeddedDataSource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.jms.Connection;
-import javax.jms.*;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicLong;
-
-/**
- * Implements the test case attached to:
- * https://issues.apache.org/jira/browse/AMQ-4351
- *
- * This version avoids the spring deps.
- */
-public class AMQ4351Test extends BrokerTestSupport {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ4351Test.class);
-
-   public static Test suite() {
-      return suite(AMQ4351Test.class);
-   }
-
-   public static void main(String[] args) {
-      junit.textui.TestRunner.run(suite());
-   }
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      BrokerService broker = new BrokerService();
-
-      // Lets clean up often.
-      broker.setOfflineDurableSubscriberTaskSchedule(500);
-      broker.setOfflineDurableSubscriberTimeout(2000); // lets delete durable subs much faster.
-
-      JDBCPersistenceAdapter jdbc = new JDBCPersistenceAdapter();
-      EmbeddedDataSource dataSource = new EmbeddedDataSource();
-      dataSource.setDatabaseName("derbyDb");
-      dataSource.setCreateDatabase("create");
-      jdbc.setDataSource(dataSource);
-
-      jdbc.deleteAllMessages();
-      broker.setPersistenceAdapter(jdbc);
-      return broker;
-   }
-
-   ActiveMQConnectionFactory connectionFactory;
-   ActiveMQTopic destination = new ActiveMQTopic("TEST");
-
-   @Override
-   protected void setUp() throws Exception {
-      super.setUp();
-      connectionFactory = new ActiveMQConnectionFactory(broker.getVmConnectorURI());
-   }
-
-   class ProducingClient implements Runnable {
-
-      final AtomicLong size = new AtomicLong();
-      final AtomicBoolean done = new AtomicBoolean();
-      CountDownLatch doneLatch = new CountDownLatch(1);
-
-      Connection connection;
-      Session session;
-      MessageProducer producer;
-
-      ProducingClient() throws JMSException {
-         connection = connectionFactory.createConnection();
-         connection.start();
-         session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         producer = session.createProducer(destination);
-      }
-
-      private void sendMessage() {
-         try {
-            producer.send(session.createTextMessage("Test"));
-            long i = size.incrementAndGet();
-            if ((i % 1000) == 0) {
-               LOG.info("produced " + i + ".");
-            }
-         }
-         catch (JMSException e) {
-            e.printStackTrace();
-         }
-      }
-
-      public void start() {
-         new Thread(this, "ProducingClient").start();
-      }
-
-      public void stop() throws InterruptedException {
-         done.set(true);
-         if (!doneLatch.await(20, TimeUnit.MILLISECONDS)) {
-            try {
-               connection.close();
-               doneLatch.await();
-            }
-            catch (JMSException e) {
-            }
-         }
-      }
-
-      @Override
-      public void run() {
-         try {
-            try {
-               while (!done.get()) {
-                  sendMessage();
-                  Thread.sleep(10);
-               }
-            }
-            finally {
-               connection.close();
-            }
-         }
-         catch (Exception e) {
-            e.printStackTrace();
-            done.set(true);
-         }
-         finally {
-            doneLatch.countDown();
-         }
-      }
-   }
-
-   class ConsumingClient implements Runnable {
-
-      final String name;
-      final AtomicLong size = new AtomicLong();
-      final AtomicBoolean done = new AtomicBoolean();
-      CountDownLatch doneLatch = new CountDownLatch(1);
-      CountDownLatch started;
-      CountDownLatch finished;
-
-      public ConsumingClient(String name, CountDownLatch started, CountDownLatch finished) {
-         this.name = name;
-         this.started = started;
-         this.finished = finished;
-      }
-
-      public void start() {
-         LOG.info("Starting JMS listener " + name);
-         new Thread(this, "ConsumingClient: " + name).start();
-      }
-
-      public void stopAsync() {
-         finished.countDown();
-         done.set(true);
-      }
-
-      public void stop() throws InterruptedException {
-         stopAsync();
-         doneLatch.await();
-      }
-
-      @Override
-      public void run() {
-         try {
-            Connection connection = connectionFactory.createConnection();
-            connection.setClientID(name);
-            connection.start();
-            try {
-               Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-               MessageConsumer consumer = session.createDurableSubscriber(destination, name, null, false);
-               started.countDown();
-               while (!done.get()) {
-                  Message msg = consumer.receive(100);
-                  if (msg != null) {
-                     size.incrementAndGet();
-                     session.commit();
-                  }
-               }
-            }
-            finally {
-               connection.close();
-               LOG.info("Stopped JMS listener " + name);
-            }
-         }
-         catch (Exception e) {
-            e.printStackTrace();
-            done.set(true);
-         }
-         finally {
-            doneLatch.countDown();
-         }
-      }
-
-   }
-
-   public void testAMQ4351() throws InterruptedException, JMSException {
-      LOG.info("Start test.");
-      int subs = 100;
-      CountDownLatch startedLatch = new CountDownLatch(subs - 1);
-      CountDownLatch shutdownLatch = new CountDownLatch(subs - 4);
-
-      ProducingClient producer = new ProducingClient();
-      ConsumingClient listener1 = new ConsumingClient("subscriber-1", startedLatch, shutdownLatch);
-      ConsumingClient listener2 = new ConsumingClient("subscriber-2", startedLatch, shutdownLatch);
-      ConsumingClient listener3 = new ConsumingClient("subscriber-3", startedLatch, shutdownLatch);
-      try {
-
-         listener1.start();
-         listener2.start();
-         listener3.start();
-
-         List<ConsumingClient> subscribers = new ArrayList<>(subs);
-         for (int i = 4; i < subs; i++) {
-            ConsumingClient client = new ConsumingClient("subscriber-" + i, startedLatch, shutdownLatch);
-            subscribers.add(client);
-            client.start();
-         }
-         startedLatch.await(10, TimeUnit.SECONDS);
-
-         LOG.info("All subscribers started.");
-         producer.sendMessage();
-
-         LOG.info("Stopping 97 subscribers....");
-         for (ConsumingClient client : subscribers) {
-            client.stopAsync();
-         }
-         shutdownLatch.await(10, TimeUnit.SECONDS);
-
-         // Start producing messages for 10 minutes, at high rate
-         LOG.info("Starting mass message producer...");
-         producer.start();
-
-         long lastSize = listener1.size.get();
-         for (int i = 0; i < 10; i++) {
-            Thread.sleep(1000);
-            long size = listener1.size.get();
-            LOG.info("Listener 1: consumed: " + (size - lastSize));
-            assertTrue(size > lastSize);
-            lastSize = size;
-         }
-      }
-      finally {
-         LOG.info("Stopping clients");
-         listener1.stop();
-         listener2.stop();
-         listener3.stop();
-         producer.stop();
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/BrokerViewSlowStoreStartupTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/BrokerViewSlowStoreStartupTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/BrokerViewSlowStoreStartupTest.java
deleted file mode 100644
index 6d0a70e..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/BrokerViewSlowStoreStartupTest.java
+++ /dev/null
@@ -1,395 +0,0 @@
-/**
- * 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.broker.jmx;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.util.NoSuchElementException;
-import java.util.concurrent.CountDownLatch;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.store.kahadb.KahaDBStore;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Used to verify that the BrokerView accessed while the BrokerSerivce is waiting
- * for a Slow Store startup to complete doesn't throw unexpected NullPointerExceptions.
- */
-public class BrokerViewSlowStoreStartupTest {
-
-   private static final Logger LOG = LoggerFactory.getLogger(BrokerViewSlowStoreStartupTest.class);
-
-   private final CountDownLatch holdStoreStart = new CountDownLatch(1);
-   private final String brokerName = "brokerViewTest";
-
-   private BrokerService broker;
-   private Thread startThread;
-
-   private BrokerService createBroker() throws Exception {
-      BrokerService broker = new BrokerService();
-      broker.setBrokerName(brokerName);
-
-      KahaDBStore kaha = new KahaDBStore() {
-
-         @Override
-         public void start() throws Exception {
-            LOG.info("Test KahaDB class is waiting for signal to complete its start()");
-            holdStoreStart.await();
-            super.start();
-            LOG.info("Test KahaDB class is completed its start()");
-         }
-      };
-
-      kaha.setDirectory(new File("target/activemq-data/kahadb"));
-      kaha.deleteAllMessages();
-
-      broker.setPersistenceAdapter(kaha);
-      broker.setUseJmx(true);
-
-      return broker;
-   }
-
-   @Before
-   public void setUp() throws Exception {
-      broker = createBroker();
-
-      startThread = new Thread(new Runnable() {
-
-         @Override
-         public void run() {
-            try {
-               broker.start();
-            }
-            catch (Exception e) {
-               e.printStackTrace();
-            }
-         }
-      });
-      startThread.start();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-
-      // ensure we don't keep the broker held if an exception occurs somewhere.
-      holdStoreStart.countDown();
-
-      startThread.join();
-
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-      }
-   }
-
-   @Test(timeout = 120000)
-   public void testBrokerViewOnSlowStoreStart() throws Exception {
-
-      // Ensure we have an Admin View.
-      assertTrue(Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return (broker.getAdminView()) != null;
-         }
-      }));
-
-      final BrokerView view = broker.getAdminView();
-
-      try {
-         view.getBrokerName();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.getBrokerId();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.getTotalEnqueueCount();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.getTotalDequeueCount();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.getTotalConsumerCount();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.getTotalProducerCount();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.getTotalMessageCount();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.getTotalMessagesCached();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.resetStatistics();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.enableStatistics();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.disableStatistics();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.isStatisticsEnabled();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.getTopics();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.getQueues();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.getTemporaryTopics();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.getTemporaryQueues();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.getTopicSubscribers();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.getDurableTopicSubscribers();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.getQueueSubscribers();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.getTemporaryTopicSubscribers();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.getTemporaryQueueSubscribers();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.getInactiveDurableTopicSubscribers();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.getTopicProducers();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.getQueueProducers();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.getTemporaryTopicProducers();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.getTemporaryQueueProducers();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.getDynamicDestinationProducers();
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.removeConnector("tcp");
-         fail("Should have thrown a NoSuchElementException");
-      }
-      catch (NoSuchElementException e) {
-      }
-
-      try {
-         view.removeNetworkConnector("tcp");
-         fail("Should have thrown a NoSuchElementException");
-      }
-      catch (NoSuchElementException e) {
-      }
-
-      try {
-         view.addTopic("TEST");
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.addQueue("TEST");
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.removeTopic("TEST");
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.removeQueue("TEST");
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.createDurableSubscriber("1", "2", "3", "4");
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      try {
-         view.destroyDurableSubscriber("1", "2");
-         fail("Should have thrown an IllegalStateException");
-      }
-      catch (IllegalStateException e) {
-      }
-
-      holdStoreStart.countDown();
-      startThread.join();
-
-      Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return view.getBroker() != null;
-         }
-      });
-      assertNotNull(view.getBroker());
-
-      try {
-         view.getBrokerName();
-      }
-      catch (Exception e) {
-         fail("caught an exception getting the Broker property: " + e.getClass().getName());
-      }
-
-      try {
-         view.getBrokerId();
-      }
-      catch (IllegalStateException e) {
-         fail("caught an exception getting the Broker property: " + e.getClass().getName());
-      }
-
-      try {
-         view.getTotalEnqueueCount();
-      }
-      catch (IllegalStateException e) {
-         fail("caught an exception getting the Broker property: " + e.getClass().getName());
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/HealthViewMBeanTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/HealthViewMBeanTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/HealthViewMBeanTest.java
deleted file mode 100644
index 6406b85..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/HealthViewMBeanTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * 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.broker.jmx;
-
-import java.util.List;
-
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerInvocationHandler;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class HealthViewMBeanTest extends EmbeddedBrokerTestSupport {
-
-   private static final Logger LOG = LoggerFactory.getLogger(MBeanTest.class);
-   protected MBeanServer mbeanServer;
-   protected String domain = "org.apache.activemq";
-
-   @Override
-   protected void setUp() throws Exception {
-      bindAddress = "tcp://localhost:0";
-      useTopic = false;
-      super.setUp();
-      mbeanServer = broker.getManagementContext().getMBeanServer();
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      super.tearDown();
-   }
-
-   @Override
-   protected ConnectionFactory createConnectionFactory() throws Exception {
-      return new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString());
-   }
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      BrokerService answer = new BrokerService();
-      answer.setPersistent(true);
-      answer.setDeleteAllMessagesOnStartup(true);
-      answer.getSystemUsage().getMemoryUsage().setLimit(1024 * 1024 * 64);
-      answer.getSystemUsage().getTempUsage().setLimit(1024 * 1024 * 64);
-      answer.getSystemUsage().getStoreUsage().setLimit(1024 * 1024 * 64);
-      answer.setUseJmx(true);
-      answer.setSchedulerSupport(true);
-
-      // allow options to be visible via jmx
-
-      answer.addConnector(bindAddress);
-      return answer;
-   }
-
-   public void testHealthView() throws Exception {
-      Connection connection = connectionFactory.createConnection();
-
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      destination = createDestination();
-      MessageProducer producer = session.createProducer(destination);
-      producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
-      for (int i = 0; i < 60; i++) {
-         BytesMessage message = session.createBytesMessage();
-         message.writeBytes(new byte[1024 * 1024]);
-         producer.send(message);
-      }
-
-      Thread.sleep(1000);
-
-      String objectNameStr = broker.getBrokerObjectName().toString();
-      objectNameStr += ",service=Health";
-      ObjectName brokerName = assertRegisteredObjectName(objectNameStr);
-      HealthViewMBean health = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, HealthViewMBean.class, true);
-      List<HealthStatus> list = health.healthList();
-
-      for (HealthStatus status : list) {
-         LOG.info("Health status: {}", status);
-      }
-
-      assertEquals(2, list.size());
-   }
-
-   protected ObjectName assertRegisteredObjectName(String name) throws MalformedObjectNameException, NullPointerException {
-      ObjectName objectName = new ObjectName(name);
-      if (mbeanServer.isRegistered(objectName)) {
-         LOG.info("Bean Registered: " + objectName);
-      }
-      else {
-         fail("Could not find MBean!: " + objectName);
-      }
-      return objectName;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/Log4JConfigTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/Log4JConfigTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/Log4JConfigTest.java
deleted file mode 100644
index 82f1c4e..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/Log4JConfigTest.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/**
- * 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.broker.jmx;
-
-import java.util.List;
-
-import javax.jms.ConnectionFactory;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerInvocationHandler;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.junit.Test;
-import org.slf4j.LoggerFactory;
-
-public class Log4JConfigTest extends EmbeddedBrokerTestSupport {
-
-   private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(Log4JConfigTest.class);
-
-   private static final String BROKER_LOGGER = "org.apache.activemq.broker.BrokerService";
-
-   protected MBeanServer mbeanServer;
-   protected String domain = "org.apache.activemq";
-
-   @Override
-   protected void setUp() throws Exception {
-      bindAddress = "tcp://localhost:0";
-      useTopic = false;
-      super.setUp();
-      mbeanServer = broker.getManagementContext().getMBeanServer();
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      super.tearDown();
-   }
-
-   @Override
-   protected ConnectionFactory createConnectionFactory() throws Exception {
-      return new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString());
-   }
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      BrokerService answer = new BrokerService();
-      answer.setPersistent(true);
-      answer.setDeleteAllMessagesOnStartup(true);
-      answer.setUseJmx(true);
-      answer.setSchedulerSupport(true);
-      answer.addConnector(bindAddress);
-      return answer;
-   }
-
-   @Test
-   public void testLog4JConfigViewExists() throws Exception {
-      String brokerObjectName = broker.getBrokerObjectName().toString();
-      String log4jConfigViewName = BrokerMBeanSupport.createLog4JConfigViewName(brokerObjectName).toString();
-      assertRegisteredObjectName(log4jConfigViewName);
-   }
-
-   @Test
-   public void testLog4JConfigViewGetLoggers() throws Throwable {
-      String brokerObjectName = broker.getBrokerObjectName().toString();
-      ObjectName log4jConfigViewName = BrokerMBeanSupport.createLog4JConfigViewName(brokerObjectName);
-      Log4JConfigViewMBean log4jConfigView = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, log4jConfigViewName, Log4JConfigViewMBean.class, true);
-
-      List<String> loggers = log4jConfigView.getLoggers();
-      assertNotNull(loggers);
-      assertFalse(loggers.isEmpty());
-   }
-
-   @Test
-   public void testLog4JConfigViewGetLevel() throws Throwable {
-      String brokerObjectName = broker.getBrokerObjectName().toString();
-      ObjectName log4jConfigViewName = BrokerMBeanSupport.createLog4JConfigViewName(brokerObjectName);
-      Log4JConfigViewMBean log4jConfigView = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, log4jConfigViewName, Log4JConfigViewMBean.class, true);
-
-      String level = log4jConfigView.getLogLevel(BROKER_LOGGER);
-      assertNotNull(level);
-      assertFalse(level.isEmpty());
-   }
-
-   @Test
-   public void testLog4JConfigViewGetLevelUnknownLoggerName() throws Throwable {
-      String brokerObjectName = broker.getBrokerObjectName().toString();
-      ObjectName log4jConfigViewName = BrokerMBeanSupport.createLog4JConfigViewName(brokerObjectName);
-      Log4JConfigViewMBean log4jConfigView = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, log4jConfigViewName, Log4JConfigViewMBean.class, true);
-
-      // Non-existent loggers will return a name equal to the root level.
-      String level = log4jConfigView.getLogLevel("not.a.logger");
-      assertNotNull(level);
-      assertFalse(level.isEmpty());
-      assertEquals(Logger.getRootLogger().getLevel().toString(), level);
-   }
-
-   @Test
-   public void testLog4JConfigViewSetLevel() throws Throwable {
-      String brokerObjectName = broker.getBrokerObjectName().toString();
-      ObjectName log4jConfigViewName = BrokerMBeanSupport.createLog4JConfigViewName(brokerObjectName);
-      Log4JConfigViewMBean log4jConfigView = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, log4jConfigViewName, Log4JConfigViewMBean.class, true);
-
-      String level = log4jConfigView.getLogLevel(BROKER_LOGGER);
-      assertNotNull(level);
-      assertFalse(level.isEmpty());
-
-      log4jConfigView.setLogLevel(BROKER_LOGGER, "WARN");
-      level = log4jConfigView.getLogLevel(BROKER_LOGGER);
-      assertNotNull(level);
-      assertEquals("WARN", level);
-
-      log4jConfigView.setLogLevel(BROKER_LOGGER, "INFO");
-      level = log4jConfigView.getLogLevel(BROKER_LOGGER);
-      assertNotNull(level);
-      assertEquals("INFO", level);
-   }
-
-   @Test
-   public void testLog4JConfigViewSetLevelNoChangeIfLevelIsBad() throws Throwable {
-      String brokerObjectName = broker.getBrokerObjectName().toString();
-      ObjectName log4jConfigViewName = BrokerMBeanSupport.createLog4JConfigViewName(brokerObjectName);
-      Log4JConfigViewMBean log4jConfigView = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, log4jConfigViewName, Log4JConfigViewMBean.class, true);
-
-      log4jConfigView.setLogLevel(BROKER_LOGGER, "INFO");
-      String level = log4jConfigView.getLogLevel(BROKER_LOGGER);
-      assertNotNull(level);
-      assertEquals("INFO", level);
-
-      log4jConfigView.setLogLevel(BROKER_LOGGER, "BAD");
-      level = log4jConfigView.getLogLevel(BROKER_LOGGER);
-      assertNotNull(level);
-      assertEquals("INFO", level);
-   }
-
-   @Test
-   public void testLog4JConfigViewGetRootLogLevel() throws Throwable {
-      String brokerObjectName = broker.getBrokerObjectName().toString();
-      ObjectName log4jConfigViewName = BrokerMBeanSupport.createLog4JConfigViewName(brokerObjectName);
-      Log4JConfigViewMBean log4jConfigView = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, log4jConfigViewName, Log4JConfigViewMBean.class, true);
-
-      String level = log4jConfigView.getRootLogLevel();
-      assertNotNull(level);
-      assertFalse(level.isEmpty());
-
-      String currentRootLevel = Logger.getRootLogger().getLevel().toString();
-      assertEquals(currentRootLevel, level);
-   }
-
-   @Test
-   public void testLog4JConfigViewSetRootLevel() throws Throwable {
-      String brokerObjectName = broker.getBrokerObjectName().toString();
-      ObjectName log4jConfigViewName = BrokerMBeanSupport.createLog4JConfigViewName(brokerObjectName);
-      Log4JConfigViewMBean log4jConfigView = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, log4jConfigViewName, Log4JConfigViewMBean.class, true);
-
-      String currentRootLevel = Logger.getRootLogger().getLevel().toString();
-      log4jConfigView.setRootLogLevel("WARN");
-      currentRootLevel = Logger.getRootLogger().getLevel().toString();
-      assertEquals("WARN", currentRootLevel);
-      log4jConfigView.setRootLogLevel("INFO");
-      currentRootLevel = Logger.getRootLogger().getLevel().toString();
-      assertEquals("INFO", currentRootLevel);
-
-      Level level;
-   }
-
-   protected ObjectName assertRegisteredObjectName(String name) throws MalformedObjectNameException, NullPointerException {
-      ObjectName objectName = new ObjectName(name);
-      if (mbeanServer.isRegistered(objectName)) {
-         LOG.info("Bean Registered: " + objectName);
-      }
-      else {
-         fail("Could not find MBean!: " + objectName);
-      }
-      return objectName;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/MBeanOperationTimeoutTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/MBeanOperationTimeoutTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/MBeanOperationTimeoutTest.java
deleted file mode 100644
index 5747efe..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/broker/jmx/MBeanOperationTimeoutTest.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/**
- * 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.broker.jmx;
-
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerInvocationHandler;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-public class MBeanOperationTimeoutTest {
-
-   private static final Logger LOG = LoggerFactory.getLogger(MBeanOperationTimeoutTest.class);
-
-   private ActiveMQConnectionFactory connectionFactory;
-   private BrokerService broker;
-   private String connectionUri;
-   private static final String destinationName = "MBeanOperationTimeoutTestQ";
-   private static final String moveToDestinationName = "MBeanOperationTimeoutTestQ.Moved";
-
-   protected MBeanServer mbeanServer;
-   protected String domain = "org.apache.activemq";
-
-   protected int messageCount = 50000;
-
-   @Test(expected = TimeoutException.class)
-   public void testLongOperationTimesOut() throws Exception {
-
-      sendMessages(messageCount);
-      LOG.info("Produced " + messageCount + " messages to the broker.");
-
-      // Now get the QueueViewMBean and purge
-      String objectNameStr = broker.getBrokerObjectName().toString();
-      objectNameStr += ",destinationType=Queue,destinationName=" + destinationName;
-
-      ObjectName queueViewMBeanName = assertRegisteredObjectName(objectNameStr);
-      QueueViewMBean proxy = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, queueViewMBeanName, QueueViewMBean.class, true);
-
-      long count = proxy.getQueueSize();
-      assertEquals("Queue size", count, messageCount);
-
-      LOG.info("Attempting to move one message, TimeoutException expected");
-      proxy.moveMatchingMessagesTo(null, moveToDestinationName);
-   }
-
-   private void sendMessages(int count) throws Exception {
-      Connection connection = connectionFactory.createConnection();
-      try {
-         Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-         Destination destination = session.createQueue(destinationName);
-         MessageProducer producer = session.createProducer(destination);
-         for (int i = 0; i < messageCount; i++) {
-            Message message = session.createMessage();
-            message.setIntProperty("id", i);
-            producer.send(message);
-         }
-         session.commit();
-      }
-      finally {
-         connection.close();
-      }
-   }
-
-   protected ObjectName assertRegisteredObjectName(String name) throws MalformedObjectNameException, NullPointerException {
-      ObjectName objectName = new ObjectName(name);
-      if (mbeanServer.isRegistered(objectName)) {
-         LOG.info("Bean Registered: " + objectName);
-      }
-      else {
-         fail("Could not find MBean!: " + objectName);
-      }
-      return objectName;
-   }
-
-   @Before
-   public void setUp() throws Exception {
-      broker = createBroker();
-      broker.start();
-      broker.waitUntilStarted();
-
-      connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
-      connectionFactory = new ActiveMQConnectionFactory(connectionUri);
-      mbeanServer = broker.getManagementContext().getMBeanServer();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      Thread.sleep(500);
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-         broker = null;
-      }
-   }
-
-   protected BrokerService createBroker() throws Exception {
-      BrokerService answer = new BrokerService();
-      answer.setMbeanInvocationTimeout(TimeUnit.SECONDS.toMillis(1));
-      answer.setUseJmx(true);
-      answer.addConnector("vm://localhost");
-      answer.setDeleteAllMessagesOnStartup(true);
-      return answer;
-   }
-}


[07/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBFastEnqueueTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBFastEnqueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBFastEnqueueTest.java
deleted file mode 100644
index 352d2f0..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBFastEnqueueTest.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/**
- * 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.store.kahadb;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Vector;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-
-import javax.jms.BytesMessage;
-import javax.jms.DeliveryMode;
-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.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ConnectionControl;
-import org.apache.activemq.store.kahadb.disk.journal.FileAppender;
-import org.apache.activemq.store.kahadb.disk.journal.Journal;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class KahaDBFastEnqueueTest {
-
-   private static final Logger LOG = LoggerFactory.getLogger(KahaDBFastEnqueueTest.class);
-   private BrokerService broker;
-   private ActiveMQConnectionFactory connectionFactory;
-   KahaDBPersistenceAdapter kahaDBPersistenceAdapter;
-   private final Destination destination = new ActiveMQQueue("Test");
-   private final String payloadString = new String(new byte[6 * 1024]);
-   private final boolean useBytesMessage = true;
-   private final int parallelProducer = 20;
-   private final Vector<Exception> exceptions = new Vector<>();
-   long toSend = 10000;
-
-   // use with:
-   // -Xmx4g -Dorg.apache.kahadb.journal.appender.WRITE_STAT_WINDOW=10000 -Dorg.apache.kahadb.journal.CALLER_BUFFER_APPENDER=true
-   @Test
-   public void testPublishNoConsumer() throws Exception {
-
-      startBroker(true, 10);
-
-      final AtomicLong sharedCount = new AtomicLong(toSend);
-      long start = System.currentTimeMillis();
-      ExecutorService executorService = Executors.newCachedThreadPool();
-      for (int i = 0; i < parallelProducer; i++) {
-         executorService.execute(new Runnable() {
-            @Override
-            public void run() {
-               try {
-                  publishMessages(sharedCount, 0);
-               }
-               catch (Exception e) {
-                  exceptions.add(e);
-               }
-            }
-         });
-      }
-      executorService.shutdown();
-      executorService.awaitTermination(30, TimeUnit.MINUTES);
-      assertTrue("Producers done in time", executorService.isTerminated());
-      assertTrue("No exceptions: " + exceptions, exceptions.isEmpty());
-      long totalSent = toSend * payloadString.length();
-
-      double duration = System.currentTimeMillis() - start;
-      stopBroker();
-      LOG.info("Duration:                " + duration + "ms");
-      LOG.info("Rate:                       " + (toSend * 1000 / duration) + "m/s");
-      LOG.info("Total send:             " + totalSent);
-      LOG.info("Total journal write: " + kahaDBPersistenceAdapter.getStore().getJournal().length());
-      LOG.info("Total index size " + kahaDBPersistenceAdapter.getStore().getPageFile().getDiskSize());
-      LOG.info("Total store size: " + kahaDBPersistenceAdapter.size());
-      LOG.info("Journal writes %:    " + kahaDBPersistenceAdapter.getStore().getJournal().length() / (double) totalSent * 100 + "%");
-
-      restartBroker(0, 1200000);
-      consumeMessages(toSend);
-   }
-
-   @Test
-   public void testPublishNoConsumerNoCheckpoint() throws Exception {
-
-      toSend = 100;
-      startBroker(true, 0);
-
-      final AtomicLong sharedCount = new AtomicLong(toSend);
-      long start = System.currentTimeMillis();
-      ExecutorService executorService = Executors.newCachedThreadPool();
-      for (int i = 0; i < parallelProducer; i++) {
-         executorService.execute(new Runnable() {
-            @Override
-            public void run() {
-               try {
-                  publishMessages(sharedCount, 0);
-               }
-               catch (Exception e) {
-                  exceptions.add(e);
-               }
-            }
-         });
-      }
-      executorService.shutdown();
-      executorService.awaitTermination(30, TimeUnit.MINUTES);
-      assertTrue("Producers done in time", executorService.isTerminated());
-      assertTrue("No exceptions: " + exceptions, exceptions.isEmpty());
-      long totalSent = toSend * payloadString.length();
-
-      broker.getAdminView().gc();
-
-      double duration = System.currentTimeMillis() - start;
-      stopBroker();
-      LOG.info("Duration:                " + duration + "ms");
-      LOG.info("Rate:                       " + (toSend * 1000 / duration) + "m/s");
-      LOG.info("Total send:             " + totalSent);
-      LOG.info("Total journal write: " + kahaDBPersistenceAdapter.getStore().getJournal().length());
-      LOG.info("Total index size " + kahaDBPersistenceAdapter.getStore().getPageFile().getDiskSize());
-      LOG.info("Total store size: " + kahaDBPersistenceAdapter.size());
-      LOG.info("Journal writes %:    " + kahaDBPersistenceAdapter.getStore().getJournal().length() / (double) totalSent * 100 + "%");
-
-      restartBroker(0, 0);
-      consumeMessages(toSend);
-   }
-
-   private void consumeMessages(long count) throws Exception {
-      ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection();
-      connection.setWatchTopicAdvisories(false);
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageConsumer consumer = session.createConsumer(destination);
-      for (int i = 0; i < count; i++) {
-         assertNotNull("got message " + i, consumer.receive(10000));
-      }
-      assertNull("none left over", consumer.receive(2000));
-   }
-
-   private void restartBroker(int restartDelay, int checkpoint) throws Exception {
-      stopBroker();
-      TimeUnit.MILLISECONDS.sleep(restartDelay);
-      startBroker(false, checkpoint);
-   }
-
-   @Before
-   public void setProps() {
-      System.setProperty(Journal.CALLER_BUFFER_APPENDER, Boolean.toString(true));
-      System.setProperty(FileAppender.PROPERTY_LOG_WRITE_STAT_WINDOW, "10000");
-   }
-
-   @After
-   public void stopBroker() throws Exception {
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-      }
-      System.clearProperty(Journal.CALLER_BUFFER_APPENDER);
-      System.clearProperty(FileAppender.PROPERTY_LOG_WRITE_STAT_WINDOW);
-   }
-
-   final double sampleRate = 100000;
-
-   private void publishMessages(AtomicLong count, int expiry) throws Exception {
-      ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection();
-      connection.setWatchTopicAdvisories(false);
-      connection.start();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      MessageProducer producer = session.createProducer(destination);
-      Long start = System.currentTimeMillis();
-      long i = 0L;
-      while ((i = count.getAndDecrement()) > 0) {
-         Message message = null;
-         if (useBytesMessage) {
-            message = session.createBytesMessage();
-            ((BytesMessage) message).writeBytes(payloadString.getBytes());
-         }
-         else {
-            message = session.createTextMessage(payloadString);
-         }
-         producer.send(message, DeliveryMode.PERSISTENT, 5, expiry);
-         if (i != toSend && i % sampleRate == 0) {
-            long now = System.currentTimeMillis();
-            LOG.info("Remainder: " + i + ", rate: " + sampleRate * 1000 / (now - start) + "m/s");
-            start = now;
-         }
-      }
-      connection.syncSendPacket(new ConnectionControl());
-      connection.close();
-   }
-
-   public void startBroker(boolean deleteAllMessages, int checkPointPeriod) throws Exception {
-      broker = new BrokerService();
-      broker.setDeleteAllMessagesOnStartup(deleteAllMessages);
-      kahaDBPersistenceAdapter = (KahaDBPersistenceAdapter) broker.getPersistenceAdapter();
-      kahaDBPersistenceAdapter.setEnableJournalDiskSyncs(false);
-      // defer checkpoints which require a sync
-      kahaDBPersistenceAdapter.setCleanupInterval(checkPointPeriod);
-      kahaDBPersistenceAdapter.setCheckpointInterval(checkPointPeriod);
-
-      // optimise for disk best batch rate
-      kahaDBPersistenceAdapter.setJournalMaxWriteBatchSize(24 * 1024 * 1024); //4mb default
-      kahaDBPersistenceAdapter.setJournalMaxFileLength(128 * 1024 * 1024); // 32mb default
-      // keep index in memory
-      kahaDBPersistenceAdapter.setIndexCacheSize(500000);
-      kahaDBPersistenceAdapter.setIndexWriteBatchSize(500000);
-      kahaDBPersistenceAdapter.setEnableIndexRecoveryFile(false);
-      kahaDBPersistenceAdapter.setEnableIndexDiskSyncs(false);
-
-      broker.addConnector("tcp://0.0.0.0:0");
-      broker.start();
-
-      String options = "?jms.watchTopicAdvisories=false&jms.useAsyncSend=true&jms.alwaysSessionAsync=false&jms.dispatchAsync=false&socketBufferSize=131072&ioBufferSize=16384&wireFormat.tightEncodingEnabled=false&wireFormat.cacheSize=8192";
-      connectionFactory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getConnectUri() + options);
-   }
-
-   @Test
-   public void testRollover() throws Exception {
-      byte flip = 0x1;
-      for (long i = 0; i < Short.MAX_VALUE; i++) {
-         assertEquals("0 @:" + i, 0, flip ^= (byte) 1);
-         assertEquals("1 @:" + i, 1, flip ^= (byte) 1);
-      }
-   }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBIndexLocationTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBIndexLocationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBIndexLocationTest.java
deleted file mode 100644
index 24229c9..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBIndexLocationTest.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/**
- * 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.store.kahadb;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.FilenameFilter;
-
-import javax.jms.Connection;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- *
- */
-public class KahaDBIndexLocationTest {
-
-   private static final Logger LOG = LoggerFactory.getLogger(KahaDBIndexLocationTest.class);
-
-   @Rule
-   public TestName name = new TestName();
-
-   private BrokerService broker;
-
-   private final File testDataDir = new File("target/activemq-data/QueuePurgeTest");
-   private final File kahaDataDir = new File(testDataDir, "kahadb");
-   private final File kahaIndexDir = new File(testDataDir, "kahadb/index");
-
-   /**
-    * @throws java.lang.Exception
-    */
-   @Before
-   public void setUp() throws Exception {
-      startBroker();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      stopBroker();
-   }
-
-   private void startBroker() throws Exception {
-      createBroker();
-      broker.start();
-      broker.waitUntilStarted();
-   }
-
-   private void stopBroker() throws Exception {
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-      }
-   }
-
-   private void restartBroker() throws Exception {
-      stopBroker();
-      createBroker();
-      broker.start();
-      broker.waitUntilStarted();
-   }
-
-   private void createBroker() throws Exception {
-      broker = new BrokerService();
-
-      KahaDBPersistenceAdapter persistenceAdapter = new KahaDBPersistenceAdapter();
-      persistenceAdapter.setDirectory(kahaDataDir);
-      persistenceAdapter.setIndexDirectory(kahaIndexDir);
-
-      broker.setDataDirectoryFile(testDataDir);
-      broker.setUseJmx(false);
-      broker.setAdvisorySupport(false);
-      broker.setSchedulerSupport(false);
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.setPersistenceAdapter(persistenceAdapter);
-   }
-
-   @Test
-   public void testIndexDirExists() throws Exception {
-      LOG.info("Index dir is configured as: {}", kahaIndexDir);
-      assertTrue(kahaDataDir.exists());
-      assertTrue(kahaIndexDir.exists());
-
-      String[] index = kahaIndexDir.list(new FilenameFilter() {
-
-         @Override
-         public boolean accept(File dir, String name) {
-            LOG.info("Testing filename: {}", name);
-            return name.endsWith("data") || name.endsWith("redo");
-         }
-      });
-
-      String[] journal = kahaDataDir.list(new FilenameFilter() {
-
-         @Override
-         public boolean accept(File dir, String name) {
-            LOG.info("Testing filename: {}", name);
-            return name.endsWith("log") || name.equals("lock");
-         }
-      });
-
-      produceMessages();
-
-      // Should be db.data and db.redo and nothing else.
-      assertNotNull(index);
-      assertEquals(2, index.length);
-
-      // Should contain the initial log for the journal and the lock.
-      assertNotNull(journal);
-      assertEquals(2, journal.length);
-   }
-
-   @Test
-   public void testRestartWithDeleteWorksWhenIndexIsSeparate() throws Exception {
-      produceMessages();
-      restartBroker();
-
-      ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost?create=false");
-      Connection connection = cf.createConnection();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Queue queue = session.createQueue(name.getMethodName());
-      MessageConsumer consumer = session.createConsumer(queue);
-      assertNull(consumer.receive(2000));
-   }
-
-   private void produceMessages() throws Exception {
-      ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost?create=false");
-      Connection connection = cf.createConnection();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Queue queue = session.createQueue(name.getMethodName());
-      MessageProducer producer = session.createProducer(queue);
-      for (int i = 0; i < 5; ++i) {
-         producer.send(session.createTextMessage("test:" + i));
-      }
-      connection.close();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBMessagePriorityTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBMessagePriorityTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBMessagePriorityTest.java
deleted file mode 100644
index bb0e954..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBMessagePriorityTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * 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.store.kahadb;
-
-import junit.framework.Test;
-
-import org.apache.activemq.store.MessagePriorityTest;
-import org.apache.activemq.store.PersistenceAdapter;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-
-public class KahaDBMessagePriorityTest extends MessagePriorityTest {
-
-   @Override
-   protected PersistenceAdapter createPersistenceAdapter(boolean delete) throws Exception {
-      KahaDBPersistenceAdapter adapter = new KahaDBPersistenceAdapter();
-      adapter.setConcurrentStoreAndDispatchQueues(false);
-      adapter.setConcurrentStoreAndDispatchTopics(false);
-      adapter.deleteAllMessages();
-      return adapter;
-   }
-
-   public static Test suite() {
-      return suite(KahaDBMessagePriorityTest.class);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBPersistenceAdapterTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBPersistenceAdapterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBPersistenceAdapterTest.java
deleted file mode 100644
index cddbd71..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBPersistenceAdapterTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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.store.kahadb;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.activemq.store.PersistenceAdapter;
-import org.apache.activemq.store.PersistenceAdapterTestSupport;
-
-/**
- * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
- */
-public class KahaDBPersistenceAdapterTest extends PersistenceAdapterTestSupport {
-
-   @Override
-   protected PersistenceAdapter createPersistenceAdapter(boolean delete) throws IOException {
-      KahaDBStore kaha = new KahaDBStore();
-      kaha.setDirectory(new File("target/activemq-data/kahadb"));
-      if (delete) {
-         kaha.deleteAllMessages();
-      }
-      return kaha;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreBrokerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreBrokerTest.java
deleted file mode 100644
index b8fef90..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreBrokerTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * 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.store.kahadb;
-
-import java.io.File;
-
-import junit.framework.Test;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.BrokerTest;
-import org.apache.activemq.util.IOHelper;
-
-/**
- * Once the wire format is completed we can test against real persistence storage.
- */
-public class KahaDBStoreBrokerTest extends BrokerTest {
-
-   @Override
-   protected void setUp() throws Exception {
-      this.setAutoFail(true);
-      super.setUp();
-   }
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      BrokerService broker = new BrokerService();
-      KahaDBStore kaha = new KahaDBStore();
-      File directory = new File("target/activemq-data/kahadb");
-      IOHelper.deleteChildren(directory);
-      kaha.setDirectory(directory);
-      kaha.deleteAllMessages();
-      broker.setPersistenceAdapter(kaha);
-      return broker;
-   }
-
-   protected BrokerService createRestartedBroker() throws Exception {
-      BrokerService broker = new BrokerService();
-      KahaDBStore kaha = new KahaDBStore();
-      kaha.setDirectory(new File("target/activemq-data/kahadb"));
-      broker.setPersistenceAdapter(kaha);
-      return broker;
-   }
-
-   public static Test suite() {
-      return suite(KahaDBStoreBrokerTest.class);
-   }
-
-   public static void main(String[] args) {
-      junit.textui.TestRunner.run(suite());
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreOrderTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreOrderTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreOrderTest.java
deleted file mode 100644
index e672890..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreOrderTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * 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.store.kahadb;
-
-import java.io.File;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.store.StoreOrderTest;
-
-//  https://issues.apache.org/activemq/browse/AMQ-2594
-public class KahaDBStoreOrderTest extends StoreOrderTest {
-
-   @Override
-   protected void setPersistentAdapter(BrokerService brokerService) throws Exception {
-      KahaDBStore kaha = new KahaDBStore();
-      File directory = new File("target/activemq-data/kahadb/storeOrder");
-      kaha.setDirectory(directory);
-      brokerService.setPersistenceAdapter(kaha);
-   }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreRecoveryBrokerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreRecoveryBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreRecoveryBrokerTest.java
deleted file mode 100644
index bddfde8..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreRecoveryBrokerTest.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/**
- * 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.store.kahadb;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.ArrayList;
-
-import junit.framework.Test;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.RecoveryBrokerTest;
-import org.apache.activemq.broker.StubConnection;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ConnectionInfo;
-import org.apache.activemq.command.ConsumerInfo;
-import org.apache.activemq.command.Message;
-import org.apache.activemq.command.MessageAck;
-import org.apache.activemq.command.ProducerInfo;
-import org.apache.activemq.command.SessionInfo;
-import org.apache.commons.io.FileUtils;
-
-/**
- * Used to verify that recovery works correctly against
- */
-public class KahaDBStoreRecoveryBrokerTest extends RecoveryBrokerTest {
-
-   public static final String KAHADB_DIR_BASE = "target/activemq-data/kahadb";
-   public static String kahaDbDirectoryName;
-
-   enum CorruptionType {None, FailToLoad, LoadInvalid, LoadCorrupt, LoadOrderIndex0}
-
-   public CorruptionType failTest = CorruptionType.None;
-
-   @Override
-   protected void setUp() throws Exception {
-      kahaDbDirectoryName = KAHADB_DIR_BASE + "/" + System.currentTimeMillis();
-      super.setUp();
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      super.tearDown();
-      try {
-         File kahaDbDir = new File(kahaDbDirectoryName);
-         FileUtils.deleteDirectory(kahaDbDir);
-      }
-      catch (IOException e) {
-      }
-   }
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      BrokerService broker = new BrokerService();
-      KahaDBStore kaha = new KahaDBStore();
-      kaha.setDirectory(new File(kahaDbDirectoryName));
-      kaha.deleteAllMessages();
-      kaha.setCheckForCorruptJournalFiles(failTest == CorruptionType.LoadOrderIndex0);
-      broker.setPersistenceAdapter(kaha);
-      return broker;
-   }
-
-   @Override
-   @SuppressWarnings("resource")
-   protected BrokerService createRestartedBroker() throws Exception {
-
-      // corrupting index
-      File index = new File(kahaDbDirectoryName + "/db.data");
-      RandomAccessFile raf = new RandomAccessFile(index, "rw");
-      switch (failTest) {
-         case FailToLoad:
-            index.delete();
-            raf = new RandomAccessFile(index, "rw");
-            raf.seek(index.length());
-            raf.writeBytes("corrupt");
-            break;
-         case LoadInvalid:
-            // page size 0
-            raf.seek(0);
-            raf.writeBytes("corrupt and cannot load metadata");
-            break;
-         case LoadCorrupt:
-            // loadable but invalid metadata
-            // location of order index low priority index for first destination...
-            raf.seek(8 * 1024 + 57);
-            raf.writeLong(Integer.MAX_VALUE - 10);
-            break;
-         case LoadOrderIndex0:
-            // loadable but invalid metadata
-            // location of order index default priority index size
-            // so looks like there are no ids in the order index
-            // picked up by setCheckForCorruptJournalFiles
-            raf.seek(12 * 1024 + 21);
-            raf.writeShort(0);
-            raf.writeChar(0);
-            raf.writeLong(-1);
-            break;
-         default:
-      }
-      raf.close();
-
-      // starting broker
-      BrokerService broker = new BrokerService();
-      KahaDBStore kaha = new KahaDBStore();
-      kaha.setCheckForCorruptJournalFiles(failTest == CorruptionType.LoadOrderIndex0);
-      // uncomment if you want to test archiving
-      //kaha.setArchiveCorruptedIndex(true);
-      kaha.setDirectory(new File(kahaDbDirectoryName));
-      broker.setPersistenceAdapter(kaha);
-      return broker;
-   }
-
-   public static Test suite() {
-      return suite(KahaDBStoreRecoveryBrokerTest.class);
-   }
-
-   public static void main(String[] args) {
-      junit.textui.TestRunner.run(suite());
-   }
-
-   public void initCombosForTestLargeQueuePersistentMessagesNotLostOnRestart() {
-      this.addCombinationValues("failTest", new CorruptionType[]{CorruptionType.FailToLoad, CorruptionType.LoadInvalid, CorruptionType.LoadCorrupt, CorruptionType.LoadOrderIndex0});
-   }
-
-   public void testLargeQueuePersistentMessagesNotLostOnRestart() throws Exception {
-
-      ActiveMQDestination destination = new ActiveMQQueue("TEST");
-
-      // Setup the producer and send the message.
-      StubConnection connection = createConnection();
-      ConnectionInfo connectionInfo = createConnectionInfo();
-      SessionInfo sessionInfo = createSessionInfo(connectionInfo);
-      ProducerInfo producerInfo = createProducerInfo(sessionInfo);
-      connection.send(connectionInfo);
-      connection.send(sessionInfo);
-      connection.send(producerInfo);
-
-      ArrayList<String> expected = new ArrayList<>();
-
-      int MESSAGE_COUNT = 10000;
-      for (int i = 0; i < MESSAGE_COUNT; i++) {
-         Message message = createMessage(producerInfo, destination);
-         message.setPersistent(true);
-         connection.send(message);
-         expected.add(message.getMessageId().toString());
-      }
-      connection.request(closeConnectionInfo(connectionInfo));
-
-      // restart the broker.
-      restartBroker();
-
-      // Setup the consumer and receive the message.
-      connection = createConnection();
-      connectionInfo = createConnectionInfo();
-      sessionInfo = createSessionInfo(connectionInfo);
-      connection.send(connectionInfo);
-      connection.send(sessionInfo);
-      ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, destination);
-      connection.send(consumerInfo);
-      producerInfo = createProducerInfo(sessionInfo);
-      connection.send(producerInfo);
-
-      for (int i = 0; i < MESSAGE_COUNT / 2; i++) {
-         Message m = receiveMessage(connection);
-         assertNotNull("Should have received message " + expected.get(0) + " by now!", m);
-         assertEquals(expected.remove(0), m.getMessageId().toString());
-         MessageAck ack = createAck(consumerInfo, m, 1, MessageAck.STANDARD_ACK_TYPE);
-         connection.send(ack);
-      }
-
-      connection.request(closeConnectionInfo(connectionInfo));
-
-      // restart the broker.
-      restartBroker();
-
-      // Setup the consumer and receive the message.
-      connection = createConnection();
-      connectionInfo = createConnectionInfo();
-      sessionInfo = createSessionInfo(connectionInfo);
-      connection.send(connectionInfo);
-      connection.send(sessionInfo);
-      consumerInfo = createConsumerInfo(sessionInfo, destination);
-      connection.send(consumerInfo);
-
-      for (int i = 0; i < MESSAGE_COUNT / 2; i++) {
-         Message m = receiveMessage(connection);
-         assertNotNull("Should have received message " + expected.get(i) + " by now!", m);
-         assertEquals(expected.get(i), m.getMessageId().toString());
-         MessageAck ack = createAck(consumerInfo, m, 1, MessageAck.STANDARD_ACK_TYPE);
-         connection.send(ack);
-
-      }
-
-      connection.request(closeConnectionInfo(connectionInfo));
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreRecoveryExpiryTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreRecoveryExpiryTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreRecoveryExpiryTest.java
deleted file mode 100644
index 6ed4000..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreRecoveryExpiryTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * 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.store.kahadb;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.BaseDestination;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.broker.region.policy.VMPendingQueueMessageStoragePolicy;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class KahaDBStoreRecoveryExpiryTest {
-
-   private BrokerService broker;
-   private ActiveMQConnection connection;
-   private final Destination destination = new ActiveMQQueue("Test");
-   private Session session;
-
-   @Test
-   public void testRestartWitExpired() throws Exception {
-      publishMessages(1, 0);
-      publishMessages(1, 2000);
-      publishMessages(1, 0);
-      restartBroker(3000);
-      consumeMessages(2);
-   }
-
-   @Test
-   public void testRestartWitExpiredLargerThanBatchRecovery() throws Exception {
-      publishMessages(BaseDestination.MAX_PAGE_SIZE + 10, 2000);
-      publishMessages(10, 0);
-      restartBroker(3000);
-      consumeMessages(10);
-   }
-
-   private void consumeMessages(int count) throws Exception {
-      MessageConsumer consumer = session.createConsumer(destination);
-      for (int i = 0; i < count; i++) {
-         assertNotNull("got message " + i, consumer.receive(4000));
-      }
-      assertNull("none left over", consumer.receive(2000));
-   }
-
-   private void restartBroker(int restartDelay) throws Exception {
-      stopBroker();
-      TimeUnit.MILLISECONDS.sleep(restartDelay);
-      startBroker();
-   }
-
-   @After
-   public void stopBroker() throws Exception {
-      broker.stop();
-      broker.waitUntilStopped();
-   }
-
-   private void publishMessages(int count, int expiry) throws Exception {
-      MessageProducer producer = session.createProducer(destination);
-      for (int i = 0; i < count; i++) {
-         producer.send(session.createTextMessage(), DeliveryMode.PERSISTENT, 5, expiry);
-      }
-   }
-
-   @Before
-   public void startBroker() throws Exception {
-      broker = new BrokerService();
-      ((KahaDBPersistenceAdapter) broker.getPersistenceAdapter()).setIndexCacheSize(0);
-      PolicyMap policyMap = new PolicyMap();
-      PolicyEntry defaultEntry = new PolicyEntry();
-      defaultEntry.setPendingQueuePolicy(new VMPendingQueueMessageStoragePolicy());
-      policyMap.setDefaultEntry(defaultEntry);
-      broker.setDestinationPolicy(policyMap);
-      broker.setUseJmx(false);
-      broker.start();
-
-      ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?create=false");
-      connection = (ActiveMQConnection) connectionFactory.createConnection();
-      connection.setWatchTopicAdvisories(false);
-      connection.start();
-
-      session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-   }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreTest.java
deleted file mode 100644
index 1b9980f..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * 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.store.kahadb;
-
-import java.util.Vector;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQMessage;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.Message;
-import org.apache.activemq.command.MessageAck;
-import org.apache.activemq.command.MessageId;
-import org.apache.activemq.command.ProducerId;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-public class KahaDBStoreTest {
-
-   KahaDBStore.KahaDBMessageStore underTest;
-   KahaDBStore store;
-   ActiveMQMessage message;
-   ProducerId producerId = new ProducerId("1.1.1");
-   private static final int MESSAGE_COUNT = 2000;
-   private Vector<Throwable> exceptions = new Vector<>();
-
-   @Before
-   public void initStore() throws Exception {
-      ActiveMQDestination destination = new ActiveMQQueue("Test");
-      store = new KahaDBStore();
-      store.setMaxAsyncJobs(100);
-      store.setDeleteAllMessages(true);
-      store.start();
-      underTest = store.new KahaDBMessageStore(destination);
-      underTest.start();
-      message = new ActiveMQMessage();
-      message.setDestination(destination);
-   }
-
-   @After
-   public void destroyStore() throws Exception {
-      if (store != null) {
-         store.stop();
-      }
-   }
-
-   @Test
-   public void testConcurrentStoreAndDispatchQueue() throws Exception {
-
-      ExecutorService executor = Executors.newCachedThreadPool();
-      for (int i = 0; i < MESSAGE_COUNT; i++) {
-         final int id = ++i;
-         executor.execute(new Runnable() {
-            @Override
-            public void run() {
-               try {
-                  Message msg = message.copy();
-                  msg.setMessageId(new MessageId(producerId, id));
-                  underTest.asyncAddQueueMessage(null, msg);
-               }
-               catch (Exception e) {
-                  exceptions.add(e);
-               }
-            }
-         });
-      }
-
-      ExecutorService executor2 = Executors.newCachedThreadPool();
-      for (int i = 0; i < MESSAGE_COUNT; i++) {
-         final int id = ++i;
-         executor2.execute(new Runnable() {
-            @Override
-            public void run() {
-               try {
-                  MessageAck ack = new MessageAck();
-                  ack.setLastMessageId(new MessageId(producerId, id));
-                  underTest.removeAsyncMessage(null, ack);
-               }
-               catch (Exception e) {
-                  exceptions.add(e);
-               }
-            }
-         });
-      }
-
-      executor.shutdown();
-      executor.awaitTermination(60, TimeUnit.SECONDS);
-
-      executor2.shutdown();
-      executor2.awaitTermination(60, TimeUnit.SECONDS);
-
-      assertTrue("no exceptions " + exceptions, exceptions.isEmpty());
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBTest.java
deleted file mode 100644
index 3b63758..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBTest.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/**
- * 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.store.kahadb;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-
-/**
- * @author chirino
- */
-public class KahaDBTest extends TestCase {
-
-   protected BrokerService createBroker(KahaDBStore kaha) throws Exception {
-
-      BrokerService broker = new BrokerService();
-      broker.setUseJmx(false);
-      broker.setPersistenceAdapter(kaha);
-      broker.start();
-      return broker;
-   }
-
-   private KahaDBStore createStore(boolean delete) throws IOException {
-      KahaDBStore kaha = new KahaDBStore();
-      kaha.setDirectory(new File("target/activemq-data/kahadb"));
-      if (delete) {
-         kaha.deleteAllMessages();
-      }
-      return kaha;
-   }
-
-   public void testIgnoreMissingJournalfilesOptionSetFalse() throws Exception {
-      KahaDBStore kaha = createStore(true);
-      kaha.setJournalMaxFileLength(1024 * 100);
-      assertFalse(kaha.isIgnoreMissingJournalfiles());
-      BrokerService broker = createBroker(kaha);
-      sendMessages(1000);
-      broker.stop();
-
-      // Delete some journal files..
-      assertExistsAndDelete(new File(kaha.getDirectory(), "db-4.log"));
-      assertExistsAndDelete(new File(kaha.getDirectory(), "db-8.log"));
-
-      kaha = createStore(false);
-      kaha.setJournalMaxFileLength(1024 * 100);
-      assertFalse(kaha.isIgnoreMissingJournalfiles());
-      try {
-         broker = createBroker(kaha);
-         fail("expected IOException");
-      }
-      catch (IOException e) {
-         assertTrue(e.getMessage().startsWith("Detected missing/corrupt journal files"));
-      }
-
-   }
-
-   public void testIgnoreMissingJournalfilesOptionSetTrue() throws Exception {
-      KahaDBStore kaha = createStore(true);
-      kaha.setJournalMaxFileLength(1024 * 100);
-      assertFalse(kaha.isIgnoreMissingJournalfiles());
-      BrokerService broker = createBroker(kaha);
-      sendMessages(1000);
-      broker.stop();
-
-      // Delete some journal files..
-      assertExistsAndDelete(new File(kaha.getDirectory(), "db-4.log"));
-      assertExistsAndDelete(new File(kaha.getDirectory(), "db-8.log"));
-
-      kaha = createStore(false);
-      kaha.setIgnoreMissingJournalfiles(true);
-      kaha.setJournalMaxFileLength(1024 * 100);
-      broker = createBroker(kaha);
-
-      // We know we won't get all the messages but we should get most of them.
-      int count = receiveMessages();
-      assertTrue(count > 800);
-      assertTrue(count < 1000);
-
-      broker.stop();
-   }
-
-   public void testCheckCorruptionNotIgnored() throws Exception {
-      KahaDBStore kaha = createStore(true);
-      assertTrue(kaha.isChecksumJournalFiles());
-      assertFalse(kaha.isCheckForCorruptJournalFiles());
-
-      kaha.setJournalMaxFileLength(1024 * 100);
-      kaha.setChecksumJournalFiles(true);
-      BrokerService broker = createBroker(kaha);
-      sendMessages(1000);
-      broker.stop();
-
-      // Modify/Corrupt some journal files..
-      assertExistsAndCorrupt(new File(kaha.getDirectory(), "db-4.log"));
-      assertExistsAndCorrupt(new File(kaha.getDirectory(), "db-8.log"));
-
-      kaha = createStore(false);
-      kaha.setJournalMaxFileLength(1024 * 100);
-      kaha.setChecksumJournalFiles(true);
-      kaha.setCheckForCorruptJournalFiles(true);
-      assertFalse(kaha.isIgnoreMissingJournalfiles());
-      try {
-         broker = createBroker(kaha);
-         fail("expected IOException");
-      }
-      catch (IOException e) {
-         assertTrue(e.getMessage().startsWith("Detected missing/corrupt journal files"));
-      }
-
-   }
-
-   public void testMigrationOnNewDefaultForChecksumJournalFiles() throws Exception {
-      KahaDBStore kaha = createStore(true);
-      kaha.setChecksumJournalFiles(false);
-      assertFalse(kaha.isChecksumJournalFiles());
-      assertFalse(kaha.isCheckForCorruptJournalFiles());
-
-      kaha.setJournalMaxFileLength(1024 * 100);
-      BrokerService broker = createBroker(kaha);
-      sendMessages(1000);
-      broker.stop();
-
-      kaha = createStore(false);
-      kaha.setJournalMaxFileLength(1024 * 100);
-      kaha.setCheckForCorruptJournalFiles(true);
-      assertFalse(kaha.isIgnoreMissingJournalfiles());
-      createBroker(kaha);
-      assertEquals(1000, receiveMessages());
-   }
-
-   private void assertExistsAndCorrupt(File file) throws IOException {
-      assertTrue(file.exists());
-      RandomAccessFile f = new RandomAccessFile(file, "rw");
-      try {
-         f.seek(1024 * 5 + 134);
-         f.write("... corruption string ...".getBytes());
-      }
-      finally {
-         f.close();
-      }
-   }
-
-   public void testCheckCorruptionIgnored() throws Exception {
-      KahaDBStore kaha = createStore(true);
-      kaha.setJournalMaxFileLength(1024 * 100);
-      BrokerService broker = createBroker(kaha);
-      sendMessages(1000);
-      broker.stop();
-
-      // Delete some journal files..
-      assertExistsAndCorrupt(new File(kaha.getDirectory(), "db-4.log"));
-      assertExistsAndCorrupt(new File(kaha.getDirectory(), "db-8.log"));
-
-      kaha = createStore(false);
-      kaha.setIgnoreMissingJournalfiles(true);
-      kaha.setJournalMaxFileLength(1024 * 100);
-      kaha.setCheckForCorruptJournalFiles(true);
-      broker = createBroker(kaha);
-
-      // We know we won't get all the messages but we should get most of them.
-      int count = receiveMessages();
-      assertTrue("Expected to received a min # of messages.. Got: " + count, count > 990);
-      assertTrue(count < 1000);
-
-      broker.stop();
-   }
-
-   private void assertExistsAndDelete(File file) {
-      assertTrue(file.exists());
-      file.delete();
-      assertFalse(file.exists());
-   }
-
-   private void sendMessages(int count) throws JMSException {
-      ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost");
-      Connection connection = cf.createConnection();
-      try {
-         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageProducer producer = session.createProducer(new ActiveMQQueue("TEST"));
-         for (int i = 0; i < count; i++) {
-            producer.send(session.createTextMessage(createContent(i)));
-         }
-      }
-      finally {
-         connection.close();
-      }
-   }
-
-   private int receiveMessages() throws JMSException {
-      int rc = 0;
-      ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost");
-      Connection connection = cf.createConnection();
-      try {
-         connection.start();
-         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageConsumer messageConsumer = session.createConsumer(new ActiveMQQueue("TEST"));
-         while (messageConsumer.receive(1000) != null) {
-            rc++;
-         }
-         return rc;
-      }
-      finally {
-         connection.close();
-      }
-   }
-
-   private String createContent(int i) {
-      StringBuilder sb = new StringBuilder(i + ":");
-      while (sb.length() < 1024) {
-         sb.append("*");
-      }
-      return sb.toString();
-   }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion1/db-1.log
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion1/db-1.log b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion1/db-1.log
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion1/db.data
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion1/db.data b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion1/db.data
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion1/db.redo
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion1/db.redo b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion1/db.redo
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion2/db-1.log
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion2/db-1.log b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion2/db-1.log
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion2/db.data
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion2/db.data b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion2/db.data
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion2/db.redo
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion2/db.redo b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion2/db.redo
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion3/db-1.log
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion3/db-1.log b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion3/db-1.log
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion3/db.data
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion3/db.data b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion3/db.data
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion3/db.redo
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion3/db.redo b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion3/db.redo
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion4/db-1.log
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion4/db-1.log b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion4/db-1.log
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion4/db.data
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion4/db.data b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion4/db.data
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion4/db.redo
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion4/db.redo b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersion4/db.redo
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersionTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersionTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersionTest.java
deleted file mode 100644
index e1b42ad..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersionTest.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/**
- * 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.store.kahadb;
-
-import java.io.File;
-import java.io.IOException;
-import java.security.ProtectionDomain;
-
-import javax.jms.Connection;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.util.IOHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author chirino
- */
-public class KahaDBVersionTest extends TestCase {
-
-   static String basedir;
-
-   static {
-      try {
-         ProtectionDomain protectionDomain = KahaDBVersionTest.class.getProtectionDomain();
-         basedir = new File(new File(protectionDomain.getCodeSource().getLocation().getPath()), "../..").getCanonicalPath();
-      }
-      catch (IOException e) {
-         basedir = ".";
-      }
-   }
-
-   static final Logger LOG = LoggerFactory.getLogger(KahaDBVersionTest.class);
-   final static File VERSION_1_DB = new File(basedir + "/src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion1");
-   final static File VERSION_2_DB = new File(basedir + "/src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion2");
-   final static File VERSION_3_DB = new File(basedir + "/src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion3");
-   final static File VERSION_4_DB = new File(basedir + "/src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion4");
-
-   BrokerService broker = null;
-
-   protected BrokerService createBroker(KahaDBPersistenceAdapter kaha) throws Exception {
-      broker = new BrokerService();
-      broker.setUseJmx(false);
-      broker.setPersistenceAdapter(kaha);
-      broker.start();
-      return broker;
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      if (broker != null) {
-         broker.stop();
-      }
-   }
-
-   public void XtestCreateStore() throws Exception {
-      KahaDBPersistenceAdapter kaha = new KahaDBPersistenceAdapter();
-      File dir = new File("src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion4");
-      IOHelper.deleteFile(dir);
-      kaha.setDirectory(dir);
-      kaha.setJournalMaxFileLength(1024 * 1024);
-      BrokerService broker = createBroker(kaha);
-      ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost");
-      Connection connection = cf.createConnection();
-      connection.setClientID("test");
-      connection.start();
-      producerSomeMessages(connection, 1000);
-      connection.close();
-      broker.stop();
-   }
-
-   private void producerSomeMessages(Connection connection, int numToSend) throws Exception {
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Topic topic = session.createTopic("test.topic");
-      Queue queue = session.createQueue("test.queue");
-      MessageConsumer consumer = session.createDurableSubscriber(topic, "test");
-      consumer.close();
-      MessageProducer producer = session.createProducer(topic);
-      producer.setPriority(9);
-      for (int i = 0; i < numToSend; i++) {
-         Message msg = session.createTextMessage("test message:" + i);
-         producer.send(msg);
-      }
-      LOG.info("sent " + numToSend + " to topic");
-      producer = session.createProducer(queue);
-      for (int i = 0; i < numToSend; i++) {
-         Message msg = session.createTextMessage("test message:" + i);
-         producer.send(msg);
-      }
-      LOG.info("sent " + numToSend + " to queue");
-   }
-
-   public void testVersion1Conversion() throws Exception {
-      doConvertRestartCycle(VERSION_1_DB);
-   }
-
-   public void testVersion2Conversion() throws Exception {
-      doConvertRestartCycle(VERSION_2_DB);
-   }
-
-   public void testVersion3Conversion() throws Exception {
-      doConvertRestartCycle(VERSION_3_DB);
-   }
-
-   public void testVersion4Conversion() throws Exception {
-      doConvertRestartCycle(VERSION_4_DB);
-   }
-
-   public void doConvertRestartCycle(File existingStore) throws Exception {
-
-      File testDir = new File("target/activemq-data/kahadb/versionDB");
-      IOHelper.deleteFile(testDir);
-      IOHelper.copyFile(existingStore, testDir);
-      final int numToSend = 1000;
-
-      // on repeat store will be upgraded
-      for (int repeats = 0; repeats < 3; repeats++) {
-         KahaDBPersistenceAdapter kaha = new KahaDBPersistenceAdapter();
-         kaha.setDirectory(testDir);
-         kaha.setJournalMaxFileLength(1024 * 1024);
-         BrokerService broker = createBroker(kaha);
-         ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost");
-         Connection connection = cf.createConnection();
-         connection.setClientID("test");
-         connection.start();
-         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         Topic topic = session.createTopic("test.topic");
-         Queue queue = session.createQueue("test.queue");
-
-         if (repeats > 0) {
-            // upgraded store will be empty so generated some more messages
-            producerSomeMessages(connection, numToSend);
-         }
-
-         MessageConsumer queueConsumer = session.createConsumer(queue);
-         int count = 0;
-         for (int i = 0; i < (repeats == 0 ? 1000 : numToSend); i++) {
-            TextMessage msg = (TextMessage) queueConsumer.receive(10000);
-            count++;
-            // System.err.println(msg.getText());
-            assertNotNull(msg);
-         }
-         LOG.info("Consumed " + count + " from queue");
-         count = 0;
-         MessageConsumer topicConsumer = session.createDurableSubscriber(topic, "test");
-         for (int i = 0; i < (repeats == 0 ? 1000 : numToSend); i++) {
-            TextMessage msg = (TextMessage) topicConsumer.receive(10000);
-            count++;
-            // System.err.println(msg.getText());
-            assertNotNull("" + count, msg);
-         }
-         LOG.info("Consumed " + count + " from topic");
-         connection.close();
-
-         broker.stop();
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/NoSpaceIOTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/NoSpaceIOTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/NoSpaceIOTest.java
deleted file mode 100644
index 30e79c9..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/NoSpaceIOTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- * 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.store.kahadb;
-
-import java.io.File;
-import java.io.RandomAccessFile;
-import java.util.concurrent.atomic.AtomicLong;
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class NoSpaceIOTest {
-
-   private static final Logger LOG = LoggerFactory.getLogger(NoSpaceIOTest.class);
-
-   // need an app to input to console in intellij idea
-   public static void main(String[] args) throws Exception {
-      new NoSpaceIOTest().testRunOutOfSpace();
-   }
-
-   // handy way to validate some out of space related errors with a usb key
-   // allow it to run out of space, delete toDelete and see it recover
-   @Ignore("needs small volume, like usb key")
-   @Test
-   public void testRunOutOfSpace() throws Exception {
-      BrokerService broker = new BrokerService();
-      File dataDir = new File("/Volumes/NO NAME/");
-      File useUpSpace = new File(dataDir, "bigFile");
-      if (!useUpSpace.exists()) {
-         LOG.info("using up some space...");
-         RandomAccessFile filler = new RandomAccessFile(useUpSpace, "rw");
-         filler.setLength(1024 * 1024 * 1212); // use ~1.xG of 2G (usb) volume
-         filler.close();
-         File toDelete = new File(dataDir, "toDelete");
-         filler = new RandomAccessFile(toDelete, "rw");
-         filler.setLength(1024 * 1024 * 32 * 10); // 10 data files
-         filler.close();
-      }
-      broker.setDataDirectoryFile(dataDir);
-      broker.start();
-      AtomicLong consumed = new AtomicLong(0);
-      consume(consumed);
-      LOG.info("consumed: " + consumed);
-
-      broker.getPersistenceAdapter().checkpoint(true);
-
-      AtomicLong sent = new AtomicLong(0);
-      try {
-         produce(sent, 200);
-      }
-      catch (Exception expected) {
-         LOG.info("got ex, sent: " + sent);
-      }
-      LOG.info("sent: " + sent);
-      System.out.println("Remove toDelete file and press any key to continue");
-      int read = System.in.read();
-      System.err.println("read:" + read);
-
-      LOG.info("Trying to send again: " + sent);
-      try {
-         produce(sent, 200);
-      }
-      catch (Exception expected) {
-         LOG.info("got ex, sent: " + sent);
-      }
-      LOG.info("sent: " + sent);
-   }
-
-   private void consume(AtomicLong consumed) throws JMSException {
-      Connection c = new ActiveMQConnectionFactory("vm://localhost").createConnection();
-      try {
-         c.start();
-         Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageConsumer consumer = s.createConsumer(new ActiveMQQueue("t"));
-         while (consumer.receive(2000) != null) {
-            consumed.incrementAndGet();
-         }
-      }
-      finally {
-         c.close();
-      }
-   }
-
-   private void produce(AtomicLong sent, long toSend) throws JMSException {
-      Connection c = new ActiveMQConnectionFactory("vm://localhost").createConnection();
-      try {
-         c.start();
-         Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageProducer producer = s.createProducer(new ActiveMQQueue("t"));
-         TextMessage m = s.createTextMessage();
-         m.setText(String.valueOf(new char[1024 * 1024]));
-         for (int i = 0; i < toSend; i++) {
-            producer.send(m);
-            sent.incrementAndGet();
-         }
-      }
-      finally {
-         c.close();
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/PBMesssagesTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/PBMesssagesTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/PBMesssagesTest.java
deleted file mode 100644
index f225dee..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/PBMesssagesTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * 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.store.kahadb;
-
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.protobuf.Buffer;
-import org.apache.activemq.store.kahadb.data.KahaAddMessageCommand;
-import org.apache.activemq.store.kahadb.data.KahaDestination;
-import org.apache.activemq.store.kahadb.data.KahaDestination.DestinationType;
-import org.apache.activemq.store.kahadb.data.KahaEntryType;
-import org.apache.activemq.util.ByteSequence;
-import org.apache.activemq.util.DataByteArrayInputStream;
-import org.apache.activemq.util.DataByteArrayOutputStream;
-
-public class PBMesssagesTest extends TestCase {
-
-   @SuppressWarnings("rawtypes")
-   public void testKahaAddMessageCommand() throws IOException {
-
-      KahaAddMessageCommand expected = new KahaAddMessageCommand();
-      expected.setDestination(new KahaDestination().setName("Foo").setType(DestinationType.QUEUE));
-      expected.setMessage(new Buffer(new byte[]{1, 2, 3, 4, 5, 6}));
-      expected.setMessageId("Hello World");
-
-      int size = expected.serializedSizeFramed();
-      DataByteArrayOutputStream os = new DataByteArrayOutputStream(size + 1);
-      os.writeByte(expected.type().getNumber());
-      expected.writeFramed(os);
-      ByteSequence seq = os.toByteSequence();
-
-      DataByteArrayInputStream is = new DataByteArrayInputStream(seq);
-      KahaEntryType type = KahaEntryType.valueOf(is.readByte());
-      JournalCommand message = (JournalCommand) type.createMessage();
-      message.mergeFramed(is);
-
-      assertEquals(expected, message);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/TempKahaDBStoreBrokerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/TempKahaDBStoreBrokerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/TempKahaDBStoreBrokerTest.java
deleted file mode 100644
index 4316fc7..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/TempKahaDBStoreBrokerTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * 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.store.kahadb;
-
-import java.io.File;
-
-import junit.framework.Test;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.BrokerTest;
-
-/**
- * Once the wire format is completed we can test against real persistence storage.
- */
-public class TempKahaDBStoreBrokerTest extends BrokerTest {
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      BrokerService broker = new BrokerService();
-      KahaDBStore kaha = new KahaDBStore();
-      kaha.setDirectory(new File("target/activemq-data/kahadb"));
-      kaha.deleteAllMessages();
-      broker.setPersistenceAdapter(kaha);
-      return broker;
-   }
-
-   protected BrokerService createRestartedBroker() throws Exception {
-      BrokerService broker = new BrokerService();
-      TempKahaDBStore kaha = new TempKahaDBStore();
-      kaha.setDirectory(new File("target/activemq-data/kahadb"));
-      broker.setPersistenceAdapter(kaha);
-      return broker;
-   }
-
-   public static Test suite() {
-      return suite(TempKahaDBStoreBrokerTest.class);
-   }
-
-   public static void main(String[] args) {
-      junit.textui.TestRunner.run(suite());
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/perf/KahaBulkLoadingTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/perf/KahaBulkLoadingTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/perf/KahaBulkLoadingTest.java
deleted file mode 100644
index 1261959..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/perf/KahaBulkLoadingTest.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/**
- * 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.store.kahadb.perf;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.jms.BytesMessage;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import junit.framework.Test;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.JmsTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.store.kahadb.KahaDBStore;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This tests bulk loading and unloading of messages to a Queue.s
- */
-public class KahaBulkLoadingTest extends JmsTestSupport {
-
-   private static final Logger LOG = LoggerFactory.getLogger(KahaBulkLoadingTest.class);
-
-   protected int messageSize = 1024 * 4;
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      BrokerService broker = new BrokerService();
-      KahaDBStore kaha = new KahaDBStore();
-      kaha.setDirectory(new File("target/activemq-data/kahadb"));
-      // kaha.deleteAllMessages();
-      broker.setPersistenceAdapter(kaha);
-      broker.addConnector("tcp://localhost:0");
-      return broker;
-   }
-
-   @Override
-   protected ConnectionFactory createConnectionFactory() throws URISyntaxException, IOException {
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getServer().getConnectURI());
-      factory.setUseAsyncSend(true);
-      return factory;
-   }
-
-   public void testQueueSendThenAddConsumer() throws Exception {
-      long start;
-      long end;
-      ActiveMQDestination destination = new ActiveMQQueue("TEST");
-
-      connection.setUseCompression(false);
-      connection.getPrefetchPolicy().setAll(10);
-      connection.start();
-
-      Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
-
-      LOG.info("Receiving messages that are in the queue");
-      MessageConsumer consumer = session.createConsumer(destination);
-      BytesMessage msg = (BytesMessage) consumer.receive(2000);
-      int consumed = 0;
-      if (msg != null) {
-         consumed++;
-      }
-      while (true) {
-         int counter = 0;
-         if (msg == null) {
-            break;
-         }
-         end = start = System.currentTimeMillis();
-         int size = 0;
-         while ((end - start) < 5000) {
-            msg = (BytesMessage) consumer.receive(5000);
-            if (msg == null) {
-               break;
-            }
-            counter++;
-            consumed++;
-            end = System.currentTimeMillis();
-            size += msg.getBodyLength();
-         }
-         LOG.info("Consumed: " + (counter * 1000.0 / (end - start)) + " " + " messages/sec, " + (1.0 * size / (1024.0 * 1024.0)) * ((1000.0 / (end - start))) + " megs/sec ");
-      }
-      consumer.close();
-      LOG.info("Consumed " + consumed + " messages from the queue.");
-
-      MessageProducer producer = session.createProducer(destination);
-      producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-
-      LOG.info("Sending messages that are " + (messageSize / 1024.0) + "k large");
-      // Send a message to the broker.
-      start = System.currentTimeMillis();
-
-      final AtomicBoolean stop = new AtomicBoolean();
-      Runtime.getRuntime().addShutdownHook(new Thread() {
-         @Override
-         public void run() {
-            stop.set(true);
-         }
-      });
-
-      int produced = 0;
-      while (!stop.get()) {
-         end = start = System.currentTimeMillis();
-         int produceCount = 0;
-         while ((end - start) < 5000 && !stop.get()) {
-            BytesMessage bm = session.createBytesMessage();
-            bm.writeBytes(new byte[messageSize]);
-            producer.send(bm);
-            produceCount++;
-            produced++;
-            end = System.currentTimeMillis();
-         }
-         LOG.info("Produced: " + (produceCount * 1000.0 / (end - start)) + " messages/sec, " + (1.0 * produceCount * messageSize / (1024.0 * 1024.0)) * ((1000.0 / (end - start))) + " megs/sec");
-      }
-      LOG.info("Prodcued " + produced + " messages to the queue.");
-
-   }
-
-   public static Test suite() {
-      return suite(KahaBulkLoadingTest.class);
-   }
-
-   public static void main(String[] args) {
-      junit.textui.TestRunner.run(suite());
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/perf/KahaStoreDurableTopicTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/perf/KahaStoreDurableTopicTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/perf/KahaStoreDurableTopicTest.java
deleted file mode 100644
index 5d52adb..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/perf/KahaStoreDurableTopicTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * 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.store.kahadb.perf;
-
-import java.io.File;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.perf.SimpleDurableTopicTest;
-import org.apache.activemq.store.kahadb.KahaDBStore;
-
-/**
- *
- */
-public class KahaStoreDurableTopicTest extends SimpleDurableTopicTest {
-
-   @Override
-   protected void configureBroker(BrokerService answer, String uri) throws Exception {
-      File dataFileDir = new File("target/test-amq-data/perfTest/amqdb");
-      dataFileDir.mkdirs();
-      // answer.setDeleteAllMessagesOnStartup(true);
-
-      KahaDBStore adaptor = new KahaDBStore();
-      adaptor.setDirectory(dataFileDir);
-
-      answer.setDataDirectoryFile(dataFileDir);
-      answer.setPersistenceAdapter(adaptor);
-      answer.addConnector(uri);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/perf/KahaStoreQueueTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/perf/KahaStoreQueueTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/perf/KahaStoreQueueTest.java
deleted file mode 100644
index a2898f9..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/kahadb/perf/KahaStoreQueueTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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.store.kahadb.perf;
-
-import java.io.File;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.perf.SimpleQueueTest;
-import org.apache.activemq.store.kahadb.KahaDBStore;
-
-/**
- *
- */
-public class KahaStoreQueueTest extends SimpleQueueTest {
-
-   @Override
-   protected void configureBroker(BrokerService answer, String uri) throws Exception {
-      File dataFileDir = new File("target/test-amq-data/perfTest/amqdb");
-      dataFileDir.mkdirs();
-      answer.setDeleteAllMessagesOnStartup(true);
-
-      KahaDBStore adaptor = new KahaDBStore();
-      adaptor.setDirectory(dataFileDir);
-
-      answer.setDataDirectoryFile(dataFileDir);
-      answer.setPersistenceAdapter(adaptor);
-      answer.addConnector(uri);
-   }
-
-}
-


[13/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5450Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5450Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5450Test.java
deleted file mode 100644
index d0066a3..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5450Test.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/**
- * 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;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.Destination;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.store.PersistenceAdapter;
-import org.apache.activemq.store.kahadb.FilteredKahaDBPersistenceAdapter;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.store.kahadb.MultiKahaDBPersistenceAdapter;
-import org.junit.After;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.*;
-
-public class AMQ5450Test {
-
-   static final Logger LOG = LoggerFactory.getLogger(AMQ5450Test.class);
-   private final static int maxFileLength = 1024 * 1024 * 32;
-
-   private final static String POSTFIX_DESTINATION_NAME = ".dlq";
-
-   private final static String DESTINATION_NAME = "test" + POSTFIX_DESTINATION_NAME;
-   private final static String DESTINATION_NAME_2 = "2.test" + POSTFIX_DESTINATION_NAME;
-   private final static String DESTINATION_NAME_3 = "3.2.test" + POSTFIX_DESTINATION_NAME;
-
-   private final static String[] DESTS = new String[]{DESTINATION_NAME, DESTINATION_NAME_2, DESTINATION_NAME_3, DESTINATION_NAME, DESTINATION_NAME};
-
-   BrokerService broker;
-   private HashMap<Object, PersistenceAdapter> adapters = new HashMap<>();
-
-   @After
-   public void tearDown() throws Exception {
-      broker.stop();
-   }
-
-   protected BrokerService createAndStartBroker(PersistenceAdapter persistenceAdapter) throws Exception {
-      BrokerService broker = new BrokerService();
-      broker.setUseJmx(false);
-      broker.setBrokerName("localhost");
-      broker.setPersistenceAdapter(persistenceAdapter);
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.start();
-      broker.waitUntilStarted();
-      return broker;
-   }
-
-   @Test
-   public void testPostFixMatch() throws Exception {
-      doTestPostFixMatch(false);
-   }
-
-   @Test
-   public void testPostFixCompositeMatch() throws Exception {
-      doTestPostFixMatch(true);
-   }
-
-   private void doTestPostFixMatch(boolean useComposite) throws Exception {
-      prepareBrokerWithMultiStore(useComposite);
-
-      sendMessage(DESTINATION_NAME, "test 1");
-      sendMessage(DESTINATION_NAME_2, "test 1");
-      sendMessage(DESTINATION_NAME_3, "test 1");
-
-      assertNotNull(broker.getDestination(new ActiveMQQueue(DESTINATION_NAME)));
-      assertNotNull(broker.getDestination(new ActiveMQQueue(DESTINATION_NAME_2)));
-      assertNotNull(broker.getDestination(new ActiveMQQueue(DESTINATION_NAME_3)));
-
-      for (String dest : DESTS) {
-         Destination destination2 = broker.getDestination(new ActiveMQQueue(dest));
-         assertNotNull(destination2);
-         assertEquals(1, destination2.getMessageStore().getMessageCount());
-      }
-
-      HashMap<Integer, PersistenceAdapter> numDests = new HashMap<>();
-      for (PersistenceAdapter pa : adapters.values()) {
-         numDests.put(pa.getDestinations().size(), pa);
-      }
-
-      // ensure wildcard does not match any
-      assertTrue("0 in wildcard matcher", adapters.get(null).getDestinations().isEmpty());
-
-      assertEquals("only two values", 2, numDests.size());
-      assertTrue("0 in others", numDests.containsKey(0));
-
-      if (useComposite) {
-         assertTrue("3 in one", numDests.containsKey(3));
-      }
-      else {
-         assertTrue("1 in some", numDests.containsKey(1));
-      }
-
-   }
-
-   protected KahaDBPersistenceAdapter createStore(boolean delete) throws IOException {
-      KahaDBPersistenceAdapter kaha = new KahaDBPersistenceAdapter();
-      kaha.setJournalMaxFileLength(maxFileLength);
-      kaha.setCleanupInterval(5000);
-      if (delete) {
-         kaha.deleteAllMessages();
-      }
-      return kaha;
-   }
-
-   public void prepareBrokerWithMultiStore(boolean compositeMatch) throws Exception {
-
-      MultiKahaDBPersistenceAdapter multiKahaDBPersistenceAdapter = new MultiKahaDBPersistenceAdapter();
-      multiKahaDBPersistenceAdapter.deleteAllMessages();
-      ArrayList<FilteredKahaDBPersistenceAdapter> adapters = new ArrayList<>();
-
-      if (compositeMatch) {
-         StringBuffer compositeDestBuf = new StringBuffer();
-         for (int i = 1; i <= DESTS.length; i++) {
-            for (int j = 0; j < i; j++) {
-               compositeDestBuf.append("*");
-               if ((j + 1 == i)) {
-                  compositeDestBuf.append(POSTFIX_DESTINATION_NAME);
-               }
-               else {
-                  compositeDestBuf.append(".");
-               }
-            }
-            if (!(i + 1 > DESTS.length)) {
-               compositeDestBuf.append(",");
-            }
-         }
-         adapters.add(createFilteredKahaDBByDestinationPrefix(compositeDestBuf.toString(), true));
-
-      }
-      else {
-         // destination map does not do post fix wild card matches on paths, so we need to cover
-         // each path length
-         adapters.add(createFilteredKahaDBByDestinationPrefix("*" + POSTFIX_DESTINATION_NAME, true));
-         adapters.add(createFilteredKahaDBByDestinationPrefix("*.*" + POSTFIX_DESTINATION_NAME, true));
-         adapters.add(createFilteredKahaDBByDestinationPrefix("*.*.*" + POSTFIX_DESTINATION_NAME, true));
-         adapters.add(createFilteredKahaDBByDestinationPrefix("*.*.*.*" + POSTFIX_DESTINATION_NAME, true));
-      }
-
-      // ensure wildcard matcher is there for other dests
-      adapters.add(createFilteredKahaDBByDestinationPrefix(null, true));
-
-      multiKahaDBPersistenceAdapter.setFilteredPersistenceAdapters(adapters);
-      broker = createAndStartBroker(multiKahaDBPersistenceAdapter);
-   }
-
-   private FilteredKahaDBPersistenceAdapter createFilteredKahaDBByDestinationPrefix(String destinationPrefix,
-                                                                                    boolean deleteAllMessages) throws IOException {
-      FilteredKahaDBPersistenceAdapter template = new FilteredKahaDBPersistenceAdapter();
-      template.setPersistenceAdapter(createStore(deleteAllMessages));
-      if (destinationPrefix != null) {
-         template.setQueue(destinationPrefix);
-      }
-      adapters.put(destinationPrefix, template.getPersistenceAdapter());
-      return template;
-   }
-
-   private void sendMessage(String destinationName, String message) throws JMSException {
-      ActiveMQConnectionFactory f = new ActiveMQConnectionFactory("vm://localhost");
-      f.setAlwaysSyncSend(true);
-      Connection c = f.createConnection();
-      c.start();
-      Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = s.createProducer(new ActiveMQQueue(destinationName));
-      producer.send(s.createTextMessage(message));
-      producer.close();
-      s.close();
-      c.stop();
-   }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5567Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5567Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5567Test.java
deleted file mode 100644
index 5ed211b..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5567Test.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/**
- * 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;
-
-import java.io.File;
-import java.util.concurrent.TimeUnit;
-import javax.jms.JMSException;
-import javax.jms.TextMessage;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import junit.framework.Test;
-
-import org.apache.activemq.broker.BrokerRestartTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.StubConnection;
-import org.apache.activemq.broker.jmx.QueueViewMBean;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ConnectionInfo;
-import org.apache.activemq.command.ConsumerInfo;
-import org.apache.activemq.command.Message;
-import org.apache.activemq.command.MessageAck;
-import org.apache.activemq.command.ProducerInfo;
-import org.apache.activemq.command.SessionInfo;
-import org.apache.activemq.command.XATransactionId;
-import org.apache.activemq.openwire.OpenWireFormat;
-import org.apache.activemq.store.PersistenceAdapter;
-import org.apache.activemq.store.jdbc.DataSourceServiceSupport;
-import org.apache.activemq.store.jdbc.JDBCPersistenceAdapter;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.store.leveldb.LevelDBPersistenceAdapter;
-import org.apache.activemq.util.IOHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ5567Test extends BrokerRestartTestSupport {
-
-   protected static final Logger LOG = LoggerFactory.getLogger(AMQ5567Test.class);
-   ActiveMQQueue destination = new ActiveMQQueue("Q");
-
-   @Override
-   protected void configureBroker(BrokerService broker) throws Exception {
-      super.configureBroker(broker);
-      broker.setPersistenceAdapter(persistenceAdapter);
-   }
-
-   @Override
-   protected PolicyEntry getDefaultPolicy() {
-      PolicyEntry policy = new PolicyEntry();
-      policy.setMemoryLimit(60 * 1024);
-      return policy;
-   }
-
-   public void initCombosForTestPreparedTransactionNotDispatched() throws Exception {
-      PersistenceAdapter[] persistenceAdapters = new PersistenceAdapter[]{new KahaDBPersistenceAdapter(), new LevelDBPersistenceAdapter(), new JDBCPersistenceAdapter(DataSourceServiceSupport.createDataSource(IOHelper.getDefaultDataDirectory()), new OpenWireFormat())};
-      for (PersistenceAdapter adapter : persistenceAdapters) {
-         adapter.setDirectory(new File(IOHelper.getDefaultDataDirectory()));
-      }
-      addCombinationValues("persistenceAdapter", persistenceAdapters);
-   }
-
-   public void testPreparedTransactionNotDispatched() throws Exception {
-
-      ActiveMQDestination destination = new ActiveMQQueue("Q");
-
-      StubConnection connection = createConnection();
-      ConnectionInfo connectionInfo = createConnectionInfo();
-      SessionInfo sessionInfo = createSessionInfo(connectionInfo);
-      ProducerInfo producerInfo = createProducerInfo(sessionInfo);
-      connection.send(connectionInfo);
-      connection.send(sessionInfo);
-      connection.send(producerInfo);
-
-      XATransactionId txid = createXATransaction(sessionInfo);
-      connection.send(createBeginTransaction(connectionInfo, txid));
-      Message message = createMessage(producerInfo, destination);
-      message.setPersistent(true);
-      message.setTransactionId(txid);
-      connection.send(message);
-
-      connection.send(createPrepareTransaction(connectionInfo, txid));
-
-      // send another non tx, will poke dispatch
-      message = createMessage(producerInfo, destination);
-      message.setPersistent(true);
-      connection.send(message);
-
-      // Since prepared but not committed.. only one should get delivered
-      StubConnection connectionC = createConnection();
-      ConnectionInfo connectionInfoC = createConnectionInfo();
-      SessionInfo sessionInfoC = createSessionInfo(connectionInfoC);
-      ConsumerInfo consumerInfo = createConsumerInfo(sessionInfoC, destination);
-      connectionC.send(connectionInfoC);
-      connectionC.send(sessionInfoC);
-      connectionC.send(consumerInfo);
-
-      Message m = receiveMessage(connectionC, TimeUnit.SECONDS.toMillis(10));
-      LOG.info("received: " + m);
-      assertNotNull("Got message", m);
-      assertNull("Got non tx message", m.getTransactionId());
-
-      // cannot get the prepared message till commit
-      assertNull(receiveMessage(connectionC));
-      assertNoMessagesLeft(connectionC);
-
-      LOG.info("commit: " + txid);
-      connection.request(createCommitTransaction2Phase(connectionInfo, txid));
-
-      m = receiveMessage(connectionC, TimeUnit.SECONDS.toMillis(10));
-      LOG.info("received: " + m);
-      assertNotNull("Got non null message", m);
-
-   }
-
-   public void initCombosForTestCursorStoreSync() throws Exception {
-      PersistenceAdapter[] persistenceAdapters = new PersistenceAdapter[]{new KahaDBPersistenceAdapter(), new LevelDBPersistenceAdapter(), new JDBCPersistenceAdapter(DataSourceServiceSupport.createDataSource(IOHelper.getDefaultDataDirectory()), new OpenWireFormat())};
-      for (PersistenceAdapter adapter : persistenceAdapters) {
-         adapter.setDirectory(new File(IOHelper.getDefaultDataDirectory()));
-      }
-      addCombinationValues("persistenceAdapter", persistenceAdapters);
-   }
-
-   public void testCursorStoreSync() throws Exception {
-
-      StubConnection connection = createConnection();
-      ConnectionInfo connectionInfo = createConnectionInfo();
-      SessionInfo sessionInfo = createSessionInfo(connectionInfo);
-      ProducerInfo producerInfo = createProducerInfo(sessionInfo);
-      connection.send(connectionInfo);
-      connection.send(sessionInfo);
-      connection.send(producerInfo);
-
-      XATransactionId txid = createXATransaction(sessionInfo);
-      connection.send(createBeginTransaction(connectionInfo, txid));
-      Message message = createMessage(producerInfo, destination);
-      message.setPersistent(true);
-      message.setTransactionId(txid);
-      connection.request(message);
-
-      connection.request(createPrepareTransaction(connectionInfo, txid));
-
-      QueueViewMBean proxy = getProxyToQueueViewMBean();
-      assertTrue("cache is enabled", proxy.isCacheEnabled());
-
-      // send another non tx, will fill cursor
-      String payload = new String(new byte[10 * 1024]);
-      for (int i = 0; i < 6; i++) {
-         message = createMessage(producerInfo, destination);
-         message.setPersistent(true);
-         ((TextMessage) message).setText(payload);
-         connection.request(message);
-      }
-
-      assertTrue("cache is disabled", !proxy.isCacheEnabled());
-
-      StubConnection connectionC = createConnection();
-      ConnectionInfo connectionInfoC = createConnectionInfo();
-      SessionInfo sessionInfoC = createSessionInfo(connectionInfoC);
-      ConsumerInfo consumerInfo = createConsumerInfo(sessionInfoC, destination);
-      connectionC.send(connectionInfoC);
-      connectionC.send(sessionInfoC);
-      connectionC.send(consumerInfo);
-
-      Message m = null;
-      for (int i = 0; i < 3; i++) {
-         m = receiveMessage(connectionC, TimeUnit.SECONDS.toMillis(10));
-         LOG.info("received: " + m);
-         assertNotNull("Got message", m);
-         assertNull("Got non tx message", m.getTransactionId());
-         connectionC.request(createAck(consumerInfo, m, 1, MessageAck.STANDARD_ACK_TYPE));
-      }
-
-      LOG.info("commit: " + txid);
-      connection.request(createCommitTransaction2Phase(connectionInfo, txid));
-      // consume the rest including the 2pc send in TX
-
-      for (int i = 0; i < 4; i++) {
-         m = receiveMessage(connectionC, TimeUnit.SECONDS.toMillis(10));
-         LOG.info("received[" + i + "] " + m);
-         assertNotNull("Got message", m);
-         if (i == 3) {
-            assertNotNull("Got  tx message", m.getTransactionId());
-         }
-         else {
-            assertNull("Got non tx message", m.getTransactionId());
-         }
-         connectionC.request(createAck(consumerInfo, m, 1, MessageAck.STANDARD_ACK_TYPE));
-      }
-   }
-
-   private QueueViewMBean getProxyToQueueViewMBean() throws MalformedObjectNameException, JMSException {
-      ObjectName queueViewMBeanName = new ObjectName("org.apache.activemq" + ":destinationType=Queue,destinationName=" + destination.getQueueName() + ",type=Broker,brokerName=localhost");
-      QueueViewMBean proxy = (QueueViewMBean) broker.getManagementContext().newProxyInstance(queueViewMBeanName, QueueViewMBean.class, true);
-      return proxy;
-   }
-
-   public static Test suite() {
-      return suite(AMQ5567Test.class);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/ActiveMQSlowConsumerManualTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/ActiveMQSlowConsumerManualTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/ActiveMQSlowConsumerManualTest.java
deleted file mode 100644
index e8414d5..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/ActiveMQSlowConsumerManualTest.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/**
- * 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;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.ConstantPendingMessageLimitStrategy;
-import org.apache.activemq.broker.region.policy.OldestMessageEvictionStrategy;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * @author James Furness
- *         https://issues.apache.org/jira/browse/AMQ-3607
- */
-public class ActiveMQSlowConsumerManualTest {
-
-   private static final int PORT = 12345;
-   private static final ActiveMQTopic TOPIC = new ActiveMQTopic("TOPIC");
-   private static final String URL = "nio://localhost:" + PORT + "?socket.tcpNoDelay=true";
-
-   @Test(timeout = 60000)
-   public void testDefaultSettings() throws Exception {
-      runTest("testDefaultSettings", 30, -1, -1, false, false, false, false);
-   }
-
-   @Test(timeout = 60000)
-   public void testDefaultSettingsWithOptimiseAcknowledge() throws Exception {
-      runTest("testDefaultSettingsWithOptimiseAcknowledge", 30, -1, -1, false, false, true, false);
-   }
-
-   @Test(timeout = 60000)
-   public void testBounded() throws Exception {
-      runTest("testBounded", 30, 5, 25, false, false, false, false);
-   }
-
-   @Test(timeout = 60000)
-   public void testBoundedWithOptimiseAcknowledge() throws Exception {
-      runTest("testBoundedWithOptimiseAcknowledge", 30, 5, 25, false, false, true, false);
-   }
-
-   public void runTest(String name,
-                       int sendMessageCount,
-                       int prefetchLimit,
-                       int messageLimit,
-                       boolean evictOldestMessage,
-                       boolean disableFlowControl,
-                       boolean optimizeAcknowledge,
-                       boolean persistent) throws Exception {
-      BrokerService broker = createBroker(persistent);
-      broker.setDestinationPolicy(buildPolicy(TOPIC, prefetchLimit, messageLimit, evictOldestMessage, disableFlowControl));
-      broker.start();
-
-      // Slow consumer
-      Session slowConsumerSession = buildSession("SlowConsumer", URL, optimizeAcknowledge);
-      final CountDownLatch blockSlowConsumer = new CountDownLatch(1);
-      final AtomicInteger slowConsumerReceiveCount = new AtomicInteger();
-      final List<Integer> slowConsumerReceived = sendMessageCount <= 1000 ? new ArrayList<Integer>() : null;
-      MessageConsumer slowConsumer = createSubscriber(slowConsumerSession, new MessageListener() {
-                                                         @Override
-                                                         public void onMessage(Message message) {
-                                                            try {
-                                                               slowConsumerReceiveCount.incrementAndGet();
-                                                               int count = Integer.parseInt(((TextMessage) message).getText());
-                                                               if (slowConsumerReceived != null)
-                                                                  slowConsumerReceived.add(count);
-                                                               if (count % 10000 == 0)
-                                                                  System.out.println("SlowConsumer: Receive " + count);
-                                                               blockSlowConsumer.await();
-                                                            }
-                                                            catch (Exception ignored) {
-                                                            }
-                                                         }
-                                                      });
-
-      // Fast consumer
-      Session fastConsumerSession = buildSession("FastConsumer", URL, optimizeAcknowledge);
-      final AtomicInteger fastConsumerReceiveCount = new AtomicInteger();
-      final List<Integer> fastConsumerReceived = sendMessageCount <= 1000 ? new ArrayList<Integer>() : null;
-      MessageConsumer fastConsumer = createSubscriber(fastConsumerSession, new MessageListener() {
-                                                         @Override
-                                                         public void onMessage(Message message) {
-                                                            try {
-                                                               fastConsumerReceiveCount.incrementAndGet();
-                                                               TimeUnit.MILLISECONDS.sleep(5);
-                                                               int count = Integer.parseInt(((TextMessage) message).getText());
-                                                               if (fastConsumerReceived != null)
-                                                                  fastConsumerReceived.add(count);
-                                                               if (count % 10000 == 0)
-                                                                  System.out.println("FastConsumer: Receive " + count);
-                                                            }
-                                                            catch (Exception ignored) {
-                                                            }
-                                                         }
-                                                      });
-
-      // Wait for consumers to connect
-      Thread.sleep(500);
-
-      // Publisher
-      AtomicInteger sentCount = new AtomicInteger();
-      List<Integer> sent = sendMessageCount <= 1000 ? new ArrayList<Integer>() : null;
-      Session publisherSession = buildSession("Publisher", URL, optimizeAcknowledge);
-      MessageProducer publisher = createPublisher(publisherSession);
-      for (int i = 0; i < sendMessageCount; i++) {
-         sentCount.incrementAndGet();
-         if (sent != null)
-            sent.add(i);
-         if (i % 10000 == 0)
-            System.out.println("Publisher: Send " + i);
-         publisher.send(publisherSession.createTextMessage(Integer.toString(i)));
-      }
-
-      // Wait for messages to arrive
-      Thread.sleep(500);
-
-      System.out.println(name + ": Publisher Sent: " + sentCount + " " + sent);
-      System.out.println(name + ": Whilst slow consumer blocked:");
-      System.out.println("\t\t- SlowConsumer Received: " + slowConsumerReceiveCount + " " + slowConsumerReceived);
-      System.out.println("\t\t- FastConsumer Received: " + fastConsumerReceiveCount + " " + fastConsumerReceived);
-
-      // Unblock slow consumer
-      blockSlowConsumer.countDown();
-
-      // Wait for messages to arrive
-      Thread.sleep(500);
-
-      System.out.println(name + ": After slow consumer unblocked:");
-      System.out.println("\t\t- SlowConsumer Received: " + slowConsumerReceiveCount + " " + slowConsumerReceived);
-      System.out.println("\t\t- FastConsumer Received: " + fastConsumerReceiveCount + " " + fastConsumerReceived);
-      System.out.println();
-
-      publisher.close();
-      publisherSession.close();
-      slowConsumer.close();
-      slowConsumerSession.close();
-      fastConsumer.close();
-      fastConsumerSession.close();
-      broker.stop();
-
-      Assert.assertEquals("Fast consumer missed messages whilst slow consumer was blocking", sent, fastConsumerReceived);
-      // this is too timine dependent  as sometimes there is message eviction, would need to check the dlq
-      //Assert.assertEquals("Slow consumer received incorrect message count", Math.min(sendMessageCount, prefetchLimit + (messageLimit > 0 ? messageLimit : Integer.MAX_VALUE)), slowConsumerReceived.size());
-   }
-
-   private static BrokerService createBroker(boolean persistent) throws Exception {
-      BrokerService broker = new BrokerService();
-      broker.setBrokerName("TestBroker");
-      broker.setPersistent(persistent);
-      broker.addConnector(URL);
-      return broker;
-   }
-
-   private static MessageConsumer createSubscriber(Session session,
-                                                   MessageListener messageListener) throws JMSException {
-      MessageConsumer consumer = session.createConsumer(TOPIC);
-      consumer.setMessageListener(messageListener);
-      return consumer;
-   }
-
-   private static MessageProducer createPublisher(Session session) throws JMSException {
-      MessageProducer producer = session.createProducer(TOPIC);
-      producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-      return producer;
-   }
-
-   private static Session buildSession(String clientId, String url, boolean optimizeAcknowledge) throws JMSException {
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
-
-      connectionFactory.setCopyMessageOnSend(false);
-      connectionFactory.setDisableTimeStampsByDefault(true);
-      connectionFactory.setOptimizeAcknowledge(optimizeAcknowledge);
-      if (optimizeAcknowledge) {
-         connectionFactory.setOptimizeAcknowledgeTimeOut(1);
-      }
-
-      Connection connection = connectionFactory.createConnection();
-      connection.setClientID(clientId);
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      connection.start();
-
-      return session;
-   }
-
-   private static PolicyMap buildPolicy(ActiveMQTopic topic,
-                                        int prefetchLimit,
-                                        int messageLimit,
-                                        boolean evictOldestMessage,
-                                        boolean disableFlowControl) {
-      PolicyMap policyMap = new PolicyMap();
-
-      PolicyEntry policyEntry = new PolicyEntry();
-
-      if (evictOldestMessage) {
-         policyEntry.setMessageEvictionStrategy(new OldestMessageEvictionStrategy());
-      }
-
-      if (disableFlowControl) {
-         policyEntry.setProducerFlowControl(false);
-      }
-
-      if (prefetchLimit > 0) {
-         policyEntry.setTopicPrefetch(prefetchLimit);
-      }
-
-      if (messageLimit > 0) {
-         ConstantPendingMessageLimitStrategy messageLimitStrategy = new ConstantPendingMessageLimitStrategy();
-         messageLimitStrategy.setLimit(messageLimit);
-         policyEntry.setPendingMessageLimitStrategy(messageLimitStrategy);
-      }
-
-      policyMap.put(topic, policyEntry);
-
-      return policyMap;
-   }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/ConnectionPerMessageTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/ConnectionPerMessageTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/ConnectionPerMessageTest.java
deleted file mode 100644
index 2d6a48c..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/ConnectionPerMessageTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * 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;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.MapMessage;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.Topic;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ConnectionPerMessageTest extends EmbeddedBrokerTestSupport {
-
-   private static final Logger LOG = LoggerFactory.getLogger(ConnectionPerMessageTest.class);
-   private static final int COUNT = 2000;
-   protected String bindAddress;
-
-   public void testConnectionPerMessage() throws Exception {
-      final String topicName = "test.topic";
-
-      LOG.info("Initializing connection factory for JMS to URL: " + bindAddress);
-      final ActiveMQConnectionFactory normalFactory = new ActiveMQConnectionFactory();
-      normalFactory.setBrokerURL(bindAddress);
-      for (int i = 0; i < COUNT; i++) {
-
-         if (i % 100 == 0) {
-            LOG.info(new Integer(i).toString());
-         }
-
-         Connection conn = null;
-         try {
-
-            conn = normalFactory.createConnection();
-            final Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-            final Topic topic = session.createTopic(topicName);
-            final MessageProducer producer = session.createProducer(topic);
-            producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-
-            final MapMessage m = session.createMapMessage();
-            m.setInt("hey", i);
-
-            producer.send(m);
-
-         }
-         catch (JMSException e) {
-            LOG.warn(e.getMessage(), e);
-         }
-         finally {
-            if (conn != null)
-               try {
-                  conn.close();
-               }
-               catch (JMSException e) {
-                  LOG.warn(e.getMessage(), e);
-               }
-         }
-      }
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      bindAddress = "vm://localhost";
-      super.setUp();
-   }
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      BrokerService answer = new BrokerService();
-      answer.setDeleteAllMessagesOnStartup(true);
-      answer.setUseJmx(false);
-      answer.setPersistent(isPersistent());
-      answer.addConnector(bindAddress);
-      return answer;
-   }
-
-   @Override
-   protected boolean isPersistent() {
-      return true;
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      super.tearDown();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/CraigsBugTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/CraigsBugTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/CraigsBugTest.java
deleted file mode 100644
index 35da06c..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/CraigsBugTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * 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;
-
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.command.ActiveMQQueue;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-public class CraigsBugTest extends EmbeddedBrokerTestSupport {
-
-   private String connectionUri;
-
-   public void testConnectionFactory() throws Exception {
-      final ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(connectionUri);
-      final ActiveMQQueue queue = new ActiveMQQueue("testqueue");
-      final Connection conn = cf.createConnection();
-
-      Runnable r = new Runnable() {
-         @Override
-         public void run() {
-            try {
-               Session session = conn.createSession(false, 1);
-               MessageConsumer consumer = session.createConsumer(queue, null);
-               consumer.receive(1000);
-            }
-            catch (JMSException e) {
-               e.printStackTrace();
-            }
-         }
-      };
-      new Thread(r).start();
-      conn.start();
-
-      try {
-         new CountDownLatch(1).await(3, TimeUnit.SECONDS);
-      }
-      catch (InterruptedException e) {
-         e.printStackTrace();
-      }
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      bindAddress = "tcp://localhost:0";
-      super.setUp();
-
-      connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/DoubleExpireTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/DoubleExpireTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/DoubleExpireTest.java
deleted file mode 100644
index a79ca58..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/DoubleExpireTest.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/**
- * 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;
-
-import java.util.concurrent.TimeoutException;
-
-import javax.jms.Connection;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.broker.region.Queue;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.junit.Assert;
-
-public class DoubleExpireTest extends EmbeddedBrokerTestSupport {
-
-   private static final long MESSAGE_TTL_MILLIS = 1000;
-   private static final long MAX_TEST_TIME_MILLIS = 60000;
-
-   @Override
-   public void setUp() throws Exception {
-      setAutoFail(true);
-      setMaxTestTime(MAX_TEST_TIME_MILLIS);
-      super.setUp();
-   }
-
-   /**
-    * This test verifies that a message that expires can be be resent to queue
-    * with a new expiration and that it will be processed as a new message and
-    * allowed to re-expire.
-    * <p>
-    * <b>NOTE:</b> This test fails on AMQ 5.4.2 because the originalExpiration
-    * timestamp is not cleared when the message is resent.
-    */
-   public void testDoubleExpireWithoutMove() throws Exception {
-      // Create the default dead letter queue.
-      final ActiveMQDestination DLQ = createDestination("ActiveMQ.DLQ");
-
-      Connection conn = createConnection();
-      try {
-         conn.start();
-         Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-         // Verify that the test queue and DLQ are empty.
-         Assert.assertEquals(0, getSize(destination));
-         Assert.assertEquals(0, getSize(DLQ));
-
-         // Enqueue a message to the test queue that will expire after 1s.
-         MessageProducer producer = session.createProducer(destination);
-         Message testMessage = session.createTextMessage("test message");
-         producer.send(testMessage, Message.DEFAULT_DELIVERY_MODE, Message.DEFAULT_PRIORITY, MESSAGE_TTL_MILLIS);
-         Assert.assertEquals(1, getSize(destination));
-
-         // Wait for the message to expire.
-         waitForSize(destination, 0, MAX_TEST_TIME_MILLIS);
-         Assert.assertEquals(1, getSize(DLQ));
-
-         // Consume the message from the DLQ and re-enqueue it to the test
-         // queue so that it expires after 1s.
-         MessageConsumer consumer = session.createConsumer(DLQ);
-         Message expiredMessage = consumer.receive();
-         Assert.assertEquals(testMessage.getJMSMessageID(), expiredMessage.getJMSMessageID());
-
-         producer.send(expiredMessage, Message.DEFAULT_DELIVERY_MODE, Message.DEFAULT_PRIORITY, MESSAGE_TTL_MILLIS);
-         Assert.assertEquals(1, getSize(destination));
-         Assert.assertEquals(0, getSize(DLQ));
-
-         // Verify that the resent message is "different" in that it has
-         // another ID.
-         Assert.assertNotSame(testMessage.getJMSMessageID(), expiredMessage.getJMSMessageID());
-
-         // Wait for the message to re-expire.
-         waitForSize(destination, 0, MAX_TEST_TIME_MILLIS);
-         Assert.assertEquals(1, getSize(DLQ));
-
-         // Re-consume the message from the DLQ.
-         Message reexpiredMessage = consumer.receive();
-         Assert.assertEquals(expiredMessage.getJMSMessageID(), reexpiredMessage.getJMSMessageID());
-      }
-      finally {
-         conn.close();
-      }
-   }
-
-   /**
-    * A helper method that returns the embedded broker's implementation of a
-    * JMS queue.
-    */
-   private Queue getPhysicalDestination(ActiveMQDestination destination) throws Exception {
-      return (Queue) broker.getAdminView().getBroker().getDestinationMap().get(destination);
-   }
-
-   /**
-    * A helper method that returns the size of the specified queue/topic.
-    */
-   private long getSize(ActiveMQDestination destination) throws Exception {
-      return getPhysicalDestination(destination) != null ? getPhysicalDestination(destination).getDestinationStatistics().getMessages().getCount() : 0;
-   }
-
-   /**
-    * A helper method that waits for a destination to reach a certain size.
-    */
-   private void waitForSize(ActiveMQDestination destination,
-                            int size,
-                            long timeoutMillis) throws Exception, TimeoutException {
-      long startTimeMillis = System.currentTimeMillis();
-
-      while (getSize(destination) != size && System.currentTimeMillis() < (startTimeMillis + timeoutMillis)) {
-         Thread.sleep(250);
-      }
-
-      if (getSize(destination) != size) {
-         throw new TimeoutException("Destination " + destination.getPhysicalName() + " did not reach size " + size + " within " + timeoutMillis + "ms.");
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/DurableConsumerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/DurableConsumerTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/DurableConsumerTest.java
deleted file mode 100644
index 3046423..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/DurableConsumerTest.java
+++ /dev/null
@@ -1,479 +0,0 @@
-/**
- * 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;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Vector;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.jms.TopicConnection;
-import javax.jms.TopicConnectionFactory;
-import javax.jms.TopicPublisher;
-import javax.jms.TopicSession;
-import javax.jms.TopicSubscriber;
-import javax.management.ObjectName;
-
-import junit.framework.Test;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.CombinationTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
-import org.apache.activemq.store.kahadb.KahaDBStore;
-import org.apache.activemq.util.IOHelper;
-import org.apache.activemq.util.Wait;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A Test case for AMQ-1479
- */
-public class DurableConsumerTest extends CombinationTestSupport {
-
-   private static final Logger LOG = LoggerFactory.getLogger(DurableConsumerTest.class);
-   private static int COUNT = 1024;
-   private static String CONSUMER_NAME = "DURABLE_TEST";
-   protected BrokerService broker;
-
-   protected String bindAddress = "tcp://localhost:61616";
-
-   protected byte[] payload = new byte[1024 * 32];
-   protected ConnectionFactory factory;
-   protected Vector<Exception> exceptions = new Vector<>();
-
-   private static final String TOPIC_NAME = "failoverTopic";
-   private static final String CONNECTION_URL = "failover:(tcp://localhost:61616,tcp://localhost:61617)";
-   public boolean useDedicatedTaskRunner = false;
-
-   private class SimpleTopicSubscriber implements MessageListener, ExceptionListener {
-
-      private TopicConnection topicConnection = null;
-
-      public SimpleTopicSubscriber(String connectionURL, String clientId, String topicName) {
-
-         ActiveMQConnectionFactory topicConnectionFactory = null;
-         TopicSession topicSession = null;
-         Topic topic = null;
-         TopicSubscriber topicSubscriber = null;
-
-         topicConnectionFactory = new ActiveMQConnectionFactory(connectionURL);
-         try {
-
-            topic = new ActiveMQTopic(topicName);
-            topicConnection = topicConnectionFactory.createTopicConnection();
-            topicConnection.setClientID((clientId));
-            topicConnection.start();
-
-            topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
-            topicSubscriber = topicSession.createDurableSubscriber(topic, (clientId));
-            topicSubscriber.setMessageListener(this);
-
-         }
-         catch (JMSException e) {
-            e.printStackTrace();
-         }
-      }
-
-      @Override
-      public void onMessage(Message arg0) {
-      }
-
-      public void closeConnection() {
-         if (topicConnection != null) {
-            try {
-               topicConnection.close();
-            }
-            catch (JMSException e) {
-            }
-         }
-      }
-
-      @Override
-      public void onException(JMSException exception) {
-         exceptions.add(exception);
-      }
-   }
-
-   private class MessagePublisher implements Runnable {
-
-      private final boolean shouldPublish = true;
-
-      @Override
-      public void run() {
-         TopicConnectionFactory topicConnectionFactory = null;
-         TopicConnection topicConnection = null;
-         TopicSession topicSession = null;
-         Topic topic = null;
-         TopicPublisher topicPublisher = null;
-         Message message = null;
-
-         topicConnectionFactory = new ActiveMQConnectionFactory(CONNECTION_URL);
-         try {
-            topic = new ActiveMQTopic(TOPIC_NAME);
-            topicConnection = topicConnectionFactory.createTopicConnection();
-            topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
-            topicPublisher = topicSession.createPublisher(topic);
-            message = topicSession.createMessage();
-         }
-         catch (Exception ex) {
-            exceptions.add(ex);
-         }
-         while (shouldPublish) {
-            try {
-               topicPublisher.publish(message, DeliveryMode.PERSISTENT, 1, 2 * 60 * 60 * 1000);
-            }
-            catch (JMSException ex) {
-               exceptions.add(ex);
-            }
-            try {
-               Thread.sleep(1);
-            }
-            catch (Exception ex) {
-            }
-         }
-      }
-   }
-
-   private void configurePersistence(BrokerService broker) throws Exception {
-      File dataDirFile = new File("target/" + getName());
-      KahaDBPersistenceAdapter kahaDBAdapter = new KahaDBPersistenceAdapter();
-      kahaDBAdapter.setDirectory(dataDirFile);
-      broker.setPersistenceAdapter(kahaDBAdapter);
-   }
-
-   public void testFailover() throws Exception {
-
-      configurePersistence(broker);
-      broker.start();
-
-      Thread publisherThread = new Thread(new MessagePublisher());
-      publisherThread.start();
-      final int numSubs = 100;
-      final List<SimpleTopicSubscriber> list = new ArrayList<>(numSubs);
-      for (int i = 0; i < numSubs; i++) {
-
-         final int id = i;
-         Thread thread = new Thread(new Runnable() {
-            @Override
-            public void run() {
-               SimpleTopicSubscriber s = new SimpleTopicSubscriber(CONNECTION_URL, System.currentTimeMillis() + "-" + id, TOPIC_NAME);
-               list.add(s);
-            }
-         });
-         thread.start();
-
-      }
-
-      Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return numSubs == list.size();
-         }
-      });
-
-      broker.stop();
-      broker = createBroker(false);
-      configurePersistence(broker);
-      broker.start();
-      Thread.sleep(10000);
-      for (SimpleTopicSubscriber s : list) {
-         s.closeConnection();
-      }
-      assertTrue("no exceptions: " + exceptions, exceptions.isEmpty());
-   }
-
-   // makes heavy use of threads and can demonstrate https://issues.apache.org/activemq/browse/AMQ-2028
-   // with use dedicatedTaskRunner=true and produce OOM
-   public void initCombosForTestConcurrentDurableConsumer() {
-      addCombinationValues("useDedicatedTaskRunner", new Object[]{Boolean.TRUE, Boolean.FALSE});
-   }
-
-   public void testConcurrentDurableConsumer() throws Exception {
-
-      broker.start();
-      broker.waitUntilStarted();
-
-      factory = createConnectionFactory();
-      final String topicName = getName();
-      final int numMessages = 500;
-      int numConsumers = 1;
-      final CountDownLatch counsumerStarted = new CountDownLatch(numConsumers);
-      final AtomicInteger receivedCount = new AtomicInteger();
-      Runnable consumer = new Runnable() {
-         @Override
-         public void run() {
-            final String consumerName = Thread.currentThread().getName();
-            int acked = 0;
-            int received = 0;
-
-            try {
-               while (acked < numMessages / 2) {
-                  // take one message and close, ack on occasion
-                  Connection consumerConnection = factory.createConnection();
-                  ((ActiveMQConnection) consumerConnection).setWatchTopicAdvisories(false);
-                  consumerConnection.setClientID(consumerName);
-                  Session consumerSession = consumerConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-                  Topic topic = consumerSession.createTopic(topicName);
-                  consumerConnection.start();
-
-                  MessageConsumer consumer = consumerSession.createDurableSubscriber(topic, consumerName);
-
-                  counsumerStarted.countDown();
-                  Message msg = null;
-                  do {
-                     msg = consumer.receive(5000);
-                     if (msg != null) {
-                        receivedCount.incrementAndGet();
-                        if (received != 0 && received % 100 == 0) {
-                           LOG.info("Received msg: " + msg.getJMSMessageID());
-                        }
-                        if (++received % 2 == 0) {
-                           msg.acknowledge();
-                           acked++;
-                        }
-                     }
-                  } while (msg == null);
-
-                  consumerConnection.close();
-               }
-               assertTrue(received >= acked);
-            }
-            catch (Exception e) {
-               e.printStackTrace();
-               exceptions.add(e);
-            }
-         }
-      };
-
-      ExecutorService executor = Executors.newFixedThreadPool(numConsumers);
-
-      for (int i = 0; i < numConsumers; i++) {
-         executor.execute(consumer);
-      }
-
-      assertTrue(counsumerStarted.await(30, TimeUnit.SECONDS));
-
-      Connection producerConnection = factory.createConnection();
-      ((ActiveMQConnection) producerConnection).setWatchTopicAdvisories(false);
-      Session producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Topic topic = producerSession.createTopic(topicName);
-      MessageProducer producer = producerSession.createProducer(topic);
-      producerConnection.start();
-      for (int i = 0; i < numMessages; i++) {
-         BytesMessage msg = producerSession.createBytesMessage();
-         msg.writeBytes(payload);
-         producer.send(msg);
-         if (i != 0 && i % 100 == 0) {
-            LOG.info("Sent msg " + i);
-         }
-      }
-
-      executor.shutdown();
-      executor.awaitTermination(30, TimeUnit.SECONDS);
-
-      Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            LOG.info("receivedCount: " + receivedCount.get());
-            return receivedCount.get() == numMessages;
-         }
-      }, 360 * 1000);
-      assertEquals("got required some messages", numMessages, receivedCount.get());
-      assertTrue("no exceptions, but: " + exceptions, exceptions.isEmpty());
-   }
-
-   public void testConsumerRecover() throws Exception {
-      doTestConsumer(true);
-   }
-
-   public void testConsumer() throws Exception {
-      doTestConsumer(false);
-   }
-
-   public void testPrefetchViaBrokerConfig() throws Exception {
-
-      Integer prefetchVal = new Integer(150);
-      PolicyEntry policyEntry = new PolicyEntry();
-      policyEntry.setDurableTopicPrefetch(prefetchVal.intValue());
-      policyEntry.setPrioritizedMessages(true);
-      PolicyMap policyMap = new PolicyMap();
-      policyMap.setDefaultEntry(policyEntry);
-      broker.setDestinationPolicy(policyMap);
-      broker.start();
-
-      factory = createConnectionFactory();
-      Connection consumerConnection = factory.createConnection();
-      consumerConnection.setClientID(CONSUMER_NAME);
-      Session consumerSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Topic topic = consumerSession.createTopic(getClass().getName());
-      MessageConsumer consumer = consumerSession.createDurableSubscriber(topic, CONSUMER_NAME);
-      consumerConnection.start();
-
-      ObjectName activeSubscriptionObjectName = broker.getAdminView().getDurableTopicSubscribers()[0];
-      Object prefetchFromSubView = broker.getManagementContext().getAttribute(activeSubscriptionObjectName, "PrefetchSize");
-      assertEquals(prefetchVal, prefetchFromSubView);
-   }
-
-   public void doTestConsumer(boolean forceRecover) throws Exception {
-
-      if (forceRecover) {
-         configurePersistence(broker);
-      }
-      broker.start();
-
-      factory = createConnectionFactory();
-      Connection consumerConnection = factory.createConnection();
-      consumerConnection.setClientID(CONSUMER_NAME);
-      Session consumerSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Topic topic = consumerSession.createTopic(getClass().getName());
-      MessageConsumer consumer = consumerSession.createDurableSubscriber(topic, CONSUMER_NAME);
-      consumerConnection.start();
-      consumerConnection.close();
-      broker.stop();
-      broker = createBroker(false);
-      if (forceRecover) {
-         configurePersistence(broker);
-      }
-      broker.start();
-
-      Connection producerConnection = factory.createConnection();
-
-      Session producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      MessageProducer producer = producerSession.createProducer(topic);
-      producerConnection.start();
-      for (int i = 0; i < COUNT; i++) {
-         BytesMessage msg = producerSession.createBytesMessage();
-         msg.writeBytes(payload);
-         producer.send(msg);
-         if (i != 0 && i % 1000 == 0) {
-            LOG.info("Sent msg " + i);
-         }
-      }
-      producerConnection.close();
-      broker.stop();
-      broker = createBroker(false);
-      if (forceRecover) {
-         configurePersistence(broker);
-      }
-      broker.start();
-
-      consumerConnection = factory.createConnection();
-      consumerConnection.setClientID(CONSUMER_NAME);
-      consumerConnection.start();
-      consumerSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      consumer = consumerSession.createDurableSubscriber(topic, CONSUMER_NAME);
-      for (int i = 0; i < COUNT; i++) {
-         Message msg = consumer.receive(10000);
-         assertNotNull("Missing message: " + i, msg);
-         if (i != 0 && i % 1000 == 0) {
-            LOG.info("Received msg " + i);
-         }
-
-      }
-      consumerConnection.close();
-
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      if (broker == null) {
-         broker = createBroker(true);
-      }
-
-      super.setUp();
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      super.tearDown();
-      if (broker != null) {
-         broker.stop();
-         broker.waitUntilStopped();
-         broker = null;
-      }
-   }
-
-   protected Topic creatTopic(Session s, String destinationName) throws JMSException {
-      return s.createTopic(destinationName);
-   }
-
-   /**
-    * Factory method to create a new broker
-    *
-    * @throws Exception
-    */
-   protected BrokerService createBroker(boolean deleteStore) throws Exception {
-      BrokerService answer = new BrokerService();
-      configureBroker(answer, deleteStore);
-      return answer;
-   }
-
-   protected void configureBroker(BrokerService answer, boolean deleteStore) throws Exception {
-      answer.setDeleteAllMessagesOnStartup(deleteStore);
-      KahaDBStore kaha = new KahaDBStore();
-      //kaha.setConcurrentStoreAndDispatchTopics(false);
-      File directory = new File("target/activemq-data/kahadb");
-      if (deleteStore) {
-         IOHelper.deleteChildren(directory);
-      }
-      kaha.setDirectory(directory);
-      //kaha.setMaxAsyncJobs(10);
-
-      answer.setPersistenceAdapter(kaha);
-      answer.addConnector(bindAddress);
-      answer.setUseShutdownHook(false);
-      answer.setAdvisorySupport(false);
-      answer.setDedicatedTaskRunner(useDedicatedTaskRunner);
-   }
-
-   protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(bindAddress);
-      factory.setUseDedicatedTaskRunner(useDedicatedTaskRunner);
-      return factory;
-   }
-
-   public static Test suite() {
-      return suite(DurableConsumerTest.class);
-   }
-
-   public static void main(String[] args) {
-      junit.textui.TestRunner.run(suite());
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/JMSDurableTopicNoLocalTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/JMSDurableTopicNoLocalTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/JMSDurableTopicNoLocalTest.java
deleted file mode 100644
index ef24795..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/JMSDurableTopicNoLocalTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * 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;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import javax.jms.Connection;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.jms.TopicSubscriber;
-
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.broker.BrokerService;
-
-/**
- *
- */
-public class JMSDurableTopicNoLocalTest extends EmbeddedBrokerTestSupport {
-
-   protected String bindAddress;
-
-   public void testConsumeNoLocal() throws Exception {
-      final String TEST_NAME = getClass().getName();
-      Connection connection = createConnection();
-      connection.setClientID(TEST_NAME);
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      TopicSubscriber subscriber = session.createDurableSubscriber((Topic) destination, "topicUser2", null, true);
-
-      final CountDownLatch latch = new CountDownLatch(1);
-      subscriber.setMessageListener(new MessageListener() {
-         @Override
-         public void onMessage(Message message) {
-            System.out.println("Receive a message " + message);
-            latch.countDown();
-         }
-      });
-
-      connection.start();
-
-      MessageProducer producer = session.createProducer(destination);
-      TextMessage message = session.createTextMessage("THIS IS A TEST");
-      producer.send(message);
-      producer.close();
-      latch.await(5, TimeUnit.SECONDS);
-      assertEquals(latch.getCount(), 1);
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      bindAddress = "vm://localhost";
-      useTopic = true;
-      super.setUp();
-   }
-
-   @Override
-   protected BrokerService createBroker() throws Exception {
-      BrokerService answer = new BrokerService();
-      answer.setUseJmx(false);
-      answer.setPersistent(true);
-      answer.setDeleteAllMessagesOnStartup(true);
-      answer.addConnector(bindAddress);
-      return answer;
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/JmsDurableTopicSlowReceiveTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/JmsDurableTopicSlowReceiveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/JmsDurableTopicSlowReceiveTest.java
deleted file mode 100644
index 137caa3..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/JmsDurableTopicSlowReceiveTest.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/**
- * 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;
-
-import java.util.Properties;
-
-import javax.jms.BytesMessage;
-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 javax.jms.Topic;
-import javax.jms.TopicSubscriber;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.test.JmsTopicSendReceiveTest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- *
- */
-public class JmsDurableTopicSlowReceiveTest extends JmsTopicSendReceiveTest {
-
-   static final int NMSG = 200;
-   static final int MSIZE = 256000;
-   private static final transient Logger LOG = LoggerFactory.getLogger(JmsDurableTopicSlowReceiveTest.class);
-   private static final String COUNT_PROPERY_NAME = "count";
-
-   protected Connection connection2;
-   protected Session session2;
-   protected Session consumeSession2;
-   protected MessageConsumer consumer2;
-   protected MessageProducer producer2;
-   protected Destination consumerDestination2;
-   BrokerService broker;
-   private Connection connection3;
-   private Session consumeSession3;
-   private TopicSubscriber consumer3;
-
-   /**
-    * Set up a durable suscriber test.
-    *
-    * @see junit.framework.TestCase#setUp()
-    */
-   @Override
-   protected void setUp() throws Exception {
-      this.durable = true;
-      broker = createBroker();
-      super.setUp();
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      super.tearDown();
-      broker.stop();
-   }
-
-   @Override
-   protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
-      ActiveMQConnectionFactory result = new ActiveMQConnectionFactory("vm://localhost?async=false");
-      Properties props = new Properties();
-      props.put("prefetchPolicy.durableTopicPrefetch", "5");
-      props.put("prefetchPolicy.optimizeDurableTopicPrefetch", "5");
-      result.setProperties(props);
-      return result;
-   }
-
-   protected BrokerService createBroker() throws Exception {
-      BrokerService answer = new BrokerService();
-      configureBroker(answer);
-      answer.start();
-      return answer;
-   }
-
-   protected void configureBroker(BrokerService answer) throws Exception {
-      answer.setDeleteAllMessagesOnStartup(true);
-   }
-
-   /**
-    * Test if all the messages sent are being received.
-    *
-    * @throws Exception
-    */
-   public void testSlowReceiver() throws Exception {
-      connection2 = createConnection();
-      connection2.setClientID("test");
-      connection2.start();
-      consumeSession2 = connection2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      session2 = connection2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      consumerDestination2 = session2.createTopic(getConsumerSubject() + "2");
-      consumer2 = consumeSession2.createDurableSubscriber((Topic) consumerDestination2, getName());
-
-      consumer2.close();
-      connection2.close();
-      new Thread(new Runnable() {
-
-         @Override
-         public void run() {
-            try {
-               int count = 0;
-               for (int loop = 0; loop < 4; loop++) {
-                  connection2 = createConnection();
-                  connection2.start();
-                  session2 = connection2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-                  producer2 = session2.createProducer(null);
-                  producer2.setDeliveryMode(deliveryMode);
-                  Thread.sleep(1000);
-                  for (int i = 0; i < NMSG / 4; i++) {
-                     BytesMessage message = session2.createBytesMessage();
-                     message.writeBytes(new byte[MSIZE]);
-                     message.setStringProperty("test", "test");
-                     message.setIntProperty(COUNT_PROPERY_NAME, count);
-                     message.setJMSType("test");
-                     producer2.send(consumerDestination2, message);
-                     Thread.sleep(50);
-                     if (verbose) {
-                        LOG.debug("Sent(" + loop + "): " + i);
-                     }
-                     count++;
-                  }
-                  producer2.close();
-                  connection2.stop();
-                  connection2.close();
-               }
-            }
-            catch (Throwable e) {
-               e.printStackTrace();
-            }
-         }
-      }, "SENDER Thread").start();
-      connection3 = createConnection();
-      connection3.setClientID("test");
-      connection3.start();
-      consumeSession3 = connection3.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-      consumer3 = consumeSession3.createDurableSubscriber((Topic) consumerDestination2, getName());
-      connection3.close();
-      int count = 0;
-      for (int loop = 0; loop < 4; ++loop) {
-         connection3 = createConnection();
-         connection3.setClientID("test");
-         connection3.start();
-         consumeSession3 = connection3.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-         consumer3 = consumeSession3.createDurableSubscriber((Topic) consumerDestination2, getName());
-         Message msg = null;
-         int i;
-         for (i = 0; i < NMSG / 4; i++) {
-            msg = consumer3.receive(10000);
-            if (msg == null) {
-               break;
-            }
-            if (verbose) {
-               LOG.debug("Received(" + loop + "): " + i + " count = " + msg.getIntProperty(COUNT_PROPERY_NAME));
-            }
-            assertNotNull(msg);
-            assertEquals(msg.getJMSType(), "test");
-            assertEquals(msg.getStringProperty("test"), "test");
-            assertEquals("Messages received out of order", count, msg.getIntProperty(COUNT_PROPERY_NAME));
-            Thread.sleep(500);
-            msg.acknowledge();
-            count++;
-         }
-         consumer3.close();
-         assertEquals("Receiver " + loop, NMSG / 4, i);
-         connection3.close();
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/JmsTimeoutTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/JmsTimeoutTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/JmsTimeoutTest.java
deleted file mode 100644
index 81987be..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/JmsTimeoutTest.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/**
- * 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;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.MessageProducer;
-import javax.jms.ResourceAllocationException;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.EmbeddedBrokerTestSupport;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.transport.RequestTimedOutIOException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class JmsTimeoutTest extends EmbeddedBrokerTestSupport {
-
-   static final Logger LOG = LoggerFactory.getLogger(JmsTimeoutTest.class);
-
-   private final int messageSize = 1024 * 64;
-   private final int messageCount = 10000;
-   private final AtomicInteger exceptionCount = new AtomicInteger(0);
-
-   /**
-    * Test the case where the broker is blocked due to a memory limit
-    * and a producer timeout is set on the connection.
-    *
-    * @throws Exception
-    */
-   public void testBlockedProducerConnectionTimeout() throws Exception {
-      final ActiveMQConnection cx = (ActiveMQConnection) createConnection();
-      final ActiveMQDestination queue = createDestination("testqueue");
-
-      // we should not take longer than 10 seconds to return from send
-      cx.setSendTimeout(10000);
-
-      Runnable r = new Runnable() {
-         @Override
-         public void run() {
-            try {
-               LOG.info("Sender thread starting");
-               Session session = cx.createSession(false, 1);
-               MessageProducer producer = session.createProducer(queue);
-               producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-
-               TextMessage message = session.createTextMessage(createMessageText());
-               for (int count = 0; count < messageCount; count++) {
-                  producer.send(message);
-               }
-               LOG.info("Done sending..");
-            }
-            catch (JMSException e) {
-               if (e.getCause() instanceof RequestTimedOutIOException) {
-                  exceptionCount.incrementAndGet();
-               }
-               else {
-                  e.printStackTrace();
-               }
-               return;
-            }
-
-         }
-      };
-      cx.start();
-      Thread producerThread = new Thread(r);
-      producerThread.start();
-      producerThread.join(30000);
-      cx.close();
-      // We should have a few timeout exceptions as memory store will fill up
-      assertTrue("No exception from the broker", exceptionCount.get() > 0);
-   }
-
-   /**
-    * Test the case where the broker is blocked due to a memory limit
-    * with a fail timeout
-    *
-    * @throws Exception
-    */
-   public void testBlockedProducerUsageSendFailTimeout() throws Exception {
-      final ActiveMQConnection cx = (ActiveMQConnection) createConnection();
-      final ActiveMQDestination queue = createDestination("testqueue");
-
-      broker.getSystemUsage().setSendFailIfNoSpaceAfterTimeout(5000);
-      Runnable r = new Runnable() {
-         @Override
-         public void run() {
-            try {
-               LOG.info("Sender thread starting");
-               Session session = cx.createSession(false, 1);
-               MessageProducer producer = session.createProducer(queue);
-               producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-
-               TextMessage message = session.createTextMessage(createMessageText());
-               for (int count = 0; count < messageCount; count++) {
-                  producer.send(message);
-               }
-               LOG.info("Done sending..");
-            }
-            catch (JMSException e) {
-               if (e instanceof ResourceAllocationException || e.getCause() instanceof RequestTimedOutIOException) {
-                  exceptionCount.incrementAndGet();
-               }
-               else {
-                  e.printStackTrace();
-               }
-               return;
-            }
-         }
-      };
-      cx.start();
-      Thread producerThread = new Thread(r);
-      producerThread.start();
-      producerThread.join(30000);
-      cx.close();
-      // We should have a few timeout exceptions as memory store will fill up
-      assertTrue("No exception from the broker", exceptionCount.get() > 0);
-   }
-
-   @Override
-   protected void setUp() throws Exception {
-      exceptionCount.set(0);
-      bindAddress = "tcp://localhost:0";
-      broker = createBroker();
-      broker.setDeleteAllMessagesOnStartup(true);
-      broker.getSystemUsage().getMemoryUsage().setLimit(5 * 1024 * 1024);
-
-      super.setUp();
-   }
-
-   @Override
-   protected ConnectionFactory createConnectionFactory() throws Exception {
-      return new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString());
-   }
-
-   private String createMessageText() {
-      StringBuffer buffer = new StringBuffer();
-      buffer.append("<filler>");
-      for (int i = buffer.length(); i < messageSize; i++) {
-         buffer.append('X');
-      }
-      buffer.append("</filler>");
-      return buffer.toString();
-   }
-
-}


[55/60] [abbrv] activemq-artemis git commit: More test clean up.

Posted by cl...@apache.org.
More test clean up.


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/0a267a38
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/0a267a38
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/0a267a38

Branch: refs/heads/refactor-openwire
Commit: 0a267a38e0df48ad57085be945aeafd16f176699
Parents: 0ceb364
Author: Howard Gao <ho...@gmail.com>
Authored: Tue Mar 1 21:18:22 2016 +0800
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:45:29 2016 -0400

----------------------------------------------------------------------
 .../activemq/artemiswrapper/ArtemisBrokerHelper.java  | 14 +++++---------
 .../broker/artemiswrapper/ArtemisBrokerWrapper.java   |  2 --
 .../java/org/apache/activemq/JmsQueueBrowserTest.java |  1 +
 .../JmsTopicSendReceiveWithTwoConnectionsTest.java    |  3 +++
 .../JmsTopicSendReceiveWithTwoConnectionsTest.java    |  2 ++
 5 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0a267a38/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/artemiswrapper/ArtemisBrokerHelper.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/artemiswrapper/ArtemisBrokerHelper.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/artemiswrapper/ArtemisBrokerHelper.java
index 4161859..fce53ee 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/artemiswrapper/ArtemisBrokerHelper.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/artemiswrapper/ArtemisBrokerHelper.java
@@ -23,8 +23,11 @@ import java.net.URI;
 
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.command.ActiveMQDestination;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class ArtemisBrokerHelper {
+   private static final Logger LOG = LoggerFactory.getLogger(ArtemisBrokerHelper.class);
 
    private static volatile Object service = null;
    private static Class<?> serviceClass;
@@ -42,7 +45,7 @@ public class ArtemisBrokerHelper {
    // start a tcp transport artemis broker, the broker need to
    // be invm with client.
    public static void startArtemisBroker(URI location) throws IOException {
-      System.out.println("---starting broker, service is there? " + service);
+      LOG.info("---starting broker, service is there? " + service);
       if (service != null) {
          return;
       }
@@ -50,7 +53,7 @@ public class ArtemisBrokerHelper {
          service = serviceClass.newInstance();
          Method startMethod = serviceClass.getMethod("start");
          startMethod.invoke(service, (Object[]) null);
-         System.out.println("started a service instance: " + service);
+         LOG.info("started a service instance: " + service);
       }
       catch (InstantiationException e) {
          throw new IOException("Inst exception", e);
@@ -77,13 +80,6 @@ public class ArtemisBrokerHelper {
       startMethod.invoke(service, activemqDestination);
    }
 
-   //some tests run broker in setUp(). This need be called
-   //to prevent auto broker creation.
-   public static void setBroker(Object startedBroker) {
-      service = startedBroker;
-      System.out.println("somebody set a broker service: " + service);
-   }
-
    public static BrokerService getBroker() {
       return (BrokerService) service;
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0a267a38/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
index 1a0e297..112d425 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/ArtemisBrokerWrapper.java
@@ -39,7 +39,6 @@ import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.core.settings.impl.SlowConsumerPolicy;
 import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
 import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
-import org.apache.activemq.artemiswrapper.ArtemisBrokerHelper;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.broker.region.policy.PolicyEntry;
 import org.apache.activemq.broker.region.policy.PolicyMap;
@@ -161,7 +160,6 @@ public class ArtemisBrokerWrapper extends ArtemisBrokerBase {
 
       server.start();
 
-      ArtemisBrokerHelper.setBroker(this.bservice);
       stopped = false;
 
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0a267a38/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java
index 12e7827..6a3cd19 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsQueueBrowserTest.java
@@ -263,6 +263,7 @@ public class JmsQueueBrowserTest extends JmsTestSupport {
       consumer.close();
    }
 
+   //ref: https://issues.apache.org/jira/browse/ARTEMIS-384
    public void testBrowseReceive() throws Exception {
       Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
       ActiveMQQueue destination = new ActiveMQQueue("TEST");

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0a267a38/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendReceiveWithTwoConnectionsTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendReceiveWithTwoConnectionsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendReceiveWithTwoConnectionsTest.java
index b5dcacc..216ed10 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendReceiveWithTwoConnectionsTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/JmsTopicSendReceiveWithTwoConnectionsTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.activemq;
 
+import org.apache.activemq.transport.tcp.TcpTransportFactory;
+
 import javax.jms.Connection;
 import javax.jms.DeliveryMode;
 import javax.jms.Destination;
@@ -109,5 +111,6 @@ public class JmsTopicSendReceiveWithTwoConnectionsTest extends JmsSendReceiveTes
       receiveSession.close();
       sendConnection.close();
       receiveConnection.close();
+      TcpTransportFactory.clearService();
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0a267a38/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsTest.java
index 1f8d8da..c999d9a 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveWithTwoConnectionsTest.java
@@ -23,6 +23,7 @@ import javax.jms.MessageConsumer;
 import javax.jms.Session;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.artemiswrapper.ArtemisBrokerHelper;
 import org.apache.activemq.transport.tcp.TcpTransportFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -105,6 +106,7 @@ public class JmsTopicSendReceiveWithTwoConnectionsTest extends JmsSendReceiveTes
       sendConnection.close();
       receiveConnection.close();
       TcpTransportFactory.clearService();
+      ArtemisBrokerHelper.stopArtemisBroker();
    }
 
    /**


[43/60] [abbrv] activemq-artemis git commit: added jboss logging dependency

Posted by cl...@apache.org.
added jboss logging dependency


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/77345c74
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/77345c74
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/77345c74

Branch: refs/heads/refactor-openwire
Commit: 77345c747d60e1467e5817df5cdb4d5c83ac71b7
Parents: 2bcfd08
Author: Howard Gao <ho...@gmail.com>
Authored: Wed Feb 3 10:37:19 2016 +0800
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:44:21 2016 -0400

----------------------------------------------------------------------
 tests/activemq5-unit-tests/pom.xml | 11 +++++++++++
 1 file changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/77345c74/tests/activemq5-unit-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/pom.xml b/tests/activemq5-unit-tests/pom.xml
index e52b9a6..0f7c9ac 100644
--- a/tests/activemq5-unit-tests/pom.xml
+++ b/tests/activemq5-unit-tests/pom.xml
@@ -336,6 +336,17 @@
             </exclusion>
          </exclusions>
       </dependency>
+       <!--
+           JBoss Logging
+       -->
+       <dependency>
+           <groupId>org.jboss.logging</groupId>
+           <artifactId>jboss-logging</artifactId>
+       </dependency>
+      <dependency>
+            <groupId>org.jboss.logmanager</groupId>
+            <artifactId>jboss-logmanager</artifactId>
+      </dependency>
 
    </dependencies>
 


[59/60] [abbrv] activemq-artemis git commit: using converter interface

Posted by cl...@apache.org.
using converter interface


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/fe6111c9
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/fe6111c9
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/fe6111c9

Branch: refs/heads/refactor-openwire
Commit: fe6111c935ddc5660111a3cfedcbfe33e80b4675
Parents: 6b3d9d9
Author: Clebert Suconic <cl...@apache.org>
Authored: Thu Feb 25 18:57:21 2016 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:45:29 2016 -0400

----------------------------------------------------------------------
 .../protocol/openwire/OpenWireConnection.java   |  7 -------
 .../openwire/OpenWireMessageConverter.java      | 22 +++++++++++++-------
 .../openwire/OpenWireProtocolManager.java       |  9 +++++++-
 .../core/protocol/openwire/amq/AMQSession.java  | 13 ++++++++++--
 4 files changed, 33 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fe6111c9/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
index 6839259..0fd8dc2 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
@@ -146,8 +146,6 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
 
    private volatile AMQSession advisorySession;
 
-   private String defaultSocketURIString;
-
    // TODO-NOW: check on why there are two connections created for every createConnection on the client.
    public OpenWireConnection(Connection connection,
                              Executor executor,
@@ -156,7 +154,6 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
       super(connection, executor);
       this.protocolManager = openWireProtocolManager;
       this.wireFormat = wf;
-      this.defaultSocketURIString = connection.getLocalAddress();
    }
 
    // SecurityAuth implementation
@@ -635,10 +632,6 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
       return this.context;
    }
 
-   public String getDefaultSocketURIString() {
-      return defaultSocketURIString;
-   }
-
    public void updateClient(ConnectionControl control) {
       //      if (!destroyed && context.isFaultTolerant()) {
       if (protocolManager.isUpdateClusterClients()) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fe6111c9/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java
index d040955..6176490 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java
@@ -96,10 +96,11 @@ public class OpenWireMessageConverter implements MessageConverter {
    private static final String AMQ_MSG_DROPPABLE = AMQ_PREFIX + "DROPPABLE";
    private static final String AMQ_MSG_COMPRESSED = AMQ_PREFIX + "COMPRESSED";
 
-   @Override
-   public ServerMessage inbound(Object message) {
-      // TODO: implement this
-      return null;
+
+   private final WireFormat marshaller;
+
+   public OpenWireMessageConverter(WireFormat marshaller) {
+      this.marshaller = marshaller;
    }
 
    @Override
@@ -108,10 +109,13 @@ public class OpenWireMessageConverter implements MessageConverter {
       return null;
    }
 
-   //convert an ActiveMQ Artemis message to coreMessage
-   public static void toCoreMessage(ServerMessageImpl coreMessage,
-                                    Message messageSend,
-                                    WireFormat marshaller) throws IOException {
+
+   @Override
+   public ServerMessage inbound(Object message) throws Exception {
+
+      Message messageSend = (Message)message;
+      ServerMessageImpl coreMessage = new ServerMessageImpl(-1, messageSend.getSize());
+
       String type = messageSend.getType();
       if (type != null) {
          coreMessage.putStringProperty(new SimpleString("JMSType"), new SimpleString(type));
@@ -398,6 +402,8 @@ public class OpenWireMessageConverter implements MessageConverter {
          origDestBytes.compact();
          coreMessage.putBytesProperty(AMQ_MSG_ORIG_DESTINATION, origDestBytes.data);
       }
+
+      return coreMessage;
    }
 
    private static void loadMapIntoProperties(TypedProperties props, Map<String, Object> map) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fe6111c9/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
index 514a2b9..51c4bec 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
@@ -115,6 +115,8 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, Cl
    private boolean updateClusterClients = false;
    private boolean updateClusterClientsOnRemove = false;
 
+   private final OpenWireMessageConverter messageConverter;
+
    public OpenWireProtocolManager(OpenWireProtocolManagerFactory factory, ActiveMQServer server) {
       this.factory = factory;
       this.server = server;
@@ -123,6 +125,7 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, Cl
       wireFactory.setCacheEnabled(false);
       advisoryProducerId.setConnectionId(ID_GENERATOR.generateId());
       scheduledPool = server.getScheduledPool();
+      this.messageConverter = new OpenWireMessageConverter(wireFactory.createWireFormat());
 
       final ClusterManager clusterManager = this.server.getClusterManager();
 
@@ -134,6 +137,10 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, Cl
       }
    }
 
+   public OpenWireFormat getNewWireFormat() {
+      return (OpenWireFormat)wireFactory.createWireFormat();
+   }
+
    @Override
    public void nodeUP(TopologyMember member, boolean last) {
       if (topologyMap.put(member.getNodeId(), member) == null) {
@@ -217,7 +224,7 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, Cl
 
    @Override
    public MessageConverter getConverter() {
-      return new OpenWireMessageConverter();
+      return messageConverter;
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fe6111c9/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
index d16d4c8..4db5967 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
@@ -61,6 +61,7 @@ import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
 import org.apache.activemq.artemis.core.transaction.impl.XidImpl;
 import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
+import org.apache.activemq.openwire.OpenWireFormat;
 import org.apache.activemq.wireformat.WireFormat;
 
 public class AMQSession implements SessionCallback {
@@ -82,6 +83,11 @@ public class AMQSession implements SessionCallback {
 
    private OpenWireProtocolManager manager;
 
+   // The sessionWireformat used by the session
+   // this object is meant to be used per thread / session
+   // so we make a new one per AMQSession
+   private final OpenWireMessageConverter converter;
+
    public AMQSession(ConnectionInfo connInfo,
                      SessionInfo sessInfo,
                      ActiveMQServer server,
@@ -95,6 +101,9 @@ public class AMQSession implements SessionCallback {
       this.connection = connection;
       this.scheduledPool = scheduledPool;
       this.manager = manager;
+      OpenWireFormat marshaller = (OpenWireFormat)connection.getMarshaller();
+
+      this.converter = new OpenWireMessageConverter(marshaller.copy());
    }
 
    public void initialize() {
@@ -254,7 +263,8 @@ public class AMQSession implements SessionCallback {
       }
 
       for (ActiveMQDestination dest : actualDestinations) {
-         ServerMessageImpl coreMsg = new ServerMessageImpl(-1, 1024);
+
+         ServerMessageImpl coreMsg = (ServerMessageImpl)converter.inbound(messageSend);
 
          /* ActiveMQ failover transport will attempt to reconnect after connection failure.  Any sent messages that did
          * not receive acks will be resent.  (ActiveMQ broker handles this by returning a last sequence id received to
@@ -263,7 +273,6 @@ public class AMQSession implements SessionCallback {
          if (producerExchange.getConnectionContext().isFaultTolerant() && !messageSend.getProperties().containsKey(org.apache.activemq.artemis.api.core.Message.HDR_DUPLICATE_DETECTION_ID)) {
             coreMsg.putStringProperty(org.apache.activemq.artemis.api.core.Message.HDR_DUPLICATE_DETECTION_ID.toString(), messageSend.getMessageId().toString());
          }
-         OpenWireMessageConverter.toCoreMessage(coreMsg, messageSend, connection.getMarshaller());
          SimpleString address = OpenWireUtil.toCoreAddress(dest);
          coreMsg.setAddress(address);
 


[16/60] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208

Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4517Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4517Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4517Test.java
deleted file mode 100644
index 8d94998..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4517Test.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.advisory.AdvisorySupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.DeadLetterStrategy;
-import org.apache.activemq.broker.region.policy.IndividualDeadLetterStrategy;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AMQ4517Test {
-
-   private BrokerService brokerService;
-   private String connectionUri;
-
-   @Before
-   public void setup() throws Exception {
-      brokerService = new BrokerService();
-
-      connectionUri = brokerService.addConnector("tcp://localhost:0").getPublishableConnectString();
-
-      // Configure Dead Letter Strategy
-      DeadLetterStrategy strategy = new IndividualDeadLetterStrategy();
-      ((IndividualDeadLetterStrategy) strategy).setUseQueueForQueueMessages(true);
-      ((IndividualDeadLetterStrategy) strategy).setQueuePrefix("DLQ.");
-      strategy.setProcessNonPersistent(false);
-      strategy.setProcessExpired(false);
-
-      // Add policy and individual DLQ strategy
-      PolicyEntry policy = new PolicyEntry();
-      policy.setTimeBeforeDispatchStarts(3000);
-      policy.setDeadLetterStrategy(strategy);
-
-      PolicyMap pMap = new PolicyMap();
-      pMap.setDefaultEntry(policy);
-
-      brokerService.setDestinationPolicy(pMap);
-      brokerService.setPersistent(false);
-      brokerService.start();
-   }
-
-   @After
-   public void stop() throws Exception {
-      brokerService.stop();
-   }
-
-   @Test(timeout = 360000)
-   public void test() throws Exception {
-
-      final ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(connectionUri);
-
-      final AtomicBoolean advised = new AtomicBoolean(false);
-      Connection connection = cf.createConnection();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Destination dlqDestination = session.createTopic(AdvisorySupport.MESSAGE_DLQ_TOPIC_PREFIX + ">");
-      MessageConsumer consumer = session.createConsumer(dlqDestination);
-      consumer.setMessageListener(new MessageListener() {
-
-         @Override
-         public void onMessage(Message message) {
-            advised.set(true);
-         }
-      });
-      connection.start();
-
-      ExecutorService service = Executors.newSingleThreadExecutor();
-
-      service.execute(new Runnable() {
-         @Override
-         public void run() {
-            try {
-               ActiveMQConnection connection = (ActiveMQConnection) cf.createConnection();
-               Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-               Destination destination = session.createTemporaryQueue();
-               MessageProducer producer = session.createProducer(destination);
-               producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-               producer.setTimeToLive(400);
-               producer.send(session.createTextMessage());
-               producer.send(session.createTextMessage());
-               TimeUnit.MILLISECONDS.sleep(500);
-               connection.close();
-            }
-            catch (Exception e) {
-            }
-         }
-      });
-
-      service.shutdown();
-      assertTrue(service.awaitTermination(1, TimeUnit.MINUTES));
-      assertFalse("Should not get any Advisories for DLQ'd Messages", advised.get());
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4518Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4518Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4518Test.java
deleted file mode 100644
index 92021bf..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4518Test.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.advisory.AdvisorySupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.DeadLetterStrategy;
-import org.apache.activemq.broker.region.policy.IndividualDeadLetterStrategy;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AMQ4518Test {
-
-   private BrokerService brokerService;
-   private String connectionUri;
-
-   @Before
-   public void setup() throws Exception {
-      brokerService = new BrokerService();
-
-      connectionUri = brokerService.addConnector("tcp://localhost:0").getPublishableConnectString();
-
-      // Configure Dead Letter Strategy
-      DeadLetterStrategy strategy = new IndividualDeadLetterStrategy();
-      ((IndividualDeadLetterStrategy) strategy).setUseQueueForQueueMessages(true);
-      ((IndividualDeadLetterStrategy) strategy).setQueuePrefix("DLQ.");
-      strategy.setProcessNonPersistent(false);
-      strategy.setProcessExpired(false);
-
-      // Add policy and individual DLQ strategy
-      PolicyEntry policy = new PolicyEntry();
-      policy.setTimeBeforeDispatchStarts(3000);
-      policy.setDeadLetterStrategy(strategy);
-
-      PolicyMap pMap = new PolicyMap();
-      pMap.setDefaultEntry(policy);
-
-      brokerService.setDestinationPolicy(pMap);
-      brokerService.setPersistent(false);
-      brokerService.start();
-   }
-
-   @After
-   public void stop() throws Exception {
-      brokerService.stop();
-   }
-
-   @Test(timeout = 360000)
-   public void test() throws Exception {
-
-      final ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(connectionUri);
-
-      final AtomicBoolean advised = new AtomicBoolean(false);
-      Connection connection = cf.createConnection();
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Destination dlqDestination = session.createTopic(AdvisorySupport.EXPIRED_QUEUE_MESSAGES_TOPIC_PREFIX + ">");
-      MessageConsumer consumer = session.createConsumer(dlqDestination);
-      consumer.setMessageListener(new MessageListener() {
-
-         @Override
-         public void onMessage(Message message) {
-            advised.set(true);
-         }
-      });
-      connection.start();
-
-      ExecutorService service = Executors.newSingleThreadExecutor();
-
-      service.execute(new Runnable() {
-         @Override
-         public void run() {
-            try {
-               ActiveMQConnection connection = (ActiveMQConnection) cf.createConnection();
-               Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-               Destination destination = session.createTemporaryQueue();
-               MessageProducer producer = session.createProducer(destination);
-               producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-               producer.setTimeToLive(400);
-               producer.send(session.createTextMessage());
-               producer.send(session.createTextMessage());
-               TimeUnit.MILLISECONDS.sleep(500);
-               connection.close();
-            }
-            catch (Exception e) {
-            }
-         }
-      });
-
-      service.shutdown();
-      assertTrue(service.awaitTermination(1, TimeUnit.MINUTES));
-      assertFalse("Should not get any Advisories for Expired Messages", advised.get());
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4530Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4530Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4530Test.java
deleted file mode 100644
index d57501e..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4530Test.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * 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;
-
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-
-import java.util.Map;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.TabularDataSupport;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.CompositeDataConstants;
-import org.apache.activemq.broker.jmx.QueueViewMBean;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AMQ4530Test {
-
-   private static BrokerService brokerService;
-   private static String TEST_QUEUE = "testQueue";
-   private static ActiveMQQueue queue = new ActiveMQQueue(TEST_QUEUE);
-   private static String BROKER_ADDRESS = "tcp://localhost:0";
-   private static String KEY = "testproperty";
-   private static String VALUE = "propvalue";
-
-   private ActiveMQConnectionFactory connectionFactory;
-   private String connectionUri;
-
-   @Before
-   public void setUp() throws Exception {
-      brokerService = new BrokerService();
-      brokerService.setPersistent(false);
-      brokerService.setUseJmx(true);
-      connectionUri = brokerService.addConnector(BROKER_ADDRESS).getPublishableConnectString();
-      brokerService.start();
-      brokerService.waitUntilStarted();
-
-      connectionFactory = new ActiveMQConnectionFactory(connectionUri);
-      sendMessage();
-   }
-
-   public void sendMessage() throws Exception {
-      final Connection conn = connectionFactory.createConnection();
-      try {
-         conn.start();
-         final Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         final Destination queue = session.createQueue(TEST_QUEUE);
-         final Message toSend = session.createMessage();
-         toSend.setStringProperty(KEY, VALUE);
-         final MessageProducer producer = session.createProducer(queue);
-         producer.send(queue, toSend);
-      }
-      finally {
-         conn.close();
-      }
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      brokerService.stop();
-      brokerService.waitUntilStopped();
-   }
-
-   @SuppressWarnings("unchecked")
-   @Test
-   public void testStringPropertiesFromCompositeData() throws Exception {
-      final QueueViewMBean queueView = getProxyToQueueViewMBean();
-      final CompositeData message = queueView.browse()[0];
-      assertNotNull(message);
-      TabularDataSupport stringProperties = (TabularDataSupport) message.get(CompositeDataConstants.STRING_PROPERTIES);
-      assertNotNull(stringProperties);
-      assertThat(stringProperties.size(), is(greaterThan(0)));
-      Map.Entry<Object, Object> compositeDataEntry = (Map.Entry<Object, Object>) stringProperties.entrySet().toArray()[0];
-      CompositeData stringEntry = (CompositeData) compositeDataEntry.getValue();
-      assertThat(String.valueOf(stringEntry.get("key")), equalTo(KEY));
-      assertThat(String.valueOf(stringEntry.get("value")), equalTo(VALUE));
-   }
-
-   private QueueViewMBean getProxyToQueueViewMBean() throws MalformedObjectNameException, NullPointerException, JMSException {
-      final ObjectName queueViewMBeanName = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=" + queue.getQueueName());
-      final QueueViewMBean proxy = (QueueViewMBean) brokerService.getManagementContext().newProxyInstance(queueViewMBeanName, QueueViewMBean.class, true);
-      return proxy;
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4531Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4531Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4531Test.java
deleted file mode 100644
index d303561..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4531Test.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/**
- * 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;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.lang.management.ManagementFactory;
-import java.util.concurrent.CountDownLatch;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.util.Wait;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Unit test for simple App.
- */
-public class AMQ4531Test extends TestCase {
-
-   private final Logger LOG = LoggerFactory.getLogger(AMQ4531Test.class);
-
-   private String connectionURI;
-   private MBeanServer mbeanServer;
-   private BrokerService broker;
-
-   @Override
-   protected void setUp() throws Exception {
-      super.setUp();
-      broker = new BrokerService();
-      connectionURI = broker.addConnector("tcp://0.0.0.0:0?maximumConnections=1").getPublishableConnectString();
-      broker.setPersistent(false);
-      broker.start();
-      mbeanServer = ManagementFactory.getPlatformMBeanServer();
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      broker.stop();
-      super.tearDown();
-   }
-
-   /**
-    * Create the test case
-    *
-    * @param testName name of the test case
-    */
-   public AMQ4531Test(String testName) {
-      super(testName);
-   }
-
-   /**
-    * @return the suite of tests being tested
-    */
-   public static Test suite() {
-      return new TestSuite(AMQ4531Test.class);
-   }
-
-   public void testFDSLeak() throws Exception {
-
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionURI);
-      ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
-      connection.start();
-
-      int connections = 100;
-      final long original = openFileDescriptorCount();
-      LOG.info("FD count: " + original);
-      final CountDownLatch done = new CountDownLatch(connections);
-      for (int i = 0; i < connections; i++) {
-         new Thread("worker: " + i) {
-            @Override
-            public void run() {
-               ActiveMQConnection connection = null;
-               try {
-                  ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionURI);
-                  connection = (ActiveMQConnection) factory.createConnection();
-                  connection.start();
-               }
-               catch (Exception e) {
-                  LOG.debug(getStack(e));
-               }
-               finally {
-                  try {
-                     connection.close();
-                  }
-                  catch (Exception e) {
-                     LOG.debug(getStack(e));
-                  }
-                  done.countDown();
-                  LOG.debug("Latch count down called.");
-               }
-            }
-         }.start();
-      }
-
-      // Wait for all the clients to finish
-      LOG.info("Waiting for latch...");
-      done.await();
-      LOG.info("Latch complete.");
-      LOG.info("FD count: " + openFileDescriptorCount());
-
-      assertTrue("Too many open file descriptors: " + openFileDescriptorCount(), Wait.waitFor(new Wait.Condition() {
-
-         @Override
-         public boolean isSatisified() throws Exception {
-            long openFDs = openFileDescriptorCount();
-            LOG.info("Current FD count [{}], original FD count[{}]", openFDs, original);
-            return (openFDs - original) < 10;
-         }
-      }));
-   }
-
-   private long openFileDescriptorCount() throws Exception {
-      return ((Long) mbeanServer.getAttribute(new ObjectName("java.lang:type=OperatingSystem"), "OpenFileDescriptorCount")).longValue();
-   }
-
-   private String getStack(Throwable aThrowable) {
-      final Writer result = new StringWriter();
-      final PrintWriter printWriter = new PrintWriter(result);
-      aThrowable.printStackTrace(printWriter);
-      return result.toString();
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4554Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4554Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4554Test.java
deleted file mode 100644
index 1113ee4..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4554Test.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * 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;
-
-import javax.jms.Connection;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Unit test for simple App.
- */
-public class AMQ4554Test extends TestCase {
-
-   private final Logger LOG = LoggerFactory.getLogger(AMQ4554Test.class);
-
-   private String connectionURI;
-   private BrokerService broker;
-
-   @Override
-   protected void setUp() throws Exception {
-      super.setUp();
-      broker = new BrokerService();
-      connectionURI = broker.addConnector("tcp://0.0.0.0:0?maximumConnections=1").getPublishableConnectString();
-      broker.setPersistent(false);
-      broker.start();
-   }
-
-   @Override
-   protected void tearDown() throws Exception {
-      broker.stop();
-      super.tearDown();
-   }
-
-   /**
-    * Create the test case
-    *
-    * @param testName name of the test case
-    */
-   public AMQ4554Test(String testName) {
-      super(testName);
-   }
-
-   /**
-    * @return the suite of tests being tested
-    */
-   public static Test suite() {
-      return new TestSuite(AMQ4554Test.class);
-   }
-
-   public void testMSXProducerTXID() throws Exception {
-
-      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionURI);
-      Connection connection = factory.createConnection();
-      connection.start();
-
-      Session producerSession = connection.createSession(true, Session.SESSION_TRANSACTED);
-      MessageProducer producer = producerSession.createProducer(producerSession.createQueue("myQueue"));
-      TextMessage producerMessage = producerSession.createTextMessage("Test Message");
-      producer.send(producerMessage);
-      producer.close();
-      producerSession.commit();
-      producerSession.close();
-
-      Session consumerSession = connection.createSession(true, Session.SESSION_TRANSACTED);
-      MessageConsumer consumer = consumerSession.createConsumer(consumerSession.createQueue("myQueue"));
-      Message consumerMessage = consumer.receive(1000);
-      try {
-         String txId = consumerMessage.getStringProperty("JMSXProducerTXID");
-         assertNotNull(txId);
-      }
-      catch (Exception e) {
-         LOG.info("Caught Exception that was not expected:", e);
-         fail("Should not throw");
-      }
-      consumer.close();
-      consumerSession.commit();
-      consumerSession.close();
-      connection.close();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4582Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4582Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4582Test.java
deleted file mode 100644
index 9612a34..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4582Test.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * 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;
-
-import java.io.IOException;
-
-import javax.jms.Connection;
-import javax.jms.Session;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.util.ConsumerThread;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ4582Test {
-
-   private static final transient Logger LOG = LoggerFactory.getLogger(AMQ4582Test.class);
-
-   BrokerService broker;
-   Connection connection;
-   Session session;
-
-   public static final String KEYSTORE_TYPE = "jks";
-   public static final String PASSWORD = "password";
-   public static final String SERVER_KEYSTORE = "src/test/resources/server.keystore";
-   public static final String TRUST_KEYSTORE = "src/test/resources/client.keystore";
-
-   public static final int PRODUCER_COUNT = 10;
-   public static final int CONSUMER_COUNT = 10;
-   public static final int MESSAGE_COUNT = 1000;
-
-   final ConsumerThread[] consumers = new ConsumerThread[CONSUMER_COUNT];
-
-   @Before
-   public void setUp() throws Exception {
-      System.setProperty("javax.net.ssl.trustStore", TRUST_KEYSTORE);
-      System.setProperty("javax.net.ssl.trustStorePassword", PASSWORD);
-      System.setProperty("javax.net.ssl.trustStoreType", KEYSTORE_TYPE);
-      System.setProperty("javax.net.ssl.keyStore", SERVER_KEYSTORE);
-      System.setProperty("javax.net.ssl.keyStoreType", KEYSTORE_TYPE);
-      System.setProperty("javax.net.ssl.keyStorePassword", PASSWORD);
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      if (broker != null) {
-         try {
-            broker.stop();
-         }
-         catch (Exception e) {
-         }
-      }
-   }
-
-   @Rule
-   public ExpectedException thrown = ExpectedException.none();
-
-   @Test
-   public void simpleTest() throws Exception {
-      thrown.expect(IOException.class);
-      thrown.expectMessage("enabledCipherSuites=BADSUITE");
-
-      broker = new BrokerService();
-      broker.setPersistent(false);
-      broker.setUseJmx(false);
-      try {
-         broker.addConnector("ssl://localhost:0?transport.needClientAuth=true&transport.enabledCipherSuites=BADSUITE");
-         broker.start();
-         broker.waitUntilStarted();
-      }
-      catch (Exception e) {
-         LOG.info("BrokerService threw:", e);
-         throw e;
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4595Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4595Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4595Test.java
deleted file mode 100644
index 3c16bab..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4595Test.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
- * 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;
-
-import java.net.URI;
-import java.util.Date;
-import java.util.Enumeration;
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.MessageProducer;
-import javax.jms.QueueBrowser;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.ActiveMQConnection;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.TransportConnector;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.assertEquals;
-
-public class AMQ4595Test {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ4595Test.class);
-
-   private BrokerService broker;
-   private URI connectUri;
-   private ActiveMQConnectionFactory factory;
-
-   @Before
-   public void startBroker() throws Exception {
-      broker = new BrokerService();
-      TransportConnector connector = broker.addConnector("vm://localhost");
-      broker.deleteAllMessages();
-
-      //PolicyMap pMap = new PolicyMap();
-      //PolicyEntry policyEntry = new PolicyEntry();
-      //policyEntry.setMaxBrowsePageSize(10000);
-      //pMap.put(new ActiveMQQueue(">"), policyEntry);
-      // when no policy match, browserSub has maxMessages==0
-      //broker.setDestinationPolicy(pMap);
-
-      broker.getSystemUsage().getMemoryUsage().setLimit(256 * 1024 * 1024);
-      broker.start();
-      broker.waitUntilStarted();
-      connectUri = connector.getConnectUri();
-      factory = new ActiveMQConnectionFactory(connectUri);
-   }
-
-   @After
-   public void stopBroker() throws Exception {
-      broker.stop();
-      broker.waitUntilStopped();
-   }
-
-   @Test(timeout = 120000)
-   public void testBrowsingSmallBatch() throws JMSException {
-      doTestBrowsing(100);
-   }
-
-   @Test(timeout = 160000)
-   public void testBrowsingMediumBatch() throws JMSException {
-      doTestBrowsing(1000);
-   }
-
-   @Test(timeout = 300000)
-   public void testBrowsingLargeBatch() throws JMSException {
-      doTestBrowsing(10000);
-   }
-
-   private void doTestBrowsing(int messageToSend) throws JMSException {
-      ActiveMQQueue queue = new ActiveMQQueue("TEST");
-
-      // Send the messages to the Queue.
-      ActiveMQConnection producerConnection = (ActiveMQConnection) factory.createConnection();
-      producerConnection.setUseAsyncSend(true);
-      producerConnection.start();
-      Session producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer producer = producerSession.createProducer(queue);
-      producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-
-      for (int i = 1; i <= messageToSend; i++) {
-         String msgStr = provideMessageText(i, 8192);
-         producer.send(producerSession.createTextMessage(msgStr));
-         if ((i % 1000) == 0) {
-            LOG.info("P&C: {}", msgStr.substring(0, 100));
-         }
-      }
-      producerConnection.close();
-
-      LOG.info("Mem usage after producer done: " + broker.getSystemUsage().getMemoryUsage().getPercentUsage() + "%");
-
-      // Browse the queue.
-      Connection connection = factory.createConnection();
-      connection.start();
-      Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
-
-      QueueBrowser browser = session.createBrowser(queue);
-      Enumeration<?> enumeration = browser.getEnumeration();
-      int browsed = 0;
-      while (enumeration.hasMoreElements()) {
-         TextMessage m = (TextMessage) enumeration.nextElement();
-         browsed++;
-         if ((browsed % 1000) == 0) {
-            LOG.info("B[{}]: {}", browsed, m.getText().substring(0, 100));
-         }
-      }
-      browser.close();
-      session.close();
-      connection.close();
-
-      LOG.info("Mem usage after browser closed: " + broker.getSystemUsage().getMemoryUsage().getPercentUsage() + "%");
-
-      // The number of messages browsed should be equal to the number of messages sent.
-      assertEquals(messageToSend, browsed);
-
-      browser.close();
-   }
-
-   public String provideMessageText(int messageNumber, int messageSize) {
-      StringBuilder buf = new StringBuilder();
-      buf.append("Message: ");
-      if (messageNumber > 0) {
-         buf.append(messageNumber);
-      }
-      buf.append(" sent at: ").append(new Date());
-
-      if (buf.length() > messageSize) {
-         return buf.substring(0, messageSize);
-      }
-      for (int i = buf.length(); i < messageSize; i++) {
-         buf.append(' ');
-      }
-      return buf.toString();
-   }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4607Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4607Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4607Test.java
deleted file mode 100644
index 527309b..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4607Test.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/**
- * 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;
-
-import java.lang.Thread.UncaughtExceptionHandler;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import javax.jms.Destination;
-import javax.jms.MessageConsumer;
-
-import junit.framework.Test;
-
-import org.apache.activemq.JmsMultipleBrokersTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.ManagementContext;
-import org.apache.activemq.broker.jmx.QueueViewMBean;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.network.ConditionalNetworkBridgeFilterFactory;
-import org.apache.activemq.network.NetworkConnector;
-import org.apache.activemq.util.Wait;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ4607Test extends JmsMultipleBrokersTestSupport implements UncaughtExceptionHandler {
-
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ4607Test.class);
-
-   public static final int BROKER_COUNT = 3;
-   public static final int CONSUMER_COUNT = 1;
-   public static final int MESSAGE_COUNT = 0;
-   public static final boolean CONDUIT = true;
-   public static final int TIMEOUT = 20000;
-
-   public boolean duplex = true;
-   protected Map<String, MessageConsumer> consumerMap;
-   final Map<Thread, Throwable> unhandeledExceptions = new HashMap<>();
-
-   private void assertNoUnhandeledExceptions() {
-      for (Entry<Thread, Throwable> e : unhandeledExceptions.entrySet()) {
-         LOG.error("Thread:" + e.getKey() + " Had unexpected: " + e.getValue());
-      }
-      assertTrue("There are no unhandelled exceptions, see: log for detail on: " + unhandeledExceptions, unhandeledExceptions.isEmpty());
-   }
-
-   public NetworkConnector bridge(String from, String to) throws Exception {
-      NetworkConnector networkConnector = bridgeBrokers(from, to, true, -1, CONDUIT);
-      networkConnector.setSuppressDuplicateQueueSubscriptions(true);
-      networkConnector.setDecreaseNetworkConsumerPriority(true);
-      networkConnector.setConsumerTTL(1);
-      networkConnector.setDuplex(duplex);
-      return networkConnector;
-   }
-
-   public static Test suite() {
-      return suite(AMQ4607Test.class);
-   }
-
-   public void initCombos() {
-      addCombinationValues("duplex", new Boolean[]{Boolean.TRUE, Boolean.FALSE});
-   }
-
-   public void testMigratingConsumer() throws Exception {
-      bridge("Broker0", "Broker1");
-      if (!duplex)
-         bridge("Broker1", "Broker0");
-
-      bridge("Broker1", "Broker2");
-      if (!duplex)
-         bridge("Broker2", "Broker1");
-
-      bridge("Broker0", "Broker2");
-      if (!duplex)
-         bridge("Broker2", "Broker0");
-
-      startAllBrokers();
-      this.waitForBridgeFormation();
-
-      Destination dest = createDestination("TEST.FOO", false);
-      sendMessages("Broker0", dest, 1);
-
-      for (int i = 0; i < BROKER_COUNT; i++) {
-         MessageConsumer messageConsumer = createConsumer("Broker" + i, dest, "DoNotConsume = 'true'");
-
-         for (int J = 0; J < BROKER_COUNT; J++) {
-            assertExactConsumersConnect("Broker" + J, dest, CONSUMER_COUNT, TIMEOUT);
-         }
-
-         assertNoUnhandeledExceptions();
-
-         assertExactMessageCount("Broker" + i, dest, 1, TIMEOUT);
-
-         messageConsumer.close();
-         LOG.info("Check for no consumers..");
-         for (int J = 0; J < BROKER_COUNT; J++) {
-            assertExactConsumersConnect("Broker" + J, dest, 0, TIMEOUT);
-         }
-      }
-
-      // now consume the message
-      final String brokerId = "Broker2";
-      MessageConsumer messageConsumer = createConsumer(brokerId, dest);
-      assertTrue("Consumed ok", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return brokers.get(brokerId).allMessages.getMessageIds().size() == 1;
-         }
-      }));
-      messageConsumer.close();
-
-   }
-
-   public void testMigratingConsumerFullCircle() throws Exception {
-      bridge("Broker0", "Broker1");
-      if (!duplex)
-         bridge("Broker1", "Broker0");
-
-      bridge("Broker1", "Broker2");
-      if (!duplex)
-         bridge("Broker2", "Broker1");
-
-      bridge("Broker0", "Broker2");
-      if (!duplex)
-         bridge("Broker2", "Broker0");
-
-      // allow full loop, immediate replay back to 0 from 2
-      ConditionalNetworkBridgeFilterFactory conditionalNetworkBridgeFilterFactory = new ConditionalNetworkBridgeFilterFactory();
-      conditionalNetworkBridgeFilterFactory.setReplayDelay(0);
-      conditionalNetworkBridgeFilterFactory.setReplayWhenNoConsumers(true);
-      brokers.get("Broker2").broker.getDestinationPolicy().getDefaultEntry().setNetworkBridgeFilterFactory(conditionalNetworkBridgeFilterFactory);
-      startAllBrokers();
-      this.waitForBridgeFormation();
-
-      Destination dest = createDestination("TEST.FOO", false);
-
-      sendMessages("Broker0", dest, 1);
-
-      for (int i = 0; i < BROKER_COUNT; i++) {
-         MessageConsumer messageConsumer = createConsumer("Broker" + i, dest, "DoNotConsume = 'true'");
-
-         for (int J = 0; J < BROKER_COUNT; J++) {
-            assertExactConsumersConnect("Broker" + J, dest, CONSUMER_COUNT, TIMEOUT);
-         }
-
-         assertNoUnhandeledExceptions();
-
-         // validate the message has been forwarded
-         assertExactMessageCount("Broker" + i, dest, 1, TIMEOUT);
-
-         messageConsumer.close();
-         LOG.info("Check for no consumers..");
-         for (int J = 0; J < BROKER_COUNT; J++) {
-            assertExactConsumersConnect("Broker" + J, dest, 0, TIMEOUT);
-         }
-      }
-
-      // now consume the message from the origin
-      LOG.info("Consume from origin...");
-      final String brokerId = "Broker0";
-      MessageConsumer messageConsumer = createConsumer(brokerId, dest);
-      assertTrue("Consumed ok", Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            return brokers.get(brokerId).allMessages.getMessageIds().size() == 1;
-         }
-      }));
-      messageConsumer.close();
-
-   }
-
-   protected void assertExactMessageCount(final String brokerName,
-                                          Destination destination,
-                                          final int count,
-                                          long timeout) throws Exception {
-      ManagementContext context = brokers.get(brokerName).broker.getManagementContext();
-      final QueueViewMBean queueViewMBean = (QueueViewMBean) context.newProxyInstance(brokers.get(brokerName).broker.getAdminView().getQueues()[0], QueueViewMBean.class, false);
-      assertTrue("Excepected queue depth: " + count + " on: " + brokerName, Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            long currentCount = queueViewMBean.getQueueSize();
-            LOG.info("On " + brokerName + " current queue size for " + queueViewMBean + ", " + currentCount);
-            if (count != currentCount) {
-               LOG.info("Sub IDs: " + Arrays.asList(queueViewMBean.getSubscriptions()));
-            }
-            return currentCount == count;
-         }
-      }, timeout));
-   }
-
-   protected void assertExactConsumersConnect(final String brokerName,
-                                              Destination destination,
-                                              final int count,
-                                              long timeout) throws Exception {
-      final ManagementContext context = brokers.get(brokerName).broker.getManagementContext();
-      assertTrue("Excepected consumers count: " + count + " on: " + brokerName, Wait.waitFor(new Wait.Condition() {
-         @Override
-         public boolean isSatisified() throws Exception {
-            try {
-               QueueViewMBean queueViewMBean = (QueueViewMBean) context.newProxyInstance(brokers.get(brokerName).broker.getAdminView().getQueues()[0], QueueViewMBean.class, false);
-               long currentCount = queueViewMBean.getConsumerCount();
-               LOG.info("On " + brokerName + " current consumer count for " + queueViewMBean + ", " + currentCount);
-               if (count != currentCount) {
-                  LOG.info("Sub IDs: " + Arrays.asList(queueViewMBean.getSubscriptions()));
-               }
-               return currentCount == count;
-            }
-            catch (Exception e) {
-               LOG.warn("Unexpected: " + e, e);
-               return false;
-            }
-         }
-      }, timeout));
-   }
-
-   @Override
-   public void setUp() throws Exception {
-      super.setUp();
-
-      unhandeledExceptions.clear();
-      Thread.setDefaultUncaughtExceptionHandler(this);
-
-      // Setup n brokers
-      for (int i = 0; i < BROKER_COUNT; i++) {
-         createBroker(new URI("broker:(tcp://localhost:6161" + i + ")/Broker" + i + "?persistent=false&useJmx=true"));
-      }
-
-      consumerMap = new LinkedHashMap<>();
-   }
-
-   @Override
-   protected void configureBroker(BrokerService brokerService) {
-      PolicyEntry policyEntry = new PolicyEntry();
-      policyEntry.setExpireMessagesPeriod(0);
-      PolicyMap policyMap = new PolicyMap();
-      policyMap.setDefaultEntry(policyEntry);
-      brokerService.setDestinationPolicy(policyMap);
-   }
-
-   @Override
-   public void uncaughtException(Thread t, Throwable e) {
-      synchronized (unhandeledExceptions) {
-         unhandeledExceptions.put(t, e);
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4636Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4636Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4636Test.java
deleted file mode 100644
index 9cb9c66..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4636Test.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/**
- * 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;
-
-import java.io.IOException;
-import java.sql.SQLException;
-import java.util.concurrent.CountDownLatch;
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.jms.TopicSubscriber;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.store.jdbc.DataSourceServiceSupport;
-import org.apache.activemq.store.jdbc.JDBCPersistenceAdapter;
-import org.apache.activemq.store.jdbc.LeaseDatabaseLocker;
-import org.apache.activemq.store.jdbc.TransactionContext;
-import org.apache.activemq.util.IOHelper;
-import org.apache.activemq.util.LeaseLockerIOExceptionHandler;
-import org.apache.derby.jdbc.EmbeddedDataSource;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.Assert.fail;
-
-/**
- * Testing how the broker reacts when a SQL Exception is thrown from
- * org.apache.activemq.store.jdbc.TransactionContext.executeBatch().
- * <br>
- * see https://issues.apache.org/jira/browse/AMQ-4636
- */
-public class AMQ4636Test {
-
-   private static final String MY_TEST_TOPIC = "MY_TEST_TOPIC";
-   private static final Logger LOG = LoggerFactory.getLogger(AMQ4636Test.class);
-   private String transportUrl = "tcp://0.0.0.0:0";
-   private BrokerService broker;
-   EmbeddedDataSource embeddedDataSource;
-   CountDownLatch throwSQLException = new CountDownLatch(0);
-
-   @Before
-   public void startBroker() throws Exception {
-      broker = createBroker();
-      broker.deleteAllMessages();
-      broker.start();
-      broker.waitUntilStarted();
-      LOG.info("Broker started...");
-   }
-
-   @After
-   public void stopBroker() throws Exception {
-      if (broker != null) {
-         LOG.info("Stopping broker...");
-         broker.stop();
-         broker.waitUntilStopped();
-      }
-      try {
-         if (embeddedDataSource != null) {
-            // ref http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCDataSource.java?view=markup
-            embeddedDataSource.setShutdownDatabase("shutdown");
-            embeddedDataSource.getConnection();
-         }
-      }
-      catch (Exception ignored) {
-      }
-      finally {
-         embeddedDataSource.setShutdownDatabase(null);
-      }
-   }
-
-   protected BrokerService createBroker() throws Exception {
-
-      embeddedDataSource = (EmbeddedDataSource) DataSourceServiceSupport.createDataSource(IOHelper.getDefaultDataDirectory());
-      embeddedDataSource.setCreateDatabase("create");
-      embeddedDataSource.getConnection().close();
-
-      //wire in a TestTransactionContext (wrapper to TransactionContext) that has an executeBatch()
-      // method that can be configured to throw a SQL exception on demand
-      JDBCPersistenceAdapter jdbc = new TestJDBCPersistenceAdapter();
-      jdbc.setDataSource(embeddedDataSource);
-
-      jdbc.setLockKeepAlivePeriod(1000L);
-      LeaseDatabaseLocker leaseDatabaseLocker = new LeaseDatabaseLocker();
-      leaseDatabaseLocker.setLockAcquireSleepInterval(2000L);
-      jdbc.setLocker(leaseDatabaseLocker);
-
-      broker = new BrokerService();
-      PolicyMap policyMap = new PolicyMap();
-      PolicyEntry defaultEntry = new PolicyEntry();
-      defaultEntry.setExpireMessagesPeriod(0);
-      policyMap.setDefaultEntry(defaultEntry);
-      broker.setDestinationPolicy(policyMap);
-      broker.setPersistenceAdapter(jdbc);
-
-      broker.setIoExceptionHandler(new LeaseLockerIOExceptionHandler());
-
-      transportUrl = broker.addConnector(transportUrl).getPublishableConnectString();
-      return broker;
-   }
-
-   /**
-    * adding a TestTransactionContext (wrapper to TransactionContext) so an SQLException is triggered
-    * during TransactionContext.executeBatch() when called in the broker.
-    * <br>
-    * Expectation: SQLException triggers a connection shutdown and failover should kick and try to redeliver the
-    * message. SQLException should NOT be returned to client
-    */
-   @Test
-   public void testProducerWithDBShutdown() throws Exception {
-
-      // failover but timeout in 1 seconds so the test does not hang
-      String failoverTransportURL = "failover:(" + transportUrl + ")?timeout=1000";
-
-      this.createDurableConsumer(MY_TEST_TOPIC, failoverTransportURL);
-
-      this.sendMessage(MY_TEST_TOPIC, failoverTransportURL, false, false);
-
-   }
-
-   @Test
-   public void testTransactedProducerCommitWithDBShutdown() throws Exception {
-
-      // failover but timeout in 1 seconds so the test does not hang
-      String failoverTransportURL = "failover:(" + transportUrl + ")?timeout=1000";
-
-      this.createDurableConsumer(MY_TEST_TOPIC, failoverTransportURL);
-
-      try {
-         this.sendMessage(MY_TEST_TOPIC, failoverTransportURL, true, true);
-         fail("Expect rollback after failover - inddoubt commit");
-      }
-      catch (javax.jms.TransactionRolledBackException expectedInDoubt) {
-         LOG.info("Got rollback after failover failed commit", expectedInDoubt);
-      }
-   }
-
-   @Test
-   public void testTransactedProducerRollbackWithDBShutdown() throws Exception {
-
-      // failover but timeout in 1 seconds so the test does not hang
-      String failoverTransportURL = "failover:(" + transportUrl + ")?timeout=1000";
-
-      this.createDurableConsumer(MY_TEST_TOPIC, failoverTransportURL);
-
-      this.sendMessage(MY_TEST_TOPIC, failoverTransportURL, true, false);
-   }
-
-   public void createDurableConsumer(String topic, String transportURL) throws JMSException {
-      Connection connection = null;
-      LOG.info("*** createDurableConsumer() called ...");
-
-      try {
-
-         ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(transportURL);
-
-         connection = factory.createConnection();
-         connection.setClientID("myconn1");
-         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         Destination destination = session.createTopic(topic);
-
-         TopicSubscriber topicSubscriber = session.createDurableSubscriber((Topic) destination, "MySub1");
-      }
-      finally {
-         if (connection != null) {
-            connection.close();
-         }
-      }
-   }
-
-   public void sendMessage(String topic, String transportURL, boolean transacted, boolean commit) throws JMSException {
-      Connection connection = null;
-
-      try {
-
-         ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(transportURL);
-
-         connection = factory.createConnection();
-         Session session = connection.createSession(transacted, transacted ? Session.SESSION_TRANSACTED : Session.AUTO_ACKNOWLEDGE);
-         Destination destination = session.createTopic(topic);
-         MessageProducer producer = session.createProducer(destination);
-         producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-
-         Message m = session.createTextMessage("testMessage");
-         LOG.info("*** send message to broker...");
-
-         // trigger SQL exception in transactionContext
-         throwSQLException = new CountDownLatch(1);
-         producer.send(m);
-
-         if (transacted) {
-            if (commit) {
-               session.commit();
-            }
-            else {
-               session.rollback();
-            }
-         }
-
-         LOG.info("*** Finished send message to broker");
-
-      }
-      finally {
-         if (connection != null) {
-            connection.close();
-         }
-      }
-   }
-
-	/*
-     * Mock classes used for testing
-	 */
-
-   public class TestJDBCPersistenceAdapter extends JDBCPersistenceAdapter {
-
-      @Override
-      public TransactionContext getTransactionContext() throws IOException {
-         return new TestTransactionContext(this);
-      }
-   }
-
-   public class TestTransactionContext extends TransactionContext {
-
-      public TestTransactionContext(JDBCPersistenceAdapter jdbcPersistenceAdapter) throws IOException {
-         super(jdbcPersistenceAdapter);
-      }
-
-      @Override
-      public void executeBatch() throws SQLException {
-         if (throwSQLException.getCount() > 0) {
-            // only throw exception once
-            throwSQLException.countDown();
-            throw new SQLException("TEST SQL EXCEPTION");
-         }
-         super.executeBatch();
-      }
-   }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4656Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4656Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4656Test.java
deleted file mode 100644
index 0fb900a..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4656Test.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/**
- * 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;
-
-import java.util.Arrays;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.management.ObjectName;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.BrokerView;
-import org.apache.activemq.broker.jmx.DurableSubscriptionViewMBean;
-import org.apache.activemq.broker.region.policy.FilePendingDurableSubscriberMessageStoragePolicy;
-import org.apache.activemq.broker.region.policy.PendingDurableSubscriberMessageStoragePolicy;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.broker.region.policy.StorePendingDurableSubscriberMessageStoragePolicy;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@RunWith(value = Parameterized.class)
-public class AMQ4656Test {
-
-   private static final transient Logger LOG = LoggerFactory.getLogger(AMQ4656Test.class);
-   private static BrokerService brokerService;
-   private static String BROKER_ADDRESS = "tcp://localhost:0";
-
-   private String connectionUri;
-
-   @Parameterized.Parameter
-   public PendingDurableSubscriberMessageStoragePolicy pendingDurableSubPolicy;
-
-   @Parameterized.Parameters(name = "{0}")
-   public static Iterable<Object[]> getTestParameters() {
-      return Arrays.asList(new Object[][]{{new FilePendingDurableSubscriberMessageStoragePolicy()}, {new StorePendingDurableSubscriberMessageStoragePolicy()}});
-   }
-
-   @Before
-   public void setUp() throws Exception {
-      brokerService = new BrokerService();
-      PolicyMap policyMap = new PolicyMap();
-      PolicyEntry defaultEntry = new PolicyEntry();
-      defaultEntry.setPendingDurableSubscriberPolicy(pendingDurableSubPolicy);
-      policyMap.setDefaultEntry(defaultEntry);
-      brokerService.setDestinationPolicy(policyMap);
-      brokerService.setPersistent(false);
-      brokerService.setUseJmx(true);
-      brokerService.setDeleteAllMessagesOnStartup(true);
-      connectionUri = brokerService.addConnector(BROKER_ADDRESS).getPublishableConnectString();
-      brokerService.start();
-      brokerService.waitUntilStarted();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      brokerService.stop();
-      brokerService.waitUntilStopped();
-   }
-
-   @Test
-   public void testDurableConsumerEnqueueCountWithZeroPrefetch() throws Exception {
-
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(connectionUri);
-
-      Connection connection = connectionFactory.createConnection();
-      connection.setClientID(getClass().getName());
-      connection.start();
-
-      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      Destination destination = session.createTopic("DurableTopic");
-
-      MessageConsumer consumer = session.createDurableSubscriber((Topic) destination, "EnqueueSub");
-
-      BrokerView view = brokerService.getAdminView();
-      view.getDurableTopicSubscribers();
-
-      ObjectName subName = view.getDurableTopicSubscribers()[0];
-
-      DurableSubscriptionViewMBean sub = (DurableSubscriptionViewMBean) brokerService.getManagementContext().newProxyInstance(subName, DurableSubscriptionViewMBean.class, true);
-
-      assertEquals(0, sub.getEnqueueCounter());
-      assertEquals(0, sub.getDequeueCounter());
-      assertEquals(0, sub.getPendingQueueSize());
-      assertEquals(0, sub.getDispatchedCounter());
-      assertEquals(0, sub.getDispatchedQueueSize());
-
-      consumer.close();
-
-      MessageProducer producer = session.createProducer(destination);
-      for (int i = 0; i < 20; i++) {
-         producer.send(session.createMessage());
-      }
-      producer.close();
-
-      consumer = session.createDurableSubscriber((Topic) destination, "EnqueueSub");
-
-      Thread.sleep(1000);
-
-      assertEquals(20, sub.getEnqueueCounter());
-      assertEquals(0, sub.getDequeueCounter());
-      assertEquals(0, sub.getPendingQueueSize());
-      assertEquals(20, sub.getDispatchedCounter());
-      assertEquals(20, sub.getDispatchedQueueSize());
-
-      LOG.info("Pending Queue Size with no receives: {}", sub.getPendingQueueSize());
-
-      assertNotNull(consumer.receive(1000));
-      assertNotNull(consumer.receive(1000));
-
-      consumer.close();
-
-      Thread.sleep(2000);
-
-      LOG.info("Pending Queue Size with two receives: {}", sub.getPendingQueueSize());
-
-      assertEquals(20, sub.getEnqueueCounter());
-      assertEquals(2, sub.getDequeueCounter());
-      assertEquals(18, sub.getPendingQueueSize());
-      assertEquals(20, sub.getDispatchedCounter());
-      assertEquals(0, sub.getDispatchedQueueSize());
-
-      session.close();
-      connection.close();
-   }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4671Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4671Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4671Test.java
deleted file mode 100644
index 165d5fd..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4671Test.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.fail;
-
-import javax.jms.Connection;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ4671Test {
-
-   private static final transient Logger LOG = LoggerFactory.getLogger(AMQ4671Test.class);
-   private static BrokerService brokerService;
-   private static String BROKER_ADDRESS = "tcp://localhost:0";
-
-   private String connectionUri;
-
-   @Before
-   public void setUp() throws Exception {
-      brokerService = new BrokerService();
-      brokerService.setPersistent(false);
-      brokerService.setUseJmx(true);
-      brokerService.setDeleteAllMessagesOnStartup(true);
-      connectionUri = brokerService.addConnector(BROKER_ADDRESS).getPublishableConnectString();
-      connectionUri = connectionUri + "?trace=true";
-      brokerService.start();
-      brokerService.waitUntilStarted();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      brokerService.stop();
-      brokerService.waitUntilStopped();
-   }
-
-   @Test
-   public void testNonDurableSubscriberInvalidUnsubscribe() throws Exception {
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(connectionUri);
-
-      Connection connection = connectionFactory.createConnection();
-      connection.setClientID(getClass().getName());
-      connection.start();
-
-      try {
-         Session ts = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-         try {
-            ts.unsubscribe("invalid-subscription-name");
-            fail("this should fail");
-         }
-         catch (javax.jms.InvalidDestinationException e) {
-            LOG.info("Test caught correct invalid destination exception");
-         }
-      }
-      finally {
-         connection.close();
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4677Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4677Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4677Test.java
deleted file mode 100644
index d7da045..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4677Test.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.*;
-import javax.management.ObjectName;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.leveldb.LevelDBStore;
-import org.apache.activemq.leveldb.LevelDBStoreViewMBean;
-import org.apache.activemq.util.Wait;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ4677Test {
-
-   private static final transient Logger LOG = LoggerFactory.getLogger(AMQ4677Test.class);
-   private static BrokerService brokerService;
-
-   @Rule
-   public TestName name = new TestName();
-
-   private File dataDirFile;
-
-   @Before
-   public void setUp() throws Exception {
-
-      dataDirFile = new File("target/LevelDBCleanupTest");
-
-      brokerService = new BrokerService();
-      brokerService.setBrokerName("LevelDBBroker");
-      brokerService.setPersistent(true);
-      brokerService.setUseJmx(true);
-      brokerService.setAdvisorySupport(false);
-      brokerService.setDeleteAllMessagesOnStartup(true);
-      brokerService.setDataDirectoryFile(dataDirFile);
-
-      LevelDBStore persistenceFactory = new LevelDBStore();
-      persistenceFactory.setDirectory(dataDirFile);
-      brokerService.setPersistenceAdapter(persistenceFactory);
-      brokerService.start();
-      brokerService.waitUntilStarted();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      brokerService.stop();
-      brokerService.waitUntilStopped();
-   }
-
-   @Test
-   public void testSendAndReceiveAllMessages() throws Exception {
-      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://LevelDBBroker");
-
-      Connection connection = connectionFactory.createConnection();
-      connection.setClientID(getClass().getName());
-      connection.start();
-
-      final Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
-      Destination destination = session.createQueue(name.toString());
-      MessageProducer producer = session.createProducer(destination);
-      producer.setDeliveryMode(DeliveryMode.PERSISTENT);
-
-      final LevelDBStoreViewMBean levelDBView = getLevelDBStoreMBean();
-      assertNotNull(levelDBView);
-      levelDBView.compact();
-
-      final int SIZE = 6 * 1024 * 5;
-      final int MSG_COUNT = 60000;
-      final CountDownLatch done = new CountDownLatch(MSG_COUNT);
-
-      byte buffer[] = new byte[SIZE];
-      for (int i = 0; i < SIZE; ++i) {
-         buffer[i] = (byte) 128;
-      }
-
-      for (int i = 0; i < MSG_COUNT; ++i) {
-         BytesMessage message = session.createBytesMessage();
-         message.writeBytes(buffer);
-         producer.send(message);
-
-         if ((i % 1000) == 0) {
-            LOG.info("Sent message #{}", i);
-            session.commit();
-         }
-      }
-
-      session.commit();
-
-      LOG.info("Finished sending all messages.");
-
-      MessageConsumer consumer = session.createConsumer(destination);
-      consumer.setMessageListener(new MessageListener() {
-
-         @Override
-         public void onMessage(Message message) {
-            if ((done.getCount() % 1000) == 0) {
-               try {
-                  LOG.info("Received message #{}", MSG_COUNT - done.getCount());
-                  session.commit();
-               }
-               catch (JMSException e) {
-               }
-            }
-            done.countDown();
-         }
-      });
-
-      done.await(15, TimeUnit.MINUTES);
-      session.commit();
-      LOG.info("Finished receiving all messages.");
-
-      assertTrue("Should < 3 logfiles left.", Wait.waitFor(new Wait.Condition() {
-
-         @Override
-         public boolean isSatisified() throws Exception {
-            levelDBView.compact();
-            return countLogFiles() < 3;
-         }
-      }, TimeUnit.MINUTES.toMillis(5), (int) TimeUnit.SECONDS.toMillis(30)));
-
-      levelDBView.compact();
-      LOG.info("Current number of logs {}", countLogFiles());
-   }
-
-   protected long countLogFiles() {
-      String[] logFiles = dataDirFile.list(new FilenameFilter() {
-
-         @Override
-         public boolean accept(File dir, String name) {
-            if (name.endsWith("log")) {
-               return true;
-            }
-            return false;
-         }
-      });
-
-      LOG.info("Current number of logs {}", logFiles.length);
-      return logFiles.length;
-   }
-
-   protected LevelDBStoreViewMBean getLevelDBStoreMBean() throws Exception {
-      ObjectName levelDbViewMBeanQuery = new ObjectName("org.apache.activemq:type=Broker,brokerName=LevelDBBroker,service=PersistenceAdapter,instanceName=LevelDB*");
-
-      Set<ObjectName> names = brokerService.getManagementContext().queryNames(null, levelDbViewMBeanQuery);
-      if (names.isEmpty() || names.size() > 1) {
-         throw new java.lang.IllegalStateException("Can't find levelDB store name.");
-      }
-
-      LevelDBStoreViewMBean proxy = (LevelDBStoreViewMBean) brokerService.getManagementContext().newProxyInstance(names.iterator().next(), LevelDBStoreViewMBean.class, true);
-      return proxy;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bcfd089/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4853Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4853Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4853Test.java
deleted file mode 100644
index ad04d96..0000000
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4853Test.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/**
- * 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;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.ArrayList;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.CyclicBarrier;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.Session;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.advisory.AdvisoryBroker;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.ConnectionContext;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ConnectionId;
-import org.apache.activemq.command.ConnectionInfo;
-import org.apache.activemq.command.ConsumerId;
-import org.apache.activemq.command.ConsumerInfo;
-import org.apache.activemq.command.SessionId;
-import org.apache.activemq.command.SessionInfo;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AMQ4853Test {
-
-   private static final transient Logger LOG = LoggerFactory.getLogger(AMQ4853Test.class);
-   private static BrokerService brokerService;
-   private static final String BROKER_ADDRESS = "tcp://localhost:0";
-   private static final ActiveMQQueue DESTINATION = new ActiveMQQueue("TEST.QUEUE");
-   private CountDownLatch cycleDoneLatch;
-
-   private String connectionUri;
-
-   @Before
-   public void setUp() throws Exception {
-      brokerService = new BrokerService();
-      brokerService.setPersistent(false);
-      brokerService.setUseJmx(false);
-      brokerService.setAdvisorySupport(true);
-      brokerService.setDeleteAllMessagesOnStartup(true);
-      connectionUri = brokerService.addConnector(BROKER_ADDRESS).getPublishableConnectString();
-
-      brokerService.start();
-      brokerService.waitUntilStarted();
-   }
-
-   @After
-   public void tearDown() throws Exception {
-      brokerService.stop();
-      brokerService.waitUntilStopped();
-   }
-
-   /**
-    * Test to shows the performance of the removing consumers while other stay active.
-    *
-    * @throws Exception
-    */
-   @Ignore
-   @Test
-   public void test() throws Exception {
-
-      // Create a stable set of consumers to fill in the advisory broker's consumer list.
-      ArrayList<Consumer> fixedConsumers = new ArrayList<>(100);
-      for (int i = 0; i < 200; ++i) {
-         fixedConsumers.add(new Consumer());
-      }
-
-      // Create a set of consumers that comes online for a short time and then
-      // goes offline again.  Cycles will repeat as each batch completes
-      final int fixedDelayConsumers = 300;
-      final int fixedDelayCycles = 25;
-
-      final CountDownLatch fixedDelayCycleLatch = new CountDownLatch(fixedDelayCycles);
-
-      // Update so done method can track state.
-      cycleDoneLatch = fixedDelayCycleLatch;
-
-      CyclicBarrier barrier = new CyclicBarrier(fixedDelayConsumers, new Runnable() {
-         @Override
-         public void run() {
-            LOG.info("Fixed delay consumers cycle {} completed.", fixedDelayCycleLatch.getCount());
-            fixedDelayCycleLatch.countDown();
-         }
-      });
-
-      for (int i = 0; i < fixedDelayConsumers; ++i) {
-         new Thread(new FixedDelyConsumer(barrier)).start();
-      }
-
-      fixedDelayCycleLatch.await(10, TimeUnit.MINUTES);
-
-      // Clean up.
-
-      for (Consumer consumer : fixedConsumers) {
-         consumer.close();
-      }
-      fixedConsumers.clear();
-   }
-
-   private ConnectionInfo createConnectionInfo() {
-      ConnectionId id = new ConnectionId();
-      id.setValue("ID:123456789:0:1");
-
-      ConnectionInfo info = new ConnectionInfo();
-      info.setConnectionId(id);
-      return info;
-   }
-
-   private SessionInfo createSessionInfo(ConnectionInfo connection) {
-      SessionId id = new SessionId(connection.getConnectionId(), 1);
-
-      SessionInfo info = new SessionInfo();
-      info.setSessionId(id);
-
-      return info;
-   }
-
-   public ConsumerInfo createConsumerInfo(SessionInfo session, int value, ActiveMQDestination destination) {
-      ConsumerId id = new ConsumerId();
-      id.setConnectionId(session.getSessionId().getConnectionId());
-      id.setSessionId(1);
-      id.setValue(value);
-
-      ConsumerInfo info = new ConsumerInfo();
-      info.setConsumerId(id);
-      info.setDestination(destination);
-      return info;
-   }
-
-   /**
-    * Test to shows the performance impact of removing consumers in various scenarios.
-    *
-    * @throws Exception
-    */
-   @Ignore
-   @Test
-   public void testPerformanceOfRemovals() throws Exception {
-      // setup
-      AdvisoryBroker testObj = (AdvisoryBroker) brokerService.getBroker().getAdaptor(AdvisoryBroker.class);
-      ActiveMQDestination destination = new ActiveMQQueue("foo");
-      ConnectionInfo connectionInfo = createConnectionInfo();
-      ConnectionContext connectionContext = new ConnectionContext(connectionInfo);
-      connectionContext.setBroker(brokerService.getBroker());
-      SessionInfo sessionInfo = createSessionInfo(connectionInfo);
-
-      long start = System.currentTimeMillis();
-
-      for (int i = 0; i < 200; ++i) {
-
-         for (int j = 1; j <= 500; j++) {
-            ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, j, destination);
-            testObj.addConsumer(connectionContext, consumerInfo);
-         }
-
-         for (int j = 500; j > 0; j--) {
-            ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, j, destination);
-            testObj.removeConsumer(connectionContext, consumerInfo);
-         }
-
-         for (int j = 1; j <= 500; j++) {
-            ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, j, destination);
-            testObj.addConsumer(connectionContext, consumerInfo);
-         }
-
-         for (int j = 1; j <= 500; j++) {
-            ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, j, destination);
-            testObj.removeConsumer(connectionContext, consumerInfo);
-         }
-      }
-
-      long finish = System.currentTimeMillis();
-
-      long totalTime = finish - start;
-
-      LOG.info("Total test time: {} seconds", TimeUnit.MILLISECONDS.toSeconds(totalTime));
-
-      assertEquals(0, testObj.getAdvisoryConsumers().size());
-   }
-
-   @Test
-   public void testEqualsNeeded() throws Exception {
-      // setup
-      AdvisoryBroker testObj = (AdvisoryBroker) brokerService.getBroker().getAdaptor(AdvisoryBroker.class);
-      ActiveMQDestination destination = new ActiveMQQueue("foo");
-      ConnectionInfo connectionInfo = createConnectionInfo();
-      ConnectionContext connectionContext = new ConnectionContext(connectionInfo);
-      connectionContext.setBroker(brokerService.getBroker());
-      SessionInfo sessionInfo = createSessionInfo(connectionInfo);
-
-      for (int j = 1; j <= 5; j++) {
-         ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, j, destination);
-         testObj.addConsumer(connectionContext, consumerInfo);
-      }
-
-      for (int j = 1; j <= 5; j++) {
-         ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, j, destination);
-         testObj.removeConsumer(connectionContext, consumerInfo);
-      }
-
-      assertEquals(0, testObj.getAdvisoryConsumers().size());
-   }
-
-   private boolean done() {
-      if (cycleDoneLatch == null) {
-         return true;
-      }
-      return cycleDoneLatch.getCount() == 0;
-   }
-
-   class Consumer implements MessageListener {
-
-      Connection connection;
-      Session session;
-      Destination destination;
-      MessageConsumer consumer;
-
-      Consumer() throws JMSException {
-         ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri);
-         connection = factory.createConnection();
-         session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         consumer = session.createConsumer(DESTINATION);
-         consumer.setMessageListener(this);
-         connection.start();
-      }
-
-      @Override
-      public void onMessage(Message message) {
-      }
-
-      public void close() {
-         try {
-            connection.close();
-         }
-         catch (Exception e) {
-         }
-
-         connection = null;
-         session = null;
-         consumer = null;
-      }
-   }
-
-   class FixedDelyConsumer implements Runnable {
-
-      private final CyclicBarrier barrier;
-      private final int sleepInterval;
-
-      public FixedDelyConsumer(CyclicBarrier barrier) {
-         this.barrier = barrier;
-         this.sleepInterval = 1000;
-      }
-
-      public FixedDelyConsumer(CyclicBarrier barrier, int sleepInterval) {
-         this.barrier = barrier;
-         this.sleepInterval = sleepInterval;
-      }
-
-      @Override
-      public void run() {
-         while (!done()) {
-
-            try {
-               Consumer consumer = new Consumer();
-               TimeUnit.MILLISECONDS.sleep(sleepInterval);
-               consumer.close();
-               barrier.await();
-            }
-            catch (Exception ex) {
-               return;
-            }
-         }
-      }
-   }
-
-}


[49/60] [abbrv] activemq-artemis git commit: fixing testsuite (the testuie broke in a lot of places after this fix now being reverted

Posted by cl...@apache.org.
fixing testsuite (the testuie broke in a lot of places after this fix now being reverted


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/6b3d9d92
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/6b3d9d92
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/6b3d9d92

Branch: refs/heads/refactor-openwire
Commit: 6b3d9d924ffdacf7aa11c5090d16cca1ed473e97
Parents: 3333d9e
Author: Clebert Suconic <cl...@apache.org>
Authored: Fri Feb 26 11:14:54 2016 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:45:29 2016 -0400

----------------------------------------------------------------------
 .../core/protocol/openwire/amq/AMQServerConsumer.java       | 9 ---------
 1 file changed, 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b3d9d92/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerConsumer.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerConsumer.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerConsumer.java
index 9e93b3d..b37e1cf 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerConsumer.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerConsumer.java
@@ -189,13 +189,4 @@ public class AMQServerConsumer extends ServerConsumerImpl {
       }
    }
 
-   @Override
-   protected void updateDeliveryCountForCanceledRef(MessageReference ref, boolean failed) {
-      //activemq5 doesn't decrease the count
-      //when not failed.
-      if (failed) {
-         ref.decrementDeliveryCount();
-      }
-   }
-
 }


[52/60] [abbrv] activemq-artemis git commit: Fixed some redelivery tests

Posted by cl...@apache.org.
Fixed some redelivery tests


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/3333d9e7
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/3333d9e7
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/3333d9e7

Branch: refs/heads/refactor-openwire
Commit: 3333d9e7f10de5f2fe8e816d73d67548a131d468
Parents: dfb047b
Author: Howard Gao <ho...@gmail.com>
Authored: Fri Feb 26 22:24:03 2016 +0800
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:45:29 2016 -0400

----------------------------------------------------------------------
 .../openwire/amq/AMQServerConsumer.java         | 22 ++++++++++++++++++++
 .../protocol/openwire/amq/AMQServerSession.java |  7 +++++++
 .../core/server/impl/ServerConsumerImpl.java    | 16 ++++++++------
 .../activemq/test/JmsTopicSendReceiveTest.java  |  2 ++
 4 files changed, 41 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/3333d9e7/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerConsumer.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerConsumer.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerConsumer.java
index f198cb7..9e93b3d 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerConsumer.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerConsumer.java
@@ -36,6 +36,7 @@ public class AMQServerConsumer extends ServerConsumerImpl {
 
    // TODO-NOW: remove this once unified
    AMQConsumer amqConsumer;
+   boolean isClosing;
 
    public AMQConsumer getAmqConsumer() {
       return amqConsumer;
@@ -69,6 +70,18 @@ public class AMQServerConsumer extends ServerConsumerImpl {
       this.browserDeliverer = newBrowserDeliverer;
    }
 
+   public void closing() {
+      isClosing = true;
+   }
+
+   @Override
+   public HandleStatus handle(final MessageReference ref) throws Exception {
+      if (isClosing) {
+         return HandleStatus.BUSY;
+      }
+      return super.handle(ref);
+   }
+
    private class AMQBrowserDeliverer extends BrowserDeliverer {
 
       private BrowserListener listener = null;
@@ -176,4 +189,13 @@ public class AMQServerConsumer extends ServerConsumerImpl {
       }
    }
 
+   @Override
+   protected void updateDeliveryCountForCanceledRef(MessageReference ref, boolean failed) {
+      //activemq5 doesn't decrease the count
+      //when not failed.
+      if (failed) {
+         ref.decrementDeliveryCount();
+      }
+   }
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/3333d9e7/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerSession.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerSession.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerSession.java
index 9a938fa..b603257 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerSession.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQServerSession.java
@@ -18,6 +18,7 @@ package org.apache.activemq.artemis.core.protocol.openwire.amq;
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -90,6 +91,12 @@ public class AMQServerSession extends ServerSessionImpl {
 
    @Override
    protected void doClose(final boolean failed) throws Exception {
+      Set<ServerConsumer> consumersClone = new HashSet<>(consumers.values());
+      for (ServerConsumer consumer : consumersClone) {
+         AMQServerConsumer amqConsumer = (AMQServerConsumer)consumer;
+         amqConsumer.closing();//prevent redeliver
+      }
+
       synchronized (this) {
          if (tx != null && tx.getXid() == null) {
             ((AMQTransactionImpl) tx).setRollbackForClose();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/3333d9e7/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
index b5ea5d9..b2ca0df 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
@@ -556,12 +556,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
                }
                else {
                   refs.add(ref);
-                  if (!failed) {
-                     // We don't decrement delivery count if the client failed, since there's a possibility that refs
-                     // were actually delivered but we just didn't get any acks for them
-                     // before failure
-                     ref.decrementDeliveryCount();
-                  }
+                  updateDeliveryCountForCanceledRef(ref, failed);
                }
 
                if (isTrace) {
@@ -576,6 +571,15 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
       return refs;
    }
 
+   protected void updateDeliveryCountForCanceledRef(MessageReference ref, boolean failed) {
+      if (!failed) {
+         // We don't decrement delivery count if the client failed, since there's a possibility that refs
+         // were actually delivered but we just didn't get any acks for them
+         // before failure
+         ref.decrementDeliveryCount();
+      }
+   }
+
    @Override
    public void setStarted(final boolean started) {
       synchronized (lock) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/3333d9e7/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveTest.java
index 28ac25e..ddc6cd8 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/test/JmsTopicSendReceiveTest.java
@@ -24,6 +24,7 @@ import javax.jms.Session;
 import javax.jms.Topic;
 
 import org.apache.activemq.artemiswrapper.ArtemisBrokerHelper;
+import org.apache.activemq.transport.tcp.TcpTransportFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -92,6 +93,7 @@ public class JmsTopicSendReceiveTest extends JmsSendReceiveTestSupport {
       session.close();
       connection.close();
       ArtemisBrokerHelper.stopArtemisBroker();
+      TcpTransportFactory.clearService();
    }
 
    /**


[41/60] [abbrv] activemq-artemis git commit: moving send method to the connection

Posted by cl...@apache.org.
moving send method to the connection


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/9898f60b
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/9898f60b
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/9898f60b

Branch: refs/heads/refactor-openwire
Commit: 9898f60b53fd77f6f3b374173fa41b879a26a89a
Parents: 8e29ff7
Author: Clebert Suconic <cl...@apache.org>
Authored: Wed Feb 24 14:26:55 2016 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 15 20:44:21 2016 -0400

----------------------------------------------------------------------
 .../protocol/openwire/OpenWireConnection.java   | 39 ++++++++++++++------
 .../openwire/OpenWireProtocolManager.java       | 36 ------------------
 2 files changed, 27 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/9898f60b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
index 7c1c094..991f24b 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
@@ -22,9 +22,7 @@ import javax.jms.JMSSecurityException;
 import javax.jms.ResourceAllocationException;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -36,13 +34,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
-import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException;
 import org.apache.activemq.artemis.api.core.ActiveMQSecurityException;
-import org.apache.activemq.artemis.core.protocol.openwire.OpenWireProtocolManager;
-import org.apache.activemq.artemis.core.protocol.openwire.OpenWireUtil;
-import org.apache.activemq.artemis.core.protocol.openwire.SendingResult;
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQCompositeConsumerBrokerExchange;
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext;
 import org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConsumer;
@@ -58,7 +52,6 @@ import org.apache.activemq.artemis.spi.core.protocol.AbstractRemotingConnection;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
 import org.apache.activemq.artemis.spi.core.remoting.Acceptor;
 import org.apache.activemq.artemis.spi.core.remoting.Connection;
-import org.apache.activemq.artemis.spi.core.remoting.ReadyListener;
 import org.apache.activemq.artemis.utils.ConcurrentHashSet;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.BrokerInfo;
@@ -104,7 +97,6 @@ import org.apache.activemq.wireformat.WireFormat;
 
 /**
  * Represents an activemq connection.
- * ToDo: extends AbstractRemotingConnection
  */
 public class OpenWireConnection extends AbstractRemotingConnection implements SecurityAuth {
 
@@ -214,7 +206,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
             info.setResponseRequired(false);
             // if we don't respond to KeepAlive commands then the client will think the server is dead and timeout
             // for some reason KeepAliveInfo.isResponseRequired() is always false
-            protocolManager.sendReply(this, info);
+            sendCommand(info);
          }
          else {
             Response response = null;
@@ -333,7 +325,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
    // throw a WireFormatInfo to the peer
    public void init() {
       WireFormatInfo info = wireFormat.getPreferedWireFormatInfo();
-      protocolManager.send(this, info);
+      sendCommand(info);
    }
 
    public ConnectionState getState() {
@@ -536,7 +528,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
          m.setBrokerOutTime(endTime);
       }
 
-      protocolManager.send(this, dispatch);
+      sendCommand(dispatch);
    }
 
    public WireFormat getMarshaller() {
@@ -577,7 +569,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
 
       destroyed = true;
 
-      //before closing transport, send the last response if any
+      //before closing transport, sendCommand the last response if any
       Command command = context.getLastCommand();
       if (command != null && command.isResponseRequired()) {
          Response lastResponse = new Response();
@@ -689,6 +681,29 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
       context.incRefCount();
    }
 
+   /** This will answer with commands to the client */
+   public boolean sendCommand(final Command command) {
+      if (ActiveMQServerLogger.LOGGER.isTraceEnabled()) {
+         ActiveMQServerLogger.LOGGER.trace("sending " + command);
+      }
+      synchronized (this) {
+         if (isDestroyed()) {
+            return false;
+         }
+
+         try {
+            physicalSend(command);
+         }
+         catch (Exception e) {
+            return false;
+         }
+         catch (Throwable t) {
+            return false;
+         }
+         return true;
+      }
+   }
+
    // This will listen for commands throught the protocolmanager
    public class CommandProcessor implements CommandVisitor {
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/9898f60b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
index 440fcce..add1455 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireProtocolManager.java
@@ -280,42 +280,6 @@ public class OpenWireProtocolManager implements ProtocolManager<Interceptor>, No
 
    }
 
-   public void sendReply(final OpenWireConnection connection, final Command command) {
-      server.getStorageManager().afterCompleteOperations(new IOCallback() {
-         @Override
-         public void onError(final int errorCode, final String errorMessage) {
-            ActiveMQServerLogger.LOGGER.errorProcessingIOCallback(errorCode, errorMessage);
-         }
-
-         @Override
-         public void done() {
-            send(connection, command);
-         }
-      });
-   }
-
-   public boolean send(final OpenWireConnection connection, final Command command) {
-      if (ActiveMQServerLogger.LOGGER.isTraceEnabled()) {
-         ActiveMQServerLogger.LOGGER.trace("sending " + command);
-      }
-      synchronized (connection) {
-         if (connection.isDestroyed()) {
-            return false;
-         }
-
-         try {
-            connection.physicalSend(command);
-         }
-         catch (Exception e) {
-            return false;
-         }
-         catch (Throwable t) {
-            return false;
-         }
-         return true;
-      }
-   }
-
    public void addConnection(OpenWireConnection connection, ConnectionInfo info) throws Exception {
       String username = info.getUserName();
       String password = info.getPassword();