Skip navigation
2011

With the installment of AS 7 we have a perfect runtime implementation for a modular environment in the form of jboss-modules.

 

Now I also want it to be usable from within an IDE (in this case Intellij) and Maven (our current build tool). So I figured that through the use of a JUnit Runner I could setup a moduler enviroment (similar to Arquillian).

 

First you'll have to pickup a piece of experimental code I call jboss-modules-junit at https://github.com/wolfc/jboss-modules-junit.

 

Now you can start to run your test case within a modular environment simply by saying @RunWith(Modules.class).

@RunWith(Modules.class)
public class MyTestCase {

 

By default Modules will take the test class name as the module name. This can be overriden with @ModuleName.

@ModuleName("org.jboss.as.test.surefire.servermodule")


First you'll need a module.xml file to represent your test module. By default the modules runner will look it up on your class path entry of your test class.

<?xml version="1.0" encoding="UTF-8"?><module xmlns="urn:jboss:module:1.0" name="org.jboss.modules.junit.SimpleTestCase">
    <resources>
        <!-- a trick to add the original class path entry -->
        <resource-root path="../../../../../.."/>
    </resources>

    <dependencies>
        <module name="junit"/>
        <module name="org.jboss.logmanager"/>
    </dependencies>
</module>


https://github.com/wolfc/jboss-modules-junit/blob/master/src/test/resources/org/jboss/modules/junit/SimpleTestCase/main/module.xml

 

Because you share JUnit with whoever is running the test (IDE or build tool) you need to define a junit module as such. Currently this is a manual requirement.

<?xml version="1.0" encoding="UTF-8"?><module xmlns="urn:jboss:module:1.0" name="junit">
    <dependencies>
        <module name="system" export="false">
            <exports>
                <include-set>
                    <path name="junit/framework"/>
                    <path name="org/junit"/>
                </include-set>
            </exports>
        </module>
    </dependencies>
</module>


https://github.com/wolfc/jboss-modules-junit/blob/master/src/test/resources/junit/main/module.xml

 

So I bring it all together on our main project, AS 7, https://github.com/wolfc/jboss-as/blob/JBAS-9020-test/testsuite/smoke/src/test/java/org/jboss/as/test/surefire/servermodule/ServerInModuleDeploymentTestCase.java. You can try it for yourself by using https://github.com/wolfc/jboss-as/tree/JBAS-9020-test. Additional VM parameters are required though:

  • -Djboss.home.dir=/home/carlo/work/jboss-as/build/target/jboss-7.0.0.Beta4-SNAPSHOT (mandatory)
  • -Dmodule.path=target/test-classes/modules:/home/carlo/work/jboss-as/build/target/jboss-7.0.0.Beta4-SNAPSHOT/modules (override module repos)
  • -Djava.util.logging.manager=org.jboss.logmanager.LogManager (because of Intellij bug, see below)
  • -Djboss.embedded.root=target/temp-config (to instruct AS Embedded to make a copy)

 

Some caveats though:

  1. Intellij contains a bug which initializes a JUnit test case class too soon (http://youtrack.jetbrains.net/issue/IDEA-68658 fixed in 108.13)
  2. Maven and Intellij disagree in which directory to start the test, so you have to explicitly specify $MODULE_DIR$ as the Working directory in the Run Configuration.

Last Saturday the "Fools' Day" release went out the door.

 

Among a long list of changes, I would like to pick out a couple of issues which I personally find a huge improvment. Before you click off into the list, the short story is that a deployment plan which does not contain all bits will be rolled back. This means that an Arquillian deployment will no longer stall when it has 'missing' or broken bits (JBAS-9077). It also has become the default mode of operation (JBAS-9146). And with a bit of magic it works (JBAS-9082).

 

To me the rollback feature is a huge boon in usability. If I make a mistake (and I make many ) the application server will provide me guidance. So this "Fools' Day" release has made this fool very happy.

 

Grab your copy here and tell me what you think.

Filter Blog

By date:
By tag: