env = new Hashtable<>();
- env.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
- env.put("java.naming.provider.url", "tcp://localhost:61616");
- context = new InitialContext(env);
- }
- catch (NamingException e) {
- e.printStackTrace();
- }
+
+ }
+
+ @Override
+ public String getName() {
+ return getClass().getName();
}
@Override
@@ -102,23 +102,18 @@ public class ActiveMQAdmin implements Admin {
}
@Override
- public void createConnectionFactory(final String name) {
- createConnection(name, 0);
- }
-
- private void createConnection(final String name, final int cfType) {
- try {
- invokeSyncOperation(ResourceNames.JMS_SERVER, "createConnectionFactory", name, false, false, cfType, "netty", name);
- }
- catch (Exception e) {
- throw new IllegalStateException(e);
- }
-
+ public Context createContext() throws NamingException {
+ return new InitialContext();
}
@Override
- public Context createContext() throws NamingException {
- return context;
+ public void createConnectionFactory(final String name) {
+ throw new RuntimeException("FIXME NYI createConnectionFactory");
+ }
+
+ @Override
+ public void deleteConnectionFactory(final String name) {
+ throw new RuntimeException("FIXME NYI deleteConnectionFactory");
}
@Override
@@ -133,38 +128,6 @@ public class ActiveMQAdmin implements Admin {
}
}
- @Override
- public void createQueueConnectionFactory(final String name) {
- createConnection(name, 1);
- }
-
- @Override
- public void createTopic(final String name) {
- Boolean result;
- try {
- result = (Boolean) invokeSyncOperation(ResourceNames.JMS_SERVER, "createTopic", name, name);
- Assert.assertEquals(true, result.booleanValue());
- }
- catch (Exception e) {
- throw new IllegalStateException(e);
- }
- }
-
- @Override
- public void createTopicConnectionFactory(final String name) {
- createConnection(name, 2);
- }
-
- @Override
- public void deleteConnectionFactory(final String name) {
- try {
- invokeSyncOperation(ResourceNames.JMS_SERVER, "destroyConnectionFactory", name);
- }
- catch (Exception e) {
- throw new IllegalStateException(e);
- }
- }
-
@Override
public void deleteQueue(final String name) {
Boolean result;
@@ -177,11 +140,28 @@ public class ActiveMQAdmin implements Admin {
}
}
+ @Override
+ public void createQueueConnectionFactory(final String name) {
+ createConnectionFactory(name);
+ }
+
@Override
public void deleteQueueConnectionFactory(final String name) {
deleteConnectionFactory(name);
}
+ @Override
+ public void createTopic(final String name) {
+ Boolean result;
+ try {
+ result = (Boolean) invokeSyncOperation(ResourceNames.JMS_SERVER, "createTopic", name, name);
+ Assert.assertEquals(true, result.booleanValue());
+ }
+ catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
@Override
public void deleteTopic(final String name) {
Boolean result;
@@ -195,13 +175,13 @@ public class ActiveMQAdmin implements Admin {
}
@Override
- public void deleteTopicConnectionFactory(final String name) {
- deleteConnectionFactory(name);
+ public void createTopicConnectionFactory(final String name) {
+ createConnectionFactory(name);
}
@Override
- public String getName() {
- return this.getClass().getName();
+ public void deleteTopicConnectionFactory(final String name) {
+ deleteConnectionFactory(name);
}
@Override
@@ -210,37 +190,42 @@ public class ActiveMQAdmin implements Admin {
return;
}
- String[] vmArgs = new String[]{};
- serverProcess = SpawnedVMSupport.spawnVM(SpawnedJMSServer.class.getName(), vmArgs, false);
- InputStreamReader isr = new InputStreamReader(serverProcess.getInputStream());
+ if (spawnServer) {
+ String[] vmArgs = new String[]{};
+ serverProcess = SpawnedVMSupport.spawnVM(SpawnedJMSServer.class.getName(), vmArgs, false);
+ InputStreamReader isr = new InputStreamReader(serverProcess.getInputStream());
- final BufferedReader br = new BufferedReader(isr);
- String line = null;
- while ((line = br.readLine()) != null) {
- System.out.println("SERVER: " + line);
- if ("OK".equals(line.trim())) {
- new Thread() {
- @Override
- public void run() {
- try {
- String line1 = null;
- while ((line1 = br.readLine()) != null) {
- System.out.println("SERVER: " + line1);
+ final BufferedReader br = new BufferedReader(isr);
+ String line = null;
+ while ((line = br.readLine()) != null) {
+ System.out.println("SERVER: " + line);
+ if ("OK".equals(line.trim())) {
+ new Thread() {
+ @Override
+ public void run() {
+ try {
+ String line1 = null;
+ while ((line1 = br.readLine()) != null) {
+ System.out.println("SERVER: " + line1);
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
}
}
- catch (Exception e) {
- e.printStackTrace();
- }
- }
- }.start();
- return;
- }
- else if ("KO".equals(line.trim())) {
- // something went wrong with the server, destroy it:
- serverProcess.destroy();
- throw new IllegalStateException("Unable to start the spawned server :" + line);
+ }.start();
+ return;
+ }
+ else if ("KO".equals(line.trim())) {
+ // something went wrong with the server, destroy it:
+ serverProcess.destroy();
+ throw new IllegalStateException("Unable to start the spawned server :" + line);
+ }
}
}
+ else {
+ SpawnedJMSServer.startServer();
+ }
}
@Override
@@ -248,18 +233,23 @@ public class ActiveMQAdmin implements Admin {
if (!serverLifeCycleActive) {
return;
}
- OutputStreamWriter osw = new OutputStreamWriter(serverProcess.getOutputStream());
- osw.write("STOP\n");
- osw.flush();
- int exitValue = serverProcess.waitFor();
- if (exitValue != 0) {
- serverProcess.destroy();
+ if (spawnServer) {
+ OutputStreamWriter osw = new OutputStreamWriter(serverProcess.getOutputStream());
+ osw.write("STOP\n");
+ osw.flush();
+ int exitValue = serverProcess.waitFor();
+ if (exitValue != 0) {
+ serverProcess.destroy();
+ }
+ }
+ else {
+ SpawnedJMSServer.stopServer();
}
}
- private Object invokeSyncOperation(final String resourceName,
- final String operationName,
- final Object... parameters) throws Exception {
+ protected Object invokeSyncOperation(final String resourceName,
+ final String operationName,
+ final Object... parameters) throws Exception {
ClientMessage message = clientSession.createMessage(false);
ManagementHelper.putOperationInvocation(message, resourceName, operationName, parameters);
ClientMessage reply;
@@ -282,6 +272,4 @@ public class ActiveMQAdmin implements Admin {
return ManagementHelper.getResult(reply);
}
- // Inner classes -------------------------------------------------
-
}
diff --git a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/SpawnedJMSServer.java b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/SpawnedJMSServer.java
similarity index 68%
rename from tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/SpawnedJMSServer.java
rename to tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/SpawnedJMSServer.java
index 205ac7fd6a..8e63326965 100644
--- a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/SpawnedJMSServer.java
+++ b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/SpawnedJMSServer.java
@@ -14,38 +14,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.activemq.artemis.jms;
+package org.apache.activemq.artemis.common;
import java.io.BufferedReader;
+import java.io.File;
import java.io.InputStreamReader;
-import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
-import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory;
-import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServers;
import org.apache.activemq.artemis.jms.server.JMSServerManager;
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
+import org.apache.activemq.artemis.utils.FileUtil;
public class SpawnedJMSServer {
- // Constants -----------------------------------------------------
- // Attributes ----------------------------------------------------
+ public static ActiveMQServer server;
+ public static JMSServerManager serverManager;
+
+ // Using files may be useful for debugging (through print-data for instance)
+ private static final boolean useFiles = false;
- // Static --------------------------------------------------------
public static void main(final String[] args) throws Exception {
try {
- Configuration config = new ConfigurationImpl().addAcceptorConfiguration(new TransportConfiguration(NettyAcceptorFactory.class.getName())).setSecurityEnabled(false).addConnectorConfiguration("netty", new TransportConfiguration(NettyConnectorFactory.class.getName()));
-
- // disable server persistence since JORAM tests do not restart server
- final ActiveMQServer server = ActiveMQServers.newActiveMQServer(config, false);
-
- JMSServerManager serverManager = new JMSServerManagerImpl(server);
- serverManager.start();
+ startServer();
System.out.println("Server started, ready to start client test");
@@ -59,7 +54,7 @@ public class SpawnedJMSServer {
String line = null;
while ((line = br.readLine()) != null) {
if ("STOP".equals(line.trim())) {
- server.stop();
+ stopServer();
System.out.println("Server stopped");
System.exit(0);
}
@@ -82,6 +77,35 @@ public class SpawnedJMSServer {
}
}
+ public static ActiveMQServer startServer() throws Exception {
+ if (server == null) {
+ Configuration config = new ConfigurationImpl().addAcceptorConfiguration("netty", "tcp://localhost:61616").setSecurityEnabled(false).addConnectorConfiguration("netty", "tcp://localhost:61616");
+ File dataPlace = new File("./target/dataJoram");
+
+ FileUtil.deleteDirectory(dataPlace);
+
+ config.setJournalDirectory(new File(dataPlace, "./journal").getAbsolutePath()).
+ setPagingDirectory(new File(dataPlace, "./paging").getAbsolutePath()).
+ setLargeMessagesDirectory(new File(dataPlace, "./largemessages").getAbsolutePath()).
+ setBindingsDirectory(new File(dataPlace, "./bindings").getAbsolutePath()).setPersistenceEnabled(true);
+
+ // disable server persistence since JORAM tests do not restart server
+ server = ActiveMQServers.newActiveMQServer(config, useFiles);
+
+ serverManager = new JMSServerManagerImpl(server);
+ serverManager.start();
+ }
+ return server;
+ }
+
+ public static void stopServer() throws Exception {
+ if (server != null) {
+ serverManager.stop();
+ }
+ server = null;
+ serverManager = null;
+ }
+
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
diff --git a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/testjndi/TestContext.java b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/testjndi/TestContext.java
new file mode 100644
index 0000000000..9daecd8720
--- /dev/null
+++ b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/testjndi/TestContext.java
@@ -0,0 +1,482 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF 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.common.testjndi;
+
+import javax.naming.Binding;
+import javax.naming.CompositeName;
+import javax.naming.Context;
+import javax.naming.LinkRef;
+import javax.naming.Name;
+import javax.naming.NameClassPair;
+import javax.naming.NameNotFoundException;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.NotContextException;
+import javax.naming.OperationNotSupportedException;
+import javax.naming.Reference;
+import javax.naming.spi.NamingManager;
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.activemq.artemis.core.client.ActiveMQClientLogger;
+import org.apache.activemq.artemis.jndi.NameParserImpl;
+
+/**
+ * A read-only Context
+ *
+ * This version assumes it and all its subcontext are
+ * read-only and any attempt to modify (e.g. through bind) will result in an
+ * OperationNotSupportedException. Each Context in the tree builds a cache of
+ * the entries in all sub-contexts to optimise the performance of lookup.
+ *
+ *
+ * This implementation is intended to optimise the performance of lookup(String)
+ * to about the level of a HashMap get. It has been observed that the scheme
+ * resolution phase performed by the JVM takes considerably longer, so for
+ * optimum performance lookups should be coded like:
+ *
+ *
+ * Context componentContext = (Context)new InitialContext().lookup("java:comp");
+ * String envEntry = (String) componentContext.lookup("env/myEntry");
+ * String envEntry2 = (String) componentContext.lookup("env/myEntry2");
+ *
+ */
+@SuppressWarnings("unchecked")
+public class TestContext implements Context, Serializable {
+
+ public static final String SEPARATOR = "/";
+ protected static final NameParser NAME_PARSER = new NameParserImpl();
+ private static final long serialVersionUID = -5754338187296859149L;
+
+ protected final Hashtable environment; // environment for this context
+ protected final Map bindings; // bindings at my level
+ protected final Map treeBindings; // all bindings under me
+
+ private boolean frozen;
+ private String nameInNamespace = "";
+
+ public TestContext() {
+ environment = new Hashtable<>();
+ bindings = new HashMap<>();
+ treeBindings = new HashMap<>();
+ }
+
+ public TestContext(Hashtable env) {
+ if (env == null) {
+ this.environment = new Hashtable<>();
+ }
+ else {
+ this.environment = new Hashtable<>(env);
+ }
+ this.bindings = Collections.EMPTY_MAP;
+ this.treeBindings = Collections.EMPTY_MAP;
+ }
+
+ public TestContext(Hashtable environment, Map bindings) {
+ if (environment == null) {
+ this.environment = new Hashtable<>();
+ }
+ else {
+ this.environment = new Hashtable<>(environment);
+ }
+ this.bindings = new HashMap<>();
+ treeBindings = new HashMap<>();
+ if (bindings != null) {
+ for (Map.Entry binding : bindings.entrySet()) {
+ try {
+ internalBind(binding.getKey(), binding.getValue());
+ }
+ catch (Throwable e) {
+ ActiveMQClientLogger.LOGGER.error("Failed to bind " + binding.getKey() + "=" + binding.getValue(), e);
+ }
+ }
+ }
+ frozen = true;
+ }
+
+ public TestContext(Hashtable environment, Map bindings, String nameInNamespace) {
+ this(environment, bindings);
+ this.nameInNamespace = nameInNamespace;
+ }
+
+ protected TestContext(TestContext clone, Hashtable env) {
+ this.bindings = clone.bindings;
+ this.treeBindings = clone.treeBindings;
+ this.environment = new Hashtable<>(env);
+ }
+
+ protected TestContext(TestContext clone, Hashtable env, String nameInNamespace) {
+ this(clone, env);
+ this.nameInNamespace = nameInNamespace;
+ }
+
+ public void freeze() {
+ frozen = true;
+ }
+
+ boolean isFrozen() {
+ return frozen;
+ }
+
+ /**
+ * internalBind is intended for use only during setup or possibly by
+ * suitably synchronized superclasses. It binds every possible lookup into a
+ * map in each context. To do this, each context strips off one name segment
+ * and if necessary creates a new context for it. Then it asks that context
+ * to bind the remaining name. It returns a map containing all the bindings
+ * from the next context, plus the context it just created (if it in fact
+ * created it). (the names are suitably extended by the segment originally
+ * lopped off).
+ *
+ * @param name
+ * @param value
+ * @return
+ * @throws NamingException
+ */
+ protected Map internalBind(String name, Object value) throws NamingException {
+ assert name != null && name.length() > 0;
+
+ Map newBindings = new HashMap<>();
+ int pos = name.indexOf('/');
+ if (pos == -1) {
+ if (treeBindings.put(name, value) != null) {
+ throw new NamingException("Something already bound at " + name);
+ }
+ bindings.put(name, value);
+ newBindings.put(name, value);
+ }
+ else {
+ String segment = name.substring(0, pos);
+ assert segment != null;
+ assert !segment.equals("");
+ Object o = treeBindings.get(segment);
+ if (o == null) {
+ o = newContext();
+ treeBindings.put(segment, o);
+ bindings.put(segment, o);
+ newBindings.put(segment, o);
+ }
+ else if (!(o instanceof TestContext)) {
+ throw new NamingException("Something already bound where a subcontext should go");
+ }
+ TestContext readOnlyContext = (TestContext) o;
+ String remainder = name.substring(pos + 1);
+ Map subBindings = readOnlyContext.internalBind(remainder, value);
+ for (Map.Entry entry : subBindings.entrySet()) {
+ String subName = segment + "/" + entry.getKey();
+ Object bound = entry.getValue();
+ treeBindings.put(subName, bound);
+ newBindings.put(subName, bound);
+ }
+ }
+ return newBindings;
+ }
+
+ protected TestContext newContext() {
+ return new TestContext();
+ }
+
+ @Override
+ public Object addToEnvironment(String propName, Object propVal) throws NamingException {
+ return environment.put(propName, propVal);
+ }
+
+ @Override
+ public Hashtable getEnvironment() throws NamingException {
+ return (Hashtable) environment.clone();
+ }
+
+ @Override
+ public Object removeFromEnvironment(String propName) throws NamingException {
+ return environment.remove(propName);
+ }
+
+ @Override
+ public Object lookup(String name) throws NamingException {
+ if (name.length() == 0) {
+ return this;
+ }
+ Object result = treeBindings.get(name);
+ if (result == null) {
+ result = bindings.get(name);
+ }
+ if (result == null) {
+ int pos = name.indexOf(':');
+ if (pos > 0) {
+ String scheme = name.substring(0, pos);
+ Context ctx = NamingManager.getURLContext(scheme, environment);
+ if (ctx == null) {
+ throw new NamingException("scheme " + scheme + " not recognized");
+ }
+ return ctx.lookup(name);
+ }
+ else {
+ // Split out the first name of the path
+ // and look for it in the bindings map.
+ CompositeName path = new CompositeName(name);
+
+ if (path.size() == 0) {
+ return this;
+ }
+ else {
+ String first = path.get(0);
+ Object obj = bindings.get(first);
+ if (obj == null) {
+ throw new NameNotFoundException(name);
+ }
+ else if (obj instanceof Context && path.size() > 1) {
+ Context subContext = (Context) obj;
+ obj = subContext.lookup(path.getSuffix(1));
+ }
+ return obj;
+ }
+ }
+ }
+ if (result instanceof LinkRef) {
+ LinkRef ref = (LinkRef) result;
+ result = lookup(ref.getLinkName());
+ }
+ if (result instanceof Reference) {
+ try {
+ result = NamingManager.getObjectInstance(result, null, null, this.environment);
+ }
+ catch (NamingException e) {
+ throw e;
+ }
+ catch (Exception e) {
+ throw (NamingException) new NamingException("could not look up : " + name).initCause(e);
+ }
+ }
+ if (result instanceof TestContext) {
+ String prefix = getNameInNamespace();
+ if (prefix.length() > 0) {
+ prefix = prefix + SEPARATOR;
+ }
+ result = new TestContext((TestContext) result, environment, prefix + name);
+ }
+ return result;
+ }
+
+ @Override
+ public Object lookup(Name name) throws NamingException {
+ return lookup(name.toString());
+ }
+
+ @Override
+ public Object lookupLink(String name) throws NamingException {
+ return lookup(name);
+ }
+
+ @Override
+ public Name composeName(Name name, Name prefix) throws NamingException {
+ Name result = (Name) prefix.clone();
+ result.addAll(name);
+ return result;
+ }
+
+ @Override
+ public String composeName(String name, String prefix) throws NamingException {
+ CompositeName result = new CompositeName(prefix);
+ result.addAll(new CompositeName(name));
+ return result.toString();
+ }
+
+ @Override
+ public NamingEnumeration list(String name) throws NamingException {
+ Object o = lookup(name);
+ if (o == this) {
+ return new ListEnumeration();
+ }
+ else if (o instanceof Context) {
+ return ((Context) o).list("");
+ }
+ else {
+ throw new NotContextException();
+ }
+ }
+
+ @Override
+ public NamingEnumeration listBindings(String name) throws NamingException {
+ Object o = lookup(name);
+ if (o == this) {
+ return new ListBindingEnumeration();
+ }
+ else if (o instanceof Context) {
+ return ((Context) o).listBindings("");
+ }
+ else {
+ throw new NotContextException();
+ }
+ }
+
+ @Override
+ public Object lookupLink(Name name) throws NamingException {
+ return lookupLink(name.toString());
+ }
+
+ @Override
+ public NamingEnumeration list(Name name) throws NamingException {
+ return list(name.toString());
+ }
+
+ @Override
+ public NamingEnumeration listBindings(Name name) throws NamingException {
+ return listBindings(name.toString());
+ }
+
+ @Override
+ public void bind(Name name, Object obj) throws NamingException {
+ internalBind(name.toString(), obj);
+ }
+
+ @Override
+ public void bind(String name, Object obj) throws NamingException {
+ internalBind(name, obj);
+ }
+
+ @Override
+ public void close() throws NamingException {
+ // ignore
+ }
+
+ @Override
+ public Context createSubcontext(Name name) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ @Override
+ public Context createSubcontext(String name) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ @Override
+ public void destroySubcontext(Name name) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ @Override
+ public void destroySubcontext(String name) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ @Override
+ public String getNameInNamespace() throws NamingException {
+ return nameInNamespace;
+ }
+
+ @Override
+ public NameParser getNameParser(Name name) throws NamingException {
+ return NAME_PARSER;
+ }
+
+ @Override
+ public NameParser getNameParser(String name) throws NamingException {
+ return NAME_PARSER;
+ }
+
+ @Override
+ public void rebind(Name name, Object obj) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ @Override
+ public void rebind(String name, Object obj) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ @Override
+ public void rename(Name oldName, Name newName) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ @Override
+ public void rename(String oldName, String newName) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ @Override
+ public void unbind(Name name) throws NamingException {
+ treeBindings.remove(name.toString());
+ }
+
+ @Override
+ public void unbind(String name) throws NamingException {
+ treeBindings.remove(name);
+ }
+
+ private abstract class LocalNamingEnumeration implements NamingEnumeration {
+
+ private final Iterator> i = bindings.entrySet().iterator();
+
+ @Override
+ public boolean hasMore() throws NamingException {
+ return i.hasNext();
+ }
+
+ @Override
+ public boolean hasMoreElements() {
+ return i.hasNext();
+ }
+
+ protected Map.Entry getNext() {
+ return i.next();
+ }
+
+ @Override
+ public void close() throws NamingException {
+ }
+ }
+
+ private class ListEnumeration extends LocalNamingEnumeration {
+
+ ListEnumeration() {
+ }
+
+ @Override
+ public Object next() throws NamingException {
+ return nextElement();
+ }
+
+ @Override
+ public Object nextElement() {
+ Map.Entry entry = getNext();
+ return new NameClassPair(entry.getKey(), entry.getValue().getClass().getName());
+ }
+ }
+
+ private class ListBindingEnumeration extends LocalNamingEnumeration {
+
+ ListBindingEnumeration() {
+ }
+
+ @Override
+ public Object next() throws NamingException {
+ return nextElement();
+ }
+
+ @Override
+ public Object nextElement() {
+ Map.Entry entry = getNext();
+ return new Binding(entry.getKey(), entry.getValue());
+ }
+ }
+}
diff --git a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/testjndi/TestContextFactory.java b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/testjndi/TestContextFactory.java
new file mode 100644
index 0000000000..3083fd371f
--- /dev/null
+++ b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/testjndi/TestContextFactory.java
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF 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.common.testjndi;
+
+import javax.jms.ConnectionFactory;
+import javax.jms.Queue;
+import javax.jms.Topic;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.spi.InitialContextFactory;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
+import org.apache.activemq.artemis.jndi.LazyCreateContext;
+import org.apache.activemq.artemis.uri.ConnectionFactoryParser;
+
+/**
+ * A factory of the ActiveMQ Artemis InitialContext which contains
+ * {@link ConnectionFactory} instances as well as a child context called
+ * destinations which contain all of the current active destinations, in
+ * child context depending on the QoS such as transient or durable and queue or
+ * topic.
+ */
+public class TestContextFactory implements InitialContextFactory {
+
+ public static final String REFRESH_TIMEOUT = "refreshTimeout";
+ public static final String DISCOVERY_INITIAL_WAIT_TIMEOUT = "discoveryInitialWaitTimeout";
+ public static final String DYNAMIC_QUEUE_CONTEXT = "dynamicQueues";
+ public static final String DYNAMIC_TOPIC_CONTEXT = "dynamicTopics";
+ private String connectionFactoryPrefix = "connectionFactory.";
+ private String queuePrefix = "queue.";
+ private String topicPrefix = "topic.";
+
+ @Override
+ public Context getInitialContext(Hashtable, ?> environment) throws NamingException {
+ // lets create a factory
+ Map data = new ConcurrentHashMap<>();
+ for (Map.Entry, ?> entry : environment.entrySet()) {
+ String key = entry.getKey().toString();
+ if (key.startsWith(connectionFactoryPrefix)) {
+ String jndiName = key.substring(connectionFactoryPrefix.length());
+ try {
+ ConnectionFactory factory = createConnectionFactory((String) environment.get(key), jndiName);
+ data.put(jndiName, factory);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ throw new NamingException("Invalid broker URL");
+ }
+ }
+ }
+
+ createQueues(data, environment);
+ createTopics(data, environment);
+
+ data.put(DYNAMIC_QUEUE_CONTEXT, new LazyCreateContext() {
+ private static final long serialVersionUID = 6503881346214855588L;
+
+ @Override
+ protected Object createEntry(String name) {
+ return ActiveMQJMSClient.createQueue(name);
+ }
+ });
+ data.put(DYNAMIC_TOPIC_CONTEXT, new LazyCreateContext() {
+ private static final long serialVersionUID = 2019166796234979615L;
+
+ @Override
+ protected Object createEntry(String name) {
+ return ActiveMQJMSClient.createTopic(name);
+ }
+ });
+
+ return createContext(environment, data);
+ }
+
+ // Properties
+ // -------------------------------------------------------------------------
+ public String getTopicPrefix() {
+ return topicPrefix;
+ }
+
+ public void setTopicPrefix(String topicPrefix) {
+ this.topicPrefix = topicPrefix;
+ }
+
+ public String getQueuePrefix() {
+ return queuePrefix;
+ }
+
+ public void setQueuePrefix(String queuePrefix) {
+ this.queuePrefix = queuePrefix;
+ }
+
+ // Implementation methods
+ // -------------------------------------------------------------------------
+
+ protected Context createContext(Hashtable, ?> environment, Map data) {
+ return new TestContext(environment, data);
+ }
+
+ protected void createQueues(Map data, Hashtable, ?> environment) {
+ for (Map.Entry, ?> entry : environment.entrySet()) {
+ String key = entry.getKey().toString();
+ if (key.startsWith(queuePrefix)) {
+ String jndiName = key.substring(queuePrefix.length());
+ data.put(jndiName, createQueue(entry.getValue().toString()));
+ }
+ }
+ }
+
+ protected void createTopics(Map data, Hashtable, ?> environment) {
+ for (Map.Entry, ?> entry : environment.entrySet()) {
+ String key = entry.getKey().toString();
+ if (key.startsWith(topicPrefix)) {
+ String jndiName = key.substring(topicPrefix.length());
+ data.put(jndiName, createTopic(entry.getValue().toString()));
+ }
+ }
+ }
+
+ /**
+ * Factory method to create new Queue instances
+ */
+ protected Queue createQueue(String name) {
+ return ActiveMQJMSClient.createQueue(name);
+ }
+
+ /**
+ * Factory method to create new Topic instances
+ */
+ protected Topic createTopic(String name) {
+ return ActiveMQJMSClient.createTopic(name);
+ }
+
+ /**
+ * Factory method to create a new connection factory from the given environment
+ */
+ protected ConnectionFactory createConnectionFactory(String uri, String name) throws Exception {
+ ConnectionFactoryParser parser = new ConnectionFactoryParser();
+ return parser.newObject(parser.expandURI(uri), name);
+ }
+}
diff --git a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/AbstractAdmin.java b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/AbstractAdmin.java
deleted file mode 100644
index 9088758475..0000000000
--- a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/AbstractAdmin.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.artemis.jms;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.objectweb.jtests.jms.admin.Admin;
-
-/**
- * AbstractAdmin.
- */
-public class AbstractAdmin implements Admin {
-
- @Override
- public String getName() {
- return getClass().getName();
- }
-
- @Override
- public void start() {
- }
-
- @Override
- public void stop() throws Exception {
-
- }
-
- @Override
- public InitialContext createContext() throws NamingException {
- return new InitialContext();
- }
-
- @Override
- public void createConnectionFactory(final String name) {
- throw new RuntimeException("FIXME NYI createConnectionFactory");
- }
-
- @Override
- public void deleteConnectionFactory(final String name) {
- throw new RuntimeException("FIXME NYI deleteConnectionFactory");
- }
-
- @Override
- public void createQueue(final String name) {
- throw new RuntimeException("FIXME NYI createQueue");
- }
-
- @Override
- public void deleteQueue(final String name) {
- throw new RuntimeException("FIXME NYI deleteQueue");
- }
-
- @Override
- public void createQueueConnectionFactory(final String name) {
- createConnectionFactory(name);
- }
-
- @Override
- public void deleteQueueConnectionFactory(final String name) {
- deleteConnectionFactory(name);
- }
-
- @Override
- public void createTopic(final String name) {
- throw new RuntimeException("FIXME NYI createTopic");
- }
-
- @Override
- public void deleteTopic(final String name) {
- throw new RuntimeException("FIXME NYI deleteTopic");
- }
-
- @Override
- public void createTopicConnectionFactory(final String name) {
- createConnectionFactory(name);
- }
-
- @Override
- public void deleteTopicConnectionFactory(final String name) {
- deleteConnectionFactory(name);
- }
-
- @Override
- public void startServer() {
- }
-
- @Override
- public void stopServer() {
- }
-}
diff --git a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/ActiveMQCoreAdmin.java b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/ActiveMQCoreAdmin.java
new file mode 100644
index 0000000000..aca9551ade
--- /dev/null
+++ b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/ActiveMQCoreAdmin.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.jms;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.Hashtable;
+
+import org.apache.activemq.artemis.api.core.management.ResourceNames;
+import org.apache.activemq.artemis.common.AbstractAdmin;
+import org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory;
+
+public class ActiveMQCoreAdmin extends AbstractAdmin {
+
+ private Context context;
+
+ Hashtable jndiProps = new Hashtable<>();
+
+
+
+ public ActiveMQCoreAdmin() {
+ super();
+ jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getCanonicalName());
+ try {
+ Hashtable env = new Hashtable<>();
+ env.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
+ env.put("java.naming.provider.url", "tcp://localhost:61616");
+ context = new InitialContext(env);
+ }
+ catch (NamingException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void start() throws Exception {
+ super.start();
+
+ }
+
+ @Override
+ public void stop() throws Exception {
+ super.stop();
+ }
+
+ @Override
+ public void createConnectionFactory(final String name) {
+ createConnection(name, 0);
+ jndiProps.put("connectionFactory." + name, "tcp://127.0.0.1:61616?type=CF");
+
+ }
+
+ private void createConnection(final String name, final int cfType) {
+ try {
+ invokeSyncOperation(ResourceNames.JMS_SERVER, "createConnectionFactory", name, false, false, cfType, "netty", name);
+ }
+ catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+
+ }
+
+ @Override
+ public Context createContext() throws NamingException {
+ return new InitialContext(jndiProps);
+ }
+
+ @Override
+ public void createQueue(final String name) {
+ super.createQueue(name);
+ jndiProps.put("queue." + name, name);
+ }
+
+ @Override
+ public void createQueueConnectionFactory(final String name) {
+ createConnection(name, 1);
+ jndiProps.put("connectionFactory." + name, "tcp://127.0.0.1:61616?type=QUEUE_CF");
+ }
+
+ @Override
+ public void createTopic(final String name) {
+ super.createTopic(name);
+ jndiProps.put("topic." + name, name);
+ }
+
+ @Override
+ public void createTopicConnectionFactory(final String name) {
+ createConnection(name, 2);
+ jndiProps.put("connectionFactory." + name, "tcp://127.0.0.1:61616?type=TOPIC_CF");
+ }
+
+ @Override
+ public void deleteConnectionFactory(final String name) {
+ try {
+ invokeSyncOperation(ResourceNames.JMS_SERVER, "destroyConnectionFactory", name);
+ jndiProps.remove("connectionFactory." + name);
+ }
+ catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ @Override
+ public void deleteQueue(final String name) {
+ super.deleteQueue(name);
+ jndiProps.remove("queue." + name);
+ }
+
+ @Override
+ public void deleteQueueConnectionFactory(final String name) {
+ deleteConnectionFactory(name);
+ jndiProps.remove("connectionFactory." + name);
+ }
+
+ @Override
+ public void deleteTopic(final String name) {
+ super.deleteTopic(name);
+ jndiProps.remove("topic." + name);
+ }
+
+ @Override
+ public void deleteTopicConnectionFactory(final String name) {
+ deleteConnectionFactory(name);
+ jndiProps.remove("connectionFactory." + name);
+
+ }
+
+ @Override
+ public String getName() {
+ return this.getClass().getName();
+ }
+
+ // Inner classes -------------------------------------------------
+
+}
diff --git a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/GenericAdmin.java b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/GenericAdmin.java
deleted file mode 100644
index 5892ee4b27..0000000000
--- a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/GenericAdmin.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.artemis.jms;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-
-import org.jboss.logging.Logger;
-import org.objectweb.jtests.jms.admin.Admin;
-
-/**
- * GenericAdmin.
- *
- * @FIXME delegate to a JBoss defined admin class
- */
-public class GenericAdmin implements Admin {
-
- public static final Logger log = Logger.getLogger(GenericAdmin.class);
-
- public static Admin delegate = new AbstractAdmin();
-
- @Override
- public String getName() {
- String name = GenericAdmin.delegate.getName();
- GenericAdmin.log.debug("Using admin '" + name + "' delegate=" + GenericAdmin.delegate);
- return name;
- }
-
- @Override
- public void start() throws Exception {
- }
-
- @Override
- public void stop() throws Exception {
- }
-
- @Override
- public Context createContext() throws NamingException {
- Context ctx = GenericAdmin.delegate.createContext();
- GenericAdmin.log.debug("Using initial context: " + ctx.getEnvironment());
- return ctx;
- }
-
- @Override
- public void createConnectionFactory(final String name) {
- GenericAdmin.log.debug("createConnectionFactory '" + name + "'");
- GenericAdmin.delegate.createConnectionFactory(name);
- }
-
- @Override
- public void deleteConnectionFactory(final String name) {
- GenericAdmin.log.debug("deleteConnectionFactory '" + name + "'");
- GenericAdmin.delegate.deleteConnectionFactory(name);
- }
-
- @Override
- public void createQueue(final String name) {
- GenericAdmin.log.debug("createQueue '" + name + "'");
- GenericAdmin.delegate.createQueue(name);
- }
-
- @Override
- public void deleteQueue(final String name) {
- GenericAdmin.log.debug("deleteQueue '" + name + "'");
- GenericAdmin.delegate.deleteQueue(name);
- }
-
- @Override
- public void createQueueConnectionFactory(final String name) {
- GenericAdmin.log.debug("createQueueConnectionFactory '" + name + "'");
- GenericAdmin.delegate.createQueueConnectionFactory(name);
- }
-
- @Override
- public void deleteQueueConnectionFactory(final String name) {
- GenericAdmin.log.debug("deleteQueueConnectionFactory '" + name + "'");
- GenericAdmin.delegate.deleteQueueConnectionFactory(name);
- }
-
- @Override
- public void createTopic(final String name) {
- GenericAdmin.log.debug("createTopic '" + name + "'");
- GenericAdmin.delegate.createTopic(name);
- }
-
- @Override
- public void deleteTopic(final String name) {
- GenericAdmin.log.debug("deleteTopic '" + name + "'");
- GenericAdmin.delegate.deleteTopic(name);
- }
-
- @Override
- public void createTopicConnectionFactory(final String name) {
- GenericAdmin.log.debug("createTopicConnectionFactory '" + name + "'");
- GenericAdmin.delegate.createTopicConnectionFactory(name);
- }
-
- @Override
- public void deleteTopicConnectionFactory(final String name) {
- GenericAdmin.log.debug("deleteTopicConnectionFactory '" + name + "'");
- GenericAdmin.delegate.deleteTopicConnectionFactory(name);
- }
-
- @Override
- public void startServer() throws Exception {
- GenericAdmin.log.debug("startEmbeddedServer");
- GenericAdmin.delegate.startServer();
- }
-
- @Override
- public void stopServer() throws Exception {
- GenericAdmin.log.debug("stopEmbeddedServer");
- GenericAdmin.delegate.stopServer();
- }
-}
diff --git a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/JoramAggregationTest.java b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/JoramCoreAggregationTest.java
similarity index 96%
rename from tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/JoramAggregationTest.java
rename to tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/JoramCoreAggregationTest.java
index c92e4f3358..7448b9ca04 100644
--- a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/JoramAggregationTest.java
+++ b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/JoramCoreAggregationTest.java
@@ -49,7 +49,7 @@ import org.objectweb.jtests.jms.framework.JMSTestCase;
@RunWith(Suite.class)
@SuiteClasses({TopicConnectionTest.class, ConnectionTest.class, MessageBodyTest.class, MessageDefaultTest.class, MessageTypeTest.class, MessageHeaderTest.class, JMSXPropertyTest.class, MessagePropertyConversionTest.class, MessagePropertyTest.class, QueueBrowserTest.class, TemporaryQueueTest.class, SelectorSyntaxTest.class, SelectorTest.class, QueueSessionTest.class, SessionTest.class, TopicSessionTest.class, UnifiedSessionTest.class, TemporaryTopicTest.class,})
-public class JoramAggregationTest extends Assert {
+public class JoramCoreAggregationTest extends Assert {
/**
* Should be overridden
@@ -58,7 +58,7 @@ public class JoramAggregationTest extends Assert {
*/
protected static Properties getProviderProperties() throws IOException {
Properties props = new Properties();
- props.load(ClassLoader.getSystemResourceAsStream(JMSTestCase.PROP_FILE_NAME));
+ props.load(ClassLoader.getSystemResourceAsStream(JMSTestCase.getPropFileName()));
return props;
}
@@ -66,6 +66,7 @@ public class JoramAggregationTest extends Assert {
@BeforeClass
public static void setUpServer() throws Exception {
+ JMSTestCase.setPropFileName("provider.properties");
JMSTestCase.startServer = false;
// Admin step
// gets the provider administration wrapper...
diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/JMSTestCase.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/JMSTestCase.java
index 9ef7a53ed7..f51dea86b4 100644
--- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/JMSTestCase.java
+++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/JMSTestCase.java
@@ -35,7 +35,16 @@ import org.objectweb.jtests.jms.admin.AdminFactory;
*/
public abstract class JMSTestCase extends Assert {
- public static final String PROP_FILE_NAME = "provider.properties";
+ public static String _PROP_FILE_NAME = "provider.properties";
+
+ public static String getPropFileName() {
+ return System.getProperty("joram.provider", _PROP_FILE_NAME);
+ }
+
+ public static void setPropFileName(String fileName) {
+ System.setProperty("joram.provider", fileName);
+ _PROP_FILE_NAME = fileName;
+ }
public static boolean startServer = true;
@@ -70,7 +79,7 @@ public abstract class JMSTestCase extends Assert {
*/
protected Properties getProviderProperties() throws IOException {
Properties props = new Properties();
- props.load(ClassLoader.getSystemResourceAsStream(JMSTestCase.PROP_FILE_NAME));
+ props.load(ClassLoader.getSystemResourceAsStream(getPropFileName()));
return props;
}
diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/PTPTestCase.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/PTPTestCase.java
index 833e4757d1..0902a03998 100644
--- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/PTPTestCase.java
+++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/PTPTestCase.java
@@ -24,11 +24,7 @@ import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.naming.Context;
-import javax.naming.InitialContext;
-import java.util.Hashtable;
-
-import org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory;
import org.junit.After;
import org.junit.Before;
@@ -115,11 +111,7 @@ public abstract class PTPTestCase extends JMSTestCase {
admin.createQueueConnectionFactory(PTPTestCase.QCF_NAME);
admin.createQueue(PTPTestCase.QUEUE_NAME);
- Hashtable props = new Hashtable<>();
- props.put(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getCanonicalName());
- props.put("connectionFactory." + PTPTestCase.QCF_NAME, "tcp://127.0.0.1:61616?type=QUEUE_CF");
- props.put("queue." + PTPTestCase.QUEUE_NAME, PTPTestCase.QUEUE_NAME);
- Context ctx = new InitialContext(props);
+ Context ctx = admin.createContext();
senderQCF = (QueueConnectionFactory) ctx.lookup(PTPTestCase.QCF_NAME);
senderQueue = (Queue) ctx.lookup(PTPTestCase.QUEUE_NAME);
diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/PubSubTestCase.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/PubSubTestCase.java
index ab6c4d81ff..9974afb9be 100644
--- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/PubSubTestCase.java
+++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/PubSubTestCase.java
@@ -24,11 +24,7 @@ import javax.jms.TopicPublisher;
import javax.jms.TopicSession;
import javax.jms.TopicSubscriber;
import javax.naming.Context;
-import javax.naming.InitialContext;
-import java.util.Hashtable;
-
-import org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory;
import org.junit.After;
import org.junit.Before;
@@ -115,11 +111,7 @@ public abstract class PubSubTestCase extends JMSTestCase {
admin.createTopicConnectionFactory(PubSubTestCase.TCF_NAME);
admin.createTopic(PubSubTestCase.TOPIC_NAME);
- Hashtable props = new Hashtable<>();
- props.put(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getCanonicalName());
- props.put("connectionFactory." + PubSubTestCase.TCF_NAME, "tcp://127.0.0.1:61616?type=TOPIC_CF");
- props.put("topic." + PubSubTestCase.TOPIC_NAME, PubSubTestCase.TOPIC_NAME);
- Context ctx = new InitialContext(props);
+ Context ctx = admin.createContext();
publisherTCF = (TopicConnectionFactory) ctx.lookup(PubSubTestCase.TCF_NAME);
publisherTopic = (Topic) ctx.lookup(PubSubTestCase.TOPIC_NAME);
@@ -140,6 +132,7 @@ public abstract class PubSubTestCase extends JMSTestCase {
// end of client step
}
catch (Exception e) {
+ e.printStackTrace();
throw new RuntimeException(e);
}
}
diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/UnifiedTestCase.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/UnifiedTestCase.java
index 367cfec10b..bab66d84d9 100644
--- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/UnifiedTestCase.java
+++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/UnifiedTestCase.java
@@ -27,11 +27,7 @@ import javax.jms.Session;
import javax.jms.Topic;
import javax.jms.TopicConnectionFactory;
import javax.naming.Context;
-import javax.naming.InitialContext;
-import java.util.Hashtable;
-
-import org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory;
import org.junit.After;
import org.junit.Before;
@@ -165,15 +161,7 @@ public abstract class UnifiedTestCase extends JMSTestCase {
admin.createQueue(UnifiedTestCase.QUEUE_NAME);
admin.createTopic(UnifiedTestCase.TOPIC_NAME);
- Hashtable props = new Hashtable<>();
- props.put(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getCanonicalName());
- props.put("connectionFactory." + UnifiedTestCase.CF_NAME, "tcp://127.0.0.1:61616");
- props.put("connectionFactory." + UnifiedTestCase.QCF_NAME, "tcp://127.0.0.1:61616?type=QUEUE_CF");
- props.put("connectionFactory." + UnifiedTestCase.TCF_NAME, "tcp://127.0.0.1:61616?type=TOPIC_CF");
- props.put("queue." + UnifiedTestCase.DESTINATION_NAME, UnifiedTestCase.DESTINATION_NAME);
- props.put("queue." + UnifiedTestCase.QUEUE_NAME, UnifiedTestCase.QUEUE_NAME);
- props.put("topic." + UnifiedTestCase.TOPIC_NAME, UnifiedTestCase.TOPIC_NAME);
- Context ctx = new InitialContext(props);
+ Context ctx = admin.createContext();
producerCF = (ConnectionFactory) ctx.lookup(UnifiedTestCase.CF_NAME);
// we see destination of the unified domain as a javax.jms.Destination
diff --git a/tests/joram-tests/src/test/resources/amqp_provider.properties b/tests/joram-tests/src/test/resources/amqp_provider.properties
new file mode 100644
index 0000000000..6a5bcfd233
--- /dev/null
+++ b/tests/joram-tests/src/test/resources/amqp_provider.properties
@@ -0,0 +1,28 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT 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 property is used to chose which provider is to be tested
+# Uncomment the chosen provider and comment the other ones
+##
+
+jms.provider.admin.class=org.apache.activemq.artemis.amqpJMS.ActiveMQAMQPAdmin
+#jms.provider.admin.class = org.apache.activemq.artemis.api.jms.GenericAdmin
+#jms.provider.admin.class = org.objectweb.jtests.providers.admin.JoramAdmin
+#jms.provider.admin.class = org.objectweb.jtests.providers.admin.AshnaMQAdmin
+#jms.provider.admin.class = org.objectweb.jtests.providers.admin.FioranoMQAdmin
+#jms.provider.admin.class = org.objectweb.jtests.providers.admin.PramatiAdmin
+#jms.provider.admin.class = org.objectweb.jtests.providers.admin.SwiftMQAdmin
\ No newline at end of file
diff --git a/tests/joram-tests/src/test/resources/provider.properties b/tests/joram-tests/src/test/resources/provider.properties
index 0af3ee5969..1307a791a1 100644
--- a/tests/joram-tests/src/test/resources/provider.properties
+++ b/tests/joram-tests/src/test/resources/provider.properties
@@ -19,7 +19,7 @@
# Uncomment the chosen provider and comment the other ones
##
-jms.provider.admin.class=org.apache.activemq.artemis.jms.ActiveMQAdmin
+jms.provider.admin.class=org.apache.activemq.artemis.jms.ActiveMQCoreAdmin
#jms.provider.admin.class = org.apache.activemq.artemis.api.jms.GenericAdmin
#jms.provider.admin.class = org.objectweb.jtests.providers.admin.JoramAdmin
#jms.provider.admin.class = org.objectweb.jtests.providers.admin.AshnaMQAdmin
diff --git a/tests/joram-tests/src/test/resources/test.properties b/tests/joram-tests/src/test/resources/test.properties
index 2364dee406..ed314367c0 100644
--- a/tests/joram-tests/src/test/resources/test.properties
+++ b/tests/joram-tests/src/test/resources/test.properties
@@ -18,4 +18,4 @@
# Time in milliseconds or 0 for never expiring
# Default is set to 30 seconds (long enough to receive slow messages
# and won't hang up tests infinitely)
-timeout = 30000
\ No newline at end of file
+timeout = 1000
\ No newline at end of file
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/SelectorTranslatorTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/SelectorTranslatorTest.java
index f2f89c8317..d0ceea4c0b 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/SelectorTranslatorTest.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/client/SelectorTranslatorTest.java
@@ -17,11 +17,11 @@
package org.apache.activemq.artemis.tests.unit.jms.client;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.activemq.artemis.utils.SelectorTranslator;
import org.junit.Test;
import org.junit.Assert;
-import org.apache.activemq.artemis.jms.client.SelectorTranslator;
public class SelectorTranslatorTest extends ActiveMQTestBase {