2 Replies Latest reply: Mar 29, 2012 5:43 AM by Galder Zamarreño RSS

Arquillian Extensions for AS7 Subsystem Authors

Andrew Rubinger Master

Galder started a discussion with us on the feasibility of contributing some Arquillian extensions useful to those building AS7 subsystems.  In effect allowing us to pre-test in an AS7-like configuration without a dependency upon AS7 (which would lead to a cyclic dependency).  In prior revisions we'd done similar stabs by firing up Microcontainer and the VDF to make "Reloaded", so this is an interesting approach to me for a couple reasons.  Galder writes:

 

If you remember correctly, a while back I was pinging you guys with questions related to Arquillian. What I did not explain is what I was trying to achieve, let me explain it in more details:

 

I'm building a extension+subsystem in AS7 and I wanted to be able to test directly from Arquillian without any need to use ant, but rather from the IDE. So, I've come up with some code (written in Scala) that does the following:

 

1. Takes all classes in a package, builds the subsystem jar.

2. Creates a module.xml with all dependencies listed

3. Copies the jar to a new modulePath (java.io.tmp)

3a. Note that arquillian.xml contains a custom modulePath to point to this as well, i.e.:

         <property name="modulePath">${java.io.tmpdir:.}/test-module:${surefire.basedir:.}/build/target/jboss-as/modules</property>

4. Takes all the dependencies of that subsystem and creates module

4a. Copies all jars from the maven coordinates

4b. Builds all module.xml of these dependencies (these dependencies are defined specifically by me, are not deduced from maven dependencies which can be a nightmare)

 

// Steps 1-4b done in a org.jboss.arquillian.core.spi.LoadableExtension implementation where I have a a method for @Observes org.jboss.arquillian.container.spi.event.container.BeforeStart

 

5. Once the container has started, it installs the subsystem and extension using management API.

6. Calls reload on the server so that deployment unit processors can properly be installed

7. Wait for N seconds for the server to reload and assert that the server is started

 

// NOTE: I sometimes have issues with arquillian which is trying to send operations to the server once the reload has been sent and before AS has reloaded, so I get ChannelClosedExceptions

 

// Steps 5-7 are done in a org.jboss.arquillian.core.spi.LoadableExtension implementation where I have a a method for @Observes org.jboss.arquillian.container.spi.event.container.BeforeDeploy

 

Finally, the war for my subsystem is created and deployed and it works beatifully because my subystem is properly installed.

 

Now, the thing is that this code is not only useful to me, but to anyone that builds AS7 subsystems because it means that you can go from a blank AS7 to an AS7 installed with your subsystem and deploying your beloved war without the need of ant nor maven.

 

You just need a brand new, unzipped JBoss instance in your build dir and you're good to go.

 

So, I'd like to contribute this to Arquillian and then call it from my own subsystem. That way Bob and others can benefit from this.

 

Now, ideally I wanna keep it in Scala because the amount of code needed is much smaller than the equivalent in Java. Also, Java can interface with Scala without, in general, major problems. So unless there'd be a big show stopper, I'd rather keep it in Scala.

 

My question is, where shall I contribute this? If you point me to the right place, I can try to generize this and see if it works for my subsystem, then share it with others.

 

WDYT?

 

 

Repo: https://github.com/galderz/scalabox

 

At a high level, these are the most important classes for what I was explaining below:

 

1. Arquillian listener:

https://github.com/galderz/scalabox/blob/master/lift/src/test/scala/org/scalabox/lift/ArquillianTestLifecycleListener.scala

 

2. Main extension build and install class:

https://github.com/galderz/scalabox/blob/master/lift/src/test/scala/org/scalabox/lift/TestLiftExtension.scala

 

3. Building of the AS7 extension with its module.xml plus all the dependencies and their module.xml happen in:

https://github.com/galderz/scalabox/blob/master/lift/src/main/scala/org/scalabox/lift/LiftModule.scala

https://github.com/galderz/scalabox/blob/master/core/src/main/scala/org/scalabox/assembly/ScalaBox.scala (this gets reused by the assembly )

 

4. Test that verifies that the AS7  extension has been correctly installed:

https://github.com/galderz/scalabox/blob/master/lift/src/test/scala/org/scalabox/lift/LiftInstallTest.scala