[jboss-cvs] JBossAS SVN: r78956 - in trunk/testsuite/src/main/org/jboss/test: ejb and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Sep 30 10:31:34 EDT 2008


Author: emuckenhuber
Date: 2008-09-30 10:31:34 -0400 (Tue, 30 Sep 2008)
New Revision: 78956

Added:
   trunk/testsuite/src/main/org/jboss/test/ejb/
   trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/
   trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/
   trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/AbstractLifeCycleTestWrapper.java
   trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/BmpLifeCycleUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/CmpLifeCycleUnitTest.java
   trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/IndependentJarLifeCycleUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/InvokersLifeCycleUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/MDBLifeCycleUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/StatefulLifeCycleUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/StatelessLifeCycleUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/UserTransactionLifeCycleUnitTest.java
Log:
[JBAS-5332] some basic tests

Added: trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/AbstractLifeCycleTestWrapper.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/AbstractLifeCycleTestWrapper.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/AbstractLifeCycleTestWrapper.java	2008-09-30 14:31:34 UTC (rev 78956)
@@ -0,0 +1,275 @@
+/*
+ * 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.test.ejb.lifecycle.test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Set;
+
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+
+import junit.framework.Protectable;
+import junit.framework.TestCase;
+import junit.framework.TestResult;
+
+import org.jboss.ejb.MessageDrivenContainer;
+import org.jboss.logging.Logger;
+import org.jboss.system.ServiceControllerMBean;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Base TestCase for lifecycle tests. This test overrides the run method of the JUnit test
+ * to execute a external test case, restart a service and run the external test case again. 
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractLifeCycleTestWrapper extends JBossTestCase
+{
+   /** The service controller objectName. */
+   private static final ObjectName serviceController = ServiceControllerMBean.OBJECT_NAME;
+   
+   /** The logger. */
+   protected static final Logger log = Logger.getLogger(AbstractLifeCycleTestWrapper.class);
+   
+   public AbstractLifeCycleTestWrapper(String name)
+   {
+      super(name);
+   }
+   
+   /**
+    * Get the package which should be deployed.
+    * 
+    * @return the deploy package
+    */
+   protected abstract String getPackage();
+   
+   /**
+    * The tests to execute.
+    * 
+    * @return the tests.
+    */
+   protected abstract Enumeration<TestCase> getTests();
+ 
+   /**
+    * Restart a service.
+    * 
+    * @param name the service name
+    * @throws Exception
+    */
+   protected void restart(String name) throws Exception
+   {
+      restart(new String[] { name });
+   }
+   
+   /**
+    * Restart more services.
+    * 
+    * @param names the service names
+    * @throws Exception
+    */
+   protected void restart(String... names) throws Exception
+   {
+      for(String restartName : names)
+      {
+         ObjectName objectName = new ObjectName(restartName);
+         restart(objectName);
+      }
+   }
+   
+   /**
+    * Restart the container. This calls stop, destroy, create and start
+    * over the ServiceController.
+    * 
+    * @param name the objectName
+    * @throws Exception
+    */
+   protected void restart(ObjectName name) throws Exception
+   {
+      log.debug("restarting service: " + name);
+      Object[] args = { name };
+      String[] sig = { ObjectName.class.getName() };
+      
+      invoke(serviceController, "stop", args, sig);
+      invoke(serviceController, "destroy", args, sig);
+      invoke(serviceController, "create", args, sig);
+      invoke(serviceController, "start", args, sig);      
+   }
+   
+   /**
+    * Get the JNDI name of a MDB bean. This is needed as the jndi name
+    * is basically something like "local/" + ejbName + '@' + System.identityHashCode(ejbName)
+    * 
+    * @param name the partial jndi name
+    * @return the jndi name of the MDB bean
+    * @throws Exception
+    */
+   protected String getMDBName(String name) throws Exception
+   {
+      Set<ObjectInstance> set = getServer().queryMBeans(new ObjectName("jboss.j2ee:service=EJB,*"), null);
+      
+      for(ObjectInstance i : set)
+      {
+         if(i.getClassName().equals(MessageDrivenContainer.class.getName()))
+         {
+            if( i.getObjectName().getKeyProperty("plugin") == null )
+            {
+               if(i.getObjectName().getKeyProperty("binding") == null)
+               {
+                  String jndi = i.getObjectName().getKeyProperty("jndiName");
+                  if(jndi != null && jndi.startsWith(name))
+                  {
+                     return jndi;
+                  }
+               }
+            }
+         }
+      }
+      return null;
+   }
+   
+   /**
+    * Deploy a deployment.
+    * 
+    * @throws Exception
+    */
+   protected void deploy() throws Exception
+   {
+      super.setUp();
+      try
+      {
+         redeploy(getPackage());
+      }
+      catch(Exception e)
+      {
+         undeploy(getPackage());
+         throw e;
+      }
+   }
+   
+   /**
+    * Undeploy a deployment.
+    * 
+    * @throws Exception
+    */
+   protected void undeploy() throws Exception
+   {
+      undeploy(getPackage());
+   }
+
+   /**
+    * Override the JUnit run test to execute external tests,
+    * restart the service and run the test again.
+    * FIXME this is a hack.
+    * 
+    * @param result the JUNIT TestResult.
+    */
+   @Override
+   public void run(TestResult result)
+   {
+      try
+      {
+         // deploy
+         deploy();
+         
+         // get the external tests
+         Enumeration<TestCase> e = getTests();
+         while(e.hasMoreElements())
+         {
+            TestCase t = e.nextElement();
+            // run the external test
+            result.runProtected(this, getProctectable(t));
+         }
+
+         // run the test case as usual
+         super.run(result);
+
+         // 
+         e = getTests();
+         while(e.hasMoreElements())
+         {
+            TestCase t = e.nextElement();
+            // run the external test again
+            result.runProtected(this, getProctectable(t));
+         }
+      }
+      catch(Exception e)
+      {
+         result.addError(this, e);
+      }
+      finally
+      {
+         try
+         {
+            // undeploy
+            undeploy();
+         } 
+         catch(Exception e)
+         {
+            result.addError(this, e);
+         }
+      }
+   }
+   
+   protected Enumeration<TestCase> getTestCases(Class<? extends TestCase> testClass)
+   {
+      return getTestCases(testClass, null);
+   }
+   
+   protected Enumeration<TestCase> getTestCases(Class<? extends TestCase> testClass, Collection<String> excludes)
+   {
+      if(testClass == null ) return Collections.enumeration(Collections.EMPTY_SET);
+      
+      Enumeration<TestCase> testCases = getTestCases(testClass);
+      if(excludes == null || excludes.isEmpty()) return testCases;
+      
+      List<TestCase> filtered = new ArrayList<TestCase>();
+      while(testCases.hasMoreElements())
+      {
+         TestCase t = testCases.nextElement();
+         if(! excludes.contains(t.getName()));
+            filtered.add(t);
+      }
+      return Collections.enumeration(filtered);
+   }
+   
+
+   /**
+    * Helper to wrap a test for JUnit.
+    * 
+    * @param test the Test
+    * @return a Protectable 
+    */
+   private Protectable getProctectable(final TestCase test)
+   {
+      return new Protectable() {
+         public void protect() throws Throwable {
+             test.runBare();
+         }
+     };
+   }
+   
+}
\ No newline at end of file

Added: trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/BmpLifeCycleUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/BmpLifeCycleUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/BmpLifeCycleUnitTestCase.java	2008-09-30 14:31:34 UTC (rev 78956)
@@ -0,0 +1,83 @@
+/*
+ * 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.test.ejb.lifecycle.test;
+
+import java.util.Enumeration;
+
+import junit.framework.TestCase;
+
+import org.jboss.ejb.Container;
+import org.jboss.test.cts.test.BmpUnitTestCase;
+
+/**
+ * LifeCycleTest for BMP beans based on the TestCase
+ * @see {@linkplain BmpUnitTestCase}
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class BmpLifeCycleUnitTestCase extends AbstractLifeCycleTestWrapper
+{
+   /** The package */
+   private static final String PACKAGE = "cts.jar";
+   
+   /** The bmp jmxName */
+   private static final String bmpName = Container.BASE_EJB_CONTAINER_NAME + ",jndiName=ejbcts/BMPBean";
+   
+   public BmpLifeCycleUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void testRestartContainer() throws Exception
+   {
+      restart(bmpName);
+   }
+   
+   public void testRestartPool() throws Exception
+   {
+      String poolName = bmpName + ",plugin=pool";
+      restart(poolName);
+   }
+   
+   public void testRestartCache() throws Exception
+   {
+      String cacheName = bmpName + ",plugin=cache";
+      restart(cacheName);
+   }
+   
+   /**
+    * Return the tests from
+    * @see {@linkplain BmpUnitTestCase}
+    */
+   protected Enumeration<TestCase> getTests()
+   {
+      return getTestCases(BmpUnitTestCase.class);
+   }
+   
+   @Override
+   protected String getPackage()
+   {
+      return PACKAGE;
+   }
+
+}
\ No newline at end of file

Added: trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/CmpLifeCycleUnitTest.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/CmpLifeCycleUnitTest.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/CmpLifeCycleUnitTest.java	2008-09-30 14:31:34 UTC (rev 78956)
@@ -0,0 +1,80 @@
+/*
+ * 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.test.ejb.lifecycle.test;
+
+import java.util.Enumeration;
+
+import junit.framework.TestCase;
+
+import org.jboss.test.cts.test.CmpUnitTestCase;
+
+/**
+ * LifecycleTest for CMP beans based on the TestCase
+ * @see {@linkplain CmpUnitTestCase}
+ * 
+ * FIXME enable this testcase
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class CmpLifeCycleUnitTest extends AbstractLifeCycleTestWrapper
+{
+   /** The package */
+   private static final String PACKAGE = "cts.jar";
+   
+   /** The service base name */
+   private static final String NAME = "jboss.j2ee:service=EJB,jndiName=ejbcts/CMPBean";
+   
+   public CmpLifeCycleUnitTest(String name)
+   {
+      super(name);
+   }
+
+   public void testRestartContainer() throws Exception
+   {
+      restart(NAME);
+   }
+
+   public void testRestartPool() throws Exception
+   {
+      String poolName = NAME + ",plugin=pool";
+      restart(poolName);
+   }
+   
+   public void testRestartCache() throws Exception
+   {
+      String cacheName = NAME + ",plugin=cache";
+      restart(cacheName);
+   }
+   
+   protected Enumeration<TestCase> getTests()
+   {
+      return getTestCases(CmpUnitTestCase.class);
+   }
+
+   @Override
+   protected String getPackage()
+   {
+      return PACKAGE;
+   }
+}
+

Added: trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/IndependentJarLifeCycleUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/IndependentJarLifeCycleUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/IndependentJarLifeCycleUnitTestCase.java	2008-09-30 14:31:34 UTC (rev 78956)
@@ -0,0 +1,75 @@
+/*
+ * 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.test.ejb.lifecycle.test;
+
+import java.util.Enumeration;
+
+import junit.framework.TestCase;
+
+import org.jboss.ejb.Container;
+import org.jboss.test.cts.test.IndependentJarsUnitTestCase;
+
+/**
+ * LifecycleTest based on the cts TestCase
+ * @see {@linkplain IndependentJarsUnitTestCase}
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class IndependentJarLifeCycleUnitTestCase extends AbstractLifeCycleTestWrapper
+{
+
+   /** The package */
+   private static final String PACKAGE = "cts.jar";
+   
+   /** The callerBean jmxName */
+   private static final String callerBean = Container.BASE_EJB_CONTAINER_NAME + ",jndiName=CallerSessionHome";
+   
+   public IndependentJarLifeCycleUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testRestartContainer() throws Exception
+   {
+      restart(callerBean);
+   }
+   
+   public void testRestartPool() throws Exception
+   {
+      String poolName = callerBean + ",plugin=pool";
+      restart(poolName);
+   }
+   
+   protected Enumeration<TestCase> getTests()
+   {
+      return getTestCases(IndependentJarsUnitTestCase.class);
+   }
+
+   @Override
+   protected String getPackage()
+   {
+      return PACKAGE;
+   }
+
+}
+

Added: trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/InvokersLifeCycleUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/InvokersLifeCycleUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/InvokersLifeCycleUnitTestCase.java	2008-09-30 14:31:34 UTC (rev 78956)
@@ -0,0 +1,148 @@
+/*
+ * 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.test.ejb.lifecycle.test;
+
+import java.util.Enumeration;
+
+import junit.framework.TestCase;
+
+import org.jboss.ejb.Container;
+import org.jboss.test.invokers.test.MultiInvokersUnitTestCase;
+
+/**
+ * LifeCycleTestCase based on the testCase
+ * @see {@linkplain MultiInvokersUnitTestCase} 
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class InvokersLifeCycleUnitTestCase extends AbstractLifeCycleTestWrapper
+{
+   /** The package */
+   private static final String PACKAGE = "invokers.jar";
+
+   /** The mdb jndi name */
+   private String mdbName;
+   
+   /** The SimpleBMP jmxName */
+   private static final String simpleBMPName = Container.BASE_EJB_CONTAINER_NAME + ",jndiName=SimpleBMP";
+   
+   /** The statelessSession jmxName */
+   private static final String statelessSessionName = Container.BASE_EJB_CONTAINER_NAME + ",jndiName=StatelessSession";
+   
+   /** The businessSession jmxName */
+   private static final String businessSessionname = Container.BASE_EJB_CONTAINER_NAME + ",jndiName=BusinessSession";
+   
+   public InvokersLifeCycleUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      mdbName = getMDBName("local/JMSGatewayMD");
+      assertNotNull(mdbName);
+   }
+
+   public void testRestartMDBContainer() throws Exception
+   {
+      String name = Container.BASE_EJB_CONTAINER_NAME + ",jndiName=" + mdbName;
+      restart(name);
+   }
+   
+   public void testRestartMDBInvokers() throws Exception
+   {
+      String invokerName = Container.BASE_EJB_CONTAINER_NAME + ",jndiName=" +  mdbName + ",plugin=invoker,binding=message-driven-bean";
+      restart(invokerName);
+   }
+   
+   public void testRestartMDBPool() throws Exception
+   {
+      String poolJMXName = Container.BASE_EJB_CONTAINER_NAME + ",jndiName=" +  mdbName + ",plugin=pool";
+      restart(poolJMXName);
+   }
+   
+   public void testRestartQueues() throws Exception
+   {
+      String[] queues = new String[] {
+            "jboss.mq.destination:service=Queue,name=A",
+            "jboss.mq.destination:service=Queue,name=B",
+            "jboss.mq.destination:service=Queue,name=C",
+            "jboss.mq.destination:service=Queue,name=D",
+            "jboss.mq.destination:service=Queue,name=ex" };
+      restart(queues);
+   }
+   
+   public void testRestartBMPContainer() throws Exception
+   {
+      restart(simpleBMPName);
+   }
+   
+   public void testRestartBMPPool() throws Exception
+   {
+      String poolName = simpleBMPName + ",plugin=pool";
+      restart(poolName);
+   }
+   
+   public void testRestartBMPCache() throws Exception
+   {
+      String cacheName = simpleBMPName + ",plugin=cache";
+      restart(cacheName);
+   }
+   
+   public void testRestartStatelessSessionContainer() throws Exception
+   {
+      restart(statelessSessionName);
+   }
+   
+   public void testRestartStatelessSessionPool() throws Exception
+   {
+      String poolName = statelessSessionName + ",plugin=pool";
+      restart(poolName);
+   }
+   
+   public void testRestartBusinessSessionContainer() throws Exception
+   {
+      restart(businessSessionname);
+   }
+   
+   public void testRestartBusinessSessionPool() throws Exception
+   {
+      String poolName = businessSessionname + ",plugin=pool";
+      restart(poolName);
+   }
+   
+   protected Enumeration<TestCase> getTests()
+   {
+      return getTestCases(MultiInvokersUnitTestCase.class);
+   }
+
+   @Override
+   protected String getPackage()
+   {
+      return PACKAGE;
+   }
+   
+}
\ No newline at end of file

Added: trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/MDBLifeCycleUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/MDBLifeCycleUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/MDBLifeCycleUnitTestCase.java	2008-09-30 14:31:34 UTC (rev 78956)
@@ -0,0 +1,89 @@
+/*
+ * 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.test.ejb.lifecycle.test;
+
+import java.util.Enumeration;
+
+import junit.framework.TestCase;
+
+import org.jboss.ejb.Container;
+import org.jboss.test.cts.test.MDBUnitTestCase;
+
+/**
+ * LifeCycleTestCase for MDB based on the cts testCase
+ * @see {@linkplain MDBUnitTestCase} 
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class MDBLifeCycleUnitTestCase extends AbstractLifeCycleTestWrapper
+{
+   /** The package */
+   private static final String PACKAGE = "cts.jar";
+
+   /** The mdb jndiName */
+   private String mdbJndiName;
+   
+   public MDBLifeCycleUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   @Override
+   public void setUp() throws Exception
+   {
+      super.setUp();
+      
+      this.mdbJndiName = getMDBName("local/StrictlyPooledMDB");
+      assertNotNull(mdbJndiName);
+   }
+   
+   public void testRestartContainer() throws Exception
+   {
+      String containerJMXName = Container.BASE_EJB_CONTAINER_NAME + ",jndiName=" +  mdbJndiName;
+      restart(containerJMXName);
+   }
+   
+   public void testRestartPool() throws Exception
+   {
+      String poolJMXName = Container.BASE_EJB_CONTAINER_NAME + ",jndiName=" +  mdbJndiName + ",plugin=pool";
+      restart(poolJMXName);
+   }
+   
+   public void testRestartInvoker() throws Exception
+   {
+      String invokerJMXName = Container.BASE_EJB_CONTAINER_NAME + ",jndiName=" +  mdbJndiName + ",plugin=invoker,binding=message-driven-bean";
+      restart(invokerJMXName);
+   }
+   
+   protected Enumeration<TestCase> getTests()
+   {
+      return getTestCases(MDBUnitTestCase.class);
+   }
+
+   @Override
+   protected String getPackage()
+   {
+      return PACKAGE;
+   }
+   
+}
\ No newline at end of file

Added: trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/StatefulLifeCycleUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/StatefulLifeCycleUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/StatefulLifeCycleUnitTestCase.java	2008-09-30 14:31:34 UTC (rev 78956)
@@ -0,0 +1,106 @@
+/*
+ * 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.test.ejb.lifecycle.test;
+
+import java.util.Enumeration;
+
+import javax.naming.InitialContext;
+import javax.rmi.PortableRemoteObject;
+
+import junit.framework.TestCase;
+
+import org.jboss.test.cts.interfaces.StatelessSession;
+import org.jboss.test.cts.interfaces.StatelessSessionHome;
+import org.jboss.test.cts.test.StatefulSessionUnitTestCase;
+
+/**
+ * LifeCycleTestCase for Stateful beans based on the cts testCase
+ * @see {@linkplain StatefulSessionUnitTestCase} 
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class StatefulLifeCycleUnitTestCase extends AbstractLifeCycleTestWrapper
+{
+
+   /** The package */
+   private static final String PACKAGE = "cts.jar";
+   
+   /** The service base name */
+   private static final String NAME = "jboss.j2ee:jndiName=ejbcts/StatefulSessionBean,service=EJB";
+   
+   static final int MAX_SIZE = 20;
+   StatelessSession sessionBean;
+
+   public StatefulLifeCycleUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      InitialContext ctx = new InitialContext();
+      Object ref = ctx.lookup("ejbcts/StatelessSessionHome");
+      StatelessSessionHome home = (StatelessSessionHome)
+            PortableRemoteObject.narrow(ref, StatelessSessionHome.class);
+      sessionBean = home.create();
+   }
+
+   protected void tearDown() throws Exception
+   {
+      if (sessionBean != null)
+         sessionBean.remove();
+      
+      super.tearDown();
+   }
+   
+   
+   public void testRestartContainer() throws Exception
+   {
+      restart(NAME);
+   }
+   
+   public void testRestartPool() throws Exception
+   {
+      String poolName = NAME + ",plugin=pool";
+      restart(poolName);
+   }
+   
+   public void testRestartCache() throws Exception
+   {
+      String cacheName = NAME + ",plugin=cache";
+      restart(cacheName);
+   }
+
+   protected Enumeration<TestCase> getTests()
+   {
+      return getTestCases(StatefulSessionUnitTestCase.class);
+   }
+   
+   @Override
+   protected String getPackage()
+   {
+      return PACKAGE;
+   }
+
+}
\ No newline at end of file

Added: trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/StatelessLifeCycleUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/StatelessLifeCycleUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/StatelessLifeCycleUnitTestCase.java	2008-09-30 14:31:34 UTC (rev 78956)
@@ -0,0 +1,99 @@
+/*
+ * 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.test.ejb.lifecycle.test;
+
+import java.util.Enumeration;
+
+import javax.naming.InitialContext;
+import javax.rmi.PortableRemoteObject;
+
+import junit.framework.TestCase;
+
+import org.jboss.test.cts.interfaces.StatelessSession;
+import org.jboss.test.cts.interfaces.StatelessSessionHome;
+import org.jboss.test.cts.test.StatelessSessionUnitTestCase;
+
+/**
+ * LifeCycleTestCase for Stateless beans based on the cts testCase
+ * @see {@linkplain StatelessSessionUnitTestCase} 
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class StatelessLifeCycleUnitTestCase extends AbstractLifeCycleTestWrapper
+{
+
+   /** The package */
+   private static final String PACKAGE = "cts.jar";
+   
+   /** The service base name */
+   private static final String NAME = "jboss.j2ee:jndiName=ejbcts/StatelessSessionHome,service=EJB";
+   
+   static final int MAX_SIZE = 20;
+   StatelessSession sessionBean;
+   
+   public StatelessLifeCycleUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      InitialContext ctx = new InitialContext();
+      Object ref = ctx.lookup("ejbcts/StatelessSessionHome");
+      StatelessSessionHome home = (StatelessSessionHome)
+            PortableRemoteObject.narrow(ref, StatelessSessionHome.class);
+      sessionBean = home.create();
+   }
+
+   protected void tearDown() throws Exception
+   {
+      if (sessionBean != null)
+         sessionBean.remove();
+      
+      super.tearDown();
+   }
+   
+   public void testRestartContainer() throws Exception
+   {
+      restart(NAME);
+   }
+
+   public void testRestartPool() throws Exception
+   {
+      String poolName = NAME + ",plugin=pool";
+      restart(poolName);
+   }
+   
+   protected Enumeration<TestCase> getTests()
+   {
+      return getTestCases(StatelessSessionUnitTestCase.class);
+   }
+
+   @Override
+   protected String getPackage()
+   {
+      return PACKAGE;
+   }
+}
+

Added: trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/UserTransactionLifeCycleUnitTest.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/UserTransactionLifeCycleUnitTest.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/ejb/lifecycle/test/UserTransactionLifeCycleUnitTest.java	2008-09-30 14:31:34 UTC (rev 78956)
@@ -0,0 +1,80 @@
+/*
+ * 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.test.ejb.lifecycle.test;
+
+import java.util.Enumeration;
+
+import junit.framework.TestCase;
+
+import org.jboss.test.cts.test.UserTransactionLookupTestCase;
+
+/**
+ * LifeCycleTestCase for CMP / transaction based on the cts testCase
+ * @see {@linkplain UserTransactionLookupTestCase}
+ * 
+ * FIXME enable this testcase
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class UserTransactionLifeCycleUnitTest extends AbstractLifeCycleTestWrapper
+{
+   /** The package */
+   private static final String PACKAGE = "cts.jar";
+   
+   /** The service base name */
+   private static final String NAME = "jboss.j2ee:service=EJB,jndiName=ejbcts/CMPBean";
+
+   public UserTransactionLifeCycleUnitTest(String name)
+   {
+      super(name);
+   }
+
+   public void testRestartContainer() throws Exception
+   {
+      restart(NAME);
+   }
+
+   public void testRestartPool() throws Exception
+   {
+      String poolName = NAME + ",plugin=pool";
+      restart(poolName);
+   }
+   
+   public void testRestartCache() throws Exception
+   {
+      String cacheName = NAME + ",plugin=cache";
+      restart(cacheName);
+   }
+   
+   protected Enumeration<TestCase> getTests()
+   {
+      return getTestCases(UserTransactionLookupTestCase.class);
+   }
+
+   @Override
+   protected String getPackage()
+   {
+      return PACKAGE;
+   }
+
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list