[jboss-cvs] JBossAS SVN: r63422 - in projects/microcontainer/trunk: kernel/src/main/org/jboss/test/kernel/junit and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jun 8 08:45:21 EDT 2007


Author: alesj
Date: 2007-06-08 08:45:21 -0400 (Fri, 08 Jun 2007)
New Revision: 63422

Added:
   projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/test/ShutdownControllerTestCase.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerShutdownTestDelegate.java
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/test/ScopingShutdownTestCase.xml
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingShutdownTestCase.java
Modified:
   projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/test/ControllerTestSuite.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTest.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/DeploymentTestSuite.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingTestDelegate.java
Log:
Controller shutdown tests.

Modified: projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/test/ControllerTestSuite.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/test/ControllerTestSuite.java	2007-06-08 11:45:26 UTC (rev 63421)
+++ projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/test/ControllerTestSuite.java	2007-06-08 12:45:21 UTC (rev 63422)
@@ -55,7 +55,8 @@
       suite.addTest(CrossContextDependencyBadObjectNameTestCase.suite());
       suite.addTest(AliasDependencyTestCase.suite());
       suite.addTest(AliasUnitTestCase.suite());
-      
+      suite.addTest(ShutdownControllerTestCase.suite());
+
       return suite;
    }
 }

Added: projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/test/ShutdownControllerTestCase.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/test/ShutdownControllerTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/test/ShutdownControllerTestCase.java	2007-06-08 12:45:21 UTC (rev 63422)
@@ -0,0 +1,75 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.dependency.controller.test;
+
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.Test;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ShutdownControllerTestCase extends AbstractDependencyTest
+{
+   public ShutdownControllerTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(ShutdownControllerTestCase.class);
+   }
+
+   protected void validateEmptyContexts()
+   {
+      List<ControllerState> states = controller.getStates();
+      for(ControllerState state : states)
+      {
+         Set<ControllerContext> contexts = controller.getContextsByState(state);
+         if (contexts != null)
+            assertEmpty(contexts);
+      }
+   }
+
+   public void testSimpleShutdown() throws Throwable
+   {
+      ControllerContext c1 = createControllerContext("test1", "alias1");
+      ControllerContext c2 = createControllerContext("test2", "alias2");
+      controller.install(c1);
+      controller.install(c2);
+
+      assertFalse(controller.isShutdown());
+      ControllerContext i1 = controller.getInstalledContext("test1");
+      assertContext(i1);
+      ControllerContext i2 = controller.getInstalledContext("test2");
+      assertContext(i2);
+
+      controller.shutdown();
+      assertTrue(controller.isShutdown());
+
+      validateEmptyContexts();
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerShutdownTestDelegate.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerShutdownTestDelegate.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerShutdownTestDelegate.java	2007-06-08 12:45:21 UTC (rev 63422)
@@ -0,0 +1,65 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.junit;
+
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * A MicrocontainerShutdownTestDelegate.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class MicrocontainerShutdownTestDelegate extends MicrocontainerTestDelegate
+{
+   public MicrocontainerShutdownTestDelegate(Class clazz)
+         throws Exception
+   {
+      super(clazz);
+   }
+
+   public void shutdown()
+   {
+      kernel.getController().shutdown();
+   }
+
+   protected BasicXMLDeployer createDeployer()
+   {
+      return new ShutdownBasicXMLDeployer(kernel);
+   }
+
+   private class ShutdownBasicXMLDeployer extends BasicXMLDeployer
+   {
+      public ShutdownBasicXMLDeployer(Kernel kernel)
+      {
+         super(kernel);
+      }
+
+      protected void undeployBean(KernelController controller, KernelControllerContext context) throws Throwable
+      {
+         if (controller.isShutdown() == false)
+            super.undeployBean(controller, context);
+      }
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTest.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTest.java	2007-06-08 11:45:26 UTC (rev 63421)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTest.java	2007-06-08 12:45:21 UTC (rev 63422)
@@ -180,7 +180,7 @@
          throw new IllegalArgumentException("Resource not found: " + resource);
       getMCDelegate().undeploy(url);
    }
-   
+
    /**
     * Validate
     * 

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/test/ScopingShutdownTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/test/ScopingShutdownTestCase.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/test/ScopingShutdownTestCase.xml	2007-06-08 12:45:21 UTC (rev 63422)
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <classloader>
+      <bean name="cl" class="org.jboss.test.kernel.deployment.support.NullClassLoader" />
+   </classloader>
+
+   <bean name="appScopeObject" class="org.jboss.test.kernel.deployment.support.SimpleObjectWithBean">
+      <annotation>@org.jboss.metadata.plugins.scope.ApplicationScope("testApp")</annotation>
+   </bean>
+
+   <bean name="deploy1" class="org.jboss.test.kernel.deployment.support.SimpleObjectWithBean">
+      <annotation>@org.jboss.metadata.plugins.scope.ApplicationScope("testApp")</annotation>
+      <annotation>@org.jboss.metadata.plugins.scope.DeploymentScope("deployment1")</annotation>
+      <property name="simpleBean"><inject bean="simple"/></property>
+   </bean>
+
+   <bean name="deploy2" class="org.jboss.test.kernel.deployment.support.SimpleObjectWithBean">
+      <annotation>@org.jboss.metadata.plugins.scope.ApplicationScope("testApp")</annotation>
+      <annotation>@org.jboss.metadata.plugins.scope.DeploymentScope("deployment2")</annotation>
+      <property name="simpleBean"><inject bean="simple"/></property>
+   </bean>
+
+   <bean name="deploy3" class="org.jboss.test.kernel.deployment.support.SimpleObjectWithBean">
+      <annotation>@org.jboss.metadata.plugins.scope.ApplicationScope("testApp")</annotation>
+      <annotation>@org.jboss.metadata.plugins.scope.DeploymentScope("deployment3")</annotation>
+      <property name="simpleBean"><inject bean="simpleFromBoot"/></property>
+   </bean>
+
+   <bean name="deploy4" class="org.jboss.test.kernel.deployment.support.SimpleObjectWithBean">
+      <annotation>@org.jboss.metadata.plugins.scope.ApplicationScope("testApp")</annotation>
+      <annotation>@org.jboss.metadata.plugins.scope.DeploymentScope("deployment4")</annotation>
+      <property name="simpleBean"><inject bean="simpleFromApp"/></property>
+   </bean>
+
+   <bean name="simple" class="org.jboss.test.kernel.deployment.support.SimpleBeanImpl">
+      <annotation>@org.jboss.metadata.plugins.scope.ApplicationScope("testApp")</annotation>
+      <annotation>@org.jboss.metadata.plugins.scope.DeploymentScope("deployment1")</annotation>
+      <constructor>
+         <parameter>deployment1</parameter>
+      </constructor>
+   </bean>
+
+   <bean name="simple" class="org.jboss.test.kernel.deployment.support.SimpleBeanImpl">
+      <annotation>@org.jboss.metadata.plugins.scope.ApplicationScope("testApp")</annotation>
+      <annotation>@org.jboss.metadata.plugins.scope.DeploymentScope("deployment2")</annotation>
+      <constructor>
+         <parameter>deployment2</parameter>
+      </constructor>
+   </bean>
+
+   <bean name="simpleFromBoot" class="org.jboss.test.kernel.deployment.support.SimpleBeanImpl">
+      <constructor>
+         <parameter>fromBoot</parameter>
+      </constructor>
+   </bean>
+
+   <bean name="simpleFromApp" class="org.jboss.test.kernel.deployment.support.SimpleBeanImpl">
+      <annotation>@org.jboss.metadata.plugins.scope.ApplicationScope("testApp")</annotation>
+      <constructor>
+         <parameter>fromApp</parameter>
+      </constructor>
+   </bean>
+
+</deployment>

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/DeploymentTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/DeploymentTestSuite.java	2007-06-08 11:45:26 UTC (rev 63421)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/DeploymentTestSuite.java	2007-06-08 12:45:21 UTC (rev 63422)
@@ -59,6 +59,7 @@
       suite.addTest(AnnotatedClassesScopingTestCase.suite());
       suite.addTest(ContextualScopingTestCase.suite());
       suite.addTest(InnerBeanScopingTestCase.suite());
+      suite.addTest(ScopingShutdownTestCase.suite());
 
       return suite;
    }

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingShutdownTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingShutdownTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingShutdownTestCase.java	2007-06-08 12:45:21 UTC (rev 63422)
@@ -0,0 +1,91 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.deployment.test;
+
+import junit.framework.Test;
+
+/**
+ * Scoping shutdown tests.
+ * Test includes same named beans.
+ *
+ * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
+ */
+public class ScopingShutdownTestCase extends ScopingDeploymentTest
+{
+   public ScopingShutdownTestCase(String name) throws Throwable
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(ScopingShutdownTestCase.class);
+   }
+
+   // ---- tests
+
+   // TODO - enable test
+   public void testScopingShutdown() throws Throwable
+   {
+/*
+      ClassLoader cl = (ClassLoader) getBean("cl");
+      assertNotNull(cl);
+
+      SimpleObjectWithBean appScopeObject = (SimpleObjectWithBean) getBean("appScopeObject");
+      assertNotNull(appScopeObject);
+
+      SimpleObjectWithBean deploy1 = (SimpleObjectWithBean) getBean("deploy1");
+      assertNotNull(deploy1);
+      SimpleBean simple1 = deploy1.getSimpleBean();
+      assertNotNull(simple1);
+      assertEquals("deployment1", simple1.getConstructorString());
+
+      SimpleObjectWithBean deploy2 = (SimpleObjectWithBean) getBean("deploy2");
+      assertNotNull(deploy2);
+      SimpleBean simple2 = deploy2.getSimpleBean();
+      assertNotNull(simple2);
+      assertEquals("deployment2", simple2.getConstructorString());
+
+      SimpleObjectWithBean deploy3 = (SimpleObjectWithBean) getBean("deploy3");
+      assertNotNull(deploy3);
+      SimpleBean simple3 = deploy3.getSimpleBean();
+      assertNotNull(simple3);
+      assertEquals("fromBoot", simple3.getConstructorString());
+
+      SimpleObjectWithBean deploy4 = (SimpleObjectWithBean) getBean("deploy4");
+      assertNotNull(deploy4);
+      SimpleBean simple4 = deploy4.getSimpleBean();
+      assertNotNull(simple4);
+      assertEquals("fromApp", simple4.getConstructorString());
+
+      ((MicrocontainerShutdownTestDelegate)getMCDelegate()).shutdown();
+
+      assertNull(getBean("deploy4"));
+      assertNull(getBean("deploy3"));
+      assertNull(getBean("deploy2"));
+      assertNull(getBean("deploy1"));
+      assertNull(getBean("appScopeObject"));
+      assertNull(getBean("cl"));
+*/
+   }
+
+}

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingTestCase.java	2007-06-08 11:45:26 UTC (rev 63421)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingTestCase.java	2007-06-08 12:45:21 UTC (rev 63422)
@@ -45,6 +45,7 @@
 
    // ---- tests
 
+   // FIXME - correct 'simple' undeploy
    public void testSimpleScoping() throws Throwable
    {
       ClassLoader cl = (ClassLoader) getBean("cl");

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingTestDelegate.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingTestDelegate.java	2007-06-08 11:45:26 UTC (rev 63421)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/ScopingTestDelegate.java	2007-06-08 12:45:21 UTC (rev 63422)
@@ -26,14 +26,14 @@
 import org.jboss.dependency.spi.ControllerContext;
 import org.jboss.dependency.spi.ControllerState;
 import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
+import org.jboss.test.kernel.junit.MicrocontainerShutdownTestDelegate;
 
 /**
  * Scoping Deployment Test Delegate.
  *
  * @author <a href="ales.justin at jboss.com">Ales Justin</a>
  */
-public class ScopingTestDelegate extends MicrocontainerTestDelegate
+public class ScopingTestDelegate extends MicrocontainerShutdownTestDelegate
 {
    public ScopingTestDelegate(Class clazz) throws Exception
    {




More information about the jboss-cvs-commits mailing list