1 2 Previous Next 28 Replies Latest reply: Nov 6, 2010 10:34 AM by Ove Ranheim RSS

JSFUnit with Arquillian example

Bernard Labno Master

Where can we get example of JSFUnit run with Arquillian, but not only test class, but the entire project?

It would be great to have Seam, Maven, JSFUnit, Arquillian combo project sample.

  • 1. Re: JSFUnit with Arquillian example
    Stan Silvert Master

    Hi Bernard,


    I've got a simple example on my local machine.  It's a bit rough right now and it doesn't use Seam, but it does use Maven, JSFUnit, and Arquillian.  I can commit what I've got later today so you can go ahead and take a look.  I'll post again when it's ready.



  • 2. Re: JSFUnit with Arquillian example
    Stan Silvert Master

    The example is uploaded.  Right now it is using "managed container" mode, so you will need to have an instance of JBoss AS6 M5 running.


    Then do "mvn test".


    The maven project is here: http://anonsvn.jboss.org/repos/jsfunit/trunk/jboss-jsfunit-examples/arquillian/



  • 3. Re: JSFUnit with Arquillian example
    Bernard Labno Master

    Thanks Stan for rapid reply.

    Your example uses servlet-api 3.0. I'm using 2.5 and get

    IllegalArgumentException: The ServletProtocolDeploymentPackager can't merge web.xml files.

    Is it possible to use Arquillian with servlet-api 2.5 for WebArchive deployment?

    I would like to create WAR using Seam 2.2.0 or 2.2.1 (JSF 1.2) and deploy it on JBossAS 4.2.2.GA. Is it feasible?

  • 4. Re: JSFUnit with Arquillian example
    Stan Silvert Master

    Arquillian does support servlet 2.5, but it looks like it does not support JBoss AS 4.2.


    The list of supported containers is in the doc:




  • 5. Re: JSFUnit with Arquillian example
    Bernard Labno Master

    Pity that JBossAS 4.2 is not supported. But let's say I will target JBossAS 5.1, then what's wrong with that exception? My web.xml is standard seam-gen created (servlet 2.5).

  • 6. Re: JSFUnit with Arquillian example
    Stan Silvert Master

    Did you change the dependencies to use the AS5 versions?


    Is there a "caused by" in the stack trace?  It would be interesting to know WHY it can't merge web.xml files.  I assume that Arquillian wants to put its servlet and filter definitions in your web.xml because it can't use web-fragment.xml with servlet 2.5.


    Also, you might want to try asking in the Arquillian forum.  I haven't tried anything besides AS6 so far.



  • 7. Re: JSFUnit with Arquillian example
    John Ament Master

    I'm not sure why, but the example doesn't seem to want to work right now.  I'm trying to run it using an embedded AS 6 over maven 3


    mvn test -Pjbossas-embedded-6
    Warning: JAVA_HOME environment variable is not set.
    [INFO] Scanning for projects...
    Downloading: http://build.canoo.com/NekoHTML/artifacts/m2-repo/org/jboss/jbossas/jboss-as-depchain/6.0.0-SNAPSHOT/maven-metadata.xml
    Downloading: http://htmlunit.sourceforge.net/m2-repo-snapshots/org/jboss/jbossas/jboss-as-depchain/6.0.0-SNAPSHOT/maven-metadata.xml
    [WARNING] Checksum validation failed, expected <html><body><h1>/opt/NekoHTML/cruisecontrol/checkout/build/dist/m2-repo/org/jboss/jbossas/jboss-as-depchain/6.0.0-SNAPSHOT/maven-metadata.xml.sha1</h1><h1>Invalid but is 00a4040847746c099002bcf35cb4b89e79cb5097 for http://build.canoo.com/NekoHTML/artifacts/m2-repo/org/jboss/jbossas/jboss-as-depchain/6.0.0-SNAPSHOT/maven-metadata.xml
    [WARNING] Checksum validation failed, expected <html><body><h1>/opt/NekoHTML/cruisecontrol/checkout/build/dist/m2-repo/org/jboss/jbossas/jboss-as-depchain/6.0.0-SNAPSHOT/maven-metadata.xml.sha1</h1><h1>Invalid but is 00a4040847746c099002bcf35cb4b89e79cb5097 for http://build.canoo.com/NekoHTML/artifacts/m2-repo/org/jboss/jbossas/jboss-as-depchain/6.0.0-SNAPSHOT/maven-metadata.xml
    Downloaded: http://build.canoo.com/NekoHTML/artifacts/m2-repo/org/jboss/jbossas/jboss-as-depchain/6.0.0-SNAPSHOT/maven-metadata.xml (194 B at 0.2 KB/sec)
    [WARNING] Could not transfer metadata org.jboss.jbossas:jboss-as-depchain:6.0.0-SNAPSHOT/maven-metadata.xml from java.net (https://maven-repository.dev.java.net/nonav/repository): No connector available to access repository java.net (https://maven-repository.dev.java.net/nonav/repository) of type legacy using the available factories WagonRepositoryConnectorFactory
    [ERROR] The build could not read 1 project -> [Help 1]
    [ERROR]   The project org.jboss.jsfunit:arquillian-example:1.3.0.Final (/src/testing/1.3.0.Final/jboss-jsfunit-examples/arquillian/pom.xml) has 4 errors
    [ERROR]     'modelVersion' is missing. @ [unknown-group-id]:[unknown-artifact-id]:[unknown-version]
    [ERROR]     'groupId' is missing. @ [unknown-group-id]:[unknown-artifact-id]:[unknown-version]
    [ERROR]     'artifactId' is missing. @ [unknown-group-id]:[unknown-artifact-id]:[unknown-version]
    [ERROR]     'version' is missing. @ [unknown-group-id]:[unknown-artifact-id]:[unknown-version]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingExcepti

  • 8. Re: JSFUnit with Arquillian example
    Moritz Winter Newbie

    Somebody was unreasonable about how maven works and tought a 301 (moved permanently) returned in HTML would make some great maven artifacts. This is how i changed the POM to build the example:

    1. Change the jboss-as-client to 6.0.0.M1
    2. Add new JBoss-Repository-Locations
              <name>JBoss Public Maven Repository Group</name>

    Then I did a maven test -C -Dmaven.repo.local=~/testrepo maven test -C -Dmaven.repo.local=~/testrepo -P jbossas-embedded-6


    The C is for strictness with the Checksums (i.e. no HTML-Trash) and the Dmaven.repo.local is a path to a newly created maven repository because the old one has those bad files in it!


    Altough the build works now, the tests dont, surefire tells me:



    Test set: org.jboss.jsfunit.example.hellojsf.FacadeAPITest
    Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.096 sec <<< FAILURE!
    initializationError(org.jboss.jsfunit.example.hellojsf.FacadeAPITest)  Time elapsed: 0.01 sec  <<< ERROR!
         at org.jboss.arquillian.impl.DeployableTestBuilder.build(DeployableTestBuilder.java:88)
         at org.jboss.arquillian.impl.DeployableTestBuilder.build(DeployableTestBuilder.java:77)
         at org.jboss.arquillian.junit.Arquillian.(Arquillian.java:85)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
         at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
         at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
         at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
         at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
         at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
         at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
         at org.apache.maven.surefire.junit4.JUnit4TestSet.(JUnit4TestSet.java:45)
         at org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite.createTestSet(JUnit4DirectoryTestSuite.java:56)
         at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.locateTestSets(AbstractDirectoryTestSuite.java:96)
         at org.apache.maven.surefire.Surefire.createSuiteFromDefinition(Surefire.java:209)
         at org.apache.maven.surefire.Surefire.run(Surefire.java:156)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
         at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)


    Any suggestions on this error?


    Added the embedded profile!

  • 9. Re: JSFUnit with Arquillian example
    John Ament Master

    yep, same here now as well.  looks like an arquillian error, but just guessing.    

  • 10. Re: JSFUnit with Arquillian example
    Moritz Winter Newbie

    Very cryptic configuration-error exception (see https://jira.jboss.org/browse/ARQ-164



         at org.jboss.arquillian.impl.DeployableTestBuilder.build(DeployableTestBuilder.java:88)


    Translates to: Please execute me with a maven profile...

    maven test -C -Dmaven.repo.local=~/testrepo -P jbossas-embedded-6


    Maven can't download the bom-requirements atm from jboss, so download:





    mvn install:install-file -Dfile=bom-as6-0.2.0-alpha-10.pom -DgroupId=org.jboss.ejb3.bom -DartifactId=bom-as6 -Dversion=0.2.0-alpha-10 -Dpackaging=pom

    mvn install:install-file -Dfile=jboss-javaee6-specs-bom-1.0.0.Beta5.pom -DgroupId=org.jboss.spec -DartifactId=jboss-javaee6-specs-bom -Dversion=1.0.0.Beta5 -Dpackaging=pom


    This leads to yet another error, four other depenecies are missing, among them:

    jboss.messaging:jboss-messaging:jar:${version.jboss.messaging} e.g. theres a unset maven-property somewhere, so thats it atm... iam to to continue today...


    P.S. if youre trying to use the jbossas-managed-6 profile, you're running in the next "error message" (https://jira.jboss.org/browse/ARQ-168) telling you to set the jboss-home

  • 11. Re: JSFUnit with Arquillian example
    John Ament Master

    In my case, I'm trying to run the embedded AS 6 implementation.  I have actually been specifying a profile, and I think if you don't specify one in the case of this build, nothing should be happening, I don't see any indication that a default profile exists.  With that said, I tried stripping out pieces that I believed to be faulty and reran it using the embedded profile - no dice.  I'll keep digging in it to see what's happening.

  • 12. Re: JSFUnit with Arquillian example
    John Ament Master

    So, I made some headway this evening (thanks Aslak) and resolved a number of issues w/ the dependency chain.  I still cannot get it to run w/ jboss as 6 embedded, but that's likely not my issue.  I was able to get 2 out of 3 tests to pass in the test case with the pom.xml located at http://pastebin.com/QwggD7aq but I had to also remove the jndi.properties.




    So after playing with it a bit more, I changed the third test case to this and it worked... weird.



       public void testSetParamAndSubmit() throws IOException
          WebClientSpec wcSpec = new WebClientSpec("/index.faces", BrowserVersion.INTERNET_EXPLORER_7);
          JSFSession jsfSession = new JSFSession(wcSpec);
          JSFClientSession client = jsfSession.getJSFClientSession();
          JSFServerSession server = jsfSession.getJSFServerSession();


          client.setValue("input_foo_text", "Stan");


          UIComponent greeting = server.findComponent("greeting");

  • 13. Re: JSFUnit with Arquillian example
    Moritz Winter Newbie

    Thats actually extremly helpful, i got it running now!

    I  used your pom, added the compiler plugin and configured source/target to java 1.6. I removed the jndi.properties and sucessfully run junit tests in eclipse. Strange thing is i didn't had to change testcase #3 its working out of the box on my linux machine!

    My only concern is that i can't run "mvn test" it says that zero tests did pass and doesnt generate any surefire-reports (which should contain the error-messages) did this work for you?


    Thank you alot!

  • 14. Re: JSFUnit with Arquillian example
    John Ament Master

    I'm still not sure why, but in some cases on my system the third test case fails I end up with a view expired exception on execution of the button click.  I wouldn't be surprised if it was my machine.  I've uploaded my code base to github if anyone's interested in seeing the differences.  https://github.com/johnament/jsfunit-arquillian-example


    I am able to run mvn test and it does work.    

1 2 Previous Next