[jboss-cvs] JBossAS SVN: r69329 - in projects/microcontainer/trunk/kernel/src: resources/tests/org/jboss/test/kernel/controller/test and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jan 24 19:14:28 EST 2008
Author: adrian at jboss.org
Date: 2008-01-24 19:14:27 -0500 (Thu, 24 Jan 2008)
New Revision: 69329
Added:
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/SecurityActions.java
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Callback.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Configure.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Constructor.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Create.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Destroy.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Factory.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_InCallBackCollection.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_InCallBackSingle.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Install.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Start.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Stop.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_UnCallBackCollection.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_UnCallBackSingle.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Uninstall.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/InstallErrorTestCase_Bean.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/InstallErrorTestCase_BeanNoInstall.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/InstallErrorTestCase_BeanWithSupply.xml
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/InstallErrorTestCase_Repositories.xml
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/support/TestBean.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/support/TestBeanRepository.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/support/TestClassLoader.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/support/TestClassLoaderBean.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/support/TestClassLoaderBeanRepository.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/test/InstallErrorTestCase.java
Modified:
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstallAction.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelControllerContextAction.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/test/ControllerTestSuite.java
Log:
[JBMICROCONT-230] - Use any specifc classloader as the context classloader for the bean during un/install actions. Also fixed some problems with the Install lifecycle not unwinding properly in case of an error
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstallAction.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstallAction.java 2008-01-25 00:13:06 UTC (rev 69328)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstallAction.java 2008-01-25 00:14:27 UTC (rev 69329)
@@ -54,32 +54,70 @@
BeanMetaData metaData = context.getBeanMetaData();
Object name = metaData.getName();
registry.registerEntry(name, context);
- controller.addSupplies(context);
-
- List<InstallMetaData> installs = metaData.getInstalls();
- if (installs != null)
+ try
{
- for (InstallMetaData install : installs)
+ controller.addSupplies(context);
+ try
{
- ControllerContext target = context;
- if (install.getBean() != null)
- target = controller.getContext(install.getBean(), install.getDependentState());
- if (target instanceof InvokeDispatchContext)
+ List<InstallMetaData> installs = metaData.getInstalls();
+ if (installs != null)
{
- InvokeDispatchHelper.invoke(
- configurator,
- target.getTarget(),
- (InvokeDispatchContext)target,
- install.getMethodName(),
- install.getParameters()
- );
+ for (InstallMetaData install : installs)
+ {
+ ControllerContext target = context;
+ if (install.getBean() != null)
+ target = controller.getContext(install.getBean(), install.getDependentState());
+ if (target instanceof InvokeDispatchContext)
+ {
+ ClassLoader previous = SecurityActions.setContextClassLoader(context);
+ try
+ {
+ InvokeDispatchHelper.invoke(
+ configurator,
+ target.getTarget(),
+ (InvokeDispatchContext)target,
+ install.getMethodName(),
+ install.getParameters()
+ );
+ }
+ finally
+ {
+ SecurityActions.resetContextClassLoader(previous);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot install, context " + target + " does not implement InvokeDispatchContext");
+ }
+ }
}
- else
+ }
+ catch (Throwable t)
+ {
+ doUninstalls(context);
+ try
{
- throw new IllegalArgumentException("Cannot install, context " + target + " does not implement InvokeDispatchContext");
+ controller.removeSupplies(context);
}
+ catch (Throwable x)
+ {
+ log.warn("Ignoring error reversing supplies, throwing original error " + name, x);
+ }
+ throw t;
}
}
+ catch (Throwable t)
+ {
+ try
+ {
+ registry.unregisterEntry(name);
+ }
+ catch (Throwable x)
+ {
+ log.warn("Ignoring error reversing install, throwing original error " + name, x);
+ }
+ throw t;
+ }
}
protected Class<? extends KernelControllerContextAware> getActionAwareInterface()
@@ -89,12 +127,37 @@
protected void uninstallActionInternal(KernelControllerContext context)
{
+ doUninstalls(context);
KernelController controller = (KernelController) context.getController();
Kernel kernel = controller.getKernel();
KernelRegistry registry = kernel.getRegistry();
+ Object name = context.getName();
+
+ try
+ {
+ controller.removeSupplies(context);
+ }
+ catch (Throwable t)
+ {
+ log.warn("Ignoring removing supplies at uninstall " + name, t);
+ }
+
+ try
+ {
+ registry.unregisterEntry(name);
+ }
+ catch (Throwable t)
+ {
+ log.warn("Ignoring unregistered entry at uninstall " + name, t);
+ }
+ }
+
+ protected void doUninstalls(KernelControllerContext context)
+ {
+ KernelController controller = (KernelController) context.getController();
+ Kernel kernel = controller.getKernel();
KernelConfigurator configurator = kernel.getConfigurator();
BeanMetaData metaData = context.getBeanMetaData();
- Object name = metaData.getName();
List<InstallMetaData> uninstalls = metaData.getUninstalls();
if (uninstalls != null)
@@ -114,8 +177,10 @@
}
if (target instanceof InvokeDispatchContext)
{
+ ClassLoader previous = null;
try
{
+ previous = SecurityActions.setContextClassLoader(context);
InvokeDispatchHelper.invoke(
configurator,
target.getTarget(),
@@ -128,23 +193,17 @@
{
log.warn("Ignoring uninstall action on target " + uninstall, t);
}
+ finally
+ {
+ if (previous != null)
+ SecurityActions.resetContextClassLoader(previous);
+ }
}
else
{
- throw new IllegalArgumentException("Cannot uninstall, context " + target + " does not implement InvokeDispatchContext");
+ log.warn("Cannot uninstall, context " + target + " does not implement InvokeDispatchContext for " + uninstall.getBean());
}
}
}
-
- try
- {
- controller.removeSupplies(context);
- registry.unregisterEntry(name);
- }
- catch (Throwable t)
- {
- log.warn("Ignoring unregistered entry at uninstall " + name);
- }
}
-
}
\ No newline at end of file
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelControllerContextAction.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelControllerContextAction.java 2008-01-25 00:13:06 UTC (rev 69328)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelControllerContextAction.java 2008-01-25 00:14:27 UTC (rev 69329)
@@ -102,15 +102,14 @@
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
try
{
- if (cl != null && access == null)
+ if (cl != null)
Thread.currentThread().setContextClassLoader(cl);
return wrapper.execute(access);
}
finally
{
- if (cl != null && access == null)
- Thread.currentThread().setContextClassLoader(tcl);
+ Thread.currentThread().setContextClassLoader(tcl);
}
}
finally
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/SecurityActions.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/SecurityActions.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/SecurityActions.java 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,103 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.kernel.plugins.dependency;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * SecurityActions.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+class SecurityActions
+{
+ static ClassLoader setContextClassLoader(final KernelControllerContext context) throws Throwable
+ {
+ if (System.getSecurityManager() == null)
+ {
+ ClassLoader result = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(context.getClassLoader());
+ return result;
+ }
+ else
+ {
+ try
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<ClassLoader>()
+ {
+ public ClassLoader run() throws Exception
+ {
+ try
+ {
+ ClassLoader result = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(context.getClassLoader());
+ return result;
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ catch (Error e)
+ {
+ throw e;
+ }
+ catch (Throwable e)
+ {
+ throw new RuntimeException("Error setting context classloader", e);
+ }
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw e.getCause();
+ }
+ }
+ }
+
+ static void resetContextClassLoader(final ClassLoader classLoader)
+ {
+ if (System.getSecurityManager() == null)
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+ else
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ return null;
+ }
+ });
+ }
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Callback.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Callback.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Callback.xml 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <classloader><inject bean="ClassLoader"/></classloader>
+
+ <bean name="ClassLoader" class="org.jboss.test.kernel.controller.support.TestClassLoader">
+ <classloader><null/></classloader>
+ </bean>
+
+ <bean name="Name1" class="org.jboss.test.kernel.controller.support.TestClassLoaderBean">
+ </bean>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Configure.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Configure.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Configure.xml 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <classloader><inject bean="ClassLoader"/></classloader>
+
+ <bean name="ClassLoader" class="org.jboss.test.kernel.controller.support.TestClassLoader">
+ <classloader><null/></classloader>
+ </bean>
+
+ <bean name="Name1" class="org.jboss.test.kernel.controller.support.TestClassLoaderBean">
+ <property name="something">hello</property>
+ </bean>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Constructor.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Constructor.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Constructor.xml 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <classloader><inject bean="ClassLoader"/></classloader>
+
+ <bean name="ClassLoader" class="org.jboss.test.kernel.controller.support.TestClassLoader">
+ <classloader><null/></classloader>
+ </bean>
+
+ <bean name="Name1" class="org.jboss.test.kernel.controller.support.TestClassLoaderBean">
+ <constructor>
+ <parameter>hello</parameter>
+ </constructor>
+ </bean>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Create.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Create.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Create.xml 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <classloader><inject bean="ClassLoader"/></classloader>
+
+ <bean name="ClassLoader" class="org.jboss.test.kernel.controller.support.TestClassLoader">
+ <classloader><null/></classloader>
+ </bean>
+
+ <bean name="Name1" class="org.jboss.test.kernel.controller.support.TestClassLoaderBean">
+ <create method="doLifecycle"/>
+ </bean>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Destroy.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Destroy.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Destroy.xml 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <classloader><inject bean="ClassLoader"/></classloader>
+
+ <bean name="ClassLoader" class="org.jboss.test.kernel.controller.support.TestClassLoader">
+ <classloader><null/></classloader>
+ </bean>
+
+ <bean name="Name1" class="org.jboss.test.kernel.controller.support.TestClassLoaderBean">
+ <destroy method="doLifecycle"/>
+ </bean>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Factory.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Factory.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Factory.xml 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <classloader><inject bean="ClassLoader"/></classloader>
+
+ <bean name="ClassLoader" class="org.jboss.test.kernel.controller.support.TestClassLoader">
+ <classloader><null/></classloader>
+ </bean>
+
+ <bean name="Name1" class="org.jboss.test.kernel.controller.support.TestClassLoaderBean">
+ <constructor factoryClass="org.jboss.test.kernel.controller.support.TestClassLoaderBean" factoryMethod="createInstance"/>
+ </bean>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_InCallBackCollection.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_InCallBackCollection.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_InCallBackCollection.xml 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Repository" class="org.jboss.test.kernel.controller.support.TestClassLoaderBeanRepository">
+ <incallback property="beans"/>
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_InCallBackSingle.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_InCallBackSingle.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_InCallBackSingle.xml 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Repository" class="org.jboss.test.kernel.controller.support.TestClassLoaderBeanRepository">
+ <incallback method="add"/>
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Install.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Install.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Install.xml 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <classloader><inject bean="ClassLoader"/></classloader>
+
+ <bean name="ClassLoader" class="org.jboss.test.kernel.controller.support.TestClassLoader">
+ <classloader><null/></classloader>
+ </bean>
+
+ <bean name="Repository" class="org.jboss.test.kernel.controller.support.TestClassLoaderBeanRepository">
+ <classloader><null/></classloader>
+ </bean>
+
+ <bean name="Name1" class="org.jboss.test.kernel.controller.support.TestClassLoaderBean">
+ <install bean="Repository" method="add">
+ <parameter><this/></parameter>
+ </install>
+ </bean>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Start.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Start.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Start.xml 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <classloader><inject bean="ClassLoader"/></classloader>
+
+ <bean name="ClassLoader" class="org.jboss.test.kernel.controller.support.TestClassLoader">
+ <classloader><null/></classloader>
+ </bean>
+
+ <bean name="Name1" class="org.jboss.test.kernel.controller.support.TestClassLoaderBean">
+ <start method="doLifecycle"/>
+ </bean>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Stop.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Stop.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Stop.xml 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <classloader><inject bean="ClassLoader"/></classloader>
+
+ <bean name="ClassLoader" class="org.jboss.test.kernel.controller.support.TestClassLoader">
+ <classloader><null/></classloader>
+ </bean>
+
+ <bean name="Name1" class="org.jboss.test.kernel.controller.support.TestClassLoaderBean">
+ <stop method="doLifecycle"/>
+ </bean>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_UnCallBackCollection.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_UnCallBackCollection.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_UnCallBackCollection.xml 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Repository" class="org.jboss.test.kernel.controller.support.TestClassLoaderBeanRepository">
+ <uncallback property="beans"/>
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_UnCallBackSingle.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_UnCallBackSingle.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_UnCallBackSingle.xml 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Repository" class="org.jboss.test.kernel.controller.support.TestClassLoaderBeanRepository">
+ <uncallback method="add"/>
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Uninstall.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Uninstall.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase_Uninstall.xml 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <classloader><inject bean="ClassLoader"/></classloader>
+
+ <bean name="ClassLoader" class="org.jboss.test.kernel.controller.support.TestClassLoader">
+ <classloader><null/></classloader>
+ </bean>
+
+ <bean name="Repository" class="org.jboss.test.kernel.controller.support.TestClassLoaderBeanRepository">
+ <classloader><null/></classloader>
+ </bean>
+
+ <bean name="Name1" class="org.jboss.test.kernel.controller.support.TestClassLoaderBean">
+ <uninstall bean="Repository" method="remove">
+ <parameter><this/></parameter>
+ </uninstall>
+ </bean>
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/InstallErrorTestCase_Bean.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/InstallErrorTestCase_Bean.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/InstallErrorTestCase_Bean.xml 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Bean" class="org.jboss.test.kernel.controller.support.TestBean">
+ <install bean="Repository1" method="add">
+ <parameter><this/></parameter>
+ </install>
+ <install bean="Repository2" method="add">
+ <parameter><this/></parameter>
+ </install>
+ <uninstall bean="Repository1" method="remove">
+ <parameter><this/></parameter>
+ </uninstall>
+ <uninstall bean="Repository2" method="remove">
+ <parameter><this/></parameter>
+ </uninstall>
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/InstallErrorTestCase_BeanNoInstall.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/InstallErrorTestCase_BeanNoInstall.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/InstallErrorTestCase_BeanNoInstall.xml 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Bean" class="org.jboss.test.kernel.controller.support.TestBean">
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/InstallErrorTestCase_BeanWithSupply.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/InstallErrorTestCase_BeanWithSupply.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/InstallErrorTestCase_BeanWithSupply.xml 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Bean" class="org.jboss.test.kernel.controller.support.TestBean">
+ <install bean="Repository1" method="add">
+ <parameter><this/></parameter>
+ </install>
+ <install bean="Repository2" method="add">
+ <parameter><this/></parameter>
+ </install>
+ <uninstall bean="Repository1" method="remove">
+ <parameter><this/></parameter>
+ </uninstall>
+ <uninstall bean="Repository2" method="remove">
+ <parameter><this/></parameter>
+ </uninstall>
+ <supply>TestSupply</supply>
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/InstallErrorTestCase_Repositories.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/InstallErrorTestCase_Repositories.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/controller/test/InstallErrorTestCase_Repositories.xml 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Repository1" class="org.jboss.test.kernel.controller.support.TestBeanRepository"/>
+
+ <bean name="Repository2" class="org.jboss.test.kernel.controller.support.TestBeanRepository"/>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/support/TestBean.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/support/TestBean.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/support/TestBean.java 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,43 @@
+/*
+* 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.controller.support;
+
+/**
+ * TestBean.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestBean
+{
+ private boolean throwError = false;
+
+ public boolean isThrowError()
+ {
+ return throwError;
+ }
+
+ public void setThrowError(boolean throwError)
+ {
+ this.throwError = throwError;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/support/TestBeanRepository.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/support/TestBeanRepository.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/support/TestBeanRepository.java 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.controller.support;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * TestBeanRepository.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestBeanRepository
+{
+ private Set<TestBean> beans = new HashSet<TestBean>();
+
+ public Set<TestBean> getBeans()
+ {
+ return beans;
+ }
+
+ public void setBeans(Set<TestBean> beans)
+ {
+ this.beans = beans;
+ }
+
+ public void add(TestBean bean)
+ {
+ if (bean.isThrowError() == false)
+ bean.setThrowError(true);
+ else
+ throw new Error();
+ beans.add(bean);
+ }
+
+ public void remove(TestBean bean)
+ {
+ beans.remove(bean);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/support/TestClassLoader.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/support/TestClassLoader.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/support/TestClassLoader.java 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.controller.support;
+
+/**
+ * TestClassLoader.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestClassLoader extends ClassLoader
+{
+ public TestClassLoader()
+ {
+ super(TestClassLoader.class.getClassLoader());
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/support/TestClassLoaderBean.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/support/TestClassLoaderBean.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/support/TestClassLoaderBean.java 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,91 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.controller.support;
+
+import org.jboss.test.AbstractTestCaseWithSetup;
+
+/**
+ * TestClassLoaderBean.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestClassLoaderBean
+{
+ private static ClassLoader classLoader;
+
+ private String something = "something";
+
+ public static ClassLoader getAndResetClassLoader()
+ {
+ ClassLoader result = classLoader;
+ classLoader = null;
+ return result;
+ }
+
+ protected static void checkClassLoader()
+ {
+ SecurityManager securityManager = AbstractTestCaseWithSetup.suspendSecurity();
+ try
+ {
+ classLoader = Thread.currentThread().getContextClassLoader();
+ }
+ finally
+ {
+ AbstractTestCaseWithSetup.resumeSecurity(securityManager);
+ }
+ }
+
+ public static TestClassLoaderBean createInstance()
+ {
+ checkClassLoader();
+ return new TestClassLoaderBean();
+ }
+
+ public TestClassLoaderBean()
+ {
+
+ }
+
+ public TestClassLoaderBean(String something)
+ {
+ checkClassLoader();
+ this.something = something;
+ }
+
+ public String getSomething()
+ {
+ checkClassLoader();
+ return something;
+ }
+
+ public void setSomething(String something)
+ {
+ checkClassLoader();
+ this.something = something;
+ }
+
+ public void doLifecycle()
+ {
+ checkClassLoader();
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/support/TestClassLoaderBeanRepository.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/support/TestClassLoaderBeanRepository.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/support/TestClassLoaderBeanRepository.java 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.controller.support;
+
+import java.util.Set;
+
+/**
+ * TestClassLoaderBeanRepository.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestClassLoaderBeanRepository
+{
+ public void add(TestClassLoaderBean bean)
+ {
+ TestClassLoaderBean.checkClassLoader();
+ }
+
+ public void remove(TestClassLoaderBean bean)
+ {
+ TestClassLoaderBean.checkClassLoader();
+ }
+
+ public void setBeans(Set<TestClassLoaderBean> beans)
+ {
+ TestClassLoaderBean.checkClassLoader();
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/test/ContextClassLoaderTestCase.java 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,309 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.controller.test;
+
+
+import junit.framework.Test;
+
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.test.kernel.controller.support.TestClassLoaderBean;
+
+/**
+ * ContextClassLoaderTestCase.
+ *
+ * TODO test others, e.g. ControllerContextAware
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ContextClassLoaderTestCase extends AbstractControllerTest
+{
+ ClassLoader cl = null;
+
+ public static Test suite()
+ {
+ return suite(ContextClassLoaderTestCase.class);
+ }
+
+ public ContextClassLoaderTestCase(String name) throws Throwable
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ SecurityManager sm = suspendSecurity();
+ try
+ {
+ cl = Thread.currentThread().getContextClassLoader();
+ }
+ finally
+ {
+ resumeSecurity(sm);
+ }
+ }
+
+ protected void tearDown() throws Exception
+ {
+ SecurityManager sm = suspendSecurity();
+ try
+ {
+ assertEquals(cl, Thread.currentThread().getContextClassLoader());
+ }
+ finally
+ {
+ resumeSecurity(sm);
+ super.tearDown();
+ }
+ }
+
+ public ClassLoader assertClassLoader() throws Exception
+ {
+ ClassLoader classLoader = (ClassLoader) getBean("ClassLoader");
+ checkClassLoader(classLoader);
+ return classLoader;
+ }
+
+ public ClassLoader assertClassLoader(ClassLoader cl) throws Exception
+ {
+ ClassLoader classLoader = (ClassLoader) getBean("ClassLoader");
+ checkClassLoader(cl);
+ return classLoader;
+ }
+
+ public void checkClassLoader(ClassLoader classLoader) throws Exception
+ {
+ assertEquals(classLoader, TestClassLoaderBean.getAndResetClassLoader());
+ }
+
+ public void testFactory() throws Throwable
+ {
+ KernelDeployment deployment = deploy("ContextClassLoaderTestCase_Factory.xml");
+ try
+ {
+ validate();
+ assertClassLoader();
+ }
+ finally
+ {
+ undeploy(deployment);
+ }
+ }
+
+ public void testConstructor() throws Throwable
+ {
+ KernelDeployment deployment = deploy("ContextClassLoaderTestCase_Constructor.xml");
+ try
+ {
+ validate();
+ assertClassLoader();
+ }
+ finally
+ {
+ undeploy(deployment);
+ }
+ }
+
+ public void testConfigure() throws Throwable
+ {
+ KernelDeployment deployment = deploy("ContextClassLoaderTestCase_Configure.xml");
+ ClassLoader cl = null;
+ try
+ {
+ validate();
+ cl = assertClassLoader();
+ }
+ finally
+ {
+ undeploy(deployment);
+ }
+ checkClassLoader(cl);
+ }
+
+ public void testCreate() throws Throwable
+ {
+ KernelDeployment deployment = deploy("ContextClassLoaderTestCase_Create.xml");
+ try
+ {
+ assertClassLoader();
+ }
+ finally
+ {
+ undeploy(deployment);
+ }
+ }
+
+ public void testStart() throws Throwable
+ {
+ KernelDeployment deployment = deploy("ContextClassLoaderTestCase_Create.xml");
+ try
+ {
+ validate();
+ assertClassLoader();
+ }
+ finally
+ {
+ undeploy(deployment);
+ }
+ }
+
+ public void testStop() throws Throwable
+ {
+ KernelDeployment deployment = deploy("ContextClassLoaderTestCase_Stop.xml");
+ ClassLoader cl = null;
+ try
+ {
+ cl = assertClassLoader(null);
+ }
+ finally
+ {
+ undeploy(deployment);
+ }
+ checkClassLoader(cl);
+ }
+
+ public void testDestroy() throws Throwable
+ {
+ KernelDeployment deployment = deploy("ContextClassLoaderTestCase_Destroy.xml");
+ ClassLoader cl = null;
+ try
+ {
+ validate();
+ cl = assertClassLoader(null);
+ }
+ finally
+ {
+ undeploy(deployment);
+ }
+ checkClassLoader(cl);
+ }
+
+ public void testInstall() throws Throwable
+ {
+ KernelDeployment deployment = deploy("ContextClassLoaderTestCase_Install.xml");
+ try
+ {
+ validate();
+ assertClassLoader();
+ }
+ finally
+ {
+ undeploy(deployment);
+ }
+ }
+
+ public void testUninstall() throws Throwable
+ {
+ KernelDeployment deployment = deploy("ContextClassLoaderTestCase_Uninstall.xml");
+ ClassLoader cl = null;
+ try
+ {
+ validate();
+ cl = assertClassLoader(null);
+ }
+ finally
+ {
+ undeploy(deployment);
+ }
+ checkClassLoader(cl);
+ }
+
+ public void testIncallbackSingle() throws Throwable
+ {
+ KernelDeployment repository = deploy("ContextClassLoaderTestCase_InCallBackSingle.xml");
+ KernelDeployment deployment = deploy("ContextClassLoaderTestCase_Callback.xml");
+ try
+ {
+ validate();
+ assertClassLoader();
+ }
+ finally
+ {
+ undeploy(deployment);
+ undeploy(repository);
+ }
+ }
+
+ public void testIncallbackCollection() throws Throwable
+ {
+ KernelDeployment repository = deploy("ContextClassLoaderTestCase_InCallBackCollection.xml");
+ KernelDeployment deployment = deploy("ContextClassLoaderTestCase_Callback.xml");
+ try
+ {
+ validate();
+ assertClassLoader();
+ }
+ finally
+ {
+ undeploy(deployment);
+ undeploy(repository);
+ }
+ }
+
+ public void testUncallbackSingle() throws Throwable
+ {
+ KernelDeployment repository = deploy("ContextClassLoaderTestCase_UnCallBackSingle.xml");
+ ClassLoader cl = null;
+ try
+ {
+ KernelDeployment deployment = deploy("ContextClassLoaderTestCase_Callback.xml");
+ try
+ {
+ validate();
+ cl = assertClassLoader(null);
+ }
+ finally
+ {
+ undeploy(deployment);
+ }
+ checkClassLoader(cl);
+ }
+ finally
+ {
+ undeploy(repository);
+ }
+ }
+
+ public void testUncallbackCollection() throws Throwable
+ {
+ KernelDeployment repository = deploy("ContextClassLoaderTestCase_UnCallBackCollection.xml");
+ ClassLoader cl = null;
+ try
+ {
+ KernelDeployment deployment = deploy("ContextClassLoaderTestCase_Callback.xml");
+ try
+ {
+ validate();
+ cl = assertClassLoader(null);
+ }
+ finally
+ {
+ undeploy(deployment);
+ }
+ checkClassLoader(cl);
+ }
+ finally
+ {
+ undeploy(repository);
+ }
+ }
+}
\ No newline at end of file
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/test/ControllerTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/test/ControllerTestSuite.java 2008-01-25 00:13:06 UTC (rev 69328)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/test/ControllerTestSuite.java 2008-01-25 00:14:27 UTC (rev 69329)
@@ -45,6 +45,8 @@
suite.addTest(AccessControlTestCase.suite());
suite.addTest(NoInstantiateTestCase.suite());
suite.addTest(RedeployAfterErrorTestCase.suite());
+ suite.addTest(ContextClassLoaderTestCase.suite());
+ suite.addTest(InstallErrorTestCase.suite());
return suite;
}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/test/InstallErrorTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/test/InstallErrorTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/controller/test/InstallErrorTestCase.java 2008-01-25 00:14:27 UTC (rev 69329)
@@ -0,0 +1,144 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.controller.test;
+
+
+import junit.framework.Test;
+
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.test.kernel.controller.support.TestBeanRepository;
+
+/**
+ * ContextClassLoaderFactoryTestCase.
+ *
+ * TODO test others, e.g. ControllerContextAware
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class InstallErrorTestCase extends AbstractControllerTest
+{
+ ClassLoader cl = null;
+
+ public static Test suite()
+ {
+ return suite(InstallErrorTestCase.class);
+ }
+
+ public InstallErrorTestCase(String name) throws Throwable
+ {
+ super(name);
+ }
+
+ public void testErrorInInstallWithSupplies() throws Throwable
+ {
+ KernelDeployment repository = deploy("InstallErrorTestCase_Repositories.xml");
+ try
+ {
+ KernelDeployment deployment = deploy("InstallErrorTestCase_BeanWithSupply.xml");
+ try
+ {
+ ControllerContext context = getControllerContext("Bean", null);
+ assertEquals(ControllerState.ERROR, context.getState());
+ checkThrowable(Error.class, context.getError());
+ try
+ {
+ getControllerContext("TestSupply", null);
+ fail("Should not be here!");
+ }
+ catch (Throwable throwable)
+ {
+ checkThrowable(IllegalStateException.class, throwable);
+ }
+ }
+ finally
+ {
+ undeploy(deployment);
+ }
+ }
+ finally
+ {
+ undeploy(repository);
+ }
+ }
+
+ public void testErrorInInstallRedeploy() throws Throwable
+ {
+ KernelDeployment repository = deploy("InstallErrorTestCase_Repositories.xml");
+ try
+ {
+ KernelDeployment deployment = deploy("InstallErrorTestCase_Bean.xml");
+ try
+ {
+ ControllerContext context = getControllerContext("Bean", null);
+ assertEquals(ControllerState.ERROR, context.getState());
+ checkThrowable(Error.class, context.getError());
+ }
+ finally
+ {
+ undeploy(deployment);
+ }
+
+ deployment = deploy("InstallErrorTestCase_BeanNoInstall.xml");
+ try
+ {
+ assertNotNull(getControllerContext("Bean"));
+ }
+ finally
+ {
+ undeploy(deployment);
+ }
+ }
+ finally
+ {
+ undeploy(repository);
+ }
+ }
+
+ public void testErrorInInstall() throws Throwable
+ {
+ KernelDeployment repository = deploy("InstallErrorTestCase_Repositories.xml");
+ try
+ {
+ TestBeanRepository repository1 = (TestBeanRepository) getBean("Repository1");
+ TestBeanRepository repository2 = (TestBeanRepository) getBean("Repository2");
+ KernelDeployment deployment = deploy("InstallErrorTestCase_Bean.xml");
+ try
+ {
+ ControllerContext context = getControllerContext("Bean", null);
+ assertEquals(ControllerState.ERROR, context.getState());
+ checkThrowable(Error.class, context.getError());
+ assertTrue(repository1.getBeans().isEmpty());
+ assertTrue(repository2.getBeans().isEmpty());
+ }
+ finally
+ {
+ undeploy(deployment);
+ }
+ }
+ finally
+ {
+ undeploy(repository);
+ }
+ }
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list