activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [3/6] activemq-artemis git commit: ARTEMIS-737 - added JUnit rules for Artemis servers and clients
Date Mon, 26 Sep 2016 21:58:48 GMT
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/db095926/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/EmbeddedJMSResource.java
----------------------------------------------------------------------
diff --git a/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/EmbeddedJMSResource.java b/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/EmbeddedJMSResource.java
new file mode 100644
index 0000000..788e0ce
--- /dev/null
+++ b/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/EmbeddedJMSResource.java
@@ -0,0 +1,749 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF 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.junit;
+
+import javax.jms.BytesMessage;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.Message;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.jms.StreamMessage;
+import javax.jms.TextMessage;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.api.core.TransportConfiguration;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.config.FileDeploymentManager;
+import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
+import org.apache.activemq.artemis.core.config.impl.FileConfiguration;
+import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory;
+import org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants;
+import org.apache.activemq.artemis.core.server.ActiveMQServer;
+import org.apache.activemq.artemis.core.server.BindingQueryResult;
+import org.apache.activemq.artemis.core.server.Queue;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
+import org.apache.activemq.artemis.jms.server.config.JMSConfiguration;
+import org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.junit.rules.ExternalResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A JUnit Rule that embeds an ActiveMQ Artemis JMS server into a test.
+ */
+public class EmbeddedJMSResource extends ExternalResource {
+
+   static final String SERVER_NAME = "embedded-jms-server";
+
+   Logger log = LoggerFactory.getLogger(this.getClass());
+   Integer serverId = null;
+
+   Configuration configuration;
+   JMSConfiguration jmsConfiguration;
+   EmbeddedJMS jmsServer;
+
+   InternalClient internalClient;
+
+   /**
+    * Create a default EmbeddedJMSResource
+    */
+   public EmbeddedJMSResource() {
+      configuration = new ConfigurationImpl().setName(SERVER_NAME).setPersistenceEnabled(false).setSecurityEnabled(false).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
+
+      jmsConfiguration = new JMSConfigurationImpl();
+
+      init();
+   }
+
+   /**
+    * Create a default EmbeddedJMSResource with the specified server id
+    */
+   public EmbeddedJMSResource(int serverId) {
+      this.serverId = serverId;
+      Map<String, Object> props = new HashMap<>();
+      props.put(TransportConstants.SERVER_ID_PROP_NAME, serverId);
+
+      configuration = new ConfigurationImpl().setName(SERVER_NAME + "-" + serverId).setPersistenceEnabled(false).setSecurityEnabled(false).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName(), props));
+
+      jmsConfiguration = new JMSConfigurationImpl();
+
+      init();
+   }
+
+   /**
+    * Create an EmbeddedJMSResource with the specified configurations
+    *
+    * @param configuration    ActiveMQServer configuration
+    * @param jmsConfiguration JMSServerManager configuration
+    */
+   public EmbeddedJMSResource(Configuration configuration, JMSConfiguration jmsConfiguration) {
+      this.configuration = configuration;
+      this.jmsConfiguration = jmsConfiguration;
+      init();
+   }
+
+   /**
+    * Create an EmbeddedJMSResource with the specified configuration file
+    *
+    * @param filename configuration file name
+    */
+   public EmbeddedJMSResource(String filename) {
+      this(filename, filename);
+   }
+
+   /**
+    * Create an EmbeddedJMSResource with the specified configuration file
+    *
+    * @param serverConfigurationFileName ActiveMQServer configuration file name
+    * @param jmsConfigurationFileName    JMSServerManager configuration file name
+    */
+   public EmbeddedJMSResource(String serverConfigurationFileName, String jmsConfigurationFileName) {
+      if (serverConfigurationFileName == null) {
+         throw new IllegalArgumentException("ActiveMQServer configuration file name cannot be null");
+      }
+      if (jmsConfigurationFileName == null) {
+         throw new IllegalArgumentException("JMSServerManager configuration file name cannot be null");
+      }
+
+      FileDeploymentManager coreDeploymentManager = new FileDeploymentManager(serverConfigurationFileName);
+      FileConfiguration coreConfiguration = new FileConfiguration();
+      coreDeploymentManager.addDeployable(coreConfiguration);
+      try {
+         coreDeploymentManager.readConfiguration();
+      }
+      catch (Exception readCoreConfigEx) {
+         throw new EmbeddedJMSResourceException(String.format("Failed to read ActiveMQServer configuration from file %s", serverConfigurationFileName), readCoreConfigEx);
+      }
+      this.configuration = coreConfiguration;
+
+      FileJMSConfiguration jmsConfiguration = new FileJMSConfiguration();
+      FileDeploymentManager jmsDeploymentManager = new FileDeploymentManager(jmsConfigurationFileName);
+      jmsDeploymentManager.addDeployable(jmsConfiguration);
+      try {
+         jmsDeploymentManager.readConfiguration();
+      }
+      catch (Exception readJmsConfigEx) {
+         throw new EmbeddedJMSResourceException(String.format("Failed to read JMSServerManager configuration from file %s", jmsConfigurationFileName), readJmsConfigEx);
+      }
+      this.jmsConfiguration = jmsConfiguration;
+
+      init();
+   }
+
+   public static void setMessageProperties(Message message, Map<String, Object> properties) {
+      if (properties != null && properties.size() > 0) {
+         for (Map.Entry<String, Object> property : properties.entrySet()) {
+            try {
+               message.setObjectProperty(property.getKey(), property.getValue());
+            }
+            catch (JMSException jmsEx) {
+               throw new EmbeddedJMSResourceException(String.format("Failed to set property {%s = %s}", property.getKey(), property.getValue().toString()), jmsEx);
+            }
+         }
+      }
+   }
+
+   private void init() {
+      if (jmsServer == null) {
+         jmsServer = new EmbeddedJMS().setConfiguration(configuration).setJmsConfiguration(jmsConfiguration);
+      }
+   }
+
+   /**
+    * Start the embedded EmbeddedJMSResource.
+    * <p/>
+    * The server will normally be started by JUnit using the before() method.  This method allows the server to
+    * be started manually to support advanced testing scenarios.
+    */
+   public void start() {
+      log.info("Starting {}: {}", this.getClass().getSimpleName(), this.getServerName());
+      try {
+         jmsServer.start();
+      }
+      catch (Exception ex) {
+         throw new RuntimeException(String.format("Exception encountered starting %s: %s", jmsServer.getClass().getSimpleName(), this.getServerName()), ex);
+      }
+   }
+
+   /**
+    * Stop the embedded ActiveMQ broker, blocking until the broker has stopped.
+    * <p/>
+    * The broker will normally be stopped by JUnit using the after() method.  This method allows the broker to
+    * be stopped manually to support advanced testing scenarios.
+    */
+   public void stop() {
+      log.info("Stopping {}: {}", this.getClass().getSimpleName(), this.getServerName());
+      if (internalClient != null) {
+         internalClient.stop();
+         internalClient = null;
+      }
+
+      if (jmsServer != null) {
+         try {
+            jmsServer.stop();
+         }
+         catch (Exception ex) {
+            log.warn(String.format("Exception encountered stopping %s: %s - ignoring", jmsServer.getClass().getSimpleName(), this.getServerName()), ex);
+         }
+      }
+   }
+
+   /**
+    * Start the embedded ActiveMQ Broker
+    * <p/>
+    * Invoked by JUnit to setup the resource
+    */
+   @Override
+   protected void before() throws Throwable {
+      log.info("Starting {}: {}", this.getClass().getSimpleName(), getServerName());
+
+      this.start();
+
+      super.before();
+   }
+
+   /**
+    * Stop the embedded ActiveMQ Broker
+    * <p/>
+    * Invoked by JUnit to tear down the resource
+    */
+   @Override
+   protected void after() {
+      log.info("Stopping {}: {}", this.getClass().getSimpleName(), getServerName());
+
+      super.after();
+
+      this.stop();
+   }
+
+   /**
+    * Get the EmbeddedJMS server.
+    * <p/>
+    * This may be required for advanced configuration of the EmbeddedJMS server.
+    *
+    * @return
+    */
+   public EmbeddedJMS getJmsServer() {
+      return jmsServer;
+   }
+
+   /**
+    * Get the name of the EmbeddedJMS server
+    *
+    * @return name of the server
+    */
+   public String getServerName() {
+      String name = "unknown";
+      ActiveMQServer activeMQServer = jmsServer.getActiveMQServer();
+      if (activeMQServer != null) {
+         name = activeMQServer.getConfiguration().getName();
+      }
+      else if (configuration != null) {
+         name = configuration.getName();
+      }
+
+      return name;
+   }
+
+   /**
+    * Get the VM URL for the embedded EmbeddedActiveMQ server
+    *
+    * @return the VM URL for the embedded server
+    */
+   public String getVmURL() {
+      String vmURL = "vm://0";
+      for (TransportConfiguration transportConfiguration : configuration.getAcceptorConfigurations()) {
+         Map<String, Object> params = transportConfiguration.getParams();
+         if (params != null && params.containsKey(TransportConstants.SERVER_ID_PROP_NAME)) {
+            vmURL = "vm://" + params.get(TransportConstants.SERVER_ID_PROP_NAME);
+         }
+      }
+
+      return vmURL;
+   }
+
+   /**
+    * Get the Queue corresponding to a JMS Destination.
+    * <p/>
+    * The full name of the JMS destination including the prefix should be provided - i.e. queue://myQueue
+    * or topic://myTopic.  If the destination type prefix is not included in the destination name, a prefix
+    * of "queue://" is assumed.
+    *
+    * @param destinationName the full name of the JMS Destination
+    * @return the number of messages in the JMS Destination
+    */
+   public Queue getDestinationQueue(String destinationName) {
+      Queue queue = null;
+      ActiveMQDestination destination = ActiveMQDestination.createDestination(destinationName, ActiveMQDestination.QUEUE_TYPE);
+      String address = destination.getAddress();
+      String name = destination.getName();
+      if (destination.isQueue()) {
+         queue = jmsServer.getActiveMQServer().locateQueue(destination.getSimpleAddress());
+      }
+      else {
+         BindingQueryResult bindingQueryResult = null;
+         try {
+            bindingQueryResult = jmsServer.getActiveMQServer().bindingQuery(destination.getSimpleAddress());
+         }
+         catch (Exception ex) {
+            log.error(String.format("getDestinationQueue( %s ) - bindingQuery for %s failed", destinationName, destination.getAddress()), ex);
+            return null;
+         }
+         if (bindingQueryResult.isExists()) {
+            List<SimpleString> queueNames = bindingQueryResult.getQueueNames();
+            if (queueNames.size() > 0) {
+               queue = jmsServer.getActiveMQServer().locateQueue(queueNames.get(0));
+            }
+         }
+      }
+
+      return queue;
+   }
+
+   /**
+    * Get the Queues corresponding to a JMS Topic.
+    * <p/>
+    * The full name of the JMS Topic including the prefix should be provided - i.e. topic://myTopic.  If the destination type prefix
+    * is not included in the destination name, a prefix of "topic://" is assumed.
+    *
+    * @param topicName the full name of the JMS Destination
+    * @return the number of messages in the JMS Destination
+    */
+   public List<Queue> getTopicQueues(String topicName) {
+      List<Queue> queues = new LinkedList<>();
+      ActiveMQDestination destination = ActiveMQDestination.createDestination(topicName, ActiveMQDestination.TOPIC_TYPE);
+      if (!destination.isQueue()) {
+         BindingQueryResult bindingQueryResult = null;
+         try {
+            bindingQueryResult = jmsServer.getActiveMQServer().bindingQuery(destination.getSimpleAddress());
+         }
+         catch (Exception ex) {
+            log.error(String.format("getTopicQueues( %s ) - bindingQuery for %s failed", topicName, destination.getAddress()), ex);
+            return queues;
+         }
+
+         if (bindingQueryResult.isExists()) {
+            ActiveMQServer activeMQServer = jmsServer.getActiveMQServer();
+            for (SimpleString queueName : bindingQueryResult.getQueueNames()) {
+               queues.add(activeMQServer.locateQueue(queueName));
+            }
+         }
+      }
+
+      return queues;
+   }
+
+   /**
+    * Get the number of messages in a specific JMS Destination.
+    * <p/>
+    * The full name of the JMS destination including the prefix should be provided - i.e. queue://myQueue
+    * or topic://myTopic.  If the destination type prefix is not included in the destination name, a prefix
+    * of "queue://" is assumed.
+    *
+    * NOTE:  For JMS Topics, this returned count will be the total number of messages for all subscribers.  For
+    * example, if there are two subscribers on the topic and a single message is published, the returned count will
+    * be two (one message for each subscriber).
+    *
+    * @param destinationName the full name of the JMS Destination
+    * @return the number of messages in the JMS Destination
+    */
+   public long getMessageCount(String destinationName) {
+      long count = 0;
+      ActiveMQDestination destination = ActiveMQDestination.createDestination(destinationName, ActiveMQDestination.QUEUE_TYPE);
+      if (destination.isQueue()) {
+         Queue queue = getDestinationQueue(destinationName);
+         if (queue == null) {
+            log.warn("getMessageCount(destinationName) - destination {} not found; returning -1", destinationName);
+            count = -1;
+         }
+         else {
+            count = queue.getMessageCount();
+         }
+      }
+      else {
+         for (Queue topicQueue : getTopicQueues(destinationName)) {
+            count += topicQueue.getMessageCount();
+         }
+      }
+
+      return count;
+   }
+
+   public BytesMessage createBytesMessage() {
+      return getInternalClient().createBytesMessage();
+   }
+
+   public TextMessage createTextMessage() {
+      return getInternalClient().createTextMessage();
+   }
+
+   public MapMessage createMapMessage() {
+      return getInternalClient().createMapMessage();
+   }
+
+   public ObjectMessage createObjectMessage() {
+      return getInternalClient().createObjectMessage();
+   }
+
+   public StreamMessage createStreamMessage() {
+      return getInternalClient().createStreamMessage();
+   }
+
+   public BytesMessage createMessage(byte[] body) {
+      return createMessage(body, null);
+   }
+
+   public TextMessage createMessage(String body) {
+      return createMessage(body, null);
+   }
+
+   public MapMessage createMessage(Map<String, Object> body) {
+      return createMessage(body, null);
+   }
+
+   public ObjectMessage createMessage(Serializable body) {
+      return createMessage(body, null);
+   }
+
+   public BytesMessage createMessage(byte[] body, Map<String, Object> properties) {
+      BytesMessage message = this.createBytesMessage();
+      if (body != null) {
+         try {
+            message.writeBytes(body);
+         }
+         catch (JMSException jmsEx) {
+            throw new EmbeddedJMSResourceException(String.format("Failed to set body {%s} on BytesMessage", new String(body)), jmsEx);
+         }
+      }
+
+      setMessageProperties(message, properties);
+
+      return message;
+   }
+
+   public TextMessage createMessage(String body, Map<String, Object> properties) {
+      TextMessage message = this.createTextMessage();
+      if (body != null) {
+         try {
+            message.setText(body);
+         }
+         catch (JMSException jmsEx) {
+            throw new EmbeddedJMSResourceException(String.format("Failed to set body {%s} on TextMessage", body), jmsEx);
+         }
+      }
+
+      setMessageProperties(message, properties);
+
+      return message;
+   }
+
+   public MapMessage createMessage(Map<String, Object> body, Map<String, Object> properties) {
+      MapMessage message = this.createMapMessage();
+
+      if (body != null) {
+         for (Map.Entry<String, Object> entry : body.entrySet()) {
+            try {
+               message.setObject(entry.getKey(), entry.getValue());
+            }
+            catch (JMSException jmsEx) {
+               throw new EmbeddedJMSResourceException(String.format("Failed to set body entry {%s = %s} on MapMessage", entry.getKey(), entry.getValue().toString()), jmsEx);
+            }
+         }
+      }
+
+      setMessageProperties(message, properties);
+
+      return message;
+   }
+
+   public ObjectMessage createMessage(Serializable body, Map<String, Object> properties) {
+      ObjectMessage message = this.createObjectMessage();
+
+      if (body != null) {
+         try {
+            message.setObject(body);
+         }
+         catch (JMSException jmsEx) {
+            throw new EmbeddedJMSResourceException(String.format("Failed to set body {%s} on ObjectMessage", body.toString()), jmsEx);
+         }
+      }
+
+      setMessageProperties(message, properties);
+
+      return message;
+   }
+
+   public void pushMessage(String destinationName, Message message) {
+      if (destinationName == null) {
+         throw new IllegalArgumentException("sendMessage failure - destination name is required");
+      }
+      else if (message == null) {
+         throw new IllegalArgumentException("sendMessage failure - a Message is required");
+      }
+      ActiveMQDestination destination = ActiveMQDestination.createDestination(destinationName, ActiveMQDestination.QUEUE_TYPE);
+
+      getInternalClient().pushMessage(destination, message);
+   }
+
+   public BytesMessage pushMessage(String destinationName, byte[] body) {
+      BytesMessage message = createMessage(body, null);
+      pushMessage(destinationName, message);
+      return message;
+   }
+
+   public TextMessage pushMessage(String destinationName, String body) {
+      TextMessage message = createMessage(body, null);
+      pushMessage(destinationName, message);
+      return message;
+   }
+
+   public MapMessage pushMessage(String destinationName, Map<String, Object> body) {
+      MapMessage message = createMessage(body, null);
+      pushMessage(destinationName, message);
+      return message;
+   }
+
+   public ObjectMessage pushMessage(String destinationName, Serializable body) {
+      ObjectMessage message = createMessage(body, null);
+      pushMessage(destinationName, message);
+      return message;
+   }
+
+   public BytesMessage pushMessageWithProperties(String destinationName, byte[] body, Map<String, Object> properties) {
+      BytesMessage message = createMessage(body, properties);
+      pushMessage(destinationName, message);
+      return message;
+   }
+
+   public TextMessage pushMessageWithProperties(String destinationName, String body, Map<String, Object> properties) {
+      TextMessage message = createMessage(body, properties);
+      pushMessage(destinationName, message);
+      return message;
+   }
+
+   public MapMessage pushMessageWithProperties(String destinationName,
+                                               Map<String, Object> body,
+                                               Map<String, Object> properties) {
+      MapMessage message = createMessage(body, properties);
+      pushMessage(destinationName, message);
+      return message;
+   }
+
+   public ObjectMessage pushMessageWithProperties(String destinationName,
+                                                  Serializable body,
+                                                  Map<String, Object> properties) {
+      ObjectMessage message = createMessage(body, properties);
+      pushMessage(destinationName, message);
+      return message;
+   }
+
+   public Message peekMessage(String destinationName) {
+      if (null == jmsServer) {
+         throw new NullPointerException("peekMessage failure  - BrokerService is null");
+      }
+
+      if (destinationName == null) {
+         throw new IllegalArgumentException("peekMessage failure - destination name is required");
+      }
+
+      throw new UnsupportedOperationException("Not yet implemented");
+   }
+
+   public BytesMessage peekBytesMessage(String destinationName) {
+      return (BytesMessage) peekMessage(destinationName);
+   }
+
+   public TextMessage peekTextMessage(String destinationName) {
+      return (TextMessage) peekMessage(destinationName);
+   }
+
+   public MapMessage peekMapMessage(String destinationName) {
+      return (MapMessage) peekMessage(destinationName);
+   }
+
+   public ObjectMessage peekObjectMessage(String destinationName) {
+      return (ObjectMessage) peekMessage(destinationName);
+   }
+
+   public StreamMessage peekStreamMessage(String destinationName) {
+      return (StreamMessage) peekMessage(destinationName);
+   }
+
+   private InternalClient getInternalClient() {
+      if (internalClient == null) {
+         log.info("Creating InternalClient");
+         internalClient = new InternalClient();
+         internalClient.start();
+      }
+
+      return internalClient;
+   }
+
+   public static class EmbeddedJMSResourceException extends RuntimeException {
+
+      public EmbeddedJMSResourceException(String message) {
+         super(message);
+      }
+
+      public EmbeddedJMSResourceException(String message, Exception cause) {
+         super(message, cause);
+      }
+   }
+
+   private class InternalClient {
+
+      ConnectionFactory connectionFactory;
+      Connection connection;
+      Session session;
+      MessageProducer producer;
+
+      InternalClient() {
+      }
+
+      void start() {
+         connectionFactory = new ActiveMQConnectionFactory(getVmURL());
+         try {
+            connection = connectionFactory.createConnection();
+            session = connection.createSession();
+            producer = session.createProducer(null);
+            connection.start();
+         }
+         catch (JMSException jmsEx) {
+            throw new EmbeddedJMSResourceException("InternalClient creation failure", jmsEx);
+         }
+      }
+
+      void stop() {
+         try {
+            producer.close();
+         }
+         catch (JMSException jmsEx) {
+            log.warn("JMSException encounter closing InternalClient Session - MessageProducer", jmsEx);
+         }
+         finally {
+            producer = null;
+         }
+
+         try {
+            session.close();
+         }
+         catch (JMSException jmsEx) {
+            log.warn("JMSException encounter closing InternalClient Session - ignoring", jmsEx);
+         }
+         finally {
+            session = null;
+         }
+
+         if (null != connection) {
+            try {
+               connection.close();
+            }
+            catch (JMSException jmsEx) {
+               log.warn("JMSException encounter closing InternalClient Connection - ignoring", jmsEx);
+            }
+            finally {
+               connection = null;
+            }
+         }
+      }
+
+      public BytesMessage createBytesMessage() {
+         checkSession();
+
+         try {
+            return session.createBytesMessage();
+         }
+         catch (JMSException jmsEx) {
+            throw new EmbeddedJMSResourceException("Failed to create BytesMessage", jmsEx);
+         }
+      }
+
+      public TextMessage createTextMessage() {
+         checkSession();
+
+         try {
+            return session.createTextMessage();
+         }
+         catch (JMSException jmsEx) {
+            throw new EmbeddedJMSResourceException("Failed to create TextMessage", jmsEx);
+         }
+      }
+
+      public MapMessage createMapMessage() {
+         checkSession();
+
+         try {
+            return session.createMapMessage();
+         }
+         catch (JMSException jmsEx) {
+            throw new EmbeddedJMSResourceException("Failed to create MapMessage", jmsEx);
+         }
+      }
+
+      public ObjectMessage createObjectMessage() {
+         checkSession();
+
+         try {
+            return session.createObjectMessage();
+         }
+         catch (JMSException jmsEx) {
+            throw new EmbeddedJMSResourceException("Failed to create ObjectMessage", jmsEx);
+         }
+      }
+
+      public StreamMessage createStreamMessage() {
+         checkSession();
+         try {
+            return session.createStreamMessage();
+         }
+         catch (JMSException jmsEx) {
+            throw new EmbeddedJMSResourceException("Failed to create StreamMessage", jmsEx);
+         }
+      }
+
+      public void pushMessage(ActiveMQDestination destination, Message message) {
+         if (producer == null) {
+            throw new IllegalStateException("JMS MessageProducer is null - has the InternalClient been started?");
+         }
+
+         try {
+            producer.send(destination, message);
+         }
+         catch (JMSException jmsEx) {
+            throw new EmbeddedJMSResourceException(String.format("Failed to push %s to %s", message.getClass().getSimpleName(), destination.toString()), jmsEx);
+         }
+      }
+
+      void checkSession() {
+         if (session == null) {
+            throw new IllegalStateException("JMS Session is null - has the InternalClient been started?");
+         }
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/db095926/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQConsumerResourceTest.java
----------------------------------------------------------------------
diff --git a/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQConsumerResourceTest.java b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQConsumerResourceTest.java
new file mode 100644
index 0000000..b8a637a
--- /dev/null
+++ b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQConsumerResourceTest.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF 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.junit;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.api.core.client.ClientMessage;
+import org.junit.After;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.RuleChain;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class ActiveMQConsumerResourceTest {
+
+   static final SimpleString TEST_QUEUE = new SimpleString("test.queue");
+   static final SimpleString TEST_ADDRESS = new SimpleString("test.queue");
+   static final String TEST_BODY = "Test Message";
+   static final Map<String, Object> TEST_PROPERTIES;
+
+   static final String ASSERT_SENT_FORMAT = "Message should have been sent to %s";
+   static final String ASSERT_RECEIVED_FORMAT = "Message should have been received from %s";
+   static final String ASSERT_COUNT_FORMAT = "Unexpected message count in queue %s";
+
+   static {
+      TEST_PROPERTIES = new HashMap<String, Object>(2);
+      TEST_PROPERTIES.put("PropertyOne", "Property Value 1");
+      TEST_PROPERTIES.put("PropertyTwo", "Property Value 2");
+   }
+
+   EmbeddedActiveMQResource server = new EmbeddedActiveMQResource();
+
+   ActiveMQConsumerResource consumer = new ActiveMQConsumerResource(server.getVmURL(), TEST_QUEUE);
+
+   @Rule
+   public RuleChain ruleChain = RuleChain.outerRule(server).around(consumer);
+
+   ClientMessage sent = null;
+
+   @After
+   public void tearDown() throws Exception {
+      assertNotNull(String.format(ASSERT_SENT_FORMAT, TEST_ADDRESS), sent);
+      assertEquals(String.format(ASSERT_COUNT_FORMAT, TEST_QUEUE), 1, server.getMessageCount(TEST_QUEUE));
+
+      ClientMessage received = consumer.receiveMessage();
+      assertNotNull(String.format(ASSERT_RECEIVED_FORMAT, TEST_ADDRESS), received);
+   }
+
+   @Test
+   public void testSendBytes() throws Exception {
+      sent = server.sendMessage(TEST_ADDRESS, TEST_BODY.getBytes());
+   }
+
+   @Test
+   public void testSendString() throws Exception {
+      sent = server.sendMessage(TEST_ADDRESS, TEST_BODY);
+   }
+
+   @Test
+   public void testSendBytesAndProperties() throws Exception {
+      sent = server.sendMessageWithProperties(TEST_ADDRESS, TEST_BODY.getBytes(), TEST_PROPERTIES);
+   }
+
+   @Test
+   public void testSendStringAndProperties() throws Exception {
+      sent = server.sendMessageWithProperties(TEST_ADDRESS, TEST_BODY, TEST_PROPERTIES);
+   }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/db095926/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQDynamicProducerResourceTest.java
----------------------------------------------------------------------
diff --git a/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQDynamicProducerResourceTest.java b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQDynamicProducerResourceTest.java
new file mode 100644
index 0000000..7d09848
--- /dev/null
+++ b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQDynamicProducerResourceTest.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF 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.junit;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.api.core.client.ClientMessage;
+import org.junit.After;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.RuleChain;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class ActiveMQDynamicProducerResourceTest {
+
+   static final SimpleString TEST_QUEUE_ONE = new SimpleString("test.queue.one");
+   static final SimpleString TEST_QUEUE_TWO = new SimpleString("test.queue.two");
+   static final String TEST_BODY = "Test Message";
+   static final Map<String, Object> TEST_PROPERTIES;
+
+   static final String ASSERT_SENT_FORMAT = "Message should have been sent to %s";
+   static final String ASSERT_RECEIVED_FORMAT = "Message should have been received from %s";
+   static final String ASSERT_COUNT_FORMAT = "Unexpected message count in queue %s";
+
+   static {
+      TEST_PROPERTIES = new HashMap<String, Object>(2);
+      TEST_PROPERTIES.put("PropertyOne", "Property Value 1");
+      TEST_PROPERTIES.put("PropertyTwo", "Property Value 2");
+   }
+
+   EmbeddedActiveMQResource server = new EmbeddedActiveMQResource();
+
+   ActiveMQDynamicProducerResource producer = new ActiveMQDynamicProducerResource(server.getVmURL(), TEST_QUEUE_ONE);
+
+   @Rule
+   public RuleChain ruleChain = RuleChain.outerRule(server).around(producer);
+
+   ClientMessage sentOne = null;
+   ClientMessage sentTwo = null;
+
+   @After
+   public void tearDown() throws Exception {
+      assertNotNull(String.format(ASSERT_SENT_FORMAT, TEST_QUEUE_ONE), sentOne);
+      assertNotNull(String.format(ASSERT_SENT_FORMAT, TEST_QUEUE_TWO), sentTwo);
+      assertEquals(String.format(ASSERT_COUNT_FORMAT, TEST_QUEUE_ONE), 1, server.getMessageCount(TEST_QUEUE_ONE));
+      assertEquals(String.format(ASSERT_COUNT_FORMAT, TEST_QUEUE_TWO), 1, server.getMessageCount(TEST_QUEUE_TWO));
+
+      ClientMessage receivedOne = server.receiveMessage(TEST_QUEUE_ONE);
+      assertNotNull(String.format(ASSERT_RECEIVED_FORMAT, TEST_QUEUE_ONE), receivedOne);
+
+      ClientMessage receivedTwo = server.receiveMessage(TEST_QUEUE_TWO);
+      assertNotNull(String.format(ASSERT_RECEIVED_FORMAT, TEST_QUEUE_TWO), receivedTwo);
+   }
+
+   @Test
+   public void testSendBytes() throws Exception {
+      sentOne = producer.sendMessage(TEST_BODY.getBytes());
+      sentTwo = producer.sendMessage(TEST_QUEUE_TWO, TEST_BODY.getBytes());
+   }
+
+   @Test
+   public void testSendString() throws Exception {
+      sentOne = producer.sendMessage(TEST_BODY);
+      sentTwo = producer.sendMessage(TEST_QUEUE_TWO, TEST_BODY);
+   }
+
+   @Test
+   public void testSendBytesAndProperties() throws Exception {
+      sentOne = producer.sendMessage(TEST_BODY.getBytes(), TEST_PROPERTIES);
+      sentTwo = producer.sendMessage(TEST_QUEUE_TWO, TEST_BODY.getBytes(), TEST_PROPERTIES);
+   }
+
+   @Test
+   public void testSendStringAndProperties() throws Exception {
+      sentOne = producer.sendMessage(TEST_BODY, TEST_PROPERTIES);
+      sentTwo = producer.sendMessage(TEST_QUEUE_TWO, TEST_BODY, TEST_PROPERTIES);
+   }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/db095926/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQDynamicProducerResourceWithoutAddressExceptionTest.java
----------------------------------------------------------------------
diff --git a/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQDynamicProducerResourceWithoutAddressExceptionTest.java b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQDynamicProducerResourceWithoutAddressExceptionTest.java
new file mode 100644
index 0000000..5367009
--- /dev/null
+++ b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQDynamicProducerResourceWithoutAddressExceptionTest.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.junit;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.api.core.client.ClientMessage;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.RuleChain;
+
+public class ActiveMQDynamicProducerResourceWithoutAddressExceptionTest {
+
+   static final SimpleString TEST_QUEUE_ONE = new SimpleString("test.queue.one");
+   static final String TEST_BODY = "Test Message";
+   static final Map<String, Object> TEST_PROPERTIES;
+
+   static {
+      TEST_PROPERTIES = new HashMap<String, Object>(2);
+      TEST_PROPERTIES.put("PropertyOne", "Property Value 1");
+      TEST_PROPERTIES.put("PropertyTwo", "Property Value 2");
+   }
+
+   EmbeddedActiveMQResource server = new EmbeddedActiveMQResource();
+
+   ActiveMQDynamicProducerResource producer = new ActiveMQDynamicProducerResource(server.getVmURL());
+
+   @Rule
+   public RuleChain ruleChain = RuleChain.outerRule(server).around(producer);
+
+   ClientMessage sentOne = null;
+
+   @Before
+   public void setUp() throws Exception {
+      producer.setAutoCreateQueue(false);
+      server.createQueue(TEST_QUEUE_ONE, TEST_QUEUE_ONE);
+   }
+
+   @Test(expected = IllegalArgumentException.class)
+   public void testSendBytesToDefaultAddress() throws Exception {
+      sentOne = producer.sendMessage(TEST_BODY.getBytes());
+   }
+
+   @Test(expected = IllegalArgumentException.class)
+   public void testSendStringToDefaultAddress() throws Exception {
+      sentOne = producer.sendMessage(TEST_BODY);
+   }
+
+   @Test(expected = IllegalArgumentException.class)
+   public void testSendBytesAndPropertiesToDefaultAddress() throws Exception {
+      sentOne = producer.sendMessage(TEST_BODY.getBytes(), TEST_PROPERTIES);
+   }
+
+   @Test(expected = IllegalArgumentException.class)
+   public void testSendStringAndPropertiesToDefaultAddress() throws Exception {
+      sentOne = producer.sendMessage(TEST_BODY, TEST_PROPERTIES);
+   }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/db095926/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQDynamicProducerResourceWithoutAddressTest.java
----------------------------------------------------------------------
diff --git a/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQDynamicProducerResourceWithoutAddressTest.java b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQDynamicProducerResourceWithoutAddressTest.java
new file mode 100644
index 0000000..6e61a3a
--- /dev/null
+++ b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQDynamicProducerResourceWithoutAddressTest.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.junit;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.api.core.client.ClientMessage;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.RuleChain;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class ActiveMQDynamicProducerResourceWithoutAddressTest {
+
+   static final SimpleString TEST_QUEUE_ONE = new SimpleString("test.queue.one");
+   static final SimpleString TEST_QUEUE_TWO = new SimpleString("test.queue.two");
+   static final String TEST_BODY = "Test Message";
+   static final Map<String, Object> TEST_PROPERTIES;
+
+   static final String ASSERT_SENT_FORMAT = "Message should have been sent to %s";
+   static final String ASSERT_RECEIVED_FORMAT = "Message should have been received from %s";
+   static final String ASSERT_COUNT_FORMAT = "Unexpected message count in queue %s";
+
+   static {
+      TEST_PROPERTIES = new HashMap<String, Object>(2);
+      TEST_PROPERTIES.put("PropertyOne", "Property Value 1");
+      TEST_PROPERTIES.put("PropertyTwo", "Property Value 2");
+   }
+
+   EmbeddedActiveMQResource server = new EmbeddedActiveMQResource();
+
+   ActiveMQDynamicProducerResource producer = new ActiveMQDynamicProducerResource(server.getVmURL());
+
+   @Rule
+   public RuleChain ruleChain = RuleChain.outerRule(server).around(producer);
+
+   ClientMessage sentOne = null;
+   ClientMessage sentTwo = null;
+
+   @Before
+   public void setUp() throws Exception {
+      producer.setAutoCreateQueue(false);
+      server.createQueue(TEST_QUEUE_ONE, TEST_QUEUE_ONE);
+      server.createQueue(TEST_QUEUE_TWO, TEST_QUEUE_TWO);
+   }
+
+   @After
+   public void tearDown() throws Exception {
+      assertNotNull(String.format(ASSERT_SENT_FORMAT, TEST_QUEUE_ONE), sentOne);
+      assertNotNull(String.format(ASSERT_SENT_FORMAT, TEST_QUEUE_TWO), sentTwo);
+      assertEquals(String.format(ASSERT_COUNT_FORMAT, TEST_QUEUE_ONE), 1, server.getMessageCount(TEST_QUEUE_ONE));
+      assertEquals(String.format(ASSERT_COUNT_FORMAT, TEST_QUEUE_TWO), 1, server.getMessageCount(TEST_QUEUE_TWO));
+
+      ClientMessage receivedOne = server.receiveMessage(TEST_QUEUE_ONE);
+      assertNotNull(String.format(ASSERT_RECEIVED_FORMAT, TEST_QUEUE_ONE), receivedOne);
+
+      ClientMessage receivedTwo = server.receiveMessage(TEST_QUEUE_TWO);
+      assertNotNull(String.format(ASSERT_RECEIVED_FORMAT, TEST_QUEUE_TWO), receivedTwo);
+   }
+
+   @Test
+   public void testSendBytes() throws Exception {
+      sentOne = producer.sendMessage(TEST_QUEUE_ONE, TEST_BODY.getBytes());
+      sentTwo = producer.sendMessage(TEST_QUEUE_TWO, TEST_BODY.getBytes());
+   }
+
+   @Test
+   public void testSendString() throws Exception {
+      sentOne = producer.sendMessage(TEST_QUEUE_ONE, TEST_BODY);
+      sentTwo = producer.sendMessage(TEST_QUEUE_TWO, TEST_BODY);
+   }
+
+   @Test
+   public void testSendBytesAndProperties() throws Exception {
+      sentOne = producer.sendMessage(TEST_QUEUE_ONE, TEST_BODY.getBytes(), TEST_PROPERTIES);
+      sentTwo = producer.sendMessage(TEST_QUEUE_TWO, TEST_BODY.getBytes(), TEST_PROPERTIES);
+   }
+
+   @Test
+   public void testSendStringAndProperties() throws Exception {
+      sentOne = producer.sendMessage(TEST_QUEUE_ONE, TEST_BODY, TEST_PROPERTIES);
+      sentTwo = producer.sendMessage(TEST_QUEUE_TWO, TEST_BODY, TEST_PROPERTIES);
+   }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/db095926/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQProducerResourceTest.java
----------------------------------------------------------------------
diff --git a/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQProducerResourceTest.java b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQProducerResourceTest.java
new file mode 100644
index 0000000..b0fd086
--- /dev/null
+++ b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/ActiveMQProducerResourceTest.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF 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.junit;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.api.core.client.ClientMessage;
+import org.junit.After;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.RuleChain;
+
+import static org.junit.Assert.assertNotNull;
+
+public class ActiveMQProducerResourceTest {
+
+   static final SimpleString TEST_QUEUE = new SimpleString("test.queue");
+   static final SimpleString TEST_ADDRESS = new SimpleString("test.queue");
+   static final String TEST_BODY = "Test Message";
+   static final Map<String, Object> TEST_PROPERTIES;
+
+   static final String ASSERT_SENT_FORMAT = "Message should have been sent to %s";
+   static final String ASSERT_RECEIVED_FORMAT = "Message should have been received from %s";
+   static final String ASSERT_COUNT_FORMAT = "Unexpected message count in queue %s";
+
+   static {
+      TEST_PROPERTIES = new HashMap<String, Object>(2);
+      TEST_PROPERTIES.put("PropertyOne", "Property Value 1");
+      TEST_PROPERTIES.put("PropertyTwo", "Property Value 2");
+   }
+
+   EmbeddedActiveMQResource server = new EmbeddedActiveMQResource();
+
+   ActiveMQProducerResource producer = new ActiveMQProducerResource(server.getVmURL(), TEST_ADDRESS);
+
+   @Rule
+   public RuleChain ruleChain = RuleChain.outerRule(server).around(producer);
+
+   ClientMessage sent = null;
+
+   @After
+   public void checkResults() throws Exception {
+      assertNotNull(String.format(ASSERT_SENT_FORMAT, TEST_ADDRESS), sent);
+
+      ClientMessage received = server.receiveMessage(TEST_QUEUE);
+      assertNotNull(String.format(ASSERT_RECEIVED_FORMAT, TEST_QUEUE), received);
+   }
+
+   @Test
+   public void testSendBytes() throws Exception {
+      sent = producer.sendMessage(TEST_BODY.getBytes());
+   }
+
+   @Test
+   public void testSendString() throws Exception {
+      sent = producer.sendMessage(TEST_BODY);
+   }
+
+   @Test
+   public void testSendBytesAndProperties() throws Exception {
+      sent = producer.sendMessage(TEST_BODY.getBytes(), TEST_PROPERTIES);
+   }
+
+   @Test
+   public void testSendStringAndProperties() throws Exception {
+      sent = producer.sendMessage(TEST_BODY, TEST_PROPERTIES);
+   }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/db095926/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResourceCustomConfigurationTest.java
----------------------------------------------------------------------
diff --git a/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResourceCustomConfigurationTest.java b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResourceCustomConfigurationTest.java
new file mode 100644
index 0000000..13a6f52
--- /dev/null
+++ b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResourceCustomConfigurationTest.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF 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.junit;
+
+import java.util.List;
+
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
+import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
+import org.apache.activemq.artemis.core.server.Queue;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class EmbeddedActiveMQResourceCustomConfigurationTest {
+   static final String TEST_QUEUE = "test.queue";
+   static final String TEST_ADDRESS = "test.address";
+
+   CoreQueueConfiguration queueConfiguration = new CoreQueueConfiguration().setAddress(TEST_ADDRESS).setName(TEST_QUEUE);
+   Configuration customConfiguration = new ConfigurationImpl().setPersistenceEnabled(false).setSecurityEnabled(true).addQueueConfiguration(queueConfiguration);
+
+   @Rule
+   public EmbeddedActiveMQResource server = new EmbeddedActiveMQResource(customConfiguration);
+
+   @Test
+   public void testCustomConfiguration() throws Exception {
+      Configuration configuration = server.getServer().getActiveMQServer().getConfiguration();
+
+      assertFalse("Persistence should have been disabled", configuration.isPersistenceEnabled());
+      assertTrue( "Security should have been enabled", configuration.isSecurityEnabled());
+
+      assertNotNull(TEST_QUEUE + " should exist", server.locateQueue(TEST_QUEUE));
+
+      List<Queue> boundQueues = server.getBoundQueues(TEST_ADDRESS);
+      assertNotNull("List should never be null", boundQueues);
+      assertEquals("Should have one queue bound to address " + TEST_ADDRESS, 1, boundQueues.size());
+   }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/db095926/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResourceFileConfigurationTest.java
----------------------------------------------------------------------
diff --git a/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResourceFileConfigurationTest.java b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResourceFileConfigurationTest.java
new file mode 100644
index 0000000..80ed251
--- /dev/null
+++ b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResourceFileConfigurationTest.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF 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.junit;
+
+import java.util.List;
+
+import org.apache.activemq.artemis.core.server.Queue;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class EmbeddedActiveMQResourceFileConfigurationTest {
+
+   // These values must match the contents of the configuration file
+   static final String TEST_QUEUE = "test.queue";
+   static final String TEST_ADDRESS = "test.address";
+
+   @Rule
+   public EmbeddedActiveMQResource server = new EmbeddedActiveMQResource("embedded-artemis-server.xml");
+
+   @Test
+   public void testConfiguredQueue() throws Exception {
+      assertNotNull(TEST_QUEUE + " should exist", server.locateQueue(TEST_QUEUE));
+
+      List<Queue> boundQueues = server.getBoundQueues(TEST_ADDRESS);
+      assertNotNull("List should never be null", boundQueues);
+      assertEquals("Should have one queue bound to address " + TEST_ADDRESS, 1, boundQueues.size());
+   }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/db095926/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResourceTest.java
----------------------------------------------------------------------
diff --git a/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResourceTest.java b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResourceTest.java
new file mode 100644
index 0000000..876695d
--- /dev/null
+++ b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedActiveMQResourceTest.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF 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.junit;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.api.core.client.ClientMessage;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class EmbeddedActiveMQResourceTest {
+
+   static final SimpleString TEST_QUEUE = new SimpleString("test.queue");
+   static final SimpleString TEST_ADDRESS = new SimpleString("test.queueName");
+   static final String TEST_BODY = "Test Message";
+   static final Map<String, Object> TEST_PROPERTIES;
+
+   static final String ASSERT_SENT_FORMAT = "Message should have been sent to %s";
+   static final String ASSERT_RECEIVED_FORMAT = "Message should have been received from %s";
+   static final String ASSERT_COUNT_FORMAT = "Unexpected message count in queue %s";
+
+   static {
+      TEST_PROPERTIES = new HashMap<String, Object>(2);
+      TEST_PROPERTIES.put("PropertyOne", "Property Value 1");
+      TEST_PROPERTIES.put("PropertyTwo", "Property Value 2");
+   }
+
+   @Rule
+   public EmbeddedActiveMQResource server = new EmbeddedActiveMQResource();
+
+   ClientMessage sent = null;
+
+   @Before
+   public void setUp() throws Exception {
+      server.createQueue(TEST_ADDRESS, TEST_QUEUE);
+   }
+
+   @After
+   public void tearDown() throws Exception {
+      assertNotNull(String.format(ASSERT_SENT_FORMAT, TEST_ADDRESS), sent);
+      assertEquals(String.format(ASSERT_COUNT_FORMAT, TEST_QUEUE), 1, server.getMessageCount(TEST_QUEUE));
+
+      ClientMessage received = server.receiveMessage(TEST_QUEUE);
+      assertNotNull(String.format(ASSERT_RECEIVED_FORMAT, TEST_ADDRESS), received);
+   }
+
+   @Test
+   public void testSendBytes() throws Exception {
+      sent = server.sendMessage(TEST_ADDRESS, TEST_BODY.getBytes());
+   }
+
+   @Test
+   public void testSendString() throws Exception {
+      sent = server.sendMessage(TEST_ADDRESS, TEST_BODY);
+   }
+
+   @Test
+   public void testSendBytesAndProperties() throws Exception {
+      sent = server.sendMessageWithProperties(TEST_ADDRESS, TEST_BODY.getBytes(), TEST_PROPERTIES);
+   }
+
+   @Test
+   public void testSendStringAndProperties() throws Exception {
+      sent = server.sendMessageWithProperties(TEST_ADDRESS, TEST_BODY, TEST_PROPERTIES);
+   }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/db095926/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedJMSResourceMultipleFileConfigurationTest.java
----------------------------------------------------------------------
diff --git a/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedJMSResourceMultipleFileConfigurationTest.java b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedJMSResourceMultipleFileConfigurationTest.java
new file mode 100644
index 0000000..aa96ab7
--- /dev/null
+++ b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedJMSResourceMultipleFileConfigurationTest.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF 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.junit;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Session;
+import java.util.List;
+
+import org.apache.activemq.artemis.core.server.Queue;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
+import org.apache.activemq.artemis.jms.client.ActiveMQMessageConsumer;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class EmbeddedJMSResourceMultipleFileConfigurationTest {
+
+   static final String TEST_QUEUE = "queue://test.queue";
+   static final String TEST_TOPIC = "topic://test.topic";
+   static final String TEST_BODY = "Test Message";
+
+   static final String ASSERT_PUSHED_FORMAT = "Message should have been pushed a message to %s";
+   static final String ASSERT_COUNT_FORMAT = "Unexpected message count in destination %s";
+
+   @Rule
+   public EmbeddedJMSResource jmsServer = new EmbeddedJMSResource("embedded-artemis-minimal-server.xml", "embedded-artemis-jms-only.xml");
+
+   ConnectionFactory connectionFactory;
+   Connection connection;
+   Session session;
+   ActiveMQMessageConsumer consumer;
+
+   @Before
+   public void setUp() throws Exception {
+      connectionFactory = new ActiveMQConnectionFactory(jmsServer.getVmURL());
+      connection = connectionFactory.createConnection();
+      session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      consumer = (ActiveMQMessageConsumer) session.createConsumer(ActiveMQDestination.createDestination(TEST_TOPIC, ActiveMQDestination.TOPIC_TYPE));
+      connection.start();
+   }
+
+   @After
+   public void tearDown() throws Exception {
+      consumer.close();
+      session.close();
+      connection.close();
+   }
+
+   @Test
+   public void testConfiguration() throws Exception {
+      assertNotNull("Queue should have been created", jmsServer.getDestinationQueue(TEST_QUEUE));
+      assertNotNull("Topic should have been created", jmsServer.getDestinationQueue(TEST_TOPIC));
+
+      List<Queue> boundQueues = jmsServer.getTopicQueues(TEST_TOPIC);
+      assertNotNull("List should never be null", boundQueues);
+      assertEquals("Should have two queues bound to topic " + TEST_TOPIC, 2, boundQueues.size());
+   }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/db095926/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedJMSResourceQueueTest.java
----------------------------------------------------------------------
diff --git a/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedJMSResourceQueueTest.java b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedJMSResourceQueueTest.java
new file mode 100644
index 0000000..19b04aa
--- /dev/null
+++ b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedJMSResourceQueueTest.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF 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.junit;
+
+import javax.jms.Message;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.After;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class EmbeddedJMSResourceQueueTest {
+
+   static final String TEST_DESTINATION_NAME = "queue://test.queue";
+   static final String TEST_BODY = "Test Message";
+   static final Map<String, Object> TEST_MAP_BODY;
+   static final Map<String, Object> TEST_PROPERTIES;
+
+   static final String ASSERT_PUSHED_FORMAT = "Message should have been pushed a message to %s";
+   static final String ASSERT_COUNT_FORMAT = "Unexpected message count in destination %s";
+
+   static {
+      TEST_MAP_BODY = new HashMap<>(2);
+      TEST_MAP_BODY.put("Element 1", "Value 1");
+      TEST_MAP_BODY.put("Element 2", "Value 2");
+
+      TEST_PROPERTIES = new HashMap<String, Object>(2);
+      TEST_PROPERTIES.put("PropertyOne", "Property Value 1");
+      TEST_PROPERTIES.put("PropertyTwo", "Property Value 2");
+   }
+
+   @Rule
+   public EmbeddedJMSResource jmsServer = new EmbeddedJMSResource();
+
+   Message pushed = null;
+
+   @After
+   public void tearDown() throws Exception {
+      assertNotNull(String.format(ASSERT_PUSHED_FORMAT, TEST_DESTINATION_NAME), pushed);
+      assertEquals(String.format(ASSERT_COUNT_FORMAT, TEST_DESTINATION_NAME), 1, jmsServer.getMessageCount(TEST_DESTINATION_NAME));
+   }
+
+   @Test
+   public void testPushBytesMessage() throws Exception {
+      pushed = jmsServer.pushMessage(TEST_DESTINATION_NAME, TEST_BODY.getBytes());
+   }
+
+   @Test
+   public void testPushTextMessage() throws Exception {
+      pushed = jmsServer.pushMessage(TEST_DESTINATION_NAME, TEST_BODY);
+   }
+
+   @Test
+   public void testPushMapMessage() throws Exception {
+      pushed = jmsServer.pushMessage(TEST_DESTINATION_NAME, TEST_MAP_BODY);
+   }
+
+   @Test
+   public void testPushObjectMessage() throws Exception {
+      pushed = jmsServer.pushMessage(TEST_DESTINATION_NAME, (Serializable) TEST_BODY);
+   }
+
+   @Test
+   public void testPushBytesMessageWithProperties() throws Exception {
+      pushed = jmsServer.pushMessageWithProperties(TEST_DESTINATION_NAME, TEST_BODY.getBytes(), TEST_PROPERTIES);
+   }
+
+   @Test
+   public void testPushTextMessageWithProperties() throws Exception {
+      pushed = jmsServer.pushMessageWithProperties(TEST_DESTINATION_NAME, TEST_BODY, TEST_PROPERTIES);
+   }
+
+   @Test
+   public void testPushMapMessageWithProperties() throws Exception {
+      pushed = jmsServer.pushMessageWithProperties(TEST_DESTINATION_NAME, TEST_MAP_BODY, TEST_PROPERTIES);
+   }
+
+   @Test
+   public void testPushObjectMessageWithProperties() throws Exception {
+      pushed = jmsServer.pushMessageWithProperties(TEST_DESTINATION_NAME, (Serializable) TEST_BODY, TEST_PROPERTIES);
+   }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/db095926/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedJMSResourceSingleFileConfigurationTest.java
----------------------------------------------------------------------
diff --git a/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedJMSResourceSingleFileConfigurationTest.java b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedJMSResourceSingleFileConfigurationTest.java
new file mode 100644
index 0000000..cdcbcaa
--- /dev/null
+++ b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedJMSResourceSingleFileConfigurationTest.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF 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.junit;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Session;
+import java.util.List;
+
+import org.apache.activemq.artemis.core.server.Queue;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
+import org.apache.activemq.artemis.jms.client.ActiveMQMessageConsumer;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class EmbeddedJMSResourceSingleFileConfigurationTest {
+
+   static final String TEST_QUEUE = "queue://test.queue";
+   static final String TEST_TOPIC = "topic://test.topic";
+   static final String TEST_BODY = "Test Message";
+
+   static final String ASSERT_PUSHED_FORMAT = "Message should have been pushed a message to %s";
+   static final String ASSERT_COUNT_FORMAT = "Unexpected message count in destination %s";
+
+   @Rule
+   public EmbeddedJMSResource jmsServer = new EmbeddedJMSResource("embedded-artemis-jms-server.xml");
+
+   ConnectionFactory connectionFactory;
+   Connection connection;
+   Session session;
+   ActiveMQMessageConsumer consumer;
+
+   @Before
+   public void setUp() throws Exception {
+      connectionFactory = new ActiveMQConnectionFactory(jmsServer.getVmURL());
+      connection = connectionFactory.createConnection();
+      session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      consumer = (ActiveMQMessageConsumer) session.createConsumer(ActiveMQDestination.createDestination(TEST_TOPIC, ActiveMQDestination.TOPIC_TYPE));
+      connection.start();
+   }
+
+   @After
+   public void tearDown() throws Exception {
+      consumer.close();
+      session.close();
+      connection.close();
+   }
+
+   @Test
+   public void testConfiguration() throws Exception {
+      assertNotNull("Queue should have been created", jmsServer.getDestinationQueue(TEST_QUEUE));
+      assertNotNull("Topic should have been created", jmsServer.getDestinationQueue(TEST_TOPIC));
+
+      List<Queue> boundQueues = jmsServer.getTopicQueues(TEST_TOPIC);
+      assertNotNull("List should never be null", boundQueues);
+      assertEquals("Should have two queues bound to topic " + TEST_TOPIC, 2, boundQueues.size());
+   }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/db095926/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedJMSResourceTopicTest.java
----------------------------------------------------------------------
diff --git a/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedJMSResourceTopicTest.java b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedJMSResourceTopicTest.java
new file mode 100644
index 0000000..d4dd738
--- /dev/null
+++ b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/EmbeddedJMSResourceTopicTest.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF 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.junit;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.Session;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class EmbeddedJMSResourceTopicTest {
+
+   static final String TEST_DESTINATION_NAME = "topic://test.topic";
+   static final String TEST_BODY = "Test Message";
+   static final Map<String, Object> TEST_MAP_BODY;
+   static final Map<String, Object> TEST_PROPERTIES;
+
+   static final String ASSERT_PUSHED_FORMAT = "Message should have been pushed a message to %s";
+   static final String ASSERT_COUNT_FORMAT = "Unexpected message count in destination %s";
+
+   static {
+      TEST_MAP_BODY = new HashMap<>(2);
+      TEST_MAP_BODY.put("Element 1", "Value 1");
+      TEST_MAP_BODY.put("Element 2", "Value 2");
+
+      TEST_PROPERTIES = new HashMap<String, Object>(2);
+      TEST_PROPERTIES.put("PropertyOne", "Property Value 1");
+      TEST_PROPERTIES.put("PropertyTwo", "Property Value 2");
+   }
+
+   @Rule
+   public EmbeddedJMSResource jmsServer = new EmbeddedJMSResource();
+
+   Message pushed = null;
+
+   ConnectionFactory connectionFactory;
+   Connection connection;
+   Session session;
+   MessageConsumer consumer;
+
+   @Before
+   public void setUp() throws Exception {
+      connectionFactory = new ActiveMQConnectionFactory(jmsServer.getVmURL());
+      connection = connectionFactory.createConnection();
+      session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      consumer = session.createConsumer(ActiveMQDestination.createDestination(TEST_DESTINATION_NAME, ActiveMQDestination.TOPIC_TYPE));
+      connection.start();
+   }
+
+   @After
+   public void tearDown() throws Exception {
+      assertNotNull(String.format(ASSERT_PUSHED_FORMAT, TEST_DESTINATION_NAME), pushed);
+      assertEquals(String.format(ASSERT_COUNT_FORMAT, TEST_DESTINATION_NAME), 1, jmsServer.getMessageCount(TEST_DESTINATION_NAME));
+
+      consumer.close();
+      session.close();
+      connection.close();
+   }
+
+   @Test
+   public void testPushBytesMessage() throws Exception {
+      pushed = jmsServer.pushMessage(TEST_DESTINATION_NAME, TEST_BODY.getBytes());
+   }
+
+   @Test
+   public void testPushTextMessage() throws Exception {
+      pushed = jmsServer.pushMessage(TEST_DESTINATION_NAME, TEST_BODY);
+   }
+
+   @Test
+   public void testPushMapMessage() throws Exception {
+      pushed = jmsServer.pushMessage(TEST_DESTINATION_NAME, TEST_MAP_BODY);
+   }
+
+   @Test
+   public void testPushObjectMessage() throws Exception {
+      pushed = jmsServer.pushMessage(TEST_DESTINATION_NAME, (Serializable) TEST_BODY);
+   }
+
+   @Test
+   public void testPushBytesMessageWithProperties() throws Exception {
+      pushed = jmsServer.pushMessageWithProperties(TEST_DESTINATION_NAME, TEST_BODY.getBytes(), TEST_PROPERTIES);
+   }
+
+   @Test
+   public void testPushTextMessageWithProperties() throws Exception {
+      pushed = jmsServer.pushMessageWithProperties(TEST_DESTINATION_NAME, TEST_BODY, TEST_PROPERTIES);
+   }
+
+   @Test
+   public void testPushMapMessageWithProperties() throws Exception {
+      pushed = jmsServer.pushMessageWithProperties(TEST_DESTINATION_NAME, TEST_MAP_BODY, TEST_PROPERTIES);
+   }
+
+   @Test
+   public void testPushObjectMessageWithProperties() throws Exception {
+      pushed = jmsServer.pushMessageWithProperties(TEST_DESTINATION_NAME, (Serializable) TEST_BODY, TEST_PROPERTIES);
+   }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/db095926/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/MultipleEmbeddedActiveMQResourcesTest.java
----------------------------------------------------------------------
diff --git a/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/MultipleEmbeddedActiveMQResourcesTest.java b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/MultipleEmbeddedActiveMQResourcesTest.java
new file mode 100644
index 0000000..97f1f5b
--- /dev/null
+++ b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/MultipleEmbeddedActiveMQResourcesTest.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF 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.junit;
+
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.api.core.client.ClientMessage;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+
+public class MultipleEmbeddedActiveMQResourcesTest {
+
+   static final SimpleString TEST_QUEUE_ONE = new SimpleString("test.queue.one");
+   static final SimpleString TEST_QUEUE_TWO = new SimpleString("test.queue.two");
+   static final SimpleString TEST_ADDRESS_ONE = new SimpleString("test.address.one");
+   static final SimpleString TEST_ADDRESS_TWO = new SimpleString("test.address.two");
+
+   static final String TEST_BODY = "Test Message";
+
+   static final String ASSERT_SENT_FORMAT = "Message should have been sent to %s";
+   static final String ASSERT_RECEIVED_FORMAT = "Message should have been received from %s";
+   static final String ASSERT_COUNT_FORMAT = "Unexpected message count in queue %s";
+
+   @Rule
+   public EmbeddedActiveMQResource serverOne = new EmbeddedActiveMQResource(0);
+
+   @Rule
+   public EmbeddedActiveMQResource serverTwo = new EmbeddedActiveMQResource(1);
+
+   @Before
+   public void setUp() throws Exception {
+      serverOne.createQueue(TEST_ADDRESS_ONE, TEST_QUEUE_ONE);
+      serverTwo.createQueue(TEST_ADDRESS_TWO, TEST_QUEUE_TWO);
+   }
+
+   @Test
+   public void testMultipleServers() throws Exception {
+      ClientMessage sentOne = serverOne.sendMessage(TEST_ADDRESS_ONE, TEST_BODY);
+      assertNotNull(String.format(ASSERT_SENT_FORMAT, TEST_QUEUE_ONE), sentOne);
+
+      ClientMessage receivedOne = serverOne.receiveMessage(TEST_QUEUE_ONE);
+      assertNotNull(String.format(ASSERT_RECEIVED_FORMAT, TEST_QUEUE_TWO), receivedOne);
+
+      ClientMessage sentTwo = serverTwo.sendMessage(TEST_ADDRESS_TWO, TEST_BODY);
+      assertNotNull(String.format(ASSERT_SENT_FORMAT, TEST_QUEUE_TWO), sentOne);
+
+      ClientMessage receivedTwo = serverTwo.receiveMessage(TEST_QUEUE_TWO);
+      assertNotNull(String.format(ASSERT_RECEIVED_FORMAT, TEST_QUEUE_TWO), receivedOne);
+   }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/db095926/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/MultipleEmbeddedJMSResourcesTest.java
----------------------------------------------------------------------
diff --git a/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/MultipleEmbeddedJMSResourcesTest.java b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/MultipleEmbeddedJMSResourcesTest.java
new file mode 100644
index 0000000..1a5381c
--- /dev/null
+++ b/artemis-junit/src/test/java/org/apache/activemq/artemis/junit/MultipleEmbeddedJMSResourcesTest.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF 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.junit;
+
+import javax.jms.Message;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class MultipleEmbeddedJMSResourcesTest {
+
+   static final String TEST_QUEUE_ONE = "queue://test.queue.one";
+   static final String TEST_QUEUE_TWO = "queue://test.queue.two";
+   static final String TEST_BODY = "Test Message";
+
+   static final String ASSERT_PUSHED_FORMAT = "Message should have been pushed a message to %s";
+   static final String ASSERT_COUNT_FORMAT = "Unexpected message count in destination %s";
+
+   @Rule
+   public EmbeddedJMSResource jmsServerOne = new EmbeddedJMSResource(0);
+
+   @Rule
+   public EmbeddedJMSResource jmsServerTwo = new EmbeddedJMSResource(1);
+
+   @Test
+   public void testMultipleServers() throws Exception {
+      Message pushedOne = jmsServerOne.pushMessage(TEST_QUEUE_ONE, TEST_BODY);
+      assertNotNull(String.format(ASSERT_PUSHED_FORMAT, TEST_QUEUE_ONE), pushedOne);
+
+      Message pushedTwo = jmsServerTwo.pushMessage(TEST_QUEUE_TWO, TEST_BODY);
+      assertNotNull(String.format(ASSERT_PUSHED_FORMAT, TEST_QUEUE_TWO), pushedTwo);
+
+      assertEquals(String.format(ASSERT_COUNT_FORMAT, TEST_QUEUE_ONE), 1, jmsServerOne.getMessageCount(TEST_QUEUE_ONE));
+      assertEquals(String.format(ASSERT_COUNT_FORMAT, TEST_QUEUE_TWO), 1, jmsServerTwo.getMessageCount(TEST_QUEUE_TWO));
+   }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/db095926/artemis-junit/src/test/resources/embedded-artemis-jms-only.xml
----------------------------------------------------------------------
diff --git a/artemis-junit/src/test/resources/embedded-artemis-jms-only.xml b/artemis-junit/src/test/resources/embedded-artemis-jms-only.xml
new file mode 100644
index 0000000..11d13ba
--- /dev/null
+++ b/artemis-junit/src/test/resources/embedded-artemis-jms-only.xml
@@ -0,0 +1,29 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<configuration xmlns="urn:activemq"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="
+               urn:activemq /schema/artemis-server.xsd
+               urn:activemq:jms /schema/artemis-jms.xsd">
+   <jms xmlns="urn:activemq:jms">
+      <queue name="test.queue" >
+         <durable>true</durable>
+      </queue>
+
+      <topic name="test.topic" />
+   </jms>
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/db095926/artemis-junit/src/test/resources/embedded-artemis-jms-server.xml
----------------------------------------------------------------------
diff --git a/artemis-junit/src/test/resources/embedded-artemis-jms-server.xml b/artemis-junit/src/test/resources/embedded-artemis-jms-server.xml
new file mode 100644
index 0000000..fda43dd
--- /dev/null
+++ b/artemis-junit/src/test/resources/embedded-artemis-jms-server.xml
@@ -0,0 +1,40 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<configuration xmlns="urn:activemq"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="
+               urn:activemq /schema/artemis-server.xsd
+               urn:activemq:core /schema/artemis-configuration.xsd
+               urn:activemq:jms /schema/artemis-jms.xsd">
+   <core xmlns="urn:activemq:core">
+      <persistence-enabled>false</persistence-enabled>
+      <security-enabled>false</security-enabled>
+
+      <!-- Acceptors -->
+      <acceptors>
+         <acceptor name="in-vm">vm://0</acceptor>
+      </acceptors>
+   </core>
+
+   <jms xmlns="urn:activemq:jms">
+      <queue name="test.queue" >
+         <durable>true</durable>
+      </queue>
+
+      <topic name="test.topic" />
+   </jms>
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/db095926/artemis-junit/src/test/resources/embedded-artemis-minimal-server.xml
----------------------------------------------------------------------
diff --git a/artemis-junit/src/test/resources/embedded-artemis-minimal-server.xml b/artemis-junit/src/test/resources/embedded-artemis-minimal-server.xml
new file mode 100644
index 0000000..451ce53
--- /dev/null
+++ b/artemis-junit/src/test/resources/embedded-artemis-minimal-server.xml
@@ -0,0 +1,31 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<configuration xmlns="urn:activemq"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="
+               urn:activemq /schema/artemis-server.xsd
+               urn:activemq:core /schema/artemis-configuration.xsd">
+   <core xmlns="urn:activemq:core">
+      <persistence-enabled>false</persistence-enabled>
+      <security-enabled>false</security-enabled>
+
+      <!-- Acceptors -->
+      <acceptors>
+         <acceptor name="in-vm">vm://0</acceptor>
+      </acceptors>
+   </core>
+</configuration>
\ No newline at end of file


Mime
View raw message