Thanks for your advice. It was very helpful for me.
I want to share my first ideas about the implementation. I am not sure about package which the test should be in and other things.
I have made a simple SAR which is responsible for deployment of testing modules like JARs, EARs, WARs and so on. The code snippet of the SAR:
package org.jboss.test.deployers_jbas5349.sar;
public class DeploymentDependencyTest
extends ServiceMBeanSupport
implements DeploymentDependencyTestMBean
{
// Constants -----------------------------------------------------
public final static String DEPLOYER_NAME = "jboss.system:service=MainDeployer";
// Attributes -----------------------------------------------------
protected String deployModule;
@Override
protected void startService() throws Exception
{
log.debug("DeploymentDependencyTest's SAR is starting");
deployModule = System.getProperty("deployment.dependency.test.module");
if (deployModule != null)
{
log.debug("deploying of " + deployModule);
deploy(deployModule);
} else {
// what should I do?
}
log.debug("DeploymentDependencyTest's SAR is started");
}
@Override
protected void stopService() throws Exception
{
log.debug("DeploymentDependencyTest's SAR is stopping");
if (deployModule != null)
{
log.debug("un-deploying of " + deployModule);
undeploy(deployModule);
}
log.debug("DeploymentDependencyTest's SAR is stopped");
}
...
protected void deploy(String name) throws Exception
{
if (Boolean.getBoolean("jbosstest.nodeploy") == true)
{
log.debug("Skipping deployment of: " + name);
return;
}
URL deployURL = getDeployURL(name);
log.debug("Deploying " + name + ", url=" + deployURL);
invoke(getDeployerName(),
"deploy",
new Object[]{deployURL},
new String[]{"java.net.URL"});
}
...
}The SAR is built inside testsuite/imports/sections/deployers.xml:
<!-- JBAS-5349 SAR -->
<jar destfile="${build.lib}/Aaadeploymentdependency-jbas5349.sar">
<fileset dir="${build.resources}/deployers/jbas5349">
<include name="**/*"/>
</fileset>
<fileset dir="${build.classes}">
<include name="org/jboss/test/deployers_jbas5349/**"/>
</fileset>
</jar>JBoss's service XML of the SAR is located in testsuite/src/resources/deployers/jbas5349/META-INF/jboss-service.xml and is pretty simple:
<mbean code="org.jboss.test.deployers_jbas5349.sar.DeploymentDependencyTest"
name="org.jboss.test.deployers_jbas5349.sar.deployment.dependency.test:service=DeploymentDependencyTest">
</mbean>
I have not found any better way how to start JBoss server repeatedly with different jvmargs or system properties than copying the configuration of the profile "all" to the new one each time.
So the test starts from testsuite/build.xml this way:
<target name="deployment-dependency-tests" description="Tests deployment dependency in new JBossMC.">
<copy file="${build.lib}/Aaadeploymentdependency-jbas5349.sar" overwrite="true" todir="${jboss.dist}/server/all/deploy/" />
<create-profileservice-config baseconf="all" conf="deploymentdependencyserviceA"/>
<server:config>
<server name="deploymentdependencyserviceA">
<jvmarg value="-Djbosstest.deploy.dir=${build.lib}" />
<jvmarg value="-Ddeployment.dependency.test.module=deploymentdependency-ejb3-dummystateless.jar" />
</server>
</server:config>
<server:start name="deploymentdependencyserviceA"/>
<antcall target="test-deployment-dependency-mbean-state"/>
<server:stop name="deploymentdependencyserviceA"/>
<create-profileservice-config baseconf="all" conf="deploymentdependencyserviceB"/>
<server:config>
<server name="deploymentdependencyserviceB">
<jvmarg value="-Djbosstest.deploy.dir=${build.lib}" />
<jvmarg value="-Ddeployment.dependency.test.module=???" />
</server>
</server:config>
<server:start name="deploymentdependencyserviceB"/>
<antcall target="test-deployment-dependency-mbean-state"/>
<server:stop name="deploymentdependencyserviceB"/>
...
<delete file="${jboss.dist}/server/all/deploy/Aaadeploymentdependency-jbas5349.sar" />
</target>Where antcall "test-deployment-dependency-mbean-state" runs simple test case which just checks the state of the SAR:
package org.jboss.test.deployers_jbas5349;
public class DeploymentDependencyTestCase
extends JBossTestCase
{
// Constants -----------------------------------------------------
public final static String DEPLOYMENT_DEPENDENCY_MBEAN_NAME =
"org.jboss.test.deployers_jbas5349.sar.deployment.dependency.test:service=DeploymentDependencyTest";
public final static int EXPECTED_MBEAN_STATE = 3;
...
public void testSARStatus()
throws Exception
{
getLog().debug("+++ testSARStatus");
assertEquals(EXPECTED_MBEAN_STATE, checkMBeanState());
}
protected ObjectName getDeploymentDependencyMBeanName() throws MalformedObjectNameException
{
return new ObjectName(DEPLOYMENT_DEPENDENCY_MBEAN_NAME);
}
protected int checkMBeanState() throws Exception
{
if (Boolean.getBoolean("jbosstest.nodeploy") == true)
return EXPECTED_MBEAN_STATE;
Object state = invoke(getDeploymentDependencyMBeanName(), "getState", null, null);
return ((Integer) state).intValue();
}
}I have written the first test module - dummy (empty) EJB3 stateless bean and run the tests with next result:
2008-09-18 13:53:59,764 WARN [org.jboss.deployment.MainDeployer] (main) Failed to deploy: file:/home/studensky/workspace/trunk/testsuite/output/lib/deploymentdependency-ejb3-dummystateless.jar
org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
*** CONTEXTS MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State}
jboss.j2ee:ear=deploymentdependency-ejb3-dummystateless.jar,jar=deploymentdependency-ejb3-dummystateless.jar,name=DummyStateless,service=EJB3
-> <UNKNOWN jboss.j2ee:ear=deploymentdependency-ejb3-dummystateless.jar,jar=deploymentdependency-ejb3-dummystateless.jar,name=DummyStateless,service=EJB3>{Described:** UNRESOLVED Demands 'jboss.ejb:service=EJBTimerService' **}I hope this is one case of errors which this test should discover.
I will continue with writing other test modules like dummy EJB3 statefull, EJB3 entity, EJB3 MDB, EJB2 stateless, EJB2 statefull, EJB2 BMP entity, EJB2 CMP entity, EJB2 MDB, simple WAR, ...
If there are any considerations/issues about my work, don't hesitate to tell me, please.