[jboss-cvs] JBossAS SVN: r85713 - in projects/ejb3/trunk: proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess and 8 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Mar 11 02:17:25 EDT 2009


Author: ALRubinger
Date: 2009-03-11 02:17:25 -0400 (Wed, 11 Mar 2009)
New Revision: 85713

Added:
   projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/unit/ProxyMockServer.java
   projects/ejb3/trunk/test-remote/src/main/java/org/
   projects/ejb3/trunk/test-remote/src/main/java/org/jboss/
   projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/
   projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/
   projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/
   projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/JndiPropertiesToJndiRemotePropertiesHackCl.java
   projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/JndiPropertiesToJnpserverPropertiesHackCl.java
   projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/MockServer.java
   projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/MockServerController.java
   projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/MockServerInvocationHandler.java
   projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/RedirectClassloader.java
Removed:
   projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/JndiPropertiesToJndiRemotePropertiesHackCl.java
   projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/JndiPropertiesToJnpserverPropertiesHackCl.java
   projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/MockServer.java
   projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/MockServerController.java
   projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/MockServerInvocationHandler.java
   projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/RedirectClassloader.java
Modified:
   projects/ejb3/trunk/proxy/pom.xml
   projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/unit/RemoteAccessTestCase.java
   projects/ejb3/trunk/test-remote/pom.xml
Log:
[EJBTHREE-1760] Moved remote MockServer from ejb3-proxy into its own component, updated ejb3-proxy to use the new component

Modified: projects/ejb3/trunk/proxy/pom.xml
===================================================================
--- projects/ejb3/trunk/proxy/pom.xml	2009-03-11 05:30:46 UTC (rev 85712)
+++ projects/ejb3/trunk/proxy/pom.xml	2009-03-11 06:17:25 UTC (rev 85713)
@@ -1,3 +1,6 @@
+<!--
+  vi:ts=2:sw=2:expandtab
+-->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 
   <!-- Parent -->
@@ -4,7 +7,7 @@
   <parent>
     <groupId>org.jboss.ejb3</groupId>
     <artifactId>jboss-ejb3-build</artifactId>
-    <version>1.0.0</version>
+    <version>1.0.3-SNAPSHOT</version>
   </parent>
 
   <!-- Model Version -->
@@ -65,17 +68,6 @@
     </plugins>
 
   </build>
-
-  <dependencyManagement>
-    <dependencies>
-      <!-- Because of a bug in m2eclipse the version of reflect must be explicitly defined 
-      <dependency>
-        <groupId>org.jboss</groupId>
-        <artifactId>jboss-reflect</artifactId>
-        <version>2.0.0.Beta12</version>
-      </dependency> -->
-    </dependencies>
-  </dependencyManagement>
   
   <!-- Dependencies -->
   <dependencies>
@@ -90,12 +82,6 @@
     <dependency>
       <groupId>org.jboss.aspects</groupId>
       <artifactId>jboss-remoting-aspects</artifactId>
-      <exclusions>
-        <exclusion>
-	  <groupId>org.jboss</groupId>
-	  <artifactId>jboss-transaction-spi</artifactId>
-	</exclusion>
-      </exclusions>
     </dependency>
 
     <dependency>
@@ -116,6 +102,13 @@
       <version>1.0.0</version>
       <scope>test</scope>
     </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.ejb3</groupId>
+      <artifactId>jboss-ejb3-test-remote</artifactId>
+      <version>0.0.1-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
 
     <dependency>
       <groupId>org.jboss.logging</groupId>
@@ -149,7 +142,7 @@
       <artifactId>concurrent</artifactId>
       <version>1.3.4-jboss-update1</version>
       <scope>test</scope>
-    </dependency>        
+    </dependency>
 
   </dependencies>
 </project>

Deleted: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/JndiPropertiesToJndiRemotePropertiesHackCl.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/JndiPropertiesToJndiRemotePropertiesHackCl.java	2009-03-11 05:30:46 UTC (rev 85712)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/JndiPropertiesToJndiRemotePropertiesHackCl.java	2009-03-11 06:17:25 UTC (rev 85713)
@@ -1,52 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.ejb3.test.proxy.remoteaccess;
-
-/**
- * JndiPropertiesToJnpserverPropertiesHackCl
- * 
- * Hacky classloader to use to switch requests for 
- * "jndi.properties" to use "jndi-remote.properties"
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class JndiPropertiesToJndiRemotePropertiesHackCl extends RedirectClassloader
-{
-
-   private static final String TO_REPLACE = "jndi.properties";
-
-   private static final String REPLACE_WITH = "jndi-remote.properties";
-
-   @Override
-   protected String getFrom()
-   {
-      return JndiPropertiesToJndiRemotePropertiesHackCl.TO_REPLACE;
-   }
-
-   @Override
-   protected String getTo()
-   {
-      return JndiPropertiesToJndiRemotePropertiesHackCl.REPLACE_WITH;
-   }
-
-}

Deleted: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/JndiPropertiesToJnpserverPropertiesHackCl.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/JndiPropertiesToJnpserverPropertiesHackCl.java	2009-03-11 05:30:46 UTC (rev 85712)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/JndiPropertiesToJnpserverPropertiesHackCl.java	2009-03-11 06:17:25 UTC (rev 85713)
@@ -1,53 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.ejb3.test.proxy.remoteaccess;
-
-/**
- * JndiPropertiesToJnpserverPropertiesHackCl
- * 
- * Hacky classloader to use to prevent the JNP Server from
- * loading jndi.properties (which should be used by clients 
- * only) and instead swapping for jnpserver.properties
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class JndiPropertiesToJnpserverPropertiesHackCl extends RedirectClassloader
-{
-
-   private static final String TO_REPLACE = "jndi.properties";
-
-   private static final String REPLACE_WITH = "jnpserver.properties";
-
-   @Override
-   protected String getFrom()
-   {
-      return JndiPropertiesToJnpserverPropertiesHackCl.TO_REPLACE;
-   }
-
-   @Override
-   protected String getTo()
-   {
-      return JndiPropertiesToJnpserverPropertiesHackCl.REPLACE_WITH;
-   }
-
-}

Deleted: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/MockServer.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/MockServer.java	2009-03-11 05:30:46 UTC (rev 85712)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/MockServer.java	2009-03-11 06:17:25 UTC (rev 85713)
@@ -1,334 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.ejb3.test.proxy.remoteaccess;
-
-import java.net.URL;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.AspectXmlLoader;
-import org.jboss.ejb3.common.registrar.plugin.mc.Ejb3McRegistrar;
-import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
-import org.jboss.ejb3.test.mc.bootstrap.EmbeddedTestMcBootstrap;
-import org.jboss.ejb3.test.proxy.common.Utils;
-import org.jboss.ejb3.test.proxy.common.container.StatefulContainer;
-import org.jboss.ejb3.test.proxy.common.container.StatelessContainer;
-import org.jboss.ejb3.test.proxy.common.ejb.sfsb.MyStatefulBean;
-import org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessBean;
-import org.jboss.logging.Logger;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.remoting.transport.Connector;
-
-/**
- * MockServer
- * 
- * Launches a new MC Bootstrap, EJB Containers, and performs
- * all initialization to mock a remote server environment
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class MockServer
-{
-
-   // --------------------------------------------------------------------------------||
-   // Class Members ------------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   private static final Logger log = Logger.getLogger(MockServer.class);
-
-   /**
-    * Invocation request to the MockServer will be handler by this
-    * invocation handler
-    */
-   private ServerInvocationHandler mockServerInvocationHandler;
-
-   private static final String FILENAME_EJB3_INTERCEPTORS_AOP = "ejb3-interceptors-aop.xml";
-
-   /**
-    * Various possible server status
-    */
-   public enum MockServerStatus {
-      STARTED, STOPPED
-   }
-
-   /**
-    * 
-    * Various possible server requests
-    */
-   public enum MockServerRequest {
-      START, STOP
-   }
-
-   // --------------------------------------------------------------------------------||
-   // Instance Members ---------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   private EmbeddedTestMcBootstrap bootstrap;
-
-   /**
-    * Accept requests from client using this {@link Connector} 
-    */
-   private Connector remoteConnector;
-
-   /**
-    * The current state of the server 
-    */
-   private MockServerStatus currentStatus = MockServerStatus.STOPPED;
-
-   /**
-    * The Test Class using this launcher
-    */
-   private Class<?> testClass;
-
-   // --------------------------------------------------------------------------------||
-   // Constructor --------------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   /**
-    * Constructor
-    * Configures and creates a socket based {@link Connector} which will
-    * accept (start/stop) requests from client 
-    */
-   public MockServer(Class<?> testClass, String serverHost, int port)
-   {
-      this.setTestClass(testClass);
-      String uri = "socket://" + serverHost + ":" + port;
-      try
-      {
-         InvokerLocator invokerLocator = new InvokerLocator(uri);
-
-         this.remoteConnector = new Connector(invokerLocator);
-         this.remoteConnector.create();
-         this.mockServerInvocationHandler = new MockServerInvocationHandler(this);
-         this.remoteConnector.addInvocationHandler("EJB3Test", this.mockServerInvocationHandler);
-         log.debug("Connector created for accepting MockServer requests");
-
-      }
-      catch (Exception e)
-      {
-         log.error("Could not create Mockserver for testclass = " + testClass + " serverHost= " + serverHost
-               + " port= " + port,e);
-         throw new RuntimeException("Could not start server at " + uri, e);
-      }
-
-   }
-
-   // --------------------------------------------------------------------------------||
-   // Main ---------------------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   /**
-    * Runtime Entry Point
-    * 
-    * @param args
-    */
-   public static void main(String... args)
-   {
-
-      // Assert test class passed in
-      assert args.length > 2 : "Parameters requried (in that order): <Fully qualified test case name> <serverBindAddress> <serverPort> ";
-
-      // Get Test Class
-      String testClassname = args[0];
-      Class<?> testClass = null;
-      try
-      {
-         testClass = Class.forName(testClassname);
-      }
-      catch (ClassNotFoundException cnfe)
-      {
-         throw new RuntimeException("Specified Test Class, \"" + testClassname + "\" could not be found", cnfe);
-      }
-
-      // Create a new Launcher
-      // the serverBindAddress and the port are always the last two arguments
-      log.debug("Creating a MockServer for testclass = " + testClass + " and serverBindAddr = " + args[args.length - 2]
-            + " and port = " + args[args.length - 1]);
-      MockServer launcher = new MockServer(testClass, args[args.length - 2], Integer.parseInt(args[args.length - 1]));
-      try
-      {
-         // Ready to receive (start/stop) requests
-         launcher.acceptRequests();
-      }
-      catch (Throwable e)
-      {
-         log.error("Exception in MockServer while wating for requests ",e);
-         throw new RuntimeException("Exception while waiting for requests ", e);
-      }
-
-   }
-
-   // --------------------------------------------------------------------------------||
-   // Functional Methods -------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   /**
-    * Initializes the instance by starting up an MC Bootstrap, 
-    * deploying relevant *-beans.xml, creating and installing EJB Containers
-    */
-   protected void initialize() throws Throwable
-   {
-      // Create and set a new MC Bootstrap 
-      this.setBootstrap(EmbeddedTestMcBootstrap.createEmbeddedMcBootstrap());
-
-      // Add a Shutdown Hook
-      //Runtime.getRuntime().addShutdownHook(new ShutdownHook());
-
-      // Bind the Ejb3Registrar
-      Ejb3RegistrarLocator.bindRegistrar(new Ejb3McRegistrar(bootstrap.getKernel()));
-
-      // Switch up to the hacky CL so that "jndi.properties" is not loaded
-      ClassLoader olderLoader = Thread.currentThread().getContextClassLoader();
-      try {
-         Thread.currentThread().setContextClassLoader(new JndiPropertiesToJnpserverPropertiesHackCl());
-   
-         // Deploy *-beans.xml
-         this.getBootstrap().deploy(this.getTestClass());
-   
-         // Load ejb3-interceptors-aop.xml into AspectManager
-         ClassLoader cl = Thread.currentThread().getContextClassLoader();
-         URL url = cl.getResource(FILENAME_EJB3_INTERCEPTORS_AOP);
-         if (url == null)
-         {
-            throw new RuntimeException("Could not load " + AspectManager.class.getSimpleName()
-                  + " with definitions from XML as file " + FILENAME_EJB3_INTERCEPTORS_AOP + " could not be found");
-         }
-         AspectXmlLoader.deployXML(url);
-      } finally {
-         // Restore old CL
-         Thread.currentThread().setContextClassLoader(olderLoader);
-      }
-
-      // Create a SLSB Container
-      StatelessContainer slsbContainer = Utils.createSlsb(MyStatelessBean.class);
-      log.info("Created SLSB Container: " + slsbContainer.getName());
-
-      // Create a SFSB Container
-      StatefulContainer sfsbContainer = Utils.createSfsb(MyStatefulBean.class);
-      log.info("Created SFSB Container: " + sfsbContainer.getName());
-
-      // Install into MC
-      this.getBootstrap().installInstance(slsbContainer.getName(), slsbContainer);
-      this.getBootstrap().installInstance(sfsbContainer.getName(), sfsbContainer);
-
-   }
-
-   /**
-    * Starts the server <br>
-    * 
-    * @throws IllegalStateException If the server is not in {@link MockServerStatus.STOPPED}
-    *           state 
-    * @throws Throwable
-    */
-   public void start() throws Throwable
-   {
-      // Server will be started only if current state is STOPPED
-      if (!this.currentStatus.equals(MockServerStatus.STOPPED))
-      {
-         throw new IllegalStateException("Cannot start MockServer when its in " + getStatus() + " state");
-      }
-      initialize();
-      this.currentStatus = MockServerStatus.STARTED;
-      log.info("MockServer started");
-   }
-
-   /**
-    * Stops the server <br>
-    * 
-    * @throws IllegalStateException If the server is not in {@link MockServerStatus.STARTED} 
-    *           state
-    */
-   public void stop()
-   {
-      // Server will be stopped only if current state is STARTED
-      if (!this.currentStatus.equals(MockServerStatus.STARTED))
-      {
-         throw new IllegalStateException("Cannot stop MockServer when its in " + getStatus() + " state");
-      }
-      this.bootstrap.shutdown();
-      this.currentStatus = MockServerStatus.STOPPED;
-      log.info("MockServer stopped");
-
-      // Note: Do not stop the Connector which is waiting for clients to 
-      // connect. Letting the Connector remain in waiting state will allow
-      // clients to restart this MockServer by sending the MockServerRequest.START
-      // request again.
-   }
-
-   /**
-    * 
-    * @return Returns the current status of the server
-    */
-   public MockServerStatus getStatus()
-   {
-      return this.currentStatus;
-   }
-
-   /**
-    * Start accepting requests <br>
-    * This is a blocking call and will wait for clients to connect
-    * 
-    * @see {@link Connector#start()}
-    * @throws Throwable
-    */
-   protected void acceptRequests() throws Throwable
-   {
-      this.remoteConnector.start();
-   }
-
-   /**
-    * 
-    * @param serverInvocationHandler The {@link ServerInvocationHandler} to
-    *   handle requests
-    */
-   protected void setInvocationHandler(ServerInvocationHandler serverInvocationHandler)
-   {
-      this.mockServerInvocationHandler = serverInvocationHandler;
-
-   }
-
-   // --------------------------------------------------------------------------------||
-   // Accessors / Mutators -----------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   public EmbeddedTestMcBootstrap getBootstrap()
-   {
-      return this.bootstrap;
-   }
-
-   public void setBootstrap(EmbeddedTestMcBootstrap bootstrap)
-   {
-      this.bootstrap = bootstrap;
-   }
-
-   public Class<?> getTestClass()
-   {
-      return testClass;
-   }
-
-   public void setTestClass(Class<?> testClass)
-   {
-      this.testClass = testClass;
-   }
-
-}

Deleted: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/MockServerController.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/MockServerController.java	2009-03-11 05:30:46 UTC (rev 85712)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/MockServerController.java	2009-03-11 06:17:25 UTC (rev 85713)
@@ -1,441 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.ejb3.test.proxy.remoteaccess;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.ejb3.common.thread.RedirectProcessOutputToSystemOutThread;
-import org.jboss.ejb3.test.proxy.remoteaccess.MockServer.MockServerRequest;
-import org.jboss.logging.Logger;
-import org.jboss.remoting.CannotConnectException;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.InvokerLocator;
-
-/**
- * MockServerController
- * 
- * Controls the startup/shutdown of the {@link MockServer} <br/>
- * 
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class MockServerController
-{
-
-   /**
-    * Instance of logger
-    */
-   private static Logger logger = Logger.getLogger(MockServerController.class);
-
-   /**
-    * JAVA_HOME env variable
-    */
-   private static final String ENV_VAR_JAVAHOME = "JAVA_HOME";
-
-   /**
-    * Java executable
-    */
-   private static final String EXECUTABLE_JAVA = "bin" + File.separator + "java";
-
-   /**
-    * The basedir
-    */
-   private static final String LOCATION_BASEDIR = System.getProperty("basedir");
-
-   private static final String LOCATION_TARGET = MockServerController.LOCATION_BASEDIR + File.separator + "target";
-
-   private static final String LOCATION_TEST_CLASSES = MockServerController.LOCATION_TARGET + File.separator
-         + "tests-classes";
-
-   private static final String LOCATION_CLASSES = MockServerController.LOCATION_TARGET + File.separator + "classes";
-
-   private static final String LOCATION_CONF = MockServerController.LOCATION_BASEDIR + File.separator + "conf";
-
-   private static final String FILENAME_DEPENDENCY_CP = MockServerController.LOCATION_TARGET + File.separator
-         + "cp.txt";
-
-   /**
-    * Timeout in milli sec. for server startup. Defaults to 2 minutes.
-    */
-   private int serverStartupTimeout = 120000;
-
-   /**
-    * Timeout in milli sec. for the server to shutdown. Defaults to 2 minutes.
-    */
-   private int serverStopTimeout = 120000;
-
-   /**
-    * The port number on which the {@link MockServer}
-    * is available for requests
-    */
-   private int port;
-
-   /**
-    * The host on which the {@link MockServer}
-    * is available for requests
-    */
-   private String serverHost;
-
-   /**
-    * Remote process in which the {@link MockServer} will run
-    */
-   private Process remoteProcess;
-
-   /**
-    * {@link Client} for sending requests to the {@link MockServer}
-    */
-   private Client mockServerClient;
-
-   /**
-    * Constructor <br>
-    * Creates a {@link Client} to send requests to the remote {@link MockServer}
-    *   
-    * @param host The host on which the {@link MockServer} is available
-    * @param port The port on which the {@link MockServer} is listening
-    */
-   public MockServerController(String host, int port)
-   {
-      this.serverHost = host;
-      this.port = port;
-      String uri = null;
-      try
-      {
-         uri = "socket://" + this.serverHost + ":" + this.port;
-         InvokerLocator invokerLocator = new InvokerLocator(uri);
-         this.mockServerClient = new Client(invokerLocator);
-
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException("Could not create server controller: ", e);
-      }
-
-   }
-
-   /**
-    * Creates a remote process (JVM) to launch the {@link MockServer}
-    * and then sends a {@link MockServerRequest#START} request to start the
-    * server
-    *   
-    * @param arguments The arguments that will be passed to the {@link MockServer} 
-    *       as JVM program arguments
-    *       
-    * @throws Throwable
-    */
-   public void startServer(String[] arguments) throws Throwable
-   {
-      // Along with the arguments that the client passes to the server,
-      // append the the serverHost and port number on which the mockserver is
-      // expected to listen
-      int numberOfArgs = arguments.length;
-      String[] processArgs = new String[numberOfArgs + 2];
-      System.arraycopy(arguments, 0, processArgs, 0, numberOfArgs);
-      // now append the server host and port
-      processArgs[processArgs.length - 2] = this.serverHost;
-      processArgs[processArgs.length - 1] = String.valueOf(this.port);
-
-      createRemoteProcess(processArgs);
-
-      /* 
-       * Wait a max of 5 seconds for the remote process (remember, not the server)
-       * to start
-       */
-      long start = System.currentTimeMillis();
-      int timeoutIntervalSeconds = 5;
-      long timeout = timeoutIntervalSeconds * 1000 + start;
-      boolean started = false;
-      while (!started)
-      {
-         try
-         {
-            // Start the server
-            sendStartRequestToServer();
-            // the server's started now
-            started = true;
-         }
-         // Couldn't start server
-         catch (CannotConnectException cce)
-         {
-            // If we haven't yet timed out
-            long current = System.currentTimeMillis();
-            if (current < timeout)
-            {
-               // Swallow exception and try again
-               logger.trace("Can't connect to server @ " + new Date(current) + ", trying until " + new Date(timeout));
-               Thread.sleep(100);
-               continue;
-            }
-            logger.error("The remote process was not up, even after 5 seconds. Aborting");
-            // Throw the exception, timeout's past
-            throw cce;
-         }
-      }
-
-   }
-
-   /**
-    * Sends a {@link MockServerRequest#STOP} request to the server
-    * and also kills the process in whic the server was running
-    * 
-    * @see MockServerController#stopServer(boolean)
-    * @throws Throwable
-    */
-   public void stopServer() throws Throwable
-   {
-      stopServer(true);
-      logger.debug("Stopped the server and killed the remote process");
-
-   }
-
-   /**
-    * Sends a {@link MockServerRequest#STOP} request to the server 
-    * and if the <code>killProcess</code> is true then it also kills
-    * the process in which the server was running.
-    * 
-    * @param killProcess If true, kills the process in which the {@link MockServer}
-    *           was running. Else, just sends a {@link MockServerRequest#STOP} request
-    *           to the server.
-    * @throws Throwable
-    */
-   public void stopServer(boolean killProcess) throws Throwable
-   {
-      // If there is nothing to stop, then return
-      if (this.remoteProcess == null)
-      {
-         logger.info("No remote process to stop. Returning");
-         return;
-      }
-      try
-      {
-         sendStopRequestToServer();
-         logger.debug("Stopped server");
-         // disconnect the client
-         this.mockServerClient.disconnect();
-
-      }
-      finally
-      {
-         if (killProcess)
-         {
-            // destroy the remote process
-            this.remoteProcess.destroy();
-            logger.debug("Remote process killed");
-         }
-      }
-   }
-
-   /**
-    * Sets the timeout for the server startup.
-    * <br/>
-    * This method has to be called before calling the {@link #startServer(String[])} method,
-    * for the timeout to be considered.
-    * 
-    * @param timeout The timeout value in milli seconds.
-    */
-   public void setServerStartupTimeout(int timeout)
-   {
-      this.serverStartupTimeout = timeout;
-   }
-
-   /**
-    * Returns the timeout set for the server startup.
-    * 
-    * @return
-    */
-   public int getServerStartupTimeout()
-   {
-      return this.serverStartupTimeout;
-   }
-
-   /**
-    * Returns the timeout set for server to stop
-    * 
-    * @return
-    */
-   public int getServerStopTimeout()
-   {
-      return this.serverStopTimeout;
-   }
-
-   /**
-    * Sets the timeout for the server to stop.
-    * <br/>
-    * This method has to be called before calling the {@link #stopServer()} method,
-    * for the timeout to be considered.
-    * 
-    * @param timeout The timeout value in milli seconds.
-    */
-   public void setServerStopTimeout(int timeout)
-   {
-      this.serverStopTimeout = timeout;
-   }
-
-   /**
-    * Sends a {@link MockServerRequest#STOP} to the server
-    * 
-    * @throws Throwable
-    */
-   protected void sendStopRequestToServer() throws Throwable
-   {
-      this.mockServerClient.connect();
-      // set a timeout - The client will wait for this amount of time 
-      // for the mockserver to shutdown
-      Map<String, String> configParams = new HashMap<String, String>();
-      configParams.put("timeout", String.valueOf(this.serverStopTimeout));
-      Object serverStatus = this.mockServerClient.invoke(MockServerRequest.STOP, configParams);
-      logger.debug("Stop request returned Status = " + serverStatus);
-
-   }
-
-   /**
-    * Sends a {@link MockServerRequest#START} to the server
-    * @throws Throwable
-    */
-   protected void sendStartRequestToServer() throws Throwable
-   {
-      this.mockServerClient.connect();
-      // set a timeout - The client will wait for this amount of time 
-      // for the mockserver to shutdown
-      Map<String, String> configParams = new HashMap<String, String>();
-      configParams.put("timeout", String.valueOf(this.serverStartupTimeout));
-      Object serverStatus = this.mockServerClient.invoke(MockServerRequest.START, configParams);
-      logger.info("Server started. Status = " + serverStatus);
-
-   }
-
-   /**
-    * Creates a new JVM process in which the {@link MockServer} will be active
-    * 
-    * 
-    * @param arguments The arguments to the passed to the {@link MockServer}
-    * 
-    * @throws Throwable
-    */
-   private void createRemoteProcess(String arguments[]) throws Throwable
-   {
-      // Get the current System Properties and Environment Variables
-      String javaHome = System.getenv(MockServerController.ENV_VAR_JAVAHOME);
-      String conf = MockServerController.LOCATION_CONF;
-      String testClasses = MockServerController.LOCATION_TEST_CLASSES;
-      String classes = MockServerController.LOCATION_CLASSES;
-
-      // Get the contents of the dependency classpath file
-      String dependencyClasspathFilename = MockServerController.FILENAME_DEPENDENCY_CP;
-      File dependencyClasspath = new File(dependencyClasspathFilename);
-      assert dependencyClasspath.exists() : "File " + dependencyClasspathFilename
-            + " is required to denote the dependency CP";
-      BufferedReader reader = new BufferedReader(new FileReader(dependencyClasspath));
-      StringBuffer contents = new StringBuffer();
-      String line = null;
-      while ((line = reader.readLine()) != null)
-      {
-         contents.append(line);
-         contents.append(System.getProperty("line.separator"));
-      }
-      String depCp = contents.toString().trim();
-
-      // Build the command
-      List<String> command = new ArrayList<String>();
-
-      // Executable (Java)
-      StringBuffer executable = new StringBuffer();
-      executable.append(javaHome); // JAVA_HOME
-      executable.append(File.separatorChar);
-      executable.append(MockServerController.EXECUTABLE_JAVA);
-
-      command.add(executable.toString());
-
-      // Classpath
-      command.add("-classpath");
-
-      StringBuffer classPath = new StringBuffer();
-      classPath.append(classes);
-      classPath.append(File.pathSeparator);
-      classPath.append(testClasses);
-      classPath.append(File.pathSeparatorChar);
-      classPath.append(conf);
-      classPath.append(File.pathSeparatorChar);
-      classPath.append(depCp); // Dependency CP
-
-      command.add(classPath.toString());
-      // Other params to the JVM
-      command.add("-ea");
-      // The class to run
-      command.add(MockServer.class.getName());
-      // The arguments to the main class
-      for (int i = 0; i < arguments.length; i++)
-      {
-         command.add(arguments[i]);
-      }
-
-      // Create a Remote Launcher
-      ProcessBuilder builder = new ProcessBuilder();
-      builder.command(command);
-      builder.redirectErrorStream(true);
-      File pwd = new File(MockServerController.LOCATION_BASEDIR);
-      assert pwd.exists() : "Present working directory for execution of remote process, " + pwd.getAbsolutePath()
-            + ", could not be found.";
-      logger.debug("Remote Process working directory: " + pwd.getAbsolutePath());
-      builder.directory(pwd);
-      logger.info("Launching in separate process: " + getPrintableCommand(command));
-      try
-      {
-         this.remoteProcess = builder.start();
-         logger.info("Remote process = " + this.remoteProcess);
-         // Redirect output from the separate process
-         new RedirectProcessOutputToSystemOutThread(this.remoteProcess).start();
-
-      }
-      catch (Throwable t)
-      {
-         throw new RuntimeException("Could not execute remote process", t);
-      }
-
-   }
-
-   /**
-    * Utility method to generate a printable string from a List.
-    * The elements of the list will be separated by a space (unlike the
-    * default comma separated List.toString()).
-    * 
-    * @param command The command
-    * @return Returns a printable form of the <code>command</code>
-    */
-   private String getPrintableCommand(List<String> command)
-   {
-      StringBuffer printableCmd = new StringBuffer();
-      for (String cmd : command)
-      {
-         printableCmd.append(cmd);
-         printableCmd.append(" ");
-      }
-      return printableCmd.toString();
-   }
-
-}

Deleted: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/MockServerInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/MockServerInvocationHandler.java	2009-03-11 05:30:46 UTC (rev 85712)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/MockServerInvocationHandler.java	2009-03-11 06:17:25 UTC (rev 85713)
@@ -1,150 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.ejb3.test.proxy.remoteaccess;
-
-import javax.management.MBeanServer;
-
-import org.jboss.ejb3.test.proxy.remoteaccess.MockServer.MockServerRequest;
-import org.jboss.logging.Logger;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.remoting.ServerInvoker;
-import org.jboss.remoting.callback.InvokerCallbackHandler;
-
-/**
- * MockServerInvocationHandler
- *
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class MockServerInvocationHandler implements ServerInvocationHandler
-{
-
-   /**
-    * Instance of logger
-    */
-   private static Logger logger = Logger.getLogger(MockServerInvocationHandler.class);
-
-   /**
-    * Instance of {@link MockServer} to which the requests will be
-    * forwarded
-    */
-   private MockServer mockServer;
-
-   /**
-    * Constructor
-    * 
-    * @param mockServer  
-    */
-   public MockServerInvocationHandler(MockServer mockServer)
-   {
-      this.mockServer = mockServer;
-   }
-
-   /**
-    * @see org.jboss.remoting.ServerInvocationHandler#addListener(org.jboss.remoting.callback.InvokerCallbackHandler)
-    */
-   public void addListener(InvokerCallbackHandler callbackHandler)
-   {
-      // no asynchronous support required as of now. Implement later if required
-
-   }
-
-   /**
-    * On receiving a {@link MockServerRequest} the invocation handler will
-    * carry out appropriate operation on the {@link MockServer} <br>
-    * 
-    * Supported requests are <br/>
-    * <li>
-    *   <ul>
-    *   {@link MockServerRequest.START} - On receiving this request, the invocation 
-    *   handler will start the {@link MockServer}
-    *   </ul>
-    *   <ul>
-    *   {@link MockServerRequest.STOP} - On receiving this request, the invocation 
-    *   handler will stop the {@link MockServer}
-    *   </ul>
-    * </li>
-    * @throws {@link IllegalArgumentException} If the <code>invocationRequest</code>
-    *           is not supported
-    * @see org.jboss.remoting.ServerInvocationHandler#invoke(org.jboss.remoting.InvocationRequest)
-    */
-   public Object invoke(InvocationRequest invocationRequest) throws Throwable
-   {
-
-      if (!(invocationRequest.getParameter() instanceof MockServerRequest))
-      {
-         throw new IllegalArgumentException("Unrecognized request type " + invocationRequest.getParameter());
-      }
-      MockServerRequest request = (MockServerRequest) invocationRequest.getParameter();
-      logger.info("Received request: " + request);
-
-      // The same invocation handler can be called by multiple threads.
-      synchronized (this.mockServer)
-      {
-         if (request.equals(MockServerRequest.START))
-         {
-            this.mockServer.start();
-         }
-         else if (request.equals(MockServerRequest.STOP))
-         {
-            this.mockServer.stop();
-            
-         }
-         else
-         {
-            throw new IllegalArgumentException("Unrecognized request " + invocationRequest.getParameter());
-         }
-         return mockServer.getStatus();
-      }
-
-      
-   }
-
-   /**
-    * @see org.jboss.remoting.ServerInvocationHandler#removeListener(org.jboss.remoting.callback.InvokerCallbackHandler)
-    */
-   public void removeListener(InvokerCallbackHandler callbackHandler)
-   {
-      // do nothing - Implement later if needed
-
-   }
-
-   /**
-    * @see org.jboss.remoting.ServerInvocationHandler#setInvoker(org.jboss.remoting.ServerInvoker)
-    */
-   public void setInvoker(ServerInvoker invoker)
-   {
-      // do nothing - Implement later if needed
-
-   }
-
-   /**
-    * @see org.jboss.remoting.ServerInvocationHandler#setMBeanServer(javax.management.MBeanServer)
-    */
-   public void setMBeanServer(MBeanServer server)
-   {
-      // do nothing - Implement later if needed
-
-   }
-
-}

Deleted: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/RedirectClassloader.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/RedirectClassloader.java	2009-03-11 05:30:46 UTC (rev 85712)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/RedirectClassloader.java	2009-03-11 06:17:25 UTC (rev 85713)
@@ -1,73 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.ejb3.test.proxy.remoteaccess;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Enumeration;
-
-import org.jboss.logging.Logger;
-
-/**
- * RedirectClassloader
- * 
- * Base for ClassLoaders that will replace a queried resource
- * with another under the hood
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public abstract class RedirectClassloader extends ClassLoader
-{
-   // --------------------------------------------------------------------------------||
-   // Class Members ------------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   private static final Logger log = Logger.getLogger(RedirectClassloader.class);
-
-   // --------------------------------------------------------------------------------||
-   // Overridden Implementations -----------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   /**
-    * Replaces a request to load "jndi.properties" with "jnpserver.properties"
-    */
-   @Override
-   public Enumeration<URL> getResources(String name) throws IOException
-   {
-      if (name.equals(this.getFrom()))
-      {
-         log.info("Replacing request for " + this.getFrom() + " with " + this.getTo());
-         name = this.getTo();
-      }
-      return super.getResources(name);
-   }
-
-   // --------------------------------------------------------------------------------||
-   // Class Members ------------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   protected abstract String getFrom();
-
-   protected abstract String getTo();
-
-}

Added: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/unit/ProxyMockServer.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/unit/ProxyMockServer.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/unit/ProxyMockServer.java	2009-03-11 06:17:25 UTC (rev 85713)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.test.proxy.remoteaccess.unit;
+
+import org.jboss.ejb3.test.proxy.common.Utils;
+import org.jboss.ejb3.test.proxy.common.container.StatefulContainer;
+import org.jboss.ejb3.test.proxy.common.container.StatelessContainer;
+import org.jboss.ejb3.test.proxy.common.ejb.sfsb.MyStatefulBean;
+import org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessBean;
+import org.jboss.ejb3.testremote.server.MockServer;
+import org.jboss.logging.Logger;
+
+/**
+ * ProxyMockServer
+ * 
+ * Mock Remotable Server used in proxy testing
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ProxyMockServer extends MockServer
+{
+
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private static final Logger log = Logger.getLogger(ProxyMockServer.class);
+
+   // --------------------------------------------------------------------------------||
+   // Constructor --------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   public ProxyMockServer(final Class<?> testClass, final String serverHost, final int port)
+   {
+      super(testClass, serverHost, port);
+   }
+
+   /**
+    * Overridden implementation to create the requisite EJB Containers for testing
+    */
+   @Override
+   protected void initialize() throws Throwable
+   {
+      // Call super implementation
+      super.initialize();
+
+      // Create a SLSB Container
+      final StatelessContainer slsbContainer = Utils.createSlsb(MyStatelessBean.class);
+      log.info("Created SLSB Container: " + slsbContainer.getName());
+
+      // Create a SFSB Container
+      final StatefulContainer sfsbContainer = Utils.createSfsb(MyStatefulBean.class);
+      log.info("Created SFSB Container: " + sfsbContainer.getName());
+
+      // Install into MC
+      this.getBootstrap().installInstance(slsbContainer.getName(), slsbContainer);
+      this.getBootstrap().installInstance(sfsbContainer.getName(), sfsbContainer);
+
+   }
+
+}

Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/unit/RemoteAccessTestCase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/unit/RemoteAccessTestCase.java	2009-03-11 05:30:46 UTC (rev 85712)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/unit/RemoteAccessTestCase.java	2009-03-11 06:17:25 UTC (rev 85713)
@@ -32,8 +32,7 @@
 
 import org.jboss.ejb3.test.proxy.common.ejb.sfsb.MyStatefulRemoteBusiness;
 import org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessRemote;
-import org.jboss.ejb3.test.proxy.remoteaccess.JndiPropertiesToJndiRemotePropertiesHackCl;
-import org.jboss.ejb3.test.proxy.remoteaccess.MockServerController;
+import org.jboss.ejb3.testremote.server.MockServerController;
 import org.jboss.logging.Logger;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -54,8 +53,6 @@
 
    private static final Logger log = Logger.getLogger(RemoteAccessTestCase.class);
 
-   private static final String JNDI_NAME_SLSB_LOCAL = "MyStatelessBean/local";
-
    private static final String JNDI_NAME_SLSB_REMOTE = "MyStatelessBean/remote";
 
    private static final String JNDI_NAME_SFSB_REMOTE = "MyStatefulBean/remote";
@@ -161,7 +158,7 @@
    @BeforeClass
    public static void beforeClass() throws Throwable
    {
-      
+
       // get the input stream for jndi-remote.properties file, which will be available
       // in classpath
       InputStream inputStream = RemoteAccessTestCase.class.getClassLoader().getResourceAsStream(
@@ -173,14 +170,15 @@
 
       // Use the non-default constructor of InitialContext and pass the 
       // properties
-      RemoteAccessTestCase.setContext(new InitialContext(jndiRemoteProperties));  
-      
+      RemoteAccessTestCase.setContext(new InitialContext(jndiRemoteProperties));
+
       // create a controller for mockserver
       mockServerController = new MockServerController(serverHost, serverPort);
 
       // Start Server
       long start = System.currentTimeMillis();
-      mockServerController.startServer(new String[]{RemoteAccessTestCase.class.getName()});
+      mockServerController.startServer(ProxyMockServer.class, new String[]
+      {RemoteAccessTestCase.class.getName()});
       long end = System.currentTimeMillis();
       log.info("MockServer started in " + (end - start) + " milli sec.");
 

Modified: projects/ejb3/trunk/test-remote/pom.xml
===================================================================
--- projects/ejb3/trunk/test-remote/pom.xml	2009-03-11 05:30:46 UTC (rev 85712)
+++ projects/ejb3/trunk/test-remote/pom.xml	2009-03-11 06:17:25 UTC (rev 85713)
@@ -8,7 +8,7 @@
   <parent>
     <groupId>org.jboss.ejb3</groupId>
     <artifactId>jboss-ejb3-build</artifactId>
-    <version>1.0.0</version>
+    <version>1.0.3-SNAPSHOT</version>
   </parent>
 
   <!-- Model Version -->
@@ -18,13 +18,15 @@
   <groupId>org.jboss.ejb3</groupId>
   <artifactId>jboss-ejb3-test-remote</artifactId>
   <name>JBoss EJB 3.0 Remote Test Server</name>
-  <description>Remotable Server ofr use in Testing EJB3</description>
+  <description>Remotable Server for use in Testing EJB3</description>
   <version>0.0.1-SNAPSHOT</version>
 
   <!-- Build Properties -->
   <properties>
   
     <version.org.jboss.ejb3_jboss.ejb3.common>1.0.0</version.org.jboss.ejb3_jboss.ejb3.common>
+    <version.org.jboss.ejb3_jboss.ejb3.test>1.0.0</version.org.jboss.ejb3_jboss.ejb3.test>
+    <version.org.jboss.remoting_jboss.remoting>2.4.0.GA</version.org.jboss.remoting_jboss.remoting>
   
   </properties>
 
@@ -56,7 +58,11 @@
   
   <dependencies>
   
-    <!-- EJB3 Project Dependencies -->
+    <!-- 
+    
+    EJB3 Project Dependencies 
+    
+    -->
   
     <!-- org.jboss.ejb3:jboss-ejb3-common -->
     <dependency>
@@ -64,7 +70,33 @@
       <artifactId>jboss-ejb3-common</artifactId>
       <version>${version.org.jboss.ejb3_jboss.ejb3.common}</version>
     </dependency>
-  
+    
+    <!-- org.jboss.ejb3:jboss-ejb3-test -->
+    <dependency>
+      <groupId>org.jboss.ejb3</groupId>
+      <artifactId>jboss-ejb3-test</artifactId>
+      <version>${version.org.jboss.ejb3_jboss.ejb3.test}</version>
+    </dependency>
+    
+    <!-- 
+    
+    External Project Dependencies
+    
+    -->
+    
+    <!-- org.jboss.aop:jboss-aop -->
+    <dependency>
+      <groupId>org.jboss.aop</groupId>
+      <artifactId>jboss-aop</artifactId>
+    </dependency>
+    
+    <!-- org.jboss.remoting:jboss-remoting -->
+    <dependency>
+      <groupId>org.jboss.remoting</groupId>
+      <artifactId>jboss-remoting</artifactId>
+      <version>${version.org.jboss.remoting_jboss.remoting}</version>
+    </dependency>
+    
   </dependencies>
 
 </project>
\ No newline at end of file


Property changes on: projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server
___________________________________________________________________
Name: svn:mergeinfo
   + 

Added: projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/JndiPropertiesToJndiRemotePropertiesHackCl.java
===================================================================
--- projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/JndiPropertiesToJndiRemotePropertiesHackCl.java	                        (rev 0)
+++ projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/JndiPropertiesToJndiRemotePropertiesHackCl.java	2009-03-11 06:17:25 UTC (rev 85713)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.testremote.server;
+
+/**
+ * JndiPropertiesToJnpserverPropertiesHackCl
+ * 
+ * Hacky classloader to use to switch requests for 
+ * "jndi.properties" to use "jndi-remote.properties"
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JndiPropertiesToJndiRemotePropertiesHackCl extends RedirectClassloader
+{
+
+   private static final String TO_REPLACE = "jndi.properties";
+
+   private static final String REPLACE_WITH = "jndi-remote.properties";
+
+   @Override
+   protected String getFrom()
+   {
+      return JndiPropertiesToJndiRemotePropertiesHackCl.TO_REPLACE;
+   }
+
+   @Override
+   protected String getTo()
+   {
+      return JndiPropertiesToJndiRemotePropertiesHackCl.REPLACE_WITH;
+   }
+
+}

Added: projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/JndiPropertiesToJnpserverPropertiesHackCl.java
===================================================================
--- projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/JndiPropertiesToJnpserverPropertiesHackCl.java	                        (rev 0)
+++ projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/JndiPropertiesToJnpserverPropertiesHackCl.java	2009-03-11 06:17:25 UTC (rev 85713)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.testremote.server;
+
+/**
+ * JndiPropertiesToJnpserverPropertiesHackCl
+ * 
+ * Hacky classloader to use to prevent the JNP Server from
+ * loading jndi.properties (which should be used by clients 
+ * only) and instead swapping for jnpserver.properties
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JndiPropertiesToJnpserverPropertiesHackCl extends RedirectClassloader
+{
+
+   private static final String TO_REPLACE = "jndi.properties";
+
+   private static final String REPLACE_WITH = "jnpserver.properties";
+
+   @Override
+   protected String getFrom()
+   {
+      return JndiPropertiesToJnpserverPropertiesHackCl.TO_REPLACE;
+   }
+
+   @Override
+   protected String getTo()
+   {
+      return JndiPropertiesToJnpserverPropertiesHackCl.REPLACE_WITH;
+   }
+
+}

Added: projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/MockServer.java
===================================================================
--- projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/MockServer.java	                        (rev 0)
+++ projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/MockServer.java	2009-03-11 06:17:25 UTC (rev 85713)
@@ -0,0 +1,363 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.testremote.server;
+
+import java.lang.reflect.Constructor;
+import java.net.URL;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.AspectXmlLoader;
+import org.jboss.ejb3.common.registrar.plugin.mc.Ejb3McRegistrar;
+import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.test.mc.bootstrap.EmbeddedTestMcBootstrap;
+import org.jboss.logging.Logger;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.transport.Connector;
+
+/**
+ * MockServer
+ * 
+ * Launches a new MC Bootstrap, EJB Containers, and performs
+ * all initialization to mock a remote server environment
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class MockServer
+{
+
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private static final Logger log = Logger.getLogger(MockServer.class);
+
+   /**
+    * Invocation request to the MockServer will be handler by this
+    * invocation handler
+    */
+   private ServerInvocationHandler mockServerInvocationHandler;
+
+   private static final String FILENAME_EJB3_INTERCEPTORS_AOP = "ejb3-interceptors-aop.xml";
+
+   /**
+    * Various possible server status
+    */
+   public enum MockServerStatus {
+      STARTED, STOPPED
+   }
+
+   /**
+    * 
+    * Various possible server requests
+    */
+   public enum MockServerRequest {
+      START, STOP
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Instance Members ---------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private EmbeddedTestMcBootstrap bootstrap;
+
+   /**
+    * Accept requests from client using this {@link Connector} 
+    */
+   private Connector remoteConnector;
+
+   /**
+    * The current state of the server 
+    */
+   private MockServerStatus currentStatus = MockServerStatus.STOPPED;
+
+   /**
+    * The Test Class using this launcher
+    */
+   private Class<?> testClass;
+
+   // --------------------------------------------------------------------------------||
+   // Constructor --------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Constructor
+    * Configures and creates a socket based {@link Connector} which will
+    * accept (start/stop) requests from client 
+    */
+   public MockServer(Class<?> testClass, String serverHost, int port)
+   {
+      this.setTestClass(testClass);
+      String uri = "socket://" + serverHost + ":" + port;
+      try
+      {
+         InvokerLocator invokerLocator = new InvokerLocator(uri);
+
+         this.remoteConnector = new Connector(invokerLocator);
+         this.remoteConnector.create();
+         this.mockServerInvocationHandler = new MockServerInvocationHandler(this);
+         this.remoteConnector.addInvocationHandler("EJB3Test", this.mockServerInvocationHandler);
+         log.debug("Connector created for accepting MockServer requests");
+
+      }
+      catch (Exception e)
+      {
+         log.error("Could not create Mockserver for testclass = " + testClass + " serverHost= " + serverHost
+               + " port= " + port, e);
+         throw new RuntimeException("Could not start server at " + uri, e);
+      }
+
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Main ---------------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Runtime Entry Point
+    * 
+    * @param args
+    */
+   public static void main(String... args) throws Throwable
+   {
+
+      // Log out the arguments
+      if (log.isDebugEnabled())
+      {
+         StringBuffer argList = new StringBuffer();
+         for (String arg : args)
+         {
+            argList.append(arg);
+            argList.append(' ');
+         }
+         log.debug("Arguments: " + argList);
+      }
+
+      // Assert test class passed in
+      assert args.length == 4 : "Parameters requried (in this order): <Fully qualified test case name> <serverFQClassName> <serverBindAddress> <serverPort>";
+
+      // Get Test Class
+      String testClassname = args[0];
+      Class<?> testClass = null;
+      try
+      {
+         testClass = Class.forName(testClassname);
+      }
+      catch (ClassNotFoundException cnfe)
+      {
+         throw new RuntimeException("Specified Test Class, \"" + testClassname + "\" could not be found", cnfe);
+      }
+
+      // Get Mock Server implementation 
+      String mockServerClassName = args[1];
+
+      // Create a new Launcher
+      // the serverBindAddress and the port are always the last two arguments
+      log.debug("Creating a MockServer for testclass = " + testClass + " and serverBindAddr = " + args[args.length - 2]
+            + " and port = " + args[args.length - 1] + " using " + MockServer.class.getSimpleName()
+            + " implementation: " + mockServerClassName);
+
+      // Get the mock server class 
+      Class<?> mockServerClass = null;
+      try
+      {
+         mockServerClass = Class.forName(mockServerClassName, true, Thread.currentThread().getContextClassLoader());
+      }
+      catch (ClassNotFoundException e1)
+      {
+         throw new RuntimeException("Cannot create " + MockServer.class.getSimpleName() + " with implementation of "
+               + mockServerClassName, e1);
+      }
+      assert MockServer.class.isAssignableFrom(mockServerClass) : "Specified implementation " + mockServerClassName
+            + " is not of type " + MockServer.class.getName();
+      Constructor<?> serverCtor = null;
+      try
+      {
+         serverCtor = mockServerClass.getConstructor(new Class<?>[]
+         {Class.class, String.class, int.class});
+      }
+      catch (NoSuchMethodException e1)
+      {
+         throw new RuntimeException(e1);
+      }
+
+      MockServer launcher = (MockServer) serverCtor.newInstance(new Object[]
+      {testClass, args[args.length - 2], Integer.parseInt(args[args.length - 1])});
+
+      try
+      {
+         // Ready to receive (start/stop) requests
+         launcher.acceptRequests();
+      }
+      catch (Throwable e)
+      {
+         log.error("Exception in MockServer while wating for requests ", e);
+         throw new RuntimeException("Exception while waiting for requests ", e);
+      }
+
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Functional Methods -------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Initializes the instance by starting up an MC Bootstrap, 
+    * deploying relevant *-beans.xml, creating and installing EJB Containers
+    */
+   protected void initialize() throws Throwable
+   {
+      // Create and set a new MC Bootstrap 
+      this.setBootstrap(EmbeddedTestMcBootstrap.createEmbeddedMcBootstrap());
+
+      // Add a Shutdown Hook
+      //Runtime.getRuntime().addShutdownHook(new ShutdownHook());
+
+      // Bind the Ejb3Registrar
+      Ejb3RegistrarLocator.bindRegistrar(new Ejb3McRegistrar(bootstrap.getKernel()));
+
+      // Switch up to the hacky CL so that "jndi.properties" is not loaded
+      ClassLoader olderLoader = Thread.currentThread().getContextClassLoader();
+      try
+      {
+         Thread.currentThread().setContextClassLoader(new JndiPropertiesToJnpserverPropertiesHackCl());
+
+         // Deploy *-beans.xml
+         this.getBootstrap().deploy(this.getTestClass());
+
+         // Load ejb3-interceptors-aop.xml into AspectManager
+         ClassLoader cl = Thread.currentThread().getContextClassLoader();
+         URL url = cl.getResource(FILENAME_EJB3_INTERCEPTORS_AOP);
+         if (url == null)
+         {
+            throw new RuntimeException("Could not load " + AspectManager.class.getSimpleName()
+                  + " with definitions from XML as file " + FILENAME_EJB3_INTERCEPTORS_AOP + " could not be found");
+         }
+         AspectXmlLoader.deployXML(url);
+      }
+      finally
+      {
+         // Restore old CL
+         Thread.currentThread().setContextClassLoader(olderLoader);
+      }
+   }
+
+   /**
+    * Starts the server <br>
+    * 
+    * @throws IllegalStateException If the server is not in {@link MockServerStatus.STOPPED}
+    *           state 
+    * @throws Throwable
+    */
+   public void start() throws Throwable
+   {
+      // Server will be started only if current state is STOPPED
+      if (!this.currentStatus.equals(MockServerStatus.STOPPED))
+      {
+         throw new IllegalStateException("Cannot start MockServer when its in " + getStatus() + " state");
+      }
+      initialize();
+      this.currentStatus = MockServerStatus.STARTED;
+      log.info("MockServer started");
+   }
+
+   /**
+    * Stops the server <br>
+    * 
+    * @throws IllegalStateException If the server is not in {@link MockServerStatus.STARTED} 
+    *           state
+    */
+   public void stop()
+   {
+      // Server will be stopped only if current state is STARTED
+      if (!this.currentStatus.equals(MockServerStatus.STARTED))
+      {
+         throw new IllegalStateException("Cannot stop MockServer when its in " + getStatus() + " state");
+      }
+      this.bootstrap.shutdown();
+      this.currentStatus = MockServerStatus.STOPPED;
+      log.info("MockServer stopped");
+
+      // Note: Do not stop the Connector which is waiting for clients to 
+      // connect. Letting the Connector remain in waiting state will allow
+      // clients to restart this MockServer by sending the MockServerRequest.START
+      // request again.
+   }
+
+   /**
+    * 
+    * @return Returns the current status of the server
+    */
+   public MockServerStatus getStatus()
+   {
+      return this.currentStatus;
+   }
+
+   /**
+    * Start accepting requests <br>
+    * This is a blocking call and will wait for clients to connect
+    * 
+    * @see {@link Connector#start()}
+    * @throws Throwable
+    */
+   protected void acceptRequests() throws Throwable
+   {
+      this.remoteConnector.start();
+   }
+
+   /**
+    * 
+    * @param serverInvocationHandler The {@link ServerInvocationHandler} to
+    *   handle requests
+    */
+   protected void setInvocationHandler(ServerInvocationHandler serverInvocationHandler)
+   {
+      this.mockServerInvocationHandler = serverInvocationHandler;
+
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Accessors / Mutators -----------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   public EmbeddedTestMcBootstrap getBootstrap()
+   {
+      return this.bootstrap;
+   }
+
+   public void setBootstrap(EmbeddedTestMcBootstrap bootstrap)
+   {
+      this.bootstrap = bootstrap;
+   }
+
+   public Class<?> getTestClass()
+   {
+      return testClass;
+   }
+
+   public void setTestClass(Class<?> testClass)
+   {
+      this.testClass = testClass;
+   }
+
+}

Added: projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/MockServerController.java
===================================================================
--- projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/MockServerController.java	                        (rev 0)
+++ projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/MockServerController.java	2009-03-11 06:17:25 UTC (rev 85713)
@@ -0,0 +1,443 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.testremote.server;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.ejb3.common.thread.RedirectProcessOutputToSystemOutThread;
+import org.jboss.ejb3.testremote.server.MockServer.MockServerRequest;
+import org.jboss.logging.Logger;
+import org.jboss.remoting.CannotConnectException;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+
+/**
+ * MockServerController
+ * 
+ * Controls the startup/shutdown of the {@link MockServer} <br/>
+ * 
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class MockServerController
+{
+
+   /**
+    * Instance of logger
+    */
+   private static Logger logger = Logger.getLogger(MockServerController.class);
+
+   /**
+    * JAVA_HOME env variable
+    */
+   private static final String ENV_VAR_JAVAHOME = "JAVA_HOME";
+
+   /**
+    * Java executable
+    */
+   private static final String EXECUTABLE_JAVA = "bin" + File.separator + "java";
+
+   /**
+    * The basedir
+    */
+   private static final String LOCATION_BASEDIR = System.getProperty("basedir");
+
+   private static final String LOCATION_TARGET = MockServerController.LOCATION_BASEDIR + File.separator + "target";
+
+   private static final String LOCATION_TEST_CLASSES = MockServerController.LOCATION_TARGET + File.separator
+         + "tests-classes";
+
+   private static final String LOCATION_CLASSES = MockServerController.LOCATION_TARGET + File.separator + "classes";
+
+   private static final String LOCATION_CONF = MockServerController.LOCATION_BASEDIR + File.separator + "conf";
+
+   private static final String FILENAME_DEPENDENCY_CP = MockServerController.LOCATION_TARGET + File.separator
+         + "cp.txt";
+
+   /**
+    * Timeout in milli sec. for server startup. Defaults to 2 minutes.
+    */
+   private int serverStartupTimeout = 120000;
+
+   /**
+    * Timeout in milli sec. for the server to shutdown. Defaults to 2 minutes.
+    */
+   private int serverStopTimeout = 120000;
+
+   /**
+    * The port number on which the {@link MockServer}
+    * is available for requests
+    */
+   private int port;
+
+   /**
+    * The host on which the {@link MockServer}
+    * is available for requests
+    */
+   private String serverHost;
+
+   /**
+    * Remote process in which the {@link MockServer} will run
+    */
+   private Process remoteProcess;
+
+   /**
+    * {@link Client} for sending requests to the {@link MockServer}
+    */
+   private Client mockServerClient;
+
+   /**
+    * Constructor <br>
+    * Creates a {@link Client} to send requests to the remote {@link MockServer}
+    *   
+    * @param host The host on which the {@link MockServer} is available
+    * @param port The port on which the {@link MockServer} is listening
+    */
+   public MockServerController(String host, int port)
+   {
+      this.serverHost = host;
+      this.port = port;
+      String uri = null;
+      try
+      {
+         uri = "socket://" + this.serverHost + ":" + this.port;
+         InvokerLocator invokerLocator = new InvokerLocator(uri);
+         this.mockServerClient = new Client(invokerLocator);
+
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException("Could not create server controller: ", e);
+      }
+
+   }
+
+   /**
+    * Creates a remote process (JVM) to launch the {@link MockServer}
+    * and then sends a {@link MockServerRequest#START} request to start the
+    * server
+    *   
+    * @param serverClass The class of the server to be used
+    * @param arguments The arguments that will be passed to the {@link MockServer} 
+    *       as JVM program arguments
+    *       
+    * @throws Throwable
+    */
+   public void startServer(Class<? extends MockServer> serverClass, String[] arguments) throws Throwable
+   {
+      // Along with the arguments that the client passes to the server,
+      // append the the serverHost and port number on which the mockserver is
+      // expected to listen
+      int numberOfArgs = arguments.length;
+      String[] processArgs = new String[numberOfArgs + 3];
+      System.arraycopy(arguments, 0, processArgs, 0, numberOfArgs);
+      // now append the server host and port
+      processArgs[processArgs.length - 3] = serverClass.getName();
+      processArgs[processArgs.length - 2] = this.serverHost;
+      processArgs[processArgs.length - 1] = String.valueOf(this.port);
+
+      createRemoteProcess(serverClass, processArgs);
+
+      /* 
+       * Wait a max of 5 seconds for the remote process (remember, not the server)
+       * to start
+       */
+      long start = System.currentTimeMillis();
+      int timeoutIntervalSeconds = 5;
+      long timeout = timeoutIntervalSeconds * 1000 + start;
+      boolean started = false;
+      while (!started)
+      {
+         try
+         {
+            // Start the server
+            sendStartRequestToServer();
+            // the server's started now
+            started = true;
+         }
+         // Couldn't start server
+         catch (CannotConnectException cce)
+         {
+            // If we haven't yet timed out
+            long current = System.currentTimeMillis();
+            if (current < timeout)
+            {
+               // Swallow exception and try again
+               logger.trace("Can't connect to server @ " + new Date(current) + ", trying until " + new Date(timeout));
+               Thread.sleep(100);
+               continue;
+            }
+            logger.error("The remote process was not up, even after 5 seconds. Aborting");
+            // Throw the exception, timeout's past
+            throw cce;
+         }
+      }
+
+   }
+
+   /**
+    * Sends a {@link MockServerRequest#STOP} request to the server
+    * and also kills the process in whic the server was running
+    * 
+    * @see MockServerController#stopServer(boolean)
+    * @throws Throwable
+    */
+   public void stopServer() throws Throwable
+   {
+      stopServer(true);
+      logger.debug("Stopped the server and killed the remote process");
+
+   }
+
+   /**
+    * Sends a {@link MockServerRequest#STOP} request to the server 
+    * and if the <code>killProcess</code> is true then it also kills
+    * the process in which the server was running.
+    * 
+    * @param killProcess If true, kills the process in which the {@link MockServer}
+    *           was running. Else, just sends a {@link MockServerRequest#STOP} request
+    *           to the server.
+    * @throws Throwable
+    */
+   public void stopServer(boolean killProcess) throws Throwable
+   {
+      // If there is nothing to stop, then return
+      if (this.remoteProcess == null)
+      {
+         logger.info("No remote process to stop. Returning");
+         return;
+      }
+      try
+      {
+         sendStopRequestToServer();
+         logger.debug("Stopped server");
+         // disconnect the client
+         this.mockServerClient.disconnect();
+
+      }
+      finally
+      {
+         if (killProcess)
+         {
+            // destroy the remote process
+            this.remoteProcess.destroy();
+            logger.debug("Remote process killed");
+         }
+      }
+   }
+
+   /**
+    * Sets the timeout for the server startup.
+    * <br/>
+    * This method has to be called before calling the {@link #startServer(String[])} method,
+    * for the timeout to be considered.
+    * 
+    * @param timeout The timeout value in milli seconds.
+    */
+   public void setServerStartupTimeout(int timeout)
+   {
+      this.serverStartupTimeout = timeout;
+   }
+
+   /**
+    * Returns the timeout set for the server startup.
+    * 
+    * @return
+    */
+   public int getServerStartupTimeout()
+   {
+      return this.serverStartupTimeout;
+   }
+
+   /**
+    * Returns the timeout set for server to stop
+    * 
+    * @return
+    */
+   public int getServerStopTimeout()
+   {
+      return this.serverStopTimeout;
+   }
+
+   /**
+    * Sets the timeout for the server to stop.
+    * <br/>
+    * This method has to be called before calling the {@link #stopServer()} method,
+    * for the timeout to be considered.
+    * 
+    * @param timeout The timeout value in milli seconds.
+    */
+   public void setServerStopTimeout(int timeout)
+   {
+      this.serverStopTimeout = timeout;
+   }
+
+   /**
+    * Sends a {@link MockServerRequest#STOP} to the server
+    * 
+    * @throws Throwable
+    */
+   protected void sendStopRequestToServer() throws Throwable
+   {
+      this.mockServerClient.connect();
+      // set a timeout - The client will wait for this amount of time 
+      // for the mockserver to shutdown
+      Map<String, String> configParams = new HashMap<String, String>();
+      configParams.put("timeout", String.valueOf(this.serverStopTimeout));
+      Object serverStatus = this.mockServerClient.invoke(MockServerRequest.STOP, configParams);
+      logger.debug("Stop request returned Status = " + serverStatus);
+
+   }
+
+   /**
+    * Sends a {@link MockServerRequest#START} to the server
+    * @throws Throwable
+    */
+   protected void sendStartRequestToServer() throws Throwable
+   {
+      this.mockServerClient.connect();
+      // set a timeout - The client will wait for this amount of time 
+      // for the mockserver to shutdown
+      Map<String, String> configParams = new HashMap<String, String>();
+      configParams.put("timeout", String.valueOf(this.serverStartupTimeout));
+      Object serverStatus = this.mockServerClient.invoke(MockServerRequest.START, configParams);
+      logger.info("Server started. Status = " + serverStatus);
+
+   }
+
+   /**
+    * Creates a new JVM process in which the {@link MockServer} will be active
+    * 
+    * @param serverClass The class of the Server to start
+    * @param arguments The arguments to the passed to the {@link MockServer}
+    * 
+    * @throws Throwable
+    */
+   private void createRemoteProcess(Class<? extends MockServer> serverClass, String arguments[]) throws Throwable
+   {
+      // Get the current System Properties and Environment Variables
+      String javaHome = System.getenv(MockServerController.ENV_VAR_JAVAHOME);
+      String conf = MockServerController.LOCATION_CONF;
+      String testClasses = MockServerController.LOCATION_TEST_CLASSES;
+      String classes = MockServerController.LOCATION_CLASSES;
+
+      // Get the contents of the dependency classpath file
+      String dependencyClasspathFilename = MockServerController.FILENAME_DEPENDENCY_CP;
+      File dependencyClasspath = new File(dependencyClasspathFilename);
+      assert dependencyClasspath.exists() : "File " + dependencyClasspathFilename
+            + " is required to denote the dependency CP";
+      BufferedReader reader = new BufferedReader(new FileReader(dependencyClasspath));
+      StringBuffer contents = new StringBuffer();
+      String line = null;
+      while ((line = reader.readLine()) != null)
+      {
+         contents.append(line);
+         contents.append(System.getProperty("line.separator"));
+      }
+      String depCp = contents.toString().trim();
+
+      // Build the command
+      List<String> command = new ArrayList<String>();
+
+      // Executable (Java)
+      StringBuffer executable = new StringBuffer();
+      executable.append(javaHome); // JAVA_HOME
+      executable.append(File.separatorChar);
+      executable.append(MockServerController.EXECUTABLE_JAVA);
+
+      command.add(executable.toString());
+
+      // Classpath
+      command.add("-classpath");
+
+      StringBuffer classPath = new StringBuffer();
+      classPath.append(classes);
+      classPath.append(File.pathSeparator);
+      classPath.append(testClasses);
+      classPath.append(File.pathSeparatorChar);
+      classPath.append(conf);
+      classPath.append(File.pathSeparatorChar);
+      classPath.append(depCp); // Dependency CP
+
+      command.add(classPath.toString());
+      // Other params to the JVM
+      command.add("-ea");
+      // The class to run
+      command.add(serverClass.getName());
+      // The arguments to the main class
+      for (int i = 0; i < arguments.length; i++)
+      {
+         command.add(arguments[i]);
+      }
+
+      // Create a Remote Launcher
+      ProcessBuilder builder = new ProcessBuilder();
+      builder.command(command);
+      builder.redirectErrorStream(true);
+      File pwd = new File(MockServerController.LOCATION_BASEDIR);
+      assert pwd.exists() : "Present working directory for execution of remote process, " + pwd.getAbsolutePath()
+            + ", could not be found.";
+      logger.debug("Remote Process working directory: " + pwd.getAbsolutePath());
+      builder.directory(pwd);
+      logger.info("Launching in separate process: " + getPrintableCommand(command));
+      try
+      {
+         this.remoteProcess = builder.start();
+         logger.info("Remote process = " + this.remoteProcess);
+         // Redirect output from the separate process
+         new RedirectProcessOutputToSystemOutThread(this.remoteProcess).start();
+
+      }
+      catch (Throwable t)
+      {
+         throw new RuntimeException("Could not execute remote process", t);
+      }
+
+   }
+
+   /**
+    * Utility method to generate a printable string from a List.
+    * The elements of the list will be separated by a space (unlike the
+    * default comma separated List.toString()).
+    * 
+    * @param command The command
+    * @return Returns a printable form of the <code>command</code>
+    */
+   private String getPrintableCommand(List<String> command)
+   {
+      StringBuffer printableCmd = new StringBuffer();
+      for (String cmd : command)
+      {
+         printableCmd.append(cmd);
+         printableCmd.append(" ");
+      }
+      return printableCmd.toString();
+   }
+
+}

Added: projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/MockServerInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/MockServerInvocationHandler.java	                        (rev 0)
+++ projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/MockServerInvocationHandler.java	2009-03-11 06:17:25 UTC (rev 85713)
@@ -0,0 +1,150 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.testremote.server;
+
+import javax.management.MBeanServer;
+
+import org.jboss.ejb3.testremote.server.MockServer.MockServerRequest;
+import org.jboss.logging.Logger;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+
+/**
+ * MockServerInvocationHandler
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class MockServerInvocationHandler implements ServerInvocationHandler
+{
+
+   /**
+    * Instance of logger
+    */
+   private static Logger logger = Logger.getLogger(MockServerInvocationHandler.class);
+
+   /**
+    * Instance of {@link MockServer} to which the requests will be
+    * forwarded
+    */
+   private MockServer mockServer;
+
+   /**
+    * Constructor
+    * 
+    * @param mockServer  
+    */
+   public MockServerInvocationHandler(MockServer mockServer)
+   {
+      this.mockServer = mockServer;
+   }
+
+   /**
+    * @see org.jboss.remoting.ServerInvocationHandler#addListener(org.jboss.remoting.callback.InvokerCallbackHandler)
+    */
+   public void addListener(InvokerCallbackHandler callbackHandler)
+   {
+      // no asynchronous support required as of now. Implement later if required
+
+   }
+
+   /**
+    * On receiving a {@link MockServerRequest} the invocation handler will
+    * carry out appropriate operation on the {@link MockServer} <br>
+    * 
+    * Supported requests are <br/>
+    * <li>
+    *   <ul>
+    *   {@link MockServerRequest.START} - On receiving this request, the invocation 
+    *   handler will start the {@link MockServer}
+    *   </ul>
+    *   <ul>
+    *   {@link MockServerRequest.STOP} - On receiving this request, the invocation 
+    *   handler will stop the {@link MockServer}
+    *   </ul>
+    * </li>
+    * @throws {@link IllegalArgumentException} If the <code>invocationRequest</code>
+    *           is not supported
+    * @see org.jboss.remoting.ServerInvocationHandler#invoke(org.jboss.remoting.InvocationRequest)
+    */
+   public Object invoke(InvocationRequest invocationRequest) throws Throwable
+   {
+
+      if (!(invocationRequest.getParameter() instanceof MockServerRequest))
+      {
+         throw new IllegalArgumentException("Unrecognized request type " + invocationRequest.getParameter());
+      }
+      MockServerRequest request = (MockServerRequest) invocationRequest.getParameter();
+      logger.info("Received request: " + request);
+
+      // The same invocation handler can be called by multiple threads.
+      synchronized (this.mockServer)
+      {
+         if (request.equals(MockServerRequest.START))
+         {
+            this.mockServer.start();
+         }
+         else if (request.equals(MockServerRequest.STOP))
+         {
+            this.mockServer.stop();
+            
+         }
+         else
+         {
+            throw new IllegalArgumentException("Unrecognized request " + invocationRequest.getParameter());
+         }
+         return mockServer.getStatus();
+      }
+
+      
+   }
+
+   /**
+    * @see org.jboss.remoting.ServerInvocationHandler#removeListener(org.jboss.remoting.callback.InvokerCallbackHandler)
+    */
+   public void removeListener(InvokerCallbackHandler callbackHandler)
+   {
+      // do nothing - Implement later if needed
+
+   }
+
+   /**
+    * @see org.jboss.remoting.ServerInvocationHandler#setInvoker(org.jboss.remoting.ServerInvoker)
+    */
+   public void setInvoker(ServerInvoker invoker)
+   {
+      // do nothing - Implement later if needed
+
+   }
+
+   /**
+    * @see org.jboss.remoting.ServerInvocationHandler#setMBeanServer(javax.management.MBeanServer)
+    */
+   public void setMBeanServer(MBeanServer server)
+   {
+      // do nothing - Implement later if needed
+
+   }
+
+}

Added: projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/RedirectClassloader.java
===================================================================
--- projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/RedirectClassloader.java	                        (rev 0)
+++ projects/ejb3/trunk/test-remote/src/main/java/org/jboss/ejb3/testremote/server/RedirectClassloader.java	2009-03-11 06:17:25 UTC (rev 85713)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.testremote.server;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
+
+import org.jboss.logging.Logger;
+
+/**
+ * RedirectClassloader
+ * 
+ * Base for ClassLoaders that will replace a queried resource
+ * with another under the hood
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public abstract class RedirectClassloader extends ClassLoader
+{
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private static final Logger log = Logger.getLogger(RedirectClassloader.class);
+
+   // --------------------------------------------------------------------------------||
+   // Overridden Implementations -----------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Replaces a request to load "jndi.properties" with "jnpserver.properties"
+    */
+   @Override
+   public Enumeration<URL> getResources(String name) throws IOException
+   {
+      if (name.equals(this.getFrom()))
+      {
+         log.info("Replacing request for " + this.getFrom() + " with " + this.getTo());
+         name = this.getTo();
+      }
+      return super.getResources(name);
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   protected abstract String getFrom();
+
+   protected abstract String getTo();
+
+}




More information about the jboss-cvs-commits mailing list