[jboss-cvs] JBoss Messaging SVN: r5901 - in trunk: tests/joram-tests/src/org/jboss/test/jms and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 19 10:04:28 EST 2009


Author: jmesnil
Date: 2009-02-19 10:04:28 -0500 (Thu, 19 Feb 2009)
New Revision: 5901

Added:
   trunk/tests/joram-tests/src/org/jboss/test/jms/SpawnedJMSServer.java
Modified:
   trunk/.classpath
   trunk/build-messaging.xml
   trunk/tests/joram-tests/src/org/jboss/test/jms/AbstractAdmin.java
   trunk/tests/joram-tests/src/org/jboss/test/jms/GenericAdmin.java
   trunk/tests/joram-tests/src/org/jboss/test/jms/JBossMessagingAdmin.java
   trunk/tests/joram-tests/src/org/objectweb/jtests/jms/admin/Admin.java
   trunk/tests/joram-tests/src/org/objectweb/jtests/jms/framework/JMSTestCase.java
   trunk/tests/src/org/jboss/messaging/tests/util/SpawnedVMSupport.java
Log:
JBMESSAGING-1499: Setup JORAM JMS compliance tests to run against JBM 2.0

* spawn the JMS Server in a new VM so that clients and server are in separate VMs
* use a real JNDI server
* removed joram-tests from hudson-tests

Modified: trunk/.classpath
===================================================================
--- trunk/.classpath	2009-02-19 14:34:03 UTC (rev 5900)
+++ trunk/.classpath	2009-02-19 15:04:28 UTC (rev 5901)
@@ -52,6 +52,7 @@
 	<classpathentry kind="lib" path="thirdparty/jboss/integration/lib/jboss-transaction-spi.jar"/>
 	<classpathentry kind="lib" path="thirdparty/jboss/jboss-jaspi-api/lib/jboss-jaspi-api.jar"/>
 	<classpathentry kind="lib" path="thirdparty/jboss/common/lib/jboss-common.jar"/>
+	<classpathentry kind="lib" path="thirdparty/jboss/jnpserver/lib/jnpserver.jar" sourcepath="thirdparty/jboss/jnpserver/lib/jnpserver-sources.jar"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="lib" path="thirdparty/jboss/jbossts14/lib/jbossjta-integration.jar"/>
 	<classpathentry kind="lib" path="thirdparty/jboss/jboss-javaee/lib/jboss-javaee.jar"/>

Modified: trunk/build-messaging.xml
===================================================================
--- trunk/build-messaging.xml	2009-02-19 14:34:03 UTC (rev 5900)
+++ trunk/build-messaging.xml	2009-02-19 15:04:28 UTC (rev 5901)
@@ -279,6 +279,8 @@
    <path id="joram.test.compilation.classpath">
       <path refid="jms.test.compilation.classpath"/>
       <path location="${test.jms.classes.dir}" />
+      <path location="${test.classes.dir}" />
+      <path refid="jboss.jnpserver.classpath"/>
    </path>
    
    <path id="findbugs.classpath">
@@ -1115,7 +1117,7 @@
       </javac>
    </target>
     
-   <target name="compile-joram-tests" depends="compile-jms-tests">
+   <target name="compile-joram-tests" depends="compile-jms-tests, compile-unit-tests">
       <mkdir dir="${test.joram.classes.dir}"/>
       <javac target="${javac.target}"
              source="${javac.source}"
@@ -1286,9 +1288,6 @@
          <jvmarg value="-Xmx1024M"/>
          <jvmarg value="-Djava.library.path=native/bin"/>
          <jvmarg value="-Dmodule.output=./"/>
-         <jvmarg value="-Djava.util.logging.config.file=src/config/logging.properties"/>
-         <jvmarg
-               value="-Dorg.jboss.logging.Logger.pluginClass=org.jboss.messaging.integration.logging.JBMLoggerPlugin"/>
          <!--<jvmarg line="-Xmx512M -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"/>-->
          <!--<jvmarg value="-ea"/>-->
          <sysproperty key="jbm.remoting.disable.invm" value="${disable.invm}"/>
@@ -1346,7 +1345,7 @@
 
    <target name="all-tests" depends="unit-tests, integration-tests, concurrent-tests, stress-tests, jms-tests"/>
 
-   <target name="hudson-tests" depends="unit-tests, integration-tests, concurrent-tests, timing-tests, jms-tests, joram-tests"/>
+   <target name="hudson-tests" depends="unit-tests, integration-tests, concurrent-tests, timing-tests, jms-tests"/>
 
    <target name="compile-reports">
       <mkdir dir="${test.stylesheets.dir}"/>

Modified: trunk/tests/joram-tests/src/org/jboss/test/jms/AbstractAdmin.java
===================================================================
--- trunk/tests/joram-tests/src/org/jboss/test/jms/AbstractAdmin.java	2009-02-19 14:34:03 UTC (rev 5900)
+++ trunk/tests/joram-tests/src/org/jboss/test/jms/AbstractAdmin.java	2009-02-19 15:04:28 UTC (rev 5901)
@@ -105,11 +105,11 @@
       deleteConnectionFactory(name);
    }
    
-   public void startEmbeddedServer()
+   public void startServer()
    {
    }
    
-   public void stopEmbeddedServer()
+   public void stopServer()
    {
    }
 }

Modified: trunk/tests/joram-tests/src/org/jboss/test/jms/GenericAdmin.java
===================================================================
--- trunk/tests/joram-tests/src/org/jboss/test/jms/GenericAdmin.java	2009-02-19 14:34:03 UTC (rev 5900)
+++ trunk/tests/joram-tests/src/org/jboss/test/jms/GenericAdmin.java	2009-02-19 15:04:28 UTC (rev 5901)
@@ -123,15 +123,15 @@
       delegate.deleteTopicConnectionFactory(name);
    }
    
-   public void startEmbeddedServer() throws Exception
+   public void startServer() throws Exception
    {
       log.debug("startEmbeddedServer");
-      delegate.startEmbeddedServer();
+      delegate.startServer();
    }
    
-   public void stopEmbeddedServer() throws Exception
+   public void stopServer() throws Exception
    {
       log.debug("stopEmbeddedServer");
-      delegate.stopEmbeddedServer();
+      delegate.stopServer();
    }
 }

Modified: trunk/tests/joram-tests/src/org/jboss/test/jms/JBossMessagingAdmin.java
===================================================================
--- trunk/tests/joram-tests/src/org/jboss/test/jms/JBossMessagingAdmin.java	2009-02-19 14:34:03 UTC (rev 5900)
+++ trunk/tests/joram-tests/src/org/jboss/test/jms/JBossMessagingAdmin.java	2009-02-19 15:04:28 UTC (rev 5901)
@@ -41,8 +41,13 @@
 import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
 import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE;
 
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.Hashtable;
+
 import javax.management.ObjectName;
 import javax.naming.Context;
+import javax.naming.InitialContext;
 import javax.naming.NamingException;
 
 import junit.framework.Assert;
@@ -52,18 +57,13 @@
 import org.jboss.messaging.core.client.ClientSession;
 import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
 import org.jboss.messaging.core.client.management.impl.ManagementHelper;
-import org.jboss.messaging.core.config.Configuration;
 import org.jboss.messaging.core.config.TransportConfiguration;
 import org.jboss.messaging.core.config.impl.ConfigurationImpl;
 import org.jboss.messaging.core.management.ObjectNames;
 import org.jboss.messaging.core.security.impl.SecurityStoreImpl;
-import org.jboss.messaging.core.server.Messaging;
-import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
-import org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory;
 import org.jboss.messaging.integration.transports.netty.NettyConnectorFactory;
-import org.jboss.messaging.jms.server.impl.JMSServerManagerImpl;
+import org.jboss.messaging.tests.util.SpawnedVMSupport;
 import org.jboss.messaging.util.SimpleString;
-import org.jboss.test.messaging.tools.container.InVMInitialContextFactory;
 import org.objectweb.jtests.jms.admin.Admin;
 
 /**
@@ -82,22 +82,26 @@
 
    private ClientRequestor requestor;
 
-   private MessagingServiceImpl embeddedServer;
-
    private Context context;
 
+   private Process serverProcess;
+
    public JBossMessagingAdmin()
    {
       try
       {
-         context = new InVMInitialContextFactory().getInitialContext(InVMInitialContextFactory.getJNDIEnvironment());
+         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
    {
       ClientSessionFactoryImpl sf = new ClientSessionFactoryImpl(new TransportConfiguration(NettyConnectorFactory.class.getName()));
@@ -111,7 +115,7 @@
       requestor = new ClientRequestor(clientSession, ConfigurationImpl.DEFAULT_MANAGEMENT_ADDRESS);
       clientSession.start();
    }
-   
+
    public void stop() throws Exception
    {
       requestor.close();
@@ -254,24 +258,30 @@
       return this.getClass().getName();
    }
 
-   public void startEmbeddedServer() throws Exception
+   public void startServer() throws Exception
    {
-      Configuration conf = new ConfigurationImpl();
-      conf.getAcceptorConfigurations().add(new TransportConfiguration(NettyAcceptorFactory.class.getName()));
-      conf.setSecurityEnabled(false);
-      embeddedServer = Messaging.newNullStorageMessagingService(conf);
-      
-      embeddedServer.start();
-      JMSServerManagerImpl serverManager = JMSServerManagerImpl.newJMSServerManagerImpl(embeddedServer.getServer());
-      serverManager.start();
-      serverManager.setContext(context);
+      serverProcess = SpawnedVMSupport.spawnVM(SpawnedJMSServer.class.getName(), false);
+      InputStreamReader isr = new InputStreamReader(serverProcess.getInputStream());
+      BufferedReader br = new BufferedReader(isr);
+      String line = null;
+      while ((line = br.readLine()) != null)
+      {
+         System.out.println(line);
+         if ("OK".equals(line.trim()))
+         {
+            return;
+         } else
+         {
+            throw new IllegalStateException("Unable to start the spawned server");
+         }
+      }
    }
-   
-   public void stopEmbeddedServer() throws Exception
+
+   public void stopServer() throws Exception
    {
-      embeddedServer.stop();
+      serverProcess.destroy();
    }
-   
+
    // Constants -----------------------------------------------------
 
    // Attributes ----------------------------------------------------

Added: trunk/tests/joram-tests/src/org/jboss/test/jms/SpawnedJMSServer.java
===================================================================
--- trunk/tests/joram-tests/src/org/jboss/test/jms/SpawnedJMSServer.java	                        (rev 0)
+++ trunk/tests/joram-tests/src/org/jboss/test/jms/SpawnedJMSServer.java	2009-02-19 15:04:28 UTC (rev 5901)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.jms;
+
+import java.util.Hashtable;
+
+import javax.naming.InitialContext;
+
+import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.server.Messaging;
+import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
+import org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory;
+import org.jboss.messaging.jms.server.impl.JMSServerManagerImpl;
+import org.jnp.server.Main;
+import org.jnp.server.NamingBeanImpl;
+
+/**
+ * A SpawnedServer
+ *
+ * @author jmesnil
+ * 
+ */
+public class SpawnedJMSServer
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   public static void main(String[] args) throws Exception
+   {
+      try
+      {
+         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();
+         conf.getAcceptorConfigurations().add(new TransportConfiguration(NettyAcceptorFactory.class.getName()));
+         conf.setSecurityEnabled(false);
+         final MessagingServiceImpl server = Messaging.newNullStorageMessagingService(conf);
+         server.start();
+
+         JMSServerManagerImpl serverManager = JMSServerManagerImpl.newJMSServerManagerImpl(server.getServer());
+         serverManager.start();
+
+         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");
+         serverManager.setContext(new InitialContext(env));
+
+         Runtime.getRuntime().addShutdownHook(new Thread()
+         {
+            @Override
+            public void run()
+            {
+               try
+               {
+                  server.stop();
+                  jndiServer.stop();
+                  namingInfo.stop();
+                  System.out.println("Server stopped");
+               }
+               catch (Exception e)
+               {
+                  e.printStackTrace();
+               }
+            }
+         });
+
+         System.out.println("OK");
+
+         while (true)
+         {
+            Thread.sleep(100);
+         }
+      }
+      finally
+      {
+         System.out.println("KO");
+      }
+   }
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Modified: trunk/tests/joram-tests/src/org/objectweb/jtests/jms/admin/Admin.java
===================================================================
--- trunk/tests/joram-tests/src/org/objectweb/jtests/jms/admin/Admin.java	2009-02-19 14:34:03 UTC (rev 5900)
+++ trunk/tests/joram-tests/src/org/objectweb/jtests/jms/admin/Admin.java	2009-02-19 15:04:28 UTC (rev 5901)
@@ -130,12 +130,12 @@
    /**
     * Optional method to start the server embedded (instead of running an external server)
     */
-   public void startEmbeddedServer() throws Exception;
+   public void startServer() throws Exception;
    
    /**
     * Optional method to stop the server embedded (instead of running an external server)
     */
-   public void stopEmbeddedServer() throws Exception;
+   public void stopServer() throws Exception;
 
    /**
     * Optional method for processing to be made after the Admin is instantiated and before

Modified: trunk/tests/joram-tests/src/org/objectweb/jtests/jms/framework/JMSTestCase.java
===================================================================
--- trunk/tests/joram-tests/src/org/objectweb/jtests/jms/framework/JMSTestCase.java	2009-02-19 14:34:03 UTC (rev 5900)
+++ trunk/tests/joram-tests/src/org/objectweb/jtests/jms/framework/JMSTestCase.java	2009-02-19 15:04:28 UTC (rev 5901)
@@ -103,7 +103,7 @@
       Properties props = getProviderProperties();
       admin = AdminFactory.getAdmin(props);
       
-      admin.startEmbeddedServer();
+      admin.startServer();
       
       admin.start();
    }
@@ -113,7 +113,7 @@
    {
       admin.stop();
       
-      admin.stopEmbeddedServer();
+      admin.stopServer();
       
       super.tearDown();
    }

Modified: trunk/tests/src/org/jboss/messaging/tests/util/SpawnedVMSupport.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/util/SpawnedVMSupport.java	2009-02-19 14:34:03 UTC (rev 5900)
+++ trunk/tests/src/org/jboss/messaging/tests/util/SpawnedVMSupport.java	2009-02-19 15:04:28 UTC (rev 5901)
@@ -56,16 +56,28 @@
    // Attributes ----------------------------------------------------
 
    // Static --------------------------------------------------------
-
+  
    public static Process spawnVM(String className, String... args)
    throws Exception
    {
-      return spawnVM(className, new String[0], args);
+      return spawnVM(className, new String[0], true, args);
    }
-   
+
+   public static Process spawnVM(String className, boolean logOutput, String... args)
+   throws Exception
+   {
+      return spawnVM(className, new String[0], logOutput, args);
+   }
+
    public static Process spawnVM(String className, String[] vmargs, String... args)
    throws Exception
    {
+      return spawnVM(className, vmargs, true, args);
+   }
+   
+   public static Process spawnVM(String className, String[] vmargs, boolean logOutput, String... args)
+   throws Exception
+   {
       StringBuffer sb = new StringBuffer();
 
       sb.append("java").append(' ');
@@ -107,10 +119,13 @@
 
       log.trace("process: " + process);
 
-      ProcessLogger outputLogger = new ProcessLogger(process.getInputStream(),
-                                                     className);
-      outputLogger.start();
-
+      if (logOutput)
+      {
+         ProcessLogger outputLogger = new ProcessLogger(process.getInputStream(),
+                                                        className);
+         outputLogger.start();
+      }
+      
       return process;
    }
 




More information about the jboss-cvs-commits mailing list