[jboss-cvs] JBossAS SVN: r90852 - in projects/kernel/trunk: aop-mc-int/src/test/java/org/jboss/test/microcontainer and 20 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jul 6 13:23:50 EDT 2009
Author: kabir.khan at jboss.com
Date: 2009-07-06 13:23:50 -0400 (Mon, 06 Jul 2009)
New Revision: 90852
Added:
projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/asynchronous/
projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/asynchronous/support/
projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/asynchronous/support/LifecycleCallback.java
projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/asynchronous/support/Marker.java
projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/asynchronous/test/
projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/asynchronous/test/AsynchronousContextWithLifecycleCallbackTestCase.java
projects/kernel/trunk/aop-mc-int/src/test/resources/build.xml
projects/kernel/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/asynchronous/
projects/kernel/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/asynchronous/test/
projects/kernel/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/asynchronous/test/AsynchronousContextWithLifecycleCallbackTestCase.txt
projects/kernel/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/asynchronous/test/AsynchronousContextWithLifecycleCallbackTestCase_Asynchronous.xml
projects/kernel/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/asynchronous/test/AsynchronousContextWithLifecycleCallbackTestCase_Callback.xml
projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/
projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/support/
projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/support/AsynchronousTest.java
projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/support/AsynchronousTestMBean.java
projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/support/Helper.java
projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/support/ServiceControllerLocator.java
projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/test/
projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/test/AsynchronousJMXTestCase.java
projects/kernel/trunk/jmx-aop-mc-int/src/test/resources/build.xml
projects/kernel/trunk/jmx-aop-mc-int/src/test/resources/org/jboss/test/system/controller/integration/asynchronous/
projects/kernel/trunk/jmx-aop-mc-int/src/test/resources/org/jboss/test/system/controller/integration/asynchronous/test/
projects/kernel/trunk/jmx-aop-mc-int/src/test/resources/org/jboss/test/system/controller/integration/asynchronous/test/AsynchronousJMXTestCase-Asynchronous.xml
projects/kernel/trunk/jmx-aop-mc-int/src/test/resources/org/jboss/test/system/controller/integration/asynchronous/test/AsynchronousJMXTestCase-Callback.xml
projects/kernel/trunk/jmx-aop-mc-int/src/test/resources/org/jboss/test/system/controller/integration/asynchronous/test/AsynchronousJMXTestCase.txt
Modified:
projects/kernel/trunk/aop-mc-int/pom.xml
projects/kernel/trunk/dependency/src/main/java/org/jboss/dependency/plugins/AbstractController.java
projects/kernel/trunk/jmx-aop-mc-int/.classpath
projects/kernel/trunk/jmx-aop-mc-int/.project
projects/kernel/trunk/jmx-aop-mc-int/pom.xml
projects/kernel/trunk/kernel/pom.xml
projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/asynchronous/support/Helper.java
projects/kernel/trunk/kernel/src/test/resources/build.xml
Log:
[JBKERNEL-25] Tests and fixes for asynchronous contexts annotated with @JMX. http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4241706#4241706
Modified: projects/kernel/trunk/aop-mc-int/pom.xml
===================================================================
--- projects/kernel/trunk/aop-mc-int/pom.xml 2009-07-06 16:22:37 UTC (rev 90851)
+++ projects/kernel/trunk/aop-mc-int/pom.xml 2009-07-06 17:23:50 UTC (rev 90852)
@@ -49,6 +49,9 @@
<includes>
<include>org/jboss/test/**/*TestCase.java</include>
</includes>
+ <excludes>
+ <exclude>org/jboss/test/microcontainer/asynchronous/test/**</exclude>
+ </excludes>
<useSystemClassLoader>true</useSystemClassLoader>
<argLine>-Djava.system.class.loader=org.jboss.aop.standalone.SystemClassLoader</argLine>
<reportsDirectory>${project.build.directory}/surefire-reports/weave</reportsDirectory>
@@ -88,6 +91,9 @@
<includes>
<include>org/jboss/test/**/*TestCase.java</include>
</includes>
+ <excludes>
+ <exclude>org/jboss/test/microcontainer/asynchronous/test/**</exclude>
+ </excludes>
<useSystemClassLoader>true</useSystemClassLoader>
<argLine>-Djava.system.class.loader=org.jboss.aop.standalone.SystemClassLoader</argLine>
<systemProperties>
@@ -177,6 +183,43 @@
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.2</version>
+ <executions>
+ <execution>
+ <id>run-asynchronous-tests</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <phase>test</phase>
+ <configuration>
+ <tasks unless="maven.test.skip">
+ <property name="byteman.path" value="${maven.dependency.org.jboss.byteman.byteman.jar.path}"/>
+ <property name="report.dir" value="${project.build.directory}/surefire-reports"/>
+ <property name="testOutputDirectory" value="${project.build.testOutputDirectory}"/>
+
+ <ant antfile="${project.build.testOutputDirectory}/build.xml" inheritrefs="true">
+ <target name="asynchronous-tests"/>
+ </ant>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-junit</artifactId>
+ <version>${version.ant.junit}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${version.junit}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
</plugins>
</build>
<dependencyManagement>
@@ -271,6 +314,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.jboss.byteman</groupId>
+ <artifactId>byteman</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.jboss.kernel</groupId>
<artifactId>jboss-kernel</artifactId>
<type>test-jar</type>
Added: projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/asynchronous/support/LifecycleCallback.java
===================================================================
--- projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/asynchronous/support/LifecycleCallback.java (rev 0)
+++ projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/asynchronous/support/LifecycleCallback.java 2009-07-06 17:23:50 UTC (rev 90852)
@@ -0,0 +1,69 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.microcontainer.asynchronous.support;
+
+import org.jboss.dependency.spi.ControllerContext;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class LifecycleCallback
+{
+ boolean installed;
+ boolean uninstalled;
+
+ public boolean isInstalled()
+ {
+ return installed;
+ }
+
+ public boolean isUninstalled()
+ {
+ return uninstalled;
+ }
+
+ public void install(ControllerContext context) throws Exception
+ {
+ synchronized(this)
+ {
+ if (installed)
+ {
+ throw new IllegalStateException("Already installed");
+ }
+ installed = true;
+ }
+ }
+
+ public void uninstall(ControllerContext context) throws Exception
+ {
+ synchronized(this)
+ {
+ if (uninstalled)
+ {
+ throw new IllegalStateException("Already uninstalled");
+ }
+ uninstalled = true;
+ }
+ }
+}
Added: projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/asynchronous/support/Marker.java
===================================================================
--- projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/asynchronous/support/Marker.java (rev 0)
+++ projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/asynchronous/support/Marker.java 2009-07-06 17:23:50 UTC (rev 90852)
@@ -0,0 +1,31 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.microcontainer.asynchronous.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public @interface Marker {
+
+}
Added: projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/asynchronous/test/AsynchronousContextWithLifecycleCallbackTestCase.java
===================================================================
--- projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/asynchronous/test/AsynchronousContextWithLifecycleCallbackTestCase.java (rev 0)
+++ projects/kernel/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/asynchronous/test/AsynchronousContextWithLifecycleCallbackTestCase.java 2009-07-06 17:23:50 UTC (rev 90852)
@@ -0,0 +1,108 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.microcontainer.asynchronous.test;
+
+import org.jboss.test.kernel.asynchronous.test.AsynchronousTest;
+import org.jboss.test.microcontainer.asynchronous.support.LifecycleCallback;
+
+/**
+ * Test that an asynchronous context with a dependency on an automatic
+ * context is paused and picked up again as expected.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AsynchronousContextWithLifecycleCallbackTestCase extends AsynchronousTest
+{
+
+ public AsynchronousContextWithLifecycleCallbackTestCase(String name)
+ {
+ super(name, 2);
+ }
+
+ public void testAsynchronousContextWithLifecycleCallback() throws Exception
+ {
+ deploy("AsynchronousContextWithLifecycleCallbackTestCase_Callback.xml");
+ try
+ {
+ LifecycleCallback describeCallback = (LifecycleCallback)getBean("DescribeCallback");
+ LifecycleCallback instantiateCallback = (LifecycleCallback)getBean("InstantiateCallback");
+ LifecycleCallback configureCallback = (LifecycleCallback)getBean("ConfigureCallback");
+ LifecycleCallback createCallback = (LifecycleCallback)getBean("CreateCallback");
+ LifecycleCallback startCallback = (LifecycleCallback)getBean("StartCallback");
+ LifecycleCallback installCallback = (LifecycleCallback)getBean("InstallCallback");
+
+ assertFalse(describeCallback.isInstalled());
+ assertFalse(instantiateCallback.isInstalled());
+ assertFalse(configureCallback.isInstalled());
+ assertFalse(createCallback.isInstalled());
+ assertFalse(startCallback.isInstalled());
+ assertFalse(installCallback.isInstalled());
+ assertFalse(describeCallback.isUninstalled());
+ assertFalse(instantiateCallback.isUninstalled());
+ assertFalse(configureCallback.isUninstalled());
+ assertFalse(createCallback.isUninstalled());
+ assertFalse(startCallback.isUninstalled());
+ assertFalse(installCallback.isUninstalled());
+
+ deploy("AsynchronousContextWithLifecycleCallbackTestCase_Asynchronous.xml");
+ try
+ {
+ Object bean1 = getBean("Bean1");
+ assertNotNull(bean1);
+
+ assertTrue(describeCallback.isInstalled());
+ assertTrue(instantiateCallback.isInstalled());
+ assertTrue(configureCallback.isInstalled());
+ assertTrue(createCallback.isInstalled());
+ assertTrue(startCallback.isInstalled());
+ assertTrue(installCallback.isInstalled());
+ assertFalse(describeCallback.isUninstalled());
+ assertFalse(instantiateCallback.isUninstalled());
+ assertFalse(configureCallback.isUninstalled());
+ assertFalse(createCallback.isUninstalled());
+ assertFalse(startCallback.isUninstalled());
+ assertFalse(installCallback.isUninstalled());
+ }
+ finally
+ {
+ undeploy("AsynchronousContextWithLifecycleCallbackTestCase_Asynchronous.xml");
+ assertTrue(describeCallback.isInstalled());
+ assertTrue(instantiateCallback.isInstalled());
+ assertTrue(configureCallback.isInstalled());
+ assertTrue(createCallback.isInstalled());
+ assertTrue(startCallback.isInstalled());
+ assertTrue(installCallback.isInstalled());
+ assertTrue(describeCallback.isUninstalled());
+ assertTrue(instantiateCallback.isUninstalled());
+ assertTrue(configureCallback.isUninstalled());
+ assertTrue(createCallback.isUninstalled());
+ assertTrue(startCallback.isUninstalled());
+ assertTrue(installCallback.isUninstalled());
+ }
+ }
+ finally
+ {
+ undeploy("AsynchronousContextWithLifecycleCallbackTestCase_Callback.xml");
+ }
+ }
+}
Added: projects/kernel/trunk/aop-mc-int/src/test/resources/build.xml
===================================================================
--- projects/kernel/trunk/aop-mc-int/src/test/resources/build.xml (rev 0)
+++ projects/kernel/trunk/aop-mc-int/src/test/resources/build.xml 2009-07-06 17:23:50 UTC (rev 90852)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project>
+ <target name="asynchronous-tests">
+ <mkdir dir="${report.dir}"/>
+ <antcall target="run-asynchronous-test" inheritrefs="true">
+ <param name="test" value="AsynchronousContextWithLifecycleCallbackTestCase"/>
+ </antcall>
+ </target>
+
+ <target name="run-asynchronous-test">
+ <property name="bytemanScript" value="${testOutputDirectory}/org/jboss/test/microcontainer/asynchronous/test/${test}.txt"/>
+
+ <junit printsummary="yes" fork="true" haltonfailure="true" haltonerror="true">
+ <classpath>
+ <path refid="maven.test.classpath"/>
+ </classpath>
+ <jvmarg value="-javaagent:${byteman.path}=script:${bytemanScript}"/>
+ <sysproperty key="org.jboss.byteman.debug" value="true"/>
+ <formatter type="plain" usefile="true" extension=".txt" />
+ <formatter classname="org.jboss.ant.taskdefs.XMLJUnitMultipleResultFormatter" usefile="true" extension=".xml" />
+ <test fork="yes" name="org.jboss.test.microcontainer.asynchronous.test.${test}" todir="${report.dir}"/>
+ </junit>
+ </target>
+</project>
\ No newline at end of file
Added: projects/kernel/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/asynchronous/test/AsynchronousContextWithLifecycleCallbackTestCase.txt
===================================================================
--- projects/kernel/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/asynchronous/test/AsynchronousContextWithLifecycleCallbackTestCase.txt (rev 0)
+++ projects/kernel/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/asynchronous/test/AsynchronousContextWithLifecycleCallbackTestCase.txt 2009-07-06 17:23:50 UTC (rev 90852)
@@ -0,0 +1,23 @@
+RULE Wait for Complete following deploy on main thread
+CLASS org.jboss.test.kernel.junit.MicrocontainerTestDelegate
+METHOD deploy(java.net.URL)
+HELPER org.jboss.test.kernel.asynchronous.support.Helper
+AT EXIT
+BIND NOTHING
+IF 1 < incrementCounter("Start")
+DO debug("wait in deploy"),
+ waitFor("Complete", 10000),
+ debug("go!!!")
+ENDRULE
+
+RULE Signal wake Complete following complete deploy in thread
+CLASS org.jboss.dependency.plugins.AbstractController$InstallControllerContextTask
+METHOD run
+HELPER org.jboss.test.kernel.asynchronous.support.Helper
+AT EXIT
+BIND NOTHING
+IF TRUE
+DO debug("signalling wake in AbstractController$InstallControllerContextTask"),
+ signalWake("Complete", true),
+ debug("signalled!")
+ENDRULE
Added: projects/kernel/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/asynchronous/test/AsynchronousContextWithLifecycleCallbackTestCase_Asynchronous.xml
===================================================================
--- projects/kernel/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/asynchronous/test/AsynchronousContextWithLifecycleCallbackTestCase_Asynchronous.xml (rev 0)
+++ projects/kernel/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/asynchronous/test/AsynchronousContextWithLifecycleCallbackTestCase_Asynchronous.xml 2009-07-06 17:23:50 UTC (rev 90852)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+ <bean name="Bean1" class="java.lang.Object" mode="Asynchronous">
+ <annotation>@org.jboss.test.microcontainer.asynchronous.support.Marker</annotation>
+ </bean>
+</deployment>
Added: projects/kernel/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/asynchronous/test/AsynchronousContextWithLifecycleCallbackTestCase_Callback.xml
===================================================================
--- projects/kernel/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/asynchronous/test/AsynchronousContextWithLifecycleCallbackTestCase_Callback.xml (rev 0)
+++ projects/kernel/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/asynchronous/test/AsynchronousContextWithLifecycleCallbackTestCase_Callback.xml 2009-07-06 17:23:50 UTC (rev 90852)
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="AspectManager" class="org.jboss.aop.AspectManager">
+ <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+ </bean>
+
+ <lifecycle-describe xmlns="urn:jboss:aop-beans:1.0"
+ name="DescribeCallback"
+ class="org.jboss.test.microcontainer.asynchronous.support.LifecycleCallback"
+ classes="@org.jboss.test.microcontainer.asynchronous.support.Marker"/>
+
+ <lifecycle-instantiate xmlns="urn:jboss:aop-beans:1.0"
+ name="InstantiateCallback"
+ class="org.jboss.test.microcontainer.asynchronous.support.LifecycleCallback"
+ classes="@org.jboss.test.microcontainer.asynchronous.support.Marker"/>
+
+ <lifecycle-configure xmlns="urn:jboss:aop-beans:1.0"
+ name="ConfigureCallback"
+ class="org.jboss.test.microcontainer.asynchronous.support.LifecycleCallback"
+ classes="@org.jboss.test.microcontainer.asynchronous.support.Marker"/>
+
+ <lifecycle-create xmlns="urn:jboss:aop-beans:1.0"
+ name="CreateCallback"
+ class="org.jboss.test.microcontainer.asynchronous.support.LifecycleCallback"
+ classes="@org.jboss.test.microcontainer.asynchronous.support.Marker"/>
+
+ <lifecycle-start xmlns="urn:jboss:aop-beans:1.0"
+ name="StartCallback"
+ class="org.jboss.test.microcontainer.asynchronous.support.LifecycleCallback"
+ classes="@org.jboss.test.microcontainer.asynchronous.support.Marker"/>
+
+ <lifecycle-install xmlns="urn:jboss:aop-beans:1.0"
+ name="InstallCallback"
+ class="org.jboss.test.microcontainer.asynchronous.support.LifecycleCallback"
+ classes="@org.jboss.test.microcontainer.asynchronous.support.Marker"/>
+</deployment>
Modified: projects/kernel/trunk/dependency/src/main/java/org/jboss/dependency/plugins/AbstractController.java
===================================================================
--- projects/kernel/trunk/dependency/src/main/java/org/jboss/dependency/plugins/AbstractController.java 2009-07-06 16:22:37 UTC (rev 90851)
+++ projects/kernel/trunk/dependency/src/main/java/org/jboss/dependency/plugins/AbstractController.java 2009-07-06 17:23:50 UTC (rev 90852)
@@ -87,6 +87,12 @@
/** The contexts that are currently being installed */
private Set<ControllerContext> installing = new CopyOnWriteArraySet<ControllerContext>();
+
+ /** The contexts that are currently being installed by the executor */
+ ContextsInstalledByExecutor contextsInstalledByExecutor = new ContextsInstalledByExecutor();
+
+ /** Indicates that a context is to be installed by the executor */
+ private final static Thread SCHEDULED_FOR_EXECUTOR = new Thread();
/** The parent controller */
private AbstractController parentController;
@@ -1066,12 +1072,12 @@
if (trace)
log.trace("Skipping already installed " + name + " for " + toState.getStateString());
}
- else if (executorThreadsByContext.get(context) != null && Thread.currentThread() != executorThreadsByContext.get(context))
+ else if (contextsInstalledByExecutor.isInstalledByOtherThread(context))
{
if (trace)
log.trace("Installed by other thread " + name);
}
- else if (installing.add(context) == false)
+ else if (installing.add(context) == false || contextsInstalledByExecutor.isBeingInstalled(context) == true)
{
if (trace)
log.trace("Already installing " + name + " for " + toState.getStateString());
@@ -1144,18 +1150,7 @@
*/
private boolean executeOrIncrementStateDirectly(ControllerContext context, boolean trace)
{
- boolean asynch = false;
- if (context.getMode() == ControllerMode.ASYNCHRONOUS)
- {
- if (Thread.currentThread() != executorThreadsByContext.get(context))
- {
- final Thread ctxThread = executorThreadsByContext.get(context);
- if (ctxThread == null || ctxThread != Thread.currentThread())
- {
- asynch = true;
- }
- }
- }
+ boolean asynch = contextsInstalledByExecutor.shouldInstallAsynchronously(context);
if (asynch)
{
@@ -1165,7 +1160,7 @@
Executor foundExecutor = searchForExecutor();
if (foundExecutor != null)
{
- executorThreadsByContext.put(context, SCHEDULED_FOR_EXECUTOR);
+ contextsInstalledByExecutor.markForThreadExecution(context);
if (trace)
log.trace("Recorded for asynchronous installation " + context.getName());
@@ -1179,7 +1174,7 @@
catch(RejectedExecutionException e)
{
log.warn("Asynchronous execution rejected by executor for context " + context.getName() + ":" + e.getMessage());
- executorThreadsByContext.remove(context);
+ contextsInstalledByExecutor.disassociateWithThread(context);
}
}
}
@@ -2155,9 +2150,6 @@
return states.get(index);
}
-
- private Map<ControllerContext, Thread> executorThreadsByContext = new ConcurrentHashMap<ControllerContext, Thread>();
-
class InstallControllerContextTask implements Runnable
{
ControllerContext context;
@@ -2178,11 +2170,19 @@
lockWrite();
ClassLoader tcl = SecurityActions.setContextClassLoader(classLoader);
- executorThreadsByContext.put(context, Thread.currentThread());
+ contextsInstalledByExecutor.associateWithThread(context);
try
{
//Move the given context as far through the states as possible
- boolean stateChanged = installMyContext();
+ boolean stateChanged = false;
+ try
+ {
+ stateChanged = installMyContext();
+ }
+ finally
+ {
+ contextsInstalledByExecutor.disassociateWithThread(context);
+ }
//The given context had its state changed, now see if anybody was dependent on it
if (stateChanged)
@@ -2198,7 +2198,6 @@
{
if (trace)
log.trace(Thread.currentThread().getName() + " asynchronous install done for " + context.getName());
- executorThreadsByContext.remove(context);
SecurityActions.resetContextClassLoader(tcl);
unlockWrite();
}
@@ -2206,13 +2205,14 @@
boolean installMyContext()
{
+ boolean stateChanged = false;
+
int currentIndex = states.indexOf(context.getState());
int requiredIndex = states.indexOf(context.getRequiredState());
if (requiredIndex == -1)
throw new IllegalArgumentException("Unknown state: " + context.getRequiredState());
boolean resolved = true;
- boolean stateChanged = false;
while(resolved && currentIndex < requiredIndex)
{
@@ -2246,9 +2246,50 @@
}
}
}
+
return stateChanged;
}
}
- final static Thread SCHEDULED_FOR_EXECUTOR = new Thread();
+ private static class ContextsInstalledByExecutor
+ {
+ /** The contexts that are currently being installed by the executor */
+ Map<ControllerContext, Thread> executorThreadsByContext = new ConcurrentHashMap<ControllerContext, Thread>();
+
+ boolean shouldInstallAsynchronously(ControllerContext context)
+ {
+ if (context.getMode() == ControllerMode.ASYNCHRONOUS)
+ {
+ final Thread ctxThread = executorThreadsByContext.get(context);
+ return ctxThread == null || ctxThread != Thread.currentThread();
+ }
+ return false;
+ }
+
+ void markForThreadExecution(ControllerContext context)
+ {
+ executorThreadsByContext.put(context, SCHEDULED_FOR_EXECUTOR);
+ }
+
+ void associateWithThread(ControllerContext context)
+ {
+ executorThreadsByContext.put(context, Thread.currentThread());
+ }
+
+ void disassociateWithThread(ControllerContext context)
+ {
+ executorThreadsByContext.remove(context);
+ }
+
+ boolean isInstalledByOtherThread(ControllerContext context)
+ {
+ final Thread ctxThread = executorThreadsByContext.get(context);
+ return ctxThread != null && Thread.currentThread() != ctxThread;
+ }
+
+ boolean isBeingInstalled(ControllerContext context)
+ {
+ return executorThreadsByContext.get(context) != null;
+ }
+ }
}
Modified: projects/kernel/trunk/jmx-aop-mc-int/.classpath
===================================================================
--- projects/kernel/trunk/jmx-aop-mc-int/.classpath 2009-07-06 16:22:37 UTC (rev 90851)
+++ projects/kernel/trunk/jmx-aop-mc-int/.classpath 2009-07-06 17:23:50 UTC (rev 90852)
@@ -1,27 +1,30 @@
<classpath>
- <classpathentry kind="src" path="src/test/java" output="eclipse-target/tests-classes" including="**/*.java"/>
- <classpathentry kind="src" path="src/test/resources" output="eclipse-target/tests-classes" excluding="**/*.java"/>
- <classpathentry kind="src" path="src/main/java" including="**/*.java"/>
+ <classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
- <classpathentry kind="output" path="eclipse-target/classes"/>
+ <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
+ <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
+ <classpathentry kind="output" path="target/classes"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.1.1/activation-1.1.1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/apache/ant/ant/1.7.0/ant-1.7.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-junit/1.7.0/ant-junit-1.7.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-launcher/1.7.0/ant-launcher-1.7.0.jar"/>
<classpathentry kind="var" path="M2_REPO/bcel/bcel/5.1/bcel-5.1.jar" sourcepath="M2_REPO/bcel/bcel/5.1/bcel-5.1-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/byteman/byteman/1.0.2/byteman-1.0.2.jar"/>
<classpathentry kind="var" path="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar" sourcepath="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar"/>
<classpathentry kind="var" path="M2_REPO/javassist/javassist/3.10.0.GA/javassist-3.10.0.GA.jar" sourcepath="M2_REPO/javassist/javassist/3.10.0.GA/javassist-3.10.0.GA-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-api/2.1.4/jaxb-api-2.1.4.jar" sourcepath="M2_REPO/sun-jaxb/jaxb-api/2.1.4/jaxb-api-2.1.4-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/aop/jboss-aop/2.1.0.CR3/jboss-aop-2.1.0.CR3.jar" sourcepath="M2_REPO/org/jboss/aop/jboss-aop/2.1.0.CR3/jboss-aop-2.1.0.CR3-sources.jar"/>
- <classpathentry kind="src" path="/jboss-aop-mc-int"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/kernel/jboss-aop-mc-int/2.2.0-SNAPSHOT/jboss-aop-mc-int-2.2.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/kernel/jboss-aop-mc-int/2.2.0-SNAPSHOT/jboss-aop-mc-int-2.2.0-SNAPSHOT-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-classloading-spi/6.0.0.Alpha4/jboss-classloading-spi-6.0.0.Alpha4.jar" sourcepath="M2_REPO/org/jboss/integration/jboss-classloading-spi/6.0.0.Alpha4/jboss-classloading-spi-6.0.0.Alpha4-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.13.GA/jboss-common-core-2.2.13.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-common-core/2.2.13.GA/jboss-common-core-2.2.13.GA-sources.jar"/>
- <classpathentry kind="src" path="/jboss-dependency"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/kernel/jboss-dependency/2.2.0-SNAPSHOT/jboss-dependency-2.2.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/kernel/jboss-dependency/2.2.0-SNAPSHOT/jboss-dependency-2.2.0-SNAPSHOT-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/mx/jboss-j2se/6.0.0.Beta2/jboss-j2se-6.0.0.Beta2.jar" sourcepath="M2_REPO/org/jboss/mx/jboss-j2se/6.0.0.Beta2/jboss-j2se-6.0.0.Beta2-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/mx/jboss-jmx/6.0.0.Beta2/jboss-jmx-6.0.0.Beta2.jar" sourcepath="M2_REPO/org/jboss/mx/jboss-jmx/6.0.0.Beta2/jboss-jmx-6.0.0.Beta2-sources.jar"/>
- <classpathentry kind="src" path="/jboss-jmx-mc-int"/>
- <classpathentry kind="src" path="/jboss-kernel"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/kernel/jboss-jmx-mc-int/2.2.0-SNAPSHOT/jboss-jmx-mc-int-2.2.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/kernel/jboss-jmx-mc-int/2.2.0-SNAPSHOT/jboss-jmx-mc-int-2.2.0-SNAPSHOT-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/kernel/jboss-jmx-mc-int/2.2.0-SNAPSHOT/jboss-jmx-mc-int-2.2.0-SNAPSHOT-tests.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/kernel/jboss-kernel/2.2.0-SNAPSHOT/jboss-kernel-2.2.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/kernel/jboss-kernel/2.2.0-SNAPSHOT/jboss-kernel-2.2.0-SNAPSHOT-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-log4j/2.0.5.GA/jboss-logging-log4j-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-log4j/2.0.5.GA/jboss-logging-log4j-2.0.5.GA-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-managed/2.1.1.CR1/jboss-managed-2.1.1.CR1.jar" sourcepath="M2_REPO/org/jboss/man/jboss-managed/2.1.1.CR1/jboss-managed-2.1.1.CR1-sources.jar"/>
@@ -41,5 +44,4 @@
<classpathentry kind="var" path="M2_REPO/trove/trove/2.1.1/trove-2.1.1.jar"/>
<classpathentry kind="var" path="M2_REPO/apache-xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar"/>
<classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.9.1/xml-apis-2.9.1.jar"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
</classpath>
\ No newline at end of file
Modified: projects/kernel/trunk/jmx-aop-mc-int/.project
===================================================================
--- projects/kernel/trunk/jmx-aop-mc-int/.project 2009-07-06 16:22:37 UTC (rev 90851)
+++ projects/kernel/trunk/jmx-aop-mc-int/.project 2009-07-06 17:23:50 UTC (rev 90852)
@@ -1,12 +1,7 @@
<projectDescription>
<name>jboss-jmx-aop-mc-int</name>
<comment>JBoss Microcontainer JMX Integration</comment>
- <projects>
- <project>jboss-aop-mc-int</project>
- <project>jboss-dependency</project>
- <project>jboss-jmx-mc-int</project>
- <project>jboss-kernel</project>
- </projects>
+ <projects/>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
Modified: projects/kernel/trunk/jmx-aop-mc-int/pom.xml
===================================================================
--- projects/kernel/trunk/jmx-aop-mc-int/pom.xml 2009-07-06 16:22:37 UTC (rev 90851)
+++ projects/kernel/trunk/jmx-aop-mc-int/pom.xml 2009-07-06 17:23:50 UTC (rev 90852)
@@ -15,10 +15,50 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <!--configuration>
+ <configuration>
<testFailureIgnore>true</testFailureIgnore>
- </configuration-->
+ <excludes>
+ <exclude>org/jboss/test/system/controller/integration/asynchronous/test/**</exclude>
+ </excludes>
+ </configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.2</version>
+ <executions>
+ <execution>
+ <id>run-asynchronous-tests</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <phase>test</phase>
+ <configuration>
+ <tasks unless="maven.test.skip">
+ <property name="byteman.path" value="${maven.dependency.org.jboss.byteman.byteman.jar.path}"/>
+ <property name="report.dir" value="${project.build.directory}/surefire-reports"/>
+ <property name="testOutputDirectory" value="${project.build.testOutputDirectory}"/>
+
+ <ant antfile="${project.build.testOutputDirectory}/build.xml" inheritrefs="true">
+ <target name="asynchronous-tests"/>
+ </ant>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-junit</artifactId>
+ <version>${version.ant.junit}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${version.junit}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
</plugins>
</build>
@@ -85,5 +125,10 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.byteman</groupId>
+ <artifactId>byteman</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Added: projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/support/AsynchronousTest.java
===================================================================
--- projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/support/AsynchronousTest.java (rev 0)
+++ projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/support/AsynchronousTest.java 2009-07-06 17:23:50 UTC (rev 90852)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.system.controller.integration.asynchronous.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AsynchronousTest implements AsynchronousTestMBean
+{
+
+ public void test()
+ {
+ }
+
+}
Added: projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/support/AsynchronousTestMBean.java
===================================================================
--- projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/support/AsynchronousTestMBean.java (rev 0)
+++ projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/support/AsynchronousTestMBean.java 2009-07-06 17:23:50 UTC (rev 90852)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.system.controller.integration.asynchronous.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface AsynchronousTestMBean
+{
+ void test();
+}
Added: projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/support/Helper.java
===================================================================
--- projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/support/Helper.java (rev 0)
+++ projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/support/Helper.java 2009-07-06 17:23:50 UTC (rev 90852)
@@ -0,0 +1,51 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.system.controller.integration.asynchronous.support;
+
+import org.jboss.byteman.agent.Transformer;
+import org.jboss.byteman.rule.Rule;
+import org.jboss.logging.Logger;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class Helper extends org.jboss.byteman.rule.helper.Helper
+{
+ Logger log = Logger.getLogger(Helper.class);
+
+ protected Helper(Rule rule)
+ {
+ super(rule);
+ }
+
+ @Override
+ public boolean debug(String text)
+ {
+ if (Transformer.isDebug())
+ {
+ log.debug("[" + Thread.currentThread().getName() + "] - rule.debug{" + rule.getName() + "} : " + text);
+ }
+ return true;
+ }
+}
Added: projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/support/ServiceControllerLocator.java
===================================================================
--- projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/support/ServiceControllerLocator.java (rev 0)
+++ projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/support/ServiceControllerLocator.java 2009-07-06 17:23:50 UTC (rev 90852)
@@ -0,0 +1,42 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.system.controller.integration.asynchronous.support;
+
+import org.jboss.system.ServiceController;
+
+/**
+ * Use this instead of org.jboss.test.system.controller.integration.support.ServiceControllerLocator
+ * since the ServiceControllerXXXCallbacks need some of the methods that are not in the MBean interface
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServiceControllerLocator
+{
+ public static ServiceController controller;
+
+ public ServiceController getServiceController()
+ {
+ return controller;
+ }
+
+}
Added: projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/test/AsynchronousJMXTestCase.java
===================================================================
--- projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/test/AsynchronousJMXTestCase.java (rev 0)
+++ projects/kernel/trunk/jmx-aop-mc-int/src/test/java/org/jboss/test/system/controller/integration/asynchronous/test/AsynchronousJMXTestCase.java 2009-07-06 17:23:50 UTC (rev 90852)
@@ -0,0 +1,86 @@
+/*
+ * 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.system.controller.integration.asynchronous.test;
+
+import java.util.concurrent.Executors;
+
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.dependency.plugins.AbstractController;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.system.ServiceContext;
+import org.jboss.system.ServiceController;
+import org.jboss.test.system.controller.integration.asynchronous.support.ServiceControllerLocator;
+import org.jboss.test.system.controller.integration.test.AbstractJMXAnnotationTest;
+
+/**
+ * JMXAnnotationTestCase.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AsynchronousJMXTestCase extends AbstractJMXAnnotationTest
+{
+ public static Test suite()
+ {
+ return suite(AsynchronousJMXTestCase.class);
+ }
+
+ public AsynchronousJMXTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testAsynchronousWithLifecycleCallback() throws Throwable
+ {
+ //I can't see a way to get hold of the actual impl of service controller needed
+ //by the ServiceControllerXXXLifecycleCallbacks so hack that here
+
+ ServiceControllerLocator.controller = (ServiceController)getController();
+ ((AbstractController)ServiceControllerLocator.controller.getKernel().getController()).setExecutor(Executors.newFixedThreadPool(2));
+
+ KernelDeployment callbackDeployment = deployMC("AsynchronousJMXTestCase-Callback.xml");
+ try
+ {
+ KernelDeployment asynchronousDeployment = deployMC("AsynchronousJMXTestCase-Asynchronous.xml");
+ try
+ {
+ ServiceContext ctx = getController().getServiceContext(new ObjectName("jboss:test=Bean"));
+ assertNotNull(ctx);
+ assertEquals("RUNNING", ctx.getStateString());
+ }
+ finally
+ {
+ undeployMC(asynchronousDeployment);
+ }
+ }
+ finally
+ {
+ undeployMC(callbackDeployment);
+ ((AbstractController)ServiceControllerLocator.controller.getKernel().getController()).setExecutor(null);
+ }
+
+
+
+ }
+}
Added: projects/kernel/trunk/jmx-aop-mc-int/src/test/resources/build.xml
===================================================================
--- projects/kernel/trunk/jmx-aop-mc-int/src/test/resources/build.xml (rev 0)
+++ projects/kernel/trunk/jmx-aop-mc-int/src/test/resources/build.xml 2009-07-06 17:23:50 UTC (rev 90852)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project>
+ <target name="asynchronous-tests">
+ <mkdir dir="${report.dir}"/>
+ <antcall target="run-asynchronous-test" inheritrefs="true">
+ <param name="test" value="AsynchronousJMXTestCase"/>
+ </antcall>
+ </target>
+
+ <target name="run-asynchronous-test">
+ <property name="bytemanScript" value="${testOutputDirectory}/org/jboss/test/system/controller/integration/asynchronous/test/${test}.txt"/>
+
+ <junit printsummary="yes" fork="true" haltonfailure="true" haltonerror="true">
+ <classpath>
+ <path refid="maven.test.classpath"/>
+ </classpath>
+ <jvmarg value="-javaagent:${byteman.path}=script:${bytemanScript}"/>
+ <sysproperty key="org.jboss.byteman.debug" value="true"/>
+ <formatter type="plain" usefile="true" extension=".txt" />
+ <formatter classname="org.jboss.ant.taskdefs.XMLJUnitMultipleResultFormatter" usefile="true" extension=".xml" />
+ <test fork="yes" name="org.jboss.test.system.controller.integration.asynchronous.test.${test}" todir="${report.dir}"/>
+ </junit>
+ </target>
+</project>
\ No newline at end of file
Added: projects/kernel/trunk/jmx-aop-mc-int/src/test/resources/org/jboss/test/system/controller/integration/asynchronous/test/AsynchronousJMXTestCase-Asynchronous.xml
===================================================================
--- projects/kernel/trunk/jmx-aop-mc-int/src/test/resources/org/jboss/test/system/controller/integration/asynchronous/test/AsynchronousJMXTestCase-Asynchronous.xml (rev 0)
+++ projects/kernel/trunk/jmx-aop-mc-int/src/test/resources/org/jboss/test/system/controller/integration/asynchronous/test/AsynchronousJMXTestCase-Asynchronous.xml 2009-07-06 17:23:50 UTC (rev 90852)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <bean name="Bean1" class="org.jboss.test.system.controller.integration.asynchronous.support.AsynchronousTest" mode="Asynchronous">
+ <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss:test=Bean", exposedInterface=org.jboss.test.system.controller.integration.asynchronous.support.AsynchronousTestMBean.class, registerDirectly=true)</annotation>
+ </bean>
+</deployment>
Added: projects/kernel/trunk/jmx-aop-mc-int/src/test/resources/org/jboss/test/system/controller/integration/asynchronous/test/AsynchronousJMXTestCase-Callback.xml
===================================================================
--- projects/kernel/trunk/jmx-aop-mc-int/src/test/resources/org/jboss/test/system/controller/integration/asynchronous/test/AsynchronousJMXTestCase-Callback.xml (rev 0)
+++ projects/kernel/trunk/jmx-aop-mc-int/src/test/resources/org/jboss/test/system/controller/integration/asynchronous/test/AsynchronousJMXTestCase-Callback.xml 2009-07-06 17:23:50 UTC (rev 90852)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="AspectManager" class="org.jboss.aop.AspectManager">
+ <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+ </bean>
+
+ <!-- The legacy JMX kernel -->
+ <bean name="ServiceControllerLocator" class="org.jboss.test.system.controller.integration.asynchronous.support.ServiceControllerLocator"/>
+
+ <!-- Support for @JMX -->
+ <lifecycle-configure xmlns="urn:jboss:aop-beans:1.0"
+ name="JMXRegistrationAdvice"
+ class="org.jboss.system.microcontainer.jmx.ServiceControllerRegistrationLifecycleCallback"
+ classes="@org.jboss.aop.microcontainer.aspects.jmx.JMX">
+ <property name="serviceController">
+ <inject bean="ServiceControllerLocator" property="serviceController"/>
+ </property>
+ </lifecycle-configure>
+ <lifecycle-create xmlns="urn:jboss:aop-beans:1.0"
+ name="JMXCreateDestroyAdvice"
+ class="org.jboss.system.microcontainer.jmx.ServiceControllerCreateDestroyLifecycleCallback"
+ classes="@org.jboss.aop.microcontainer.aspects.jmx.JMX">
+ <property name="serviceController">
+ <inject bean="ServiceControllerLocator" property="serviceController"/>
+ </property>
+ </lifecycle-create>
+ <lifecycle-install xmlns="urn:jboss:aop-beans:1.0"
+ name="JMXStartStopAdvice"
+ class="org.jboss.system.microcontainer.jmx.ServiceControllerStartStopLifecycleCallback"
+ classes="@org.jboss.aop.microcontainer.aspects.jmx.JMX">
+ <property name="serviceController">
+ <inject bean="ServiceControllerLocator" property="serviceController"/>
+ </property>
+ </lifecycle-install>
+
+</deployment>
Added: projects/kernel/trunk/jmx-aop-mc-int/src/test/resources/org/jboss/test/system/controller/integration/asynchronous/test/AsynchronousJMXTestCase.txt
===================================================================
--- projects/kernel/trunk/jmx-aop-mc-int/src/test/resources/org/jboss/test/system/controller/integration/asynchronous/test/AsynchronousJMXTestCase.txt (rev 0)
+++ projects/kernel/trunk/jmx-aop-mc-int/src/test/resources/org/jboss/test/system/controller/integration/asynchronous/test/AsynchronousJMXTestCase.txt 2009-07-06 17:23:50 UTC (rev 90852)
@@ -0,0 +1,23 @@
+RULE Wait for the asynchronous deployments
+CLASS org.jboss.test.system.controller.integration.test.AbstractIntegrationTest
+METHOD deployMC(java.lang.String)
+HELPER org.jboss.test.system.controller.integration.asynchronous.support.Helper
+AT EXIT
+BIND NOTHING
+IF !createCounter("Counter") && incrementCounter("Counter")==1
+DO debug("wait in deploy"),
+ waitFor("Complete", 10000),
+ debug("go!!!")
+ENDRULE
+
+RULE Signal Complete for Bean1 in StartStopLifecycleAction
+CLASS org.jboss.system.microcontainer.jmx.ServiceControllerStartStopLifecycleCallback
+METHOD install
+HELPER org.jboss.test.system.controller.integration.asynchronous.support.Helper
+AT EXIT
+BIND NOTHING
+IF TRUE
+DO debug("signalling wake"),
+ signalWake("Complete", true),
+ debug("signalled!")
+ENDRULE
Modified: projects/kernel/trunk/kernel/pom.xml
===================================================================
--- projects/kernel/trunk/kernel/pom.xml 2009-07-06 16:22:37 UTC (rev 90851)
+++ projects/kernel/trunk/kernel/pom.xml 2009-07-06 17:23:50 UTC (rev 90852)
@@ -79,7 +79,7 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${version.junit}</version>
- </dependency>
+ </dependency>
</dependencies>
</plugin>
</plugins>
@@ -142,7 +142,6 @@
<dependency>
<groupId>org.jboss.byteman</groupId>
<artifactId>byteman</artifactId>
- <version>1.0.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Modified: projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/asynchronous/support/Helper.java
===================================================================
--- projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/asynchronous/support/Helper.java 2009-07-06 16:22:37 UTC (rev 90851)
+++ projects/kernel/trunk/kernel/src/test/java/org/jboss/test/kernel/asynchronous/support/Helper.java 2009-07-06 17:23:50 UTC (rev 90852)
@@ -65,4 +65,12 @@
return points;
}
+ @Override
+ public int incrementCounter(Object arg0)
+ {
+ int i = super.incrementCounter(arg0);
+ debug("incremented: " + i);
+ return i;
+ }
+
}
Modified: projects/kernel/trunk/kernel/src/test/resources/build.xml
===================================================================
--- projects/kernel/trunk/kernel/src/test/resources/build.xml 2009-07-06 16:22:37 UTC (rev 90851)
+++ projects/kernel/trunk/kernel/src/test/resources/build.xml 2009-07-06 17:23:50 UTC (rev 90852)
@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- $Id: build-tests-jdk50.xml 87118 2009-04-10 10:42:21Z kabir.khan at jboss.com $ -->
-
<project>
<target name="asynchronous-tests">
<mkdir dir="${report.dir}"/>
More information about the jboss-cvs-commits
mailing list