[jboss-cvs] JBoss Messaging SVN: r1972 - in trunk: src/main/org/jboss/jms/server and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jan 17 09:29:46 EST 2007
Author: ovidiu.feodorov at jboss.com
Date: 2007-01-17 09:29:46 -0500 (Wed, 17 Jan 2007)
New Revision: 1972
Added:
trunk/tests/src/org/jboss/test/messaging/util/JNDITest.java
trunk/tests/src/org/jboss/test/messaging/util/JNDITesterService.java
trunk/tests/src/org/jboss/test/messaging/util/JNDITesterServiceMBean.java
Modified:
trunk/src/main/org/jboss/jms/client/container/ExceptionInterceptor.java
trunk/src/main/org/jboss/jms/server/ServerPeer.java
trunk/tests/etc/log4j.trace.xml
trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java
trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMInitialContextFactory.java
trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMInitialContextFactoryBuilder.java
trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java
Log:
added a test for a JNDI-related test framework problem, plus the fix, and also some extra minor refactoring
Modified: trunk/src/main/org/jboss/jms/client/container/ExceptionInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/ExceptionInterceptor.java 2007-01-16 21:55:16 UTC (rev 1971)
+++ trunk/src/main/org/jboss/jms/client/container/ExceptionInterceptor.java 2007-01-17 14:29:46 UTC (rev 1972)
@@ -51,8 +51,6 @@
// Attributes -----------------------------------------------------------------------------------
- private boolean trace = log.isTraceEnabled();
-
// Constructors ---------------------------------------------------------------------------------
// Public ---------------------------------------------------------------------------------------
Modified: trunk/src/main/org/jboss/jms/server/ServerPeer.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/ServerPeer.java 2007-01-16 21:55:16 UTC (rev 1971)
+++ trunk/src/main/org/jboss/jms/server/ServerPeer.java 2007-01-17 14:29:46 UTC (rev 1972)
@@ -186,7 +186,7 @@
throw new IllegalArgumentException("ID cannot be negative");
}
- log.info(this + " creating serverpeer with id " + serverPeerID);
+ log.info(this + " creating server peer with ID " + serverPeerID);
this.serverPeerID = serverPeerID;
this.defaultQueueJNDIContext = defaultQueueJNDIContext;
Modified: trunk/tests/etc/log4j.trace.xml
===================================================================
--- trunk/tests/etc/log4j.trace.xml 2007-01-16 21:55:16 UTC (rev 1971)
+++ trunk/tests/etc/log4j.trace.xml 2007-01-17 14:29:46 UTC (rev 1972)
@@ -37,6 +37,10 @@
</layout>
</appender>
+ <category name="com.arjuna">
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+ </category>
+
<category name="org.apache">
<priority value="INFO"/>
</category>
Modified: trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java 2007-01-16 21:55:16 UTC (rev 1971)
+++ trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java 2007-01-17 14:29:46 UTC (rev 1972)
@@ -35,7 +35,6 @@
import javax.management.NotificationListener;
import javax.management.Notification;
import javax.transaction.UserTransaction;
-import org.jboss.jms.message.MessageIdGeneratorFactory;
import org.jboss.jms.server.DestinationManager;
import org.jboss.logging.Logger;
import org.jboss.messaging.core.plugin.contract.MessageStore;
@@ -263,14 +262,14 @@
servers[i] = null;
}
}
-
+
//Need to do this after a poison otherwise this will think the server is still alive
public static synchronized void nullServer(int i)
{
servers[i] = null;
}
- /**
+ /**
* Kills the server and waits keep trying any dumb communication until the server is effectively
* killed. We had to implement this method as kill will actually schedule a thread that will
* perform System.exit after few milliseconds. We will use this method in places where we need
@@ -342,7 +341,7 @@
{
return null;
}
-
+
StringBuffer sb = new StringBuffer();
sb.append("java").append(' ');
@@ -354,7 +353,7 @@
{
moduleOutput = "./output";
}
-
+
sb.append("-Dmodule.output=").append(moduleOutput).append(' ');
sb.append("-Dtest.bind.address=localhost").append(' ');
@@ -403,12 +402,11 @@
testLogfileSuffix = testLogfileSuffix.substring(0, pos) + "server";
}
- //We need to add the i even in the non clustered case since we can have multiple
- //non clustered servers
+ // We need to add the i even in the non clustered case since we can have multiple
+ // non clustered servers
testLogfileSuffix += i;
-
}
-
+
sb.append("-Dtest.logfile.suffix=").append(testLogfileSuffix).append(' ');
String classPath = System.getProperty("java.class.path");
@@ -641,7 +639,7 @@
insureStarted();
return servers[0].getServer().getUserTransaction();
}
-
+
public static void log(int level, String text)
{
log(level, text, 0);
@@ -795,7 +793,7 @@
insureStarted();
return servers[0].getServer().getDefaultSecurityConfig();
}
-
+
/**
* Simulates a topic deployment (copying the topic descriptor in the deploy directory).
*/
@@ -848,7 +846,7 @@
{
undeployDestination(false, name);
}
-
+
/**
* Simulates a topic un-deployment (deleting the topic descriptor from the deploy directory).
*/
@@ -873,7 +871,7 @@
{
return servers[0].getServer().destroyDestination(false, name);
}
-
+
/**
* Simulates a queue deployment (copying the queue descriptor in the deploy directory).
*/
@@ -926,7 +924,7 @@
{
undeployDestination(true, name);
}
-
+
/**
* Simulates a queue un-deployment (deleting the queue descriptor from the deploy directory).
*/
@@ -961,7 +959,7 @@
insureStarted();
servers[0].getServer().undeployDestination(isQueue, name);
}
-
+
/**
* Simulates a destination un-deployment (deleting the destination descriptor from the deploy
* directory).
@@ -972,7 +970,7 @@
insureStarted(serverIndex);
servers[serverIndex].getServer().undeployDestination(isQueue, name);
}
-
+
public static void deployConnectionFactory(String objectName,
String[] jndiBindings,
int prefetchSize,
@@ -996,7 +994,7 @@
{
servers[0].getServer().deployConnectionFactory(objectName, jndiBindings, prefetchSize);
}
-
+
public static void deployConnectionFactory(String objectName,
String[] jndiBindings)
throws Exception
@@ -1013,7 +1011,7 @@
{
return getJNDIEnvironment(0);
}
-
+
public static Hashtable getJNDIEnvironment(int serverIndex)
{
if (isLocal())
@@ -1031,7 +1029,7 @@
String name =
"//localhost:" + RMITestServer.DEFAULT_REGISTRY_PORT + "/" +
RMITestServer.RMI_SERVER_PREFIX + index;
-
+
Server s = null;
int retries = initialRetries;
Modified: trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMInitialContextFactory.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMInitialContextFactory.java 2007-01-16 21:55:16 UTC (rev 1971)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMInitialContextFactory.java 2007-01-17 14:29:46 UTC (rev 1972)
@@ -62,7 +62,7 @@
{
Hashtable env = new Hashtable();
env.put("java.naming.factory.initial",
- "org.jboss.messaging.tools.jndi.InVMInitialContextFactory");
+ "org.jboss.test.messaging.tools.jndi.InVMInitialContextFactory");
env.put("java.naming.provider.url", "");
env.put("java.naming.factory.url.pkgs", "");
env.put(Constants.SERVER_INDEX_PROPERTY_NAME, Integer.toString(serverIndex));
Modified: trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMInitialContextFactoryBuilder.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMInitialContextFactoryBuilder.java 2007-01-16 21:55:16 UTC (rev 1971)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMInitialContextFactoryBuilder.java 2007-01-17 14:29:46 UTC (rev 1972)
@@ -21,6 +21,8 @@
*/
package org.jboss.test.messaging.tools.jndi;
+import org.jboss.logging.Logger;
+
import javax.naming.spi.InitialContextFactoryBuilder;
import javax.naming.spi.InitialContextFactory;
import javax.naming.NamingException;
@@ -35,34 +37,80 @@
*/
public class InVMInitialContextFactoryBuilder implements InitialContextFactoryBuilder
{
- // Constants -----------------------------------------------------
+ // Constants ------------------------------------------------------------------------------------
- // Static --------------------------------------------------------
+ private static final Logger log = Logger.getLogger(InVMInitialContextFactoryBuilder.class);
- // Attributes ----------------------------------------------------
+ // Static ---------------------------------------------------------------------------------------
- // Constructors --------------------------------------------------
+ // Attributes -----------------------------------------------------------------------------------
+ // Constructors ---------------------------------------------------------------------------------
+
public InVMInitialContextFactoryBuilder()
{
}
- // InitialContextFactoryBuilder implementation -------------------
+ // InitialContextFactoryBuilder implementation --------------------------------------------------
public InitialContextFactory createInitialContextFactory(Hashtable environment)
throws NamingException
{
- return new InVMInitialContextFactory();
+
+ InitialContextFactory icf = null;
+
+ if (environment != null)
+ {
+ String icfName = (String)environment.get("java.naming.factory.initial");
+
+ if (icfName != null)
+ {
+ Class c = null;
+
+ try
+ {
+ c = Class.forName(icfName);
+ }
+ catch(ClassNotFoundException e)
+ {
+ log.error("\"" + icfName + "\" cannot be loaded", e);
+ throw new NamingException("\"" + icfName + "\" cannot be loaded");
+ }
+
+ try
+ {
+ icf = (InitialContextFactory)c.newInstance();
+ }
+ catch(InstantiationException e)
+ {
+ log.error(c.getName() + " cannot be instantiated", e);
+ throw new NamingException(c.getName() + " cannot be instantiated");
+ }
+ catch(IllegalAccessException e)
+ {
+ log.error(c.getName() + " instantiation generated an IllegalAccessException", e);
+ throw new NamingException(c.getName() +
+ " instantiation generated an IllegalAccessException");
+ }
+ }
+ }
+
+ if (icf == null)
+ {
+ icf = new InVMInitialContextFactory();
+ }
+
+ return icf;
}
- // Public --------------------------------------------------------
+ // Public ---------------------------------------------------------------------------------------
- // Package protected ---------------------------------------------
+ // Package protected ----------------------------------------------------------------------------
- // Protected -----------------------------------------------------
+ // Protected ------------------------------------------------------------------------------------
- // Private -------------------------------------------------------
+ // Private --------------------------------------------------------------------------------------
- // Inner classes -------------------------------------------------
+ // Inner classes --------------------------------------------------------------------------------
}
Modified: trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java 2007-01-16 21:55:16 UTC (rev 1971)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java 2007-01-17 14:29:46 UTC (rev 1972)
@@ -26,7 +26,6 @@
import javax.naming.NamingException;
import javax.naming.spi.InitialContextFactory;
import org.jboss.logging.Logger;
-import org.jboss.test.messaging.tools.jmx.rmi.RMITestServer;
/**
* @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
Added: trunk/tests/src/org/jboss/test/messaging/util/JNDITest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/util/JNDITest.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/util/JNDITest.java 2007-01-17 14:29:46 UTC (rev 1972)
@@ -0,0 +1,115 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.messaging.util;
+
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.logging.Logger;
+
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+import java.util.Hashtable;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class JNDITest extends MessagingTestCase
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(JNDITest.class);
+
+ // Static ---------------------------------------------------------------------------------------
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public JNDITest(String name)
+ {
+ super(name);
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ public void testInterServerJNDI() throws Exception
+ {
+ // this test doesn't make sense in a colocated topology.
+
+ if (!isRemote())
+ {
+ return;
+ }
+
+ try
+ {
+ ServerManagement.start(0, "all", true);
+ ServerManagement.start(1, "all", false);
+
+ // deploy an initial context "consumer" service on server 0
+
+ String serviceName = "test:service=JNDITesterService";
+ ObjectName on = new ObjectName(serviceName);
+
+ String serviceConfig =
+ "<mbean code=\"org.jboss.test.messaging.util.JNDITesterService\"\n" +
+ " name=\"" + serviceName + "\">\n" +
+ "</mbean>";
+
+ ServerManagement.deploy(serviceConfig);
+
+ // Deploy something into the server 1 JNDI namespace
+
+ InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment(1));
+
+ ic.bind("/", "bingo");
+
+ log.debug("deployed");
+
+ // feed the service with an JNDI environment from server 1
+
+ Hashtable environment = ServerManagement.getJNDIEnvironment(1);
+ String s = (String)ServerManagement.
+ invoke(on, "installAndUseJNDIEnvironment",
+ new Object[] { environment, "/" },
+ new String[] { "java.util.Hashtable", "java.lang.String" });
+
+ assertEquals("bingo", s);
+
+ }
+ finally
+ {
+ ServerManagement.stop(1);
+ ServerManagement.kill(1);
+ ServerManagement.stop(0);
+ }
+ }
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+
+
+}
Property changes on: trunk/tests/src/org/jboss/test/messaging/util/JNDITest.java
___________________________________________________________________
Name: svn:keywords
+ Id LastChangedDate Author Revision
Added: trunk/tests/src/org/jboss/test/messaging/util/JNDITesterService.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/util/JNDITesterService.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/util/JNDITesterService.java 2007-01-17 14:29:46 UTC (rev 1972)
@@ -0,0 +1,48 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.messaging.util;
+
+import javax.naming.InitialContext;
+import java.util.Hashtable;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ * $Id$
+ */
+public class JNDITesterService implements JNDITesterServiceMBean
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ // Static ---------------------------------------------------------------------------------------
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ // JNDITesterServiceMBean implementation --------------------------------------------------------
+
+ public Object installAndUseJNDIEnvironment(Hashtable environment, String thingToLookUp)
+ throws Exception
+ {
+
+ InitialContext ic = new InitialContext(environment);
+
+ return ic.lookup(thingToLookUp);
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+
+}
Property changes on: trunk/tests/src/org/jboss/test/messaging/util/JNDITesterService.java
___________________________________________________________________
Name: svn:keywords
+ Id LastChangedDate Author Revision
Added: trunk/tests/src/org/jboss/test/messaging/util/JNDITesterServiceMBean.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/util/JNDITesterServiceMBean.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/util/JNDITesterServiceMBean.java 2007-01-17 14:29:46 UTC (rev 1972)
@@ -0,0 +1,20 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.messaging.util;
+
+import java.util.Hashtable;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ * $Id$
+ */
+public interface JNDITesterServiceMBean
+{
+ Object installAndUseJNDIEnvironment(Hashtable environment, String thingToLookUp)
+ throws Exception;
+}
Property changes on: trunk/tests/src/org/jboss/test/messaging/util/JNDITesterServiceMBean.java
___________________________________________________________________
Name: svn:keywords
+ Id LastChangedDate Author Revision
More information about the jboss-cvs-commits
mailing list