Repository: activemq-6 Updated Branches: refs/heads/master e419feb88 -> 46182e415
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/ConnectionFactoryTest.java ---------------------------------------------------------------------- diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/ConnectionFactoryTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/ConnectionFactoryTest.java index 5c2650c..cafe37f 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/ConnectionFactoryTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/ConnectionFactoryTest.java @@ -39,6 +39,7 @@ import javax.jms.XAQueueConnectionFactory; import javax.jms.XATopicConnection; import javax.jms.XATopicConnectionFactory; +import org.apache.activemq.api.jms.JMSFactoryType; import org.apache.activemq.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.jms.tests.util.ProxyAssertSupport; import org.junit.Assert; @@ -69,9 +70,11 @@ public class ConnectionFactoryTest extends JMSTestCase @Test public void testQueueConnectionFactory() throws Exception { + deployConnectionFactory(0, JMSFactoryType.QUEUE_CF, "CF_QUEUE_XA_FALSE", "/CF_QUEUE_XA_FALSE"); QueueConnectionFactory qcf = (QueueConnectionFactory)ic.lookup("/CF_QUEUE_XA_FALSE"); QueueConnection qc = qcf.createQueueConnection(); qc.close(); + undeployConnectionFactory("CF_QUEUE_XA_FALSE"); } /** @@ -81,9 +84,11 @@ public class ConnectionFactoryTest extends JMSTestCase @Test public void testTopicConnectionFactory() throws Exception { + deployConnectionFactory(0, JMSFactoryType.TOPIC_CF, "CF_TOPIC_XA_FALSE", "/CF_TOPIC_XA_FALSE"); TopicConnectionFactory qcf = (TopicConnectionFactory)ic.lookup("/CF_TOPIC_XA_FALSE"); TopicConnection tc = qcf.createTopicConnection(); tc.close(); + undeployConnectionFactory("CF_TOPIC_XA_FALSE"); } @Test @@ -117,12 +122,14 @@ public class ConnectionFactoryTest extends JMSTestCase // the ConnectionFactories that ship with ActiveMQ do not have their clientID // administratively configured. + deployConnectionFactory(0, JMSFactoryType.TOPIC_CF, "CF_XA_FALSE", "/CF_XA_FALSE"); ConnectionFactory cf = (ConnectionFactory)ic.lookup("/CF_XA_FALSE"); Connection c = cf.createConnection(); ProxyAssertSupport.assertNull(c.getClientID()); c.close(); + undeployConnectionFactory("CF_XA_FALSE"); } @Test @@ -131,6 +138,7 @@ public class ConnectionFactoryTest extends JMSTestCase // the ConnectionFactories that ship with ActiveMQ do not have their clientID // administratively configured. + deployConnectionFactory(0, JMSFactoryType.TOPIC_CF, "CF_XA_FALSE", "/CF_XA_FALSE"); ConnectionFactory cf = (ConnectionFactory)ic.lookup("/CF_XA_FALSE"); Connection c = cf.createConnection(); @@ -140,6 +148,7 @@ public class ConnectionFactoryTest extends JMSTestCase ProxyAssertSupport.assertEquals(testClientId, c.getClientID()); c.close(); + undeployConnectionFactory("CF_XA_FALSE"); } // Added for http://jira.jboss.org/jira/browse/JBMESSAGING-939 @@ -337,6 +346,19 @@ public class ConnectionFactoryTest extends JMSTestCase @Test public void testFactoryTypes() throws Exception { + deployConnectionFactory(0, JMSFactoryType.CF, "ConnectionFactory", "/ConnectionFactory"); + deployConnectionFactory(0, JMSFactoryType.QUEUE_XA_CF, "CF_QUEUE_XA_TRUE", "/CF_QUEUE_XA_TRUE"); + deployConnectionFactory(0, JMSFactoryType.QUEUE_CF, "CF_QUEUE_XA_FALSE", "/CF_QUEUE_XA_FALSE"); + deployConnectionFactory(0, JMSFactoryType.XA_CF, "CF_XA_TRUE", "/CF_XA_TRUE"); + deployConnectionFactory(0, JMSFactoryType.CF, "CF_XA_FALSE", "/CF_XA_FALSE"); + deployConnectionFactory(0, JMSFactoryType.QUEUE_CF, "CF_QUEUE", "/CF_QUEUE"); + deployConnectionFactory(0, JMSFactoryType.TOPIC_CF, "CF_TOPIC", "/CF_TOPIC"); + deployConnectionFactory(0, JMSFactoryType.TOPIC_XA_CF, "CF_TOPIC_XA_TRUE", "/CF_TOPIC_XA_TRUE"); + deployConnectionFactory(0, JMSFactoryType.CF, "CF_GENERIC", "/CF_GENERIC"); + deployConnectionFactory(0, JMSFactoryType.XA_CF, "CF_GENERIC_XA_TRUE", "/CF_GENERIC_XA_TRUE"); + deployConnectionFactory(0, JMSFactoryType.CF, "CF_GENERIC_XA_FALSE", "/CF_GENERIC_XA_FALSE"); + deployConnectionFactory(0, JMSFactoryType.TOPIC_CF, "CF_TOPIC_XA_FALSE", "/CF_TOPIC_XA_FALSE"); + ActiveMQConnectionFactory factory = null; factory = (ActiveMQConnectionFactory)ic.lookup("/ConnectionFactory"); @@ -398,11 +420,31 @@ public class ConnectionFactoryTest extends JMSTestCase Assert.assertTrue(factory instanceof TopicConnectionFactory); assertNTypes(factory, 3); + + undeployConnectionFactory("ConnectionFactory"); + undeployConnectionFactory("CF_QUEUE_XA_TRUE"); + undeployConnectionFactory("CF_QUEUE_XA_FALSE"); + undeployConnectionFactory("CF_XA_TRUE"); + undeployConnectionFactory("CF_XA_FALSE"); + undeployConnectionFactory("CF_QUEUE"); + undeployConnectionFactory("CF_TOPIC"); + undeployConnectionFactory("CF_TOPIC_XA_TRUE"); + undeployConnectionFactory("CF_GENERIC"); + undeployConnectionFactory("CF_GENERIC_XA_TRUE"); + undeployConnectionFactory("CF_GENERIC_XA_FALSE"); + undeployConnectionFactory("CF_TOPIC_XA_FALSE"); } @Test public void testConnectionTypes() throws Exception { + deployConnectionFactory(0, JMSFactoryType.CF, "ConnectionFactory", "/ConnectionFactory"); + deployConnectionFactory(0, JMSFactoryType.QUEUE_XA_CF, "CF_QUEUE_XA_TRUE", "/CF_QUEUE_XA_TRUE"); + deployConnectionFactory(0, JMSFactoryType.XA_CF, "CF_XA_TRUE", "/CF_XA_TRUE"); + deployConnectionFactory(0, JMSFactoryType.QUEUE_CF, "CF_QUEUE", "/CF_QUEUE"); + deployConnectionFactory(0, JMSFactoryType.TOPIC_CF, "CF_TOPIC", "/CF_TOPIC"); + deployConnectionFactory(0, JMSFactoryType.TOPIC_XA_CF, "CF_TOPIC_XA_TRUE", "/CF_TOPIC_XA_TRUE"); + Connection genericConnection = null; XAConnection xaConnection = null; QueueConnection queueConnection = null; @@ -440,6 +482,13 @@ public class ConnectionFactoryTest extends JMSTestCase topicConnection.close(); xaQueueConnection.close(); xaTopicConnection.close(); + + undeployConnectionFactory("ConnectionFactory"); + undeployConnectionFactory("CF_QUEUE_XA_TRUE"); + undeployConnectionFactory("CF_XA_TRUE"); + undeployConnectionFactory("CF_QUEUE"); + undeployConnectionFactory("CF_TOPIC"); + undeployConnectionFactory("CF_TOPIC_XA_TRUE"); } private void assertConnectionType(Connection conn, String type) http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/SessionTest.java ---------------------------------------------------------------------- diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/SessionTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/SessionTest.java index bf48bca..c062fe8 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/SessionTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/SessionTest.java @@ -33,6 +33,7 @@ import javax.jms.TopicSession; import javax.jms.XAConnection; import javax.jms.XASession; +import org.apache.activemq.api.jms.JMSFactoryType; import org.apache.activemq.jms.tests.util.ProxyAssertSupport; import org.junit.Test; @@ -97,6 +98,7 @@ public class SessionTest extends ActiveMQServerTestCase @Test public void testGetSession2() throws Exception { + deployConnectionFactory(0, JMSFactoryType.CF, "ConnectionFactory", "/ConnectionFactory"); XAConnection conn = getXAConnectionFactory().createXAConnection(); XASession sess = conn.createXASession(); http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/message/SimpleJMSStreamMessage.java ---------------------------------------------------------------------- diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/message/SimpleJMSStreamMessage.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/message/SimpleJMSStreamMessage.java index bd8b142..09274e6 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/message/SimpleJMSStreamMessage.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/message/SimpleJMSStreamMessage.java @@ -26,8 +26,6 @@ import javax.jms.MessageNotReadableException; import javax.jms.MessageNotWriteableException; import javax.jms.StreamMessage; -import org.jboss.util.Primitives; - /** * @author <a href="mailto:ovi...@feodorov.com">Ovidiu Feodorov</a> * @version $Revision$ @@ -555,7 +553,7 @@ public class SimpleJMSStreamMessage extends SimpleJMSMessage implements StreamMe { throw new MessageNotWriteableException("The message body is readonly"); } - content.add(Primitives.valueOf(value)); + content.add(new Boolean(value)); } public void writeByte(final byte value) throws JMSException http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/WrappedJNDIServer.java ---------------------------------------------------------------------- diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/WrappedJNDIServer.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/WrappedJNDIServer.java deleted file mode 100644 index b1d55db..0000000 --- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/WrappedJNDIServer.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.activemq.jms.tests.tools; - -import java.net.UnknownHostException; - -import org.jnp.server.Main; -import org.jnp.server.NamingBean; - -/** - * A WrappedJNDIServer - * - * We wrap the JBoss AS JNDI server, since we want to introduce a pause of 500 milliseconds on stop() - * - * This is because there is a bug in the JBoss AS class whereby the socket can remaining open some time after - * stop() is called. - * - * So if you call stop() then start() quickly after, you can hit an exception: - * - * java.rmi.server.ExportException: Port already in use: 1098; nested exception is: - * java.net.BindException: Address already in use - * - * @author <a href="mailto:tim....@jboss.com">Tim Fox</a> - * - * - */ -public class WrappedJNDIServer -{ - private final Main main; - - public WrappedJNDIServer() - { - main = new Main(); - } - - public void start() throws Exception - { - main.start(); - } - - public void stop() - { - main.stop(); - - try - { - Thread.sleep(500); - } - catch (Exception e) - { - } - } - - public void setNamingInfo(final NamingBean naming) - { - main.setNamingInfo(naming); - } - - public void setPort(final int port) - { - main.setPort(port); - } - - public void setBindAddress(final String bindAddress) throws UnknownHostException - { - main.setBindAddress(bindAddress); - } - - public void setRmiPort(final int port) - { - main.setRmiPort(port); - } - - public void setRmiBindAddress(final String address) throws UnknownHostException - { - main.setRmiBindAddress(address); - } -} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/InVMContext.java ---------------------------------------------------------------------- diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/InVMContext.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/InVMContext.java index bcf1236..4acc367 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/InVMContext.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/InVMContext.java @@ -276,7 +276,6 @@ public class InVMContext implements Context, Serializable { Hashtable<String, String> env = new Hashtable<String, String>(); env.put("java.naming.factory.initial", InVMInitialContextFactory.class.getCanonicalName()); - env.put("java.naming.provider.url", "org.jboss.naming:org.jnp.interface"); return env; } http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/InVMInitialContextFactory.java ---------------------------------------------------------------------- diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/InVMInitialContextFactory.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/InVMInitialContextFactory.java index 6d6c2a4..2924514 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/InVMInitialContextFactory.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/InVMInitialContextFactory.java @@ -56,8 +56,6 @@ public class InVMInitialContextFactory implements InitialContextFactory { Hashtable<String, String> env = new Hashtable<String, String>(); env.put("java.naming.factory.initial", "org.apache.activemq.jms.tests.tools.container.InVMInitialContextFactory"); - env.put("java.naming.provider.url", "org.jboss.naming:org.jnp.interface"); - // env.put("java.naming.factory.url.pkgs", ""); env.put(Constants.SERVER_INDEX_PROPERTY_NAME, Integer.toString(serverIndex)); return env; } http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/LocalTestServer.java ---------------------------------------------------------------------- diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/LocalTestServer.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/LocalTestServer.java index 25bede3..920ac21 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/LocalTestServer.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/LocalTestServer.java @@ -45,8 +45,6 @@ import org.apache.activemq.jms.server.JMSServerManager; import org.apache.activemq.jms.server.impl.JMSServerManagerImpl; import org.apache.activemq.jms.tests.JmsTestLogger; import org.apache.activemq.spi.core.security.ActiveMQSecurityManagerImpl; -import org.jnp.server.Main; -import org.jnp.server.NamingBeanImpl; /** * @author <a href="mailto:ovi...@feodorov.com">Ovidiu Feodorov</a> @@ -62,7 +60,6 @@ public class LocalTestServer implements Server, Runnable private boolean started = false; private final HashMap<String, List<String>> allBindings = new HashMap<String, List<String>>(); - private Main jndiServer; private JMSServerManagerImpl jmsServerManager; // Static --------------------------------------------------------------------------------------- @@ -116,14 +113,6 @@ public class LocalTestServer implements Server, Runnable JmsTestLogger.LOGGER.info("Deleted dir: " + dir.getAbsolutePath() + " deleted: " + deleted); } - org.jnp.server.NamingBeanImpl namingBean = new NamingBeanImpl(); - jndiServer = new Main(); - jndiServer.setNamingInfo(namingBean); - jndiServer.setPort(1099); - jndiServer.setBindAddress("localhost"); - jndiServer.setRmiPort(1098); - jndiServer.setRmiBindAddress("localhost"); - javax.management.MBeanServer beanServer = java.lang.management.ManagementFactory.getPlatformMBeanServer(); FileConfiguration fileConfiguration = new FileConfiguration(); ActiveMQSecurityManagerImpl securityManager = new ActiveMQSecurityManagerImpl(); @@ -131,8 +120,6 @@ public class LocalTestServer implements Server, Runnable jmsServerManager = new JMSServerManagerImpl(activeMQServer); System.setProperty(Constants.SERVER_INDEX_PROPERTY_NAME, "" + getServerID()); - namingBean.start(); - jndiServer.start(); fileConfiguration.start(); jmsServerManager.start(); started = true; @@ -160,11 +147,9 @@ public class LocalTestServer implements Server, Runnable public synchronized boolean stop() throws Exception { jmsServerManager.stop(); - jndiServer.stop(); started = false; unbindAll(); jmsServerManager = null; - jndiServer.stop(); return true; } @@ -242,19 +227,24 @@ public class LocalTestServer implements Server, Runnable public void deployConnectionFactory(final String clientId, final String objectName, final String ... jndiBindings) throws Exception { - deployConnectionFactory(clientId, objectName, -1, -1, -1, -1, false, false, -1, false, jndiBindings); + deployConnectionFactory(clientId, JMSFactoryType.CF, objectName, -1, -1, -1, -1, false, false, -1, false, jndiBindings); } public void deployConnectionFactory(final String objectName, final int consumerWindowSize, final String ... jndiBindings) throws Exception { - deployConnectionFactory(null, objectName, consumerWindowSize, -1, -1, -1, false, false, -1, false, jndiBindings); + deployConnectionFactory(null, JMSFactoryType.CF, objectName, consumerWindowSize, -1, -1, -1, false, false, -1, false, jndiBindings); } public void deployConnectionFactory(final String objectName, final String ... jndiBindings) throws Exception { - deployConnectionFactory(null, objectName, -1, -1, -1, -1, false, false, -1, false, jndiBindings); + deployConnectionFactory(null, JMSFactoryType.CF, objectName, -1, -1, -1, -1, false, false, -1, false, jndiBindings); + } + + public void deployConnectionFactory(final String objectName, JMSFactoryType type, final String ... jndiBindings) throws Exception + { + deployConnectionFactory(null, type, objectName, -1, -1, -1, -1, false, false, -1, false, jndiBindings); } public void deployConnectionFactory(final String objectName, @@ -265,6 +255,7 @@ public class LocalTestServer implements Server, Runnable final String ... jndiBindings) throws Exception { this.deployConnectionFactory(null, + JMSFactoryType.CF, objectName, prefetchSize, defaultTempQueueFullSize, @@ -283,6 +274,7 @@ public class LocalTestServer implements Server, Runnable final String ... jndiBindings) throws Exception { this.deployConnectionFactory(null, + JMSFactoryType.CF, objectName, -1, -1, @@ -296,6 +288,7 @@ public class LocalTestServer implements Server, Runnable } public void deployConnectionFactory(final String clientId, + final JMSFactoryType type, final String objectName, final int prefetchSize, final int defaultTempQueueFullSize, @@ -315,7 +308,7 @@ public class LocalTestServer implements Server, Runnable getJMSServerManager().createConnectionFactory(objectName, false, - JMSFactoryType.CF, + type, connectors, clientId, ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD, @@ -392,7 +385,6 @@ public class LocalTestServer implements Server, Runnable props.setProperty("java.naming.factory.initial", "org.apache.activemq.jms.tests.tools.container.InVMInitialContextFactory"); props.setProperty(Constants.SERVER_INDEX_PROPERTY_NAME, "" + getServerID()); - // props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces"); return new InitialContext(props); } http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/NonSerializableFactory.java ---------------------------------------------------------------------- diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/NonSerializableFactory.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/NonSerializableFactory.java index deec225..dcf7c9a 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/NonSerializableFactory.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/NonSerializableFactory.java @@ -26,11 +26,8 @@ import javax.naming.Name; import javax.naming.NamingException; import javax.naming.RefAddr; import javax.naming.Reference; -import javax.naming.StringRefAddr; import javax.naming.spi.ObjectFactory; -import org.jboss.util.naming.Util; - /** * used by the default context when running in embedded local configuration * @author <a href="atay...@redhat.com">Andy Taylor</a> @@ -42,47 +39,47 @@ public final class NonSerializableFactory implements ObjectFactory { } - public static void unbind(final Context ctx, final String strName) throws NamingException - { - Name name = ctx.getNameParser("").parse(strName); - int size = name.size(); - String atom = name.get(size - 1); - Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1)); - String key = new StringBuilder().append(parentCtx.getNameInNamespace()).append("/").append(atom).toString(); - NonSerializableFactory.getWrapperMap().remove(key); - Util.unbind(ctx, strName); - } - - public static void rebind(final Context ctx, final String strName, final Object value) throws NamingException - { - Name name = ctx.getNameParser("").parse(strName); - int size = name.size(); - String atom = name.get(size - 1); - Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1)); - String key = new StringBuilder().append(parentCtx.getNameInNamespace()).append("/").append(atom).toString(); - NonSerializableFactory.getWrapperMap().put(key, value); - String className = value.getClass().getName(); - String factory = NonSerializableFactory.class.getName(); - StringRefAddr addr = new StringRefAddr("nns", key); - Reference memoryRef = new Reference(className, addr, factory, null); - parentCtx.rebind(atom, memoryRef); - } - - public static void bind(final Context ctx, final String strName, final Object value) throws NamingException - { - Name name = ctx.getNameParser("").parse(strName); - int size = name.size(); - String atom = name.get(size - 1); - Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1)); - String key = new StringBuilder().append(parentCtx.getNameInNamespace()).append("/").append(atom).toString(); - NonSerializableFactory.getWrapperMap().put(key, value); - String className = value.getClass().getName(); - String factory = NonSerializableFactory.class.getName(); - StringRefAddr addr = new StringRefAddr("nns", key); - Reference memoryRef = new Reference(className, addr, factory, null); - - parentCtx.bind(atom, memoryRef); - } +// public static void unbind(final Context ctx, final String strName) throws NamingException +// { +// Name name = ctx.getNameParser("").parse(strName); +// int size = name.size(); +// String atom = name.get(size - 1); +// Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1)); +// String key = new StringBuilder().append(parentCtx.getNameInNamespace()).append("/").append(atom).toString(); +// NonSerializableFactory.getWrapperMap().remove(key); +// Util.unbind(ctx, strName); +// } +// +// public static void rebind(final Context ctx, final String strName, final Object value) throws NamingException +// { +// Name name = ctx.getNameParser("").parse(strName); +// int size = name.size(); +// String atom = name.get(size - 1); +// Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1)); +// String key = new StringBuilder().append(parentCtx.getNameInNamespace()).append("/").append(atom).toString(); +// NonSerializableFactory.getWrapperMap().put(key, value); +// String className = value.getClass().getName(); +// String factory = NonSerializableFactory.class.getName(); +// StringRefAddr addr = new StringRefAddr("nns", key); +// Reference memoryRef = new Reference(className, addr, factory, null); +// parentCtx.rebind(atom, memoryRef); +// } +// +// public static void bind(final Context ctx, final String strName, final Object value) throws NamingException +// { +// Name name = ctx.getNameParser("").parse(strName); +// int size = name.size(); +// String atom = name.get(size - 1); +// Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1)); +// String key = new StringBuilder().append(parentCtx.getNameInNamespace()).append("/").append(atom).toString(); +// NonSerializableFactory.getWrapperMap().put(key, value); +// String className = value.getClass().getName(); +// String factory = NonSerializableFactory.class.getName(); +// StringRefAddr addr = new StringRefAddr("nns", key); +// Reference memoryRef = new Reference(className, addr, factory, null); +// +// parentCtx.bind(atom, memoryRef); +// } public static Object lookup(final String name) throws NamingException { http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/Server.java ---------------------------------------------------------------------- diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/Server.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/Server.java index 1015473..efa597f 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/Server.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/tools/container/Server.java @@ -22,6 +22,7 @@ import java.util.HashMap; import java.util.List; import java.util.Set; +import org.apache.activemq.api.jms.JMSFactoryType; import org.apache.activemq.core.security.Role; import org.apache.activemq.core.server.ActiveMQServer; import org.apache.activemq.jms.server.JMSServerManager; @@ -136,6 +137,7 @@ public interface Server extends Remote */ // boolean undeployDestinationProgrammatically(boolean isQueue, String name) throws Exception; void deployConnectionFactory(String clientId, + JMSFactoryType type, String objectName, int prefetchSize, int defaultTempQueueFullSize, @@ -168,6 +170,10 @@ public interface Server extends Remote void deployConnectionFactory(String objectName, final String... jndiBindings) throws Exception; + void deployConnectionFactory(String objectName, + JMSFactoryType type, + final String... jndiBindings) throws Exception; + void undeployConnectionFactory(String objectName) throws Exception; void configureSecurityForDestination(String destName, boolean isQueue, Set<Role> roles) throws Exception; http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/jms-tests/src/test/resources/activemq-jms.xml ---------------------------------------------------------------------- diff --git a/tests/jms-tests/src/test/resources/activemq-jms.xml b/tests/jms-tests/src/test/resources/activemq-jms.xml index 8d32412..36b800a 100644 --- a/tests/jms-tests/src/test/resources/activemq-jms.xml +++ b/tests/jms-tests/src/test/resources/activemq-jms.xml @@ -2,125 +2,5 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/activemq-jms.xsd"> - <connection-factory name="ConnectionFactory"> - <connectors> - <connector-ref connector-name="netty"/> - </connectors> - <entries> - <entry name="ConnectionFactory"/> - <entry name="/ConnectionFactory"/> - <entry name="/XAConnectionFactory"/> - <entry name="java:/ConnectionFactory"/> - <entry name="java:/XAConnectionFactory"/> - </entries> - </connection-factory> - - <connection-factory name="JMSConnectionFactory1"> - <xa>true</xa> - <connectors> - <connector-ref connector-name="netty"/> - </connectors> - <entries> - <entry name="/CF_XA_TRUE"/> - </entries> - </connection-factory> - - <connection-factory name="JMSConnectionFactory2"> - <xa>false</xa> - <connectors> - <connector-ref connector-name="netty"/> - </connectors> - <entries> - <entry name="/CF_XA_FALSE"/> - </entries> - </connection-factory> - - <connection-factory name="JMSConnectionFactory3" signature="generic"> - <connectors> - <connector-ref connector-name="netty"/> - </connectors> - <entries> - <entry name="/CF_GENERIC"/> - </entries> - </connection-factory> - - <connection-factory name="JMSConnectionFactory4" signature="generic"> - <xa>true</xa> - <connectors> - <connector-ref connector-name="netty"/> - </connectors> - <entries> - <entry name="/CF_GENERIC_XA_TRUE"/> - </entries> - </connection-factory> - - <connection-factory name="JMSConnectionFactory5" signature="generic"> - <xa>false</xa> - <connectors> - <connector-ref connector-name="netty"/> - </connectors> - <entries> - <entry name="/CF_GENERIC_XA_FALSE"/> - </entries> - </connection-factory> - - <connection-factory name="JMSConnectionFactory6" signature="queue"> - <connectors> - <connector-ref connector-name="netty"/> - </connectors> - <entries> - <entry name="/CF_QUEUE"/> - </entries> - </connection-factory> - - <connection-factory name="JMSConnectionFactory7" signature="queue"> - <xa>true</xa> - <connectors> - <connector-ref connector-name="netty"/> - </connectors> - <entries> - <entry name="/CF_QUEUE_XA_TRUE"/> - </entries> - </connection-factory> - - <connection-factory name="JMSConnectionFactory8" signature="queue"> - <xa>false</xa> - <connectors> - <connector-ref connector-name="netty"/> - </connectors> - <entries> - <entry name="/CF_QUEUE_XA_FALSE"/> - </entries> - </connection-factory> - - <connection-factory name="JMSConnectionFactory9" signature="topic"> - <connectors> - <connector-ref connector-name="netty"/> - </connectors> - <entries> - <entry name="/CF_TOPIC"/> - </entries> - </connection-factory> - - <connection-factory name="JMSConnectionFactory10" signature="topic"> - <xa>true</xa> - <connectors> - <connector-ref connector-name="netty"/> - </connectors> - <entries> - <entry name="/CF_TOPIC_XA_TRUE"/> - </entries> - </connection-factory> - - <connection-factory name="JMSConnectionFactory11" signature="topic"> - <xa>false</xa> - <connectors> - <connector-ref connector-name="netty"/> - </connectors> - <entries> - <entry name="/CF_TOPIC_XA_FALSE"/> - </entries> - </connection-factory> - </configuration> http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/jms-tests/src/test/resources/jndi.properties ---------------------------------------------------------------------- diff --git a/tests/jms-tests/src/test/resources/jndi.properties b/tests/jms-tests/src/test/resources/jndi.properties index e2a9832..ca08725 100644 --- a/tests/jms-tests/src/test/resources/jndi.properties +++ b/tests/jms-tests/src/test/resources/jndi.properties @@ -1,2 +1 @@ -java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory -java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces \ No newline at end of file +java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/joram-tests/pom.xml ---------------------------------------------------------------------- diff --git a/tests/joram-tests/pom.xml b/tests/joram-tests/pom.xml index 5e59d20..b157500 100644 --- a/tests/joram-tests/pom.xml +++ b/tests/joram-tests/pom.xml @@ -67,10 +67,6 @@ <artifactId>junit</artifactId> </dependency> <dependency> - <groupId>org.jboss.naming</groupId> - <artifactId>jnpserver</artifactId> - </dependency> - <dependency> <groupId>apache-logging</groupId> <artifactId>commons-logging</artifactId> </dependency> http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/joram-tests/src/test/java/org/apache/activemq/jms/AbstractAdmin.java ---------------------------------------------------------------------- diff --git a/tests/joram-tests/src/test/java/org/apache/activemq/jms/AbstractAdmin.java b/tests/joram-tests/src/test/java/org/apache/activemq/jms/AbstractAdmin.java index 65b8639..d123e6d 100644 --- a/tests/joram-tests/src/test/java/org/apache/activemq/jms/AbstractAdmin.java +++ b/tests/joram-tests/src/test/java/org/apache/activemq/jms/AbstractAdmin.java @@ -19,7 +19,6 @@ package org.apache.activemq.jms; import javax.naming.InitialContext; import javax.naming.NamingException; -import org.jboss.util.NotImplementedException; import org.objectweb.jtests.jms.admin.Admin; /** @@ -51,22 +50,22 @@ public class AbstractAdmin implements Admin public void createConnectionFactory(final String name) { - throw new NotImplementedException("FIXME NYI createConnectionFactory"); + throw new RuntimeException("FIXME NYI createConnectionFactory"); } public void deleteConnectionFactory(final String name) { - throw new NotImplementedException("FIXME NYI deleteConnectionFactory"); + throw new RuntimeException("FIXME NYI deleteConnectionFactory"); } public void createQueue(final String name) { - throw new NotImplementedException("FIXME NYI createQueue"); + throw new RuntimeException("FIXME NYI createQueue"); } public void deleteQueue(final String name) { - throw new NotImplementedException("FIXME NYI deleteQueue"); + throw new RuntimeException("FIXME NYI deleteQueue"); } public void createQueueConnectionFactory(final String name) @@ -81,12 +80,12 @@ public class AbstractAdmin implements Admin public void createTopic(final String name) { - throw new NotImplementedException("FIXME NYI createTopic"); + throw new RuntimeException("FIXME NYI createTopic"); } public void deleteTopic(final String name) { - throw new NotImplementedException("FIXME NYI deleteTopic"); + throw new RuntimeException("FIXME NYI deleteTopic"); } public void createTopicConnectionFactory(final String name) http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/joram-tests/src/test/java/org/apache/activemq/jms/ActiveMQAdmin.java ---------------------------------------------------------------------- diff --git a/tests/joram-tests/src/test/java/org/apache/activemq/jms/ActiveMQAdmin.java b/tests/joram-tests/src/test/java/org/apache/activemq/jms/ActiveMQAdmin.java new file mode 100644 index 0000000..4e9779b --- /dev/null +++ b/tests/joram-tests/src/test/java/org/apache/activemq/jms/ActiveMQAdmin.java @@ -0,0 +1,339 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq.jms; + +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.util.Hashtable; + +import org.apache.activemq.api.config.ActiveMQDefaultConfiguration; +import org.apache.activemq.api.core.TransportConfiguration; +import org.apache.activemq.api.core.client.ClientMessage; +import org.apache.activemq.api.core.client.ClientRequestor; +import org.apache.activemq.api.core.client.ClientSession; +import org.apache.activemq.api.core.client.ClientSessionFactory; +import org.apache.activemq.api.core.client.ActiveMQClient; +import org.apache.activemq.api.core.client.ServerLocator; +import org.apache.activemq.api.core.management.ManagementHelper; +import org.apache.activemq.api.core.management.ResourceNames; +import org.apache.activemq.core.remoting.impl.netty.NettyConnectorFactory; +import org.apache.activemq.tests.util.SpawnedVMSupport; +import org.junit.Assert; +import org.objectweb.jtests.jms.admin.Admin; + +/** + * A ActiveMQAdmin + * + * @author <a href="jmes...@redhat.com">Jeff Mesnil</a> + */ +public class ActiveMQAdmin implements Admin +{ + + private ClientSession clientSession; + + private ClientRequestor requestor; + + private Context context; + + private Process serverProcess; + + private ClientSessionFactory sf; + + ServerLocator serverLocator; + /** + * Determines whether to act or 'no-op' on {@link ActiveMQAdmin#serverStart()} and + * {@link ActiveMQAdmin#serverStop()}. This is used when testing combinations of client and + * servers with different versions. + * + * @see https://github.com/activemq/activemq-version-tests + */ + private final boolean serverLifeCycleActive; + private static final String SERVER_LIVE_CYCLE_PROPERTY = "org.apache.activemq.jms.ActiveMQAdmin.serverLifeCycle"; + + public ActiveMQAdmin() + { + serverLifeCycleActive = Boolean.valueOf(System.getProperty(SERVER_LIVE_CYCLE_PROPERTY, "true")); + try + { + Hashtable<String, String> env = new Hashtable<String, String>(); + env.put("java.naming.factory.initial", "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); + env.put("java.naming.provider.url", "tcp://localhost:5445"); + context = new InitialContext(env); + } + catch (NamingException e) + { + e.printStackTrace(); + } + } + + public void start() throws Exception + { + serverLocator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(NettyConnectorFactory.class.getName())); + sf = serverLocator.createSessionFactory(); + clientSession = sf.createSession(ActiveMQDefaultConfiguration.getDefaultClusterUser(), + ActiveMQDefaultConfiguration.getDefaultClusterPassword(), + false, + true, + true, + false, + 1); + requestor = new ClientRequestor(clientSession, ActiveMQDefaultConfiguration.getDefaultManagementAddress()); + clientSession.start(); + + } + + public void stop() throws Exception + { + requestor.close(); + + if (sf != null) + { + sf.close(); + } + + if (serverLocator != null) + { + serverLocator.close(); + } + + sf = null; + serverLocator = null; + } + + 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 context; + } + + public void createQueue(final String name) + { + Boolean result; + try + { + result = (Boolean) invokeSyncOperation(ResourceNames.JMS_SERVER, "createQueue", name, name); + Assert.assertEquals(true, result.booleanValue()); + } + catch (Exception e) + { + throw new IllegalStateException(e); + } + } + + public void createQueueConnectionFactory(final String name) + { + createConnection(name, 1); + } + + 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); + } + } + + public void createTopicConnectionFactory(final String name) + { + createConnection(name, 2); + } + + public void deleteConnectionFactory(final String name) + { + try + { + invokeSyncOperation(ResourceNames.JMS_SERVER, "destroyConnectionFactory", name); + } + catch (Exception e) + { + throw new IllegalStateException(e); + } + } + + public void deleteQueue(final String name) + { + Boolean result; + try + { + result = (Boolean) invokeSyncOperation(ResourceNames.JMS_SERVER, "destroyQueue", name); + Assert.assertEquals(true, result.booleanValue()); + } + catch (Exception e) + { + throw new IllegalStateException(e); + } + } + + public void deleteQueueConnectionFactory(final String name) + { + deleteConnectionFactory(name); + } + + public void deleteTopic(final String name) + { + Boolean result; + try + { + result = (Boolean) invokeSyncOperation(ResourceNames.JMS_SERVER, "destroyTopic", name); + Assert.assertEquals(true, result.booleanValue()); + } + catch (Exception e) + { + throw new IllegalStateException(e); + } + } + + public void deleteTopicConnectionFactory(final String name) + { + deleteConnectionFactory(name); + } + + public String getName() + { + return this.getClass().getName(); + } + + public void startServer() throws Exception + { + if (!serverLifeCycleActive) + { + return; + } + + 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); + line.replace('|', '\n'); + 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(); + } + } + }.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); + } + } + } + + public void stopServer() throws Exception + { + if (!serverLifeCycleActive) + { + return; + } + OutputStreamWriter osw = new OutputStreamWriter(serverProcess.getOutputStream()); + osw.write("STOP\n"); + osw.flush(); + int exitValue = serverProcess.waitFor(); + if (exitValue != 0) + { + serverProcess.destroy(); + } + } + + private 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; + try + { + reply = requestor.request(message, 3000); + } + catch (Exception e) + { + throw new IllegalStateException("Exception while invoking " + operationName + " on " + resourceName, e); + } + if (reply == null) + { + throw new IllegalStateException("no reply received when invoking " + operationName + " on " + resourceName); + } + if (!ManagementHelper.hasOperationSucceeded(reply)) + { + throw new IllegalStateException("operation failed when invoking " + operationName + + " on " + + resourceName + + ": " + + ManagementHelper.getResult(reply)); + } + return ManagementHelper.getResult(reply); + } + + // Inner classes ------------------------------------------------- + +} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/joram-tests/src/test/java/org/apache/activemq/jms/ActiveMQQAdmin.java ---------------------------------------------------------------------- diff --git a/tests/joram-tests/src/test/java/org/apache/activemq/jms/ActiveMQQAdmin.java b/tests/joram-tests/src/test/java/org/apache/activemq/jms/ActiveMQQAdmin.java deleted file mode 100644 index acd05bb..0000000 --- a/tests/joram-tests/src/test/java/org/apache/activemq/jms/ActiveMQQAdmin.java +++ /dev/null @@ -1,340 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.activemq.jms; - -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.util.Hashtable; - -import org.apache.activemq.api.config.ActiveMQDefaultConfiguration; -import org.apache.activemq.api.core.TransportConfiguration; -import org.apache.activemq.api.core.client.ClientMessage; -import org.apache.activemq.api.core.client.ClientRequestor; -import org.apache.activemq.api.core.client.ClientSession; -import org.apache.activemq.api.core.client.ClientSessionFactory; -import org.apache.activemq.api.core.client.ActiveMQClient; -import org.apache.activemq.api.core.client.ServerLocator; -import org.apache.activemq.api.core.management.ManagementHelper; -import org.apache.activemq.api.core.management.ResourceNames; -import org.apache.activemq.core.remoting.impl.netty.NettyConnectorFactory; -import org.apache.activemq.tests.util.SpawnedVMSupport; -import org.junit.Assert; -import org.objectweb.jtests.jms.admin.Admin; - -/** - * A ActiveMQAdmin - * - * @author <a href="jmes...@redhat.com">Jeff Mesnil</a> - */ -public class ActiveMQQAdmin implements Admin -{ - - private ClientSession clientSession; - - private ClientRequestor requestor; - - private Context context; - - private Process serverProcess; - - private ClientSessionFactory sf; - - ServerLocator serverLocator; - /** - * Determines whether to act or 'no-op' on {@link ActiveMQQAdmin#serverStart()} and - * {@link ActiveMQQAdmin#serverStop()}. This is used when testing combinations of client and - * servers with different versions. - * - * @see https://github.com/activemq/activemq-version-tests - */ - private final boolean serverLifeCycleActive; - private static final String SERVER_LIVE_CYCLE_PROPERTY = "org.apache.activemq.jms.ActiveMQAdmin.serverLifeCycle"; - - public ActiveMQQAdmin() - { - serverLifeCycleActive = Boolean.valueOf(System.getProperty(SERVER_LIVE_CYCLE_PROPERTY, "true")); - try - { - Hashtable<String, String> env = new Hashtable<String, String>(); - env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); - env.put("java.naming.provider.url", "jnp://localhost:1099"); - env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces"); - context = new InitialContext(env); - } - catch (NamingException e) - { - e.printStackTrace(); - } - } - - public void start() throws Exception - { - serverLocator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(NettyConnectorFactory.class.getName())); - sf = serverLocator.createSessionFactory(); - clientSession = sf.createSession(ActiveMQDefaultConfiguration.getDefaultClusterUser(), - ActiveMQDefaultConfiguration.getDefaultClusterPassword(), - false, - true, - true, - false, - 1); - requestor = new ClientRequestor(clientSession, ActiveMQDefaultConfiguration.getDefaultManagementAddress()); - clientSession.start(); - - } - - public void stop() throws Exception - { - requestor.close(); - - if (sf != null) - { - sf.close(); - } - - if (serverLocator != null) - { - serverLocator.close(); - } - - sf = null; - serverLocator = null; - } - - 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 context; - } - - public void createQueue(final String name) - { - Boolean result; - try - { - result = (Boolean) invokeSyncOperation(ResourceNames.JMS_SERVER, "createQueue", name, name); - Assert.assertEquals(true, result.booleanValue()); - } - catch (Exception e) - { - throw new IllegalStateException(e); - } - } - - public void createQueueConnectionFactory(final String name) - { - createConnection(name, 1); - } - - 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); - } - } - - public void createTopicConnectionFactory(final String name) - { - createConnection(name, 2); - } - - public void deleteConnectionFactory(final String name) - { - try - { - invokeSyncOperation(ResourceNames.JMS_SERVER, "destroyConnectionFactory", name); - } - catch (Exception e) - { - throw new IllegalStateException(e); - } - } - - public void deleteQueue(final String name) - { - Boolean result; - try - { - result = (Boolean) invokeSyncOperation(ResourceNames.JMS_SERVER, "destroyQueue", name); - Assert.assertEquals(true, result.booleanValue()); - } - catch (Exception e) - { - throw new IllegalStateException(e); - } - } - - public void deleteQueueConnectionFactory(final String name) - { - deleteConnectionFactory(name); - } - - public void deleteTopic(final String name) - { - Boolean result; - try - { - result = (Boolean) invokeSyncOperation(ResourceNames.JMS_SERVER, "destroyTopic", name); - Assert.assertEquals(true, result.booleanValue()); - } - catch (Exception e) - { - throw new IllegalStateException(e); - } - } - - public void deleteTopicConnectionFactory(final String name) - { - deleteConnectionFactory(name); - } - - public String getName() - { - return this.getClass().getName(); - } - - public void startServer() throws Exception - { - if (!serverLifeCycleActive) - { - return; - } - - 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); - line.replace('|', '\n'); - 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(); - } - } - }.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); - } - } - } - - public void stopServer() throws Exception - { - if (!serverLifeCycleActive) - { - return; - } - OutputStreamWriter osw = new OutputStreamWriter(serverProcess.getOutputStream()); - osw.write("STOP\n"); - osw.flush(); - int exitValue = serverProcess.waitFor(); - if (exitValue != 0) - { - serverProcess.destroy(); - } - } - - private 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; - try - { - reply = requestor.request(message, 3000); - } - catch (Exception e) - { - throw new IllegalStateException("Exception while invoking " + operationName + " on " + resourceName, e); - } - if (reply == null) - { - throw new IllegalStateException("no reply received when invoking " + operationName + " on " + resourceName); - } - if (!ManagementHelper.hasOperationSucceeded(reply)) - { - throw new IllegalStateException("operation failed when invoking " + operationName + - " on " + - resourceName + - ": " + - ManagementHelper.getResult(reply)); - } - return ManagementHelper.getResult(reply); - } - - // Inner classes ------------------------------------------------- - -} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/joram-tests/src/test/java/org/apache/activemq/jms/SpawnedJMSServer.java ---------------------------------------------------------------------- diff --git a/tests/joram-tests/src/test/java/org/apache/activemq/jms/SpawnedJMSServer.java b/tests/joram-tests/src/test/java/org/apache/activemq/jms/SpawnedJMSServer.java index b624cdc..3a8b2fb 100644 --- a/tests/joram-tests/src/test/java/org/apache/activemq/jms/SpawnedJMSServer.java +++ b/tests/joram-tests/src/test/java/org/apache/activemq/jms/SpawnedJMSServer.java @@ -18,9 +18,6 @@ package org.apache.activemq.jms; import java.io.BufferedReader; import java.io.InputStreamReader; -import java.util.Hashtable; - -import javax.naming.InitialContext; import org.apache.activemq.api.core.TransportConfiguration; import org.apache.activemq.core.config.Configuration; @@ -31,8 +28,6 @@ import org.apache.activemq.core.server.ActiveMQServer; import org.apache.activemq.core.server.ActiveMQServers; import org.apache.activemq.jms.server.JMSServerManager; import org.apache.activemq.jms.server.impl.JMSServerManagerImpl; -import org.jnp.server.Main; -import org.jnp.server.NamingBeanImpl; /** * A SpawnedServer @@ -53,20 +48,6 @@ public class SpawnedJMSServer { try { - System.setProperty("java.rmi.server.hostname", "localhost"); - System.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); - System.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces"); - - final NamingBeanImpl namingInfo = new NamingBeanImpl(); - namingInfo.start(); - final Main jndiServer = new Main(); - jndiServer.setNamingInfo(namingInfo); - jndiServer.setPort(1099); - jndiServer.setBindAddress("localhost"); - jndiServer.setRmiPort(1098); - jndiServer.setRmiBindAddress("localhost"); - jndiServer.start(); - Configuration conf = new ConfigurationImpl() .addAcceptorConfiguration(new TransportConfiguration(NettyAcceptorFactory.class.getName())) .setSecurityEnabled(false) @@ -77,11 +58,7 @@ public class SpawnedJMSServer // disable server persistence since JORAM tests do not restart server final ActiveMQServer server = ActiveMQServers.newActiveMQServer(conf, false); - Hashtable<String, String> env = new Hashtable<String, String>(); - env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); - env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces"); JMSServerManager serverManager = new JMSServerManagerImpl(server); - serverManager.setContext(new InitialContext(env)); serverManager.start(); System.out.println("Server started, ready to start client test"); @@ -99,8 +76,6 @@ public class SpawnedJMSServer if ("STOP".equals(line.trim())) { server.stop(); - jndiServer.stop(); - namingInfo.stop(); System.out.println("Server stopped"); System.exit(0); } http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/admin/AdminFactory.java ---------------------------------------------------------------------- diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/admin/AdminFactory.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/admin/AdminFactory.java index a6c1b94..650bfd0 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/admin/AdminFactory.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/admin/AdminFactory.java @@ -18,8 +18,6 @@ package org.objectweb.jtests.jms.admin; import java.util.Properties; -import org.jboss.util.NestedRuntimeException; - public class AdminFactory { private static final String PROP_NAME = "jms.provider.admin.class"; @@ -36,7 +34,7 @@ public class AdminFactory Admin admin = null; if (adminClassName == null) { - throw new NestedRuntimeException("Property " + AdminFactory.PROP_NAME + " has not been found in input props"); + throw new RuntimeException("Property " + AdminFactory.PROP_NAME + " has not been found in input props"); } try { @@ -45,11 +43,11 @@ public class AdminFactory } catch (ClassNotFoundException e) { - throw new NestedRuntimeException("Class " + adminClassName + " not found.", e); + throw new RuntimeException("Class " + adminClassName + " not found.", e); } catch (Exception e) { - throw new NestedRuntimeException(e); + throw new RuntimeException(e); } return admin; } http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/headers/MessageHeaderTest.java ---------------------------------------------------------------------- diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/headers/MessageHeaderTest.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/headers/MessageHeaderTest.java index ff15eef..530e8a1 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/headers/MessageHeaderTest.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/message/headers/MessageHeaderTest.java @@ -23,8 +23,11 @@ import javax.jms.Message; import javax.jms.Queue; import javax.jms.TemporaryQueue; import javax.naming.Context; +import javax.naming.InitialContext; import javax.naming.NamingException; +import java.util.Hashtable; + import org.junit.Assert; import org.junit.Test; import org.objectweb.jtests.jms.framework.PTPTestCase; @@ -204,7 +207,12 @@ public class MessageHeaderTest extends PTPTestCase try { admin.createQueue("anotherQueue"); - Context ctx = admin.createContext(); + + Hashtable props = new Hashtable<>(); + props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); + props.put("queue.anotherQueue", "anotherQueue"); + + Context ctx = new InitialContext(props); Queue anotherQueue = (Queue)ctx.lookup("anotherQueue"); Assert.assertTrue(anotherQueue != senderQueue); http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/queue/QueueBrowserTest.java ---------------------------------------------------------------------- diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/queue/QueueBrowserTest.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/queue/QueueBrowserTest.java index 7e1496b..7626a54 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/queue/QueueBrowserTest.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/queue/QueueBrowserTest.java @@ -22,7 +22,6 @@ import javax.jms.Message; import javax.jms.QueueBrowser; import javax.jms.TextMessage; -import org.jboss.util.NestedRuntimeException; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -164,7 +163,7 @@ public class QueueBrowserTest extends PTPTestCase } catch (JMSException e) { - throw new NestedRuntimeException(e); + throw new RuntimeException(e); } } http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/session/UnifiedSessionTest.java ---------------------------------------------------------------------- diff --git a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/session/UnifiedSessionTest.java b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/session/UnifiedSessionTest.java index 6d8bc0c..1496579 100644 --- a/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/session/UnifiedSessionTest.java +++ b/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/conform/session/UnifiedSessionTest.java @@ -23,7 +23,6 @@ import javax.jms.Session; import javax.jms.TopicConnection; import javax.jms.TopicSession; -import org.jboss.util.NestedRuntimeException; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -279,7 +278,7 @@ public class UnifiedSessionTest extends UnifiedTestCase } catch (Exception e) { - throw new NestedRuntimeException(e); + throw new RuntimeException(e); } } http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/PTPTestCase.java ---------------------------------------------------------------------- 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 6b39eb6..7d72a3f 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 @@ -23,8 +23,11 @@ import javax.jms.QueueSender; import javax.jms.QueueSession; import javax.jms.Session; import javax.naming.Context; +import javax.naming.InitialContext; -import org.jboss.util.NestedRuntimeException; +import java.util.Hashtable; + +import org.apache.activemq.jndi.ActiveMQInitialContextFactory; import org.junit.After; import org.junit.Before; @@ -117,8 +120,12 @@ public abstract class PTPTestCase extends JMSTestCase admin.createQueueConnectionFactory(PTPTestCase.QCF_NAME); admin.createQueue(PTPTestCase.QUEUE_NAME); - // end of admin step, start of JMS client step - ctx = admin.createContext(); + Hashtable props = new Hashtable<>(); + props.put(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getCanonicalName()); + props.put(ActiveMQInitialContextFactory.CONNECTION_FACTORY_NAMES, PTPTestCase.QCF_NAME); + props.put(Context.PROVIDER_URL, "tcp://127.0.0.1:5445"); + props.put("queue." + PTPTestCase.QUEUE_NAME, PTPTestCase.QUEUE_NAME); + Context ctx = new InitialContext(props); senderQCF = (QueueConnectionFactory)ctx.lookup(PTPTestCase.QCF_NAME); senderQueue = (Queue)ctx.lookup(PTPTestCase.QUEUE_NAME); @@ -138,7 +145,7 @@ public abstract class PTPTestCase extends JMSTestCase } catch (Exception e) { - throw new NestedRuntimeException(e); + throw new RuntimeException(e); } } http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/PubSubTestCase.java ---------------------------------------------------------------------- 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 a4cf57f..fa0282b 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 @@ -23,8 +23,11 @@ import javax.jms.TopicPublisher; import javax.jms.TopicSession; import javax.jms.TopicSubscriber; import javax.naming.Context; +import javax.naming.InitialContext; -import org.jboss.util.NestedRuntimeException; +import java.util.Hashtable; + +import org.apache.activemq.jndi.ActiveMQInitialContextFactory; import org.junit.After; import org.junit.Before; @@ -117,8 +120,12 @@ public abstract class PubSubTestCase extends JMSTestCase admin.createTopicConnectionFactory(PubSubTestCase.TCF_NAME); admin.createTopic(PubSubTestCase.TOPIC_NAME); - // end of admin step, start of JMS client step - ctx = admin.createContext(); + Hashtable props = new Hashtable<>(); + props.put(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getCanonicalName()); + props.put(ActiveMQInitialContextFactory.CONNECTION_FACTORY_NAMES, PubSubTestCase.TCF_NAME); + props.put(Context.PROVIDER_URL, "tcp://127.0.0.1:5445"); + props.put("topic." + PubSubTestCase.TOPIC_NAME, PubSubTestCase.TOPIC_NAME); + Context ctx = new InitialContext(props); publisherTCF = (TopicConnectionFactory)ctx.lookup(PubSubTestCase.TCF_NAME); publisherTopic = (Topic)ctx.lookup(PubSubTestCase.TOPIC_NAME); @@ -140,7 +147,7 @@ public abstract class PubSubTestCase extends JMSTestCase } catch (Exception e) { - throw new NestedRuntimeException(e); + throw new RuntimeException(e); } } http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/joram-tests/src/test/java/org/objectweb/jtests/jms/framework/UnifiedTestCase.java ---------------------------------------------------------------------- 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 2f4b5b2..3264bd5 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 @@ -26,8 +26,11 @@ import javax.jms.Session; import javax.jms.Topic; import javax.jms.TopicConnectionFactory; import javax.naming.Context; +import javax.naming.InitialContext; -import org.jboss.util.NestedRuntimeException; +import java.util.Hashtable; + +import org.apache.activemq.jndi.ActiveMQInitialContextFactory; import org.junit.After; import org.junit.Before; @@ -166,8 +169,14 @@ public abstract class UnifiedTestCase extends JMSTestCase admin.createQueue(UnifiedTestCase.QUEUE_NAME); admin.createTopic(UnifiedTestCase.TOPIC_NAME); - // end of admin step, start of JMS client step - ctx = admin.createContext(); + Hashtable props = new Hashtable<>(); + props.put(Context.INITIAL_CONTEXT_FACTORY, ActiveMQInitialContextFactory.class.getCanonicalName()); + props.put(ActiveMQInitialContextFactory.CONNECTION_FACTORY_NAMES, UnifiedTestCase.CF_NAME + ", " + UnifiedTestCase.QCF_NAME + ", " + UnifiedTestCase.TCF_NAME); + props.put(Context.PROVIDER_URL, "tcp://127.0.0.1:5445"); + 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); producerCF = (ConnectionFactory)ctx.lookup(UnifiedTestCase.CF_NAME); // we see destination of the unified domain as a javax.jms.Destination @@ -197,7 +206,7 @@ public abstract class UnifiedTestCase extends JMSTestCase } catch (Exception e) { - throw new NestedRuntimeException(e); + throw new RuntimeException(e); } } http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/joram-tests/src/test/resources/provider.properties ---------------------------------------------------------------------- diff --git a/tests/joram-tests/src/test/resources/provider.properties b/tests/joram-tests/src/test/resources/provider.properties index b8f137f..49829f3 100644 --- a/tests/joram-tests/src/test/resources/provider.properties +++ b/tests/joram-tests/src/test/resources/provider.properties @@ -27,7 +27,7 @@ # Uncomment the chosen provider and comment the other ones ## -jms.provider.admin.class=org.apache.activemq.jms.ActiveMQQAdmin +jms.provider.admin.class=org.apache.activemq.jms.ActiveMQAdmin #jms.provider.admin.class = org.apache.activemq.api.jms.GenericAdmin #jms.provider.admin.class = org.objectweb.jtests.providers.admin.JoramAdmin #jms.provider.admin.class = org.objectweb.jtests.providers.admin.AshnaMQAdmin http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/performance-tests/pom.xml ---------------------------------------------------------------------- diff --git a/tests/performance-tests/pom.xml b/tests/performance-tests/pom.xml index 7737c3d..ea82e65 100644 --- a/tests/performance-tests/pom.xml +++ b/tests/performance-tests/pom.xml @@ -85,10 +85,6 @@ <artifactId>junit</artifactId> </dependency> <dependency> - <groupId>org.jboss.naming</groupId> - <artifactId>jnpserver</artifactId> - </dependency> - <dependency> <groupId>org.apache.geronimo.specs</groupId> <artifactId>geronimo-ejb_3.0_spec</artifactId> </dependency> http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/soak-tests/pom.xml ---------------------------------------------------------------------- diff --git a/tests/soak-tests/pom.xml b/tests/soak-tests/pom.xml index 7605f74..b876dc1 100644 --- a/tests/soak-tests/pom.xml +++ b/tests/soak-tests/pom.xml @@ -100,10 +100,6 @@ <artifactId>junit</artifactId> </dependency> <dependency> - <groupId>org.jboss.naming</groupId> - <artifactId>jnpserver</artifactId> - </dependency> - <dependency> <groupId>apache-logging</groupId> <artifactId>commons-logging</artifactId> </dependency> http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/stress-tests/pom.xml ---------------------------------------------------------------------- diff --git a/tests/stress-tests/pom.xml b/tests/stress-tests/pom.xml index c957190..9918a61 100644 --- a/tests/stress-tests/pom.xml +++ b/tests/stress-tests/pom.xml @@ -100,10 +100,6 @@ <artifactId>junit</artifactId> </dependency> <dependency> - <groupId>org.jboss.naming</groupId> - <artifactId>jnpserver</artifactId> - </dependency> - <dependency> <groupId>apache-logging</groupId> <artifactId>commons-logging</artifactId> </dependency> http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/timing-tests/pom.xml ---------------------------------------------------------------------- diff --git a/tests/timing-tests/pom.xml b/tests/timing-tests/pom.xml index 202ea26..3b1fb1a 100644 --- a/tests/timing-tests/pom.xml +++ b/tests/timing-tests/pom.xml @@ -82,10 +82,6 @@ <artifactId>junit</artifactId> </dependency> <dependency> - <groupId>org.jboss.naming</groupId> - <artifactId>jnpserver</artifactId> - </dependency> - <dependency> <groupId>org.apache.geronimo.specs</groupId> <artifactId>geronimo-ejb_3.0_spec</artifactId> </dependency> http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/unit-tests/src/test/java/org/apache/activemq/tests/unit/util/InVMContext.java ---------------------------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/tests/unit/util/InVMContext.java b/tests/unit-tests/src/test/java/org/apache/activemq/tests/unit/util/InVMContext.java index 4103b80..88ef024 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/tests/unit/util/InVMContext.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/tests/unit/util/InVMContext.java @@ -277,7 +277,6 @@ public class InVMContext implements Context, Serializable { Hashtable<String, String> env = new Hashtable<String, String>(); env.put("java.naming.factory.initial", "org.apache.activemq.jms.tests.tools.container.InVMInitialContextFactory"); - env.put("java.naming.provider.url", "org.jboss.naming:org.jnp.interface"); return env; } http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/unit-tests/src/test/java/org/apache/activemq/tests/unit/util/InVMNamingContext.java ---------------------------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/tests/unit/util/InVMNamingContext.java b/tests/unit-tests/src/test/java/org/apache/activemq/tests/unit/util/InVMNamingContext.java index edfeae8..7fab4fa 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/tests/unit/util/InVMNamingContext.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/tests/unit/util/InVMNamingContext.java @@ -276,7 +276,6 @@ public class InVMNamingContext implements Context, Serializable { Hashtable<String, String> env = new Hashtable<String, String>(); env.put("java.naming.factory.initial", "org.apache.activemq.jms.tests.tools.container.InVMInitialContextFactory"); - env.put("java.naming.provider.url", "org.jboss.naming:org.jnp.interface"); return env; } http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a3d3a0/tests/unit-tests/src/test/java/org/apache/activemq/tests/unit/util/NonSerializableFactory.java ---------------------------------------------------------------------- diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/tests/unit/util/NonSerializableFactory.java b/tests/unit-tests/src/test/java/org/apache/activemq/tests/unit/util/NonSerializableFactory.java index 4fe692f..767fabf 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/tests/unit/util/NonSerializableFactory.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/tests/unit/util/NonSerializableFactory.java @@ -21,15 +21,12 @@ import javax.naming.Name; import javax.naming.NamingException; import javax.naming.RefAddr; import javax.naming.Reference; -import javax.naming.StringRefAddr; import javax.naming.spi.ObjectFactory; import java.util.Collections; import java.util.HashMap; import java.util.Hashtable; import java.util.Map; -import org.jboss.util.naming.Util; - /** * used by the default context when running in embedded local configuration * @@ -42,47 +39,47 @@ public class NonSerializableFactory implements ObjectFactory { } - public static void unbind(final Context ctx, final String strName) throws NamingException - { - Name name = ctx.getNameParser("").parse(strName); - int size = name.size(); - String atom = name.get(size - 1); - Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1)); - String key = new StringBuilder().append(parentCtx.getNameInNamespace()).append("/").append(atom).toString(); - NonSerializableFactory.getWrapperMap().remove(key); - Util.unbind(ctx, strName); - } - - public static void rebind(final Context ctx, final String strName, final Object value) throws NamingException - { - Name name = ctx.getNameParser("").parse(strName); - int size = name.size(); - String atom = name.get(size - 1); - Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1)); - String key = new StringBuilder().append(parentCtx.getNameInNamespace()).append("/").append(atom).toString(); - NonSerializableFactory.getWrapperMap().put(key, value); - String className = value.getClass().getName(); - String factory = NonSerializableFactory.class.getName(); - StringRefAddr addr = new StringRefAddr("nns", key); - Reference memoryRef = new Reference(className, addr, factory, null); - parentCtx.rebind(atom, memoryRef); - } +// public static void unbind(final Context ctx, final String strName) throws NamingException +// { +// Name name = ctx.getNameParser("").parse(strName); +// int size = name.size(); +// String atom = name.get(size - 1); +// Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1)); +// String key = new StringBuilder().append(parentCtx.getNameInNamespace()).append("/").append(atom).toString(); +// NonSerializableFactory.getWrapperMap().remove(key); +// Util.unbind(ctx, strName); +// } - public static void bind(final Context ctx, final String strName, final Object value) throws NamingException - { - Name name = ctx.getNameParser("").parse(strName); - int size = name.size(); - String atom = name.get(size - 1); - Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1)); - String key = new StringBuilder().append(parentCtx.getNameInNamespace()).append("/").append(atom).toString(); - NonSerializableFactory.getWrapperMap().put(key, value); - String className = value.getClass().getName(); - String factory = NonSerializableFactory.class.getName(); - StringRefAddr addr = new StringRefAddr("nns", key); - Reference memoryRef = new Reference(className, addr, factory, null); +// public static void rebind(final Context ctx, final String strName, final Object value) throws NamingException +// { +// Name name = ctx.getNameParser("").parse(strName); +// int size = name.size(); +// String atom = name.get(size - 1); +// Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1)); +// String key = new StringBuilder().append(parentCtx.getNameInNamespace()).append("/").append(atom).toString(); +// NonSerializableFactory.getWrapperMap().put(key, value); +// String className = value.getClass().getName(); +// String factory = NonSerializableFactory.class.getName(); +// StringRefAddr addr = new StringRefAddr("nns", key); +// Reference memoryRef = new Reference(className, addr, factory, null); +// parentCtx.rebind(atom, memoryRef); +// } - parentCtx.bind(atom, memoryRef); - } +// public static void bind(final Context ctx, final String strName, final Object value) throws NamingException +// { +// Name name = ctx.getNameParser("").parse(strName); +// int size = name.size(); +// String atom = name.get(size - 1); +// Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1)); +// String key = new StringBuilder().append(parentCtx.getNameInNamespace()).append("/").append(atom).toString(); +// NonSerializableFactory.getWrapperMap().put(key, value); +// String className = value.getClass().getName(); +// String factory = NonSerializableFactory.class.getName(); +// StringRefAddr addr = new StringRefAddr("nns", key); +// Reference memoryRef = new Reference(className, addr, factory, null); +// +// parentCtx.bind(atom, memoryRef); +// } public static Object lookup(final String name) throws NamingException {