-
1. Re: Testing a JBoss module using Arquillian
aslak Feb 20, 2012 11:27 AM (in response to paul.robinson)1 of 1 people found this helpfulIf you run on a clean jboss-as, you should be able to deploy your module as part of the test. (deploying when it already exists will probably cause problems, unless you just rename it for the sake of the test)
Something like:
@RunWith(Arquillian.class) public class TestClass { @Deployment(name = "mymodule", order = 1, testable = false) public static JavaArchive createModule() { return ShrinkWrap.create(JavaArchive.class) .addXXXXX() .setManifest(new StringAsset( "... module description\n module-name:XXXX...")); } @Deployment(name = "myapp", order = 2) public static ? createApp() { return ShrinkWrap.create(?) .setManifest(new StringAsset( "...Dependencies: XXXX...")); } @Test public void shouldDoWhatItShouldDo() {} }
-
2. Re: Testing a JBoss module using Arquillian
paul.robinson Feb 21, 2012 4:36 AM (in response to aslak)Thanks Aslak,
That looks like a nice simple solution. I have a couple of concerens, which hopefully I should be able to overcome:
- This never tests the real module that will live in the AS. This is fine during development, but not during CI, QE etc. I'll need to figure out a way of turning off the module @Deployment for these tests, when not run in dev mode.
- The real module has a module.xml that brings in some other dependencies. I'de need to make sure I can use that in the module @Deployment
- A clean JBossAS (hopefully) will eventually have my module installed, so I will need a way to have them co-existing. Your idea of naming the @Deployment module differently should work (I think), but that would meen specifying a different dependency in my testable @Deployment. This would need switching back, somehow, whne the test are run on CI.
If you have any ideas, off the top of your head, I'd be interested to know. But if you havn't, it's not a problem, I can see what I can come up with.
Paul.
-
3. Re: Testing a JBoss module using Arquillian
paul.robinson Feb 24, 2012 5:51 AM (in response to aslak)Alsak,
I don't think I can create a full JBoss module, using the shrinkwrap deployment you suggest. By a 'full deployment', I mean one that contains a module.xml and offers all the features available in the module.xml. I think your suggestion just allows me to update the java code, which is probably enough in most scenarios. CI would need to use the module that ships with JBossAS, but that shouldn't be too difficult to work around.
If I understand your suggestion correctly, doesn't the following provide me with the same functionality, in a simpler manor?
@RunWith(Arquillian.class) public class TestClass { @Deployment public static ? createApp() { return ShrinkWrap.create(?) .addPackages(module packages...) //this is where I'm ading the changed module code .addPackages(test packages...) .setManifest(new StringAsset( "...Dependencies: XXXX...")); } @Test public void shouldDoWhatItShouldDo() {} }
Thanks,
Paul.
-
4. Re: Testing a JBoss module using Arquillian
tomjenkinson Feb 24, 2012 6:12 AM (in response to paul.robinson)1 of 1 people found this helpfulHi Paul,
I *think* there is a unit test in AS7 that appears to do the scaffolding you need already:
[tom@tomsfc16 jboss-as]$ find . -name \module.xml | grep test
./testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/extension/remove/module.xml
gedit testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/extension/remove/*
Seems to deploy a real module (i.e. a filesystem using module.xml), then enables it using:
ModelControllerClient client = ModelControllerClient.Factory.create(InetAddress.getByName("localhost"), 9999, getCallbackHandler());
Hope this is on topic and is of use to you,
Tom
-
5. Re: Testing a JBoss module using Arquillian
tomjenkinson Feb 29, 2012 8:20 AM (in response to tomjenkinson)Hi Paul,
Did that pointer I suggested help at all?Thanks,
Tom -
6. Re: Testing a JBoss module using Arquillian
paul.robinson Feb 29, 2012 8:59 AM (in response to tomjenkinson)Tom,
Thanks for the link. I took a quick look on Friday and it certainly looks like it could be what I want. I've been on PTO, so not had chance to take a proper look.
Thanks,
Paul.
-
7. Re: Testing a JBoss module using Arquillian
paul.robinson Mar 7, 2012 9:04 AM (in response to paul.robinson)Tom,
I've spoke to Kabir, and this approach should work, providing you use a different module name each time the test is ran. It doesn't look like it's possible to re-load a particular module. However, I've now realized there are (at least) two fundamental problems with what I am trying to achieve:
1) You can't update the code used by existing dependants. For example, I boot the AS with a sub-system that depends on Module A. I also have an application that depends on Module A. I can change the code used by the application by deploying Module A' and have the application depend on that. However, the sub-system will still depend on Module A.
2) If I want to change the contents of the module.xml, I can have the test application see this change, as it will depend on Module A'. However, existing sub-systems will still see the old module.xml from Module A.
I'm thinking the simplest approach is to just add the module code in my test archive during development (as suggested in https://community.jboss.org/message/719411#719411). The only problem is that I can't modify the module.xml without re-booting the AS. This is not a major problem as it is done so infrequently.
Paul.
-
8. Re: Testing a JBoss module using Arquillian
tomjenkinson Mar 7, 2012 9:07 AM (in response to paul.robinson)I see, thanks for getting back to me on this. Perhaps different tests would benefit from the different approaches?
-
9. Re: Testing a JBoss module using Arquillian
paul.robinson Mar 7, 2012 9:46 AM (in response to tomjenkinson)What "different tests" where you thinking of?
-
10. Re: Testing a JBoss module using Arquillian
tomjenkinson Mar 7, 2012 10:00 AM (in response to paul.robinson)If you have a module that is only depended upon my applications then the approach I outlined would give you the most freedom.
Without knowing more of the specifics of your module I am not clear if other subsystems do have a dependency upon your module - though I presume from your concern, then other subsystems will do.
Can you use the approach I suggested to offline configure the AS (i.e. put the files in place), then boot up the AS to run the tests with all subsystems now using the new module?
I think arq lets you do work before it boots the server iirc?
-
11. Re: Testing a JBoss module using Arquillian
paul.robinson Mar 7, 2012 11:08 AM (in response to tomjenkinson)Tom,
If you have a module that is only depended upon my applications then the approach I outlined would give you the most freedom.
Agreed.
Without knowing more of the specifics of your module I am not clear if other subsystems do have a dependency upon your module - though I presume from your concern, then other subsystems will do.
I do have a subsystem that also depends on this module, so it is a concern.
Can you use the approach I suggested to offline configure the AS (i.e. put the files in place), then boot up the AS to run the tests with all subsystems now using the new module?
I think arq lets you do work before it boots the server iirc?
Yes, I was thinking about this; it would only work for managed mode though, as remote leaves the server running.
Paul.
-
12. Re: Testing a JBoss module using Arquillian
tomjenkinson Mar 7, 2012 11:26 AM (in response to paul.robinson)Good point re managed vs remote - I hadnt thought through that far, there isn't an AS7 admin command to remotely bounce the server is there?