11 Replies Latest reply: Nov 7, 2011 2:15 PM by Edward Laczynski RSS

JSFUnit with Arquillian and Jboss7

Martin Dixon Newbie

Hello,

 

I have had a crack at trying to get JSFUnit (2.0.0.Beta1) to work with Arquillian (1.0.0.CR1) and Jboss 7 (either 7.0.0.Final or 7.1.0.Alpha1), but this does not seem to work right now...

 

Looking around the JSFUnit wiki I can't find any mention of Jboss 7 being supported yet - can you tell me whether JSFUnit will work with Jboss 7 and Arquillian, and if so, what version?

 

Thanks,

 

Martin.

  • 1. Re: JSFUnit with Arquillian and Jboss7
    Ove Ranheim Novice

    Hi Martin,

     

    I recommend you to use 2.0.0-SNAPSHOT instead. The interfaces for arquillian in AS7 and JSFUnit has changed.

     

     

    <dependency>
        <groupId>org.jboss.arquillian.junit</groupId>
        <artifactId>arquillian-junit-container</artifactId>
        <version>1.0.0.CR1</version>
        <scope>test</test>
    </dependency>
    
    <dependency>
        <groupId>org.jboss.jsfunit</groupId>
        <artifactId>jsfunit-arquillian</artifactId>
        <version>2.0.0-SNAPSHOT</version>
        <scope>test</scope>
    </dependency>
    
    <profile>
        <id>arq-jbossas-remote-7</id>
        <activation>
            <property>
                <name>remote</name>                    
            </property>
        </activation>
        <dependencies>
            <dependency>
                <groupId>org.jboss.as</groupId>
                <artifactId>jboss-as-arquillian-container-remote</artifactId>
                <version>7.0.1.Final</version>
                <scope>test</scope>
            </dependency>
            <!-- Java EE 6 API dependency -->
            <dependency>
                <groupId>org.jboss.spec</groupId>
                <artifactId>jboss-javaee-web-6.0</artifactId>
                <version>2.0.0.Final</version>
                <type>pom</type>
                <scope>provided</scope>
            </dependency>
        </dependencies>
    </profile>
    

     

    You'll find more information about AS7 and Arquillian here: https://docs.jboss.org/author/display/ARQ/JBoss+AS+7.0+-+Remote

     

    Ove

  • 2. Re: JSFUnit with Arquillian and Jboss7
    Martin Dixon Newbie

    Thanks Ove..

     

    I have tried with 2.0.0-SNAPSHOT, but get this error on deployment of the arquillian generated test.war:

     

    13:04:30,221 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC00001: Failed to start service jboss.deployment.unit."test.war".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."test.war".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [JSFClientSession] with qualifiers [@Default] at injection point [[field] @Inject private com.acme.security.TestLogin.client]

            at org.jboss.as.weld.services.WeldService.start(WeldService.java:96)

            at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)

            at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)

            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_22]

            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_22]

            at java.lang.Thread.run(Thread.java:662) [:1.6.0_22]

    Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [JSFClientSession] with qualifiers [@Default]

    at injection point [[field] @Inject private com.acme.security.TestLogin.client]

            at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:270)

            at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:106)

            at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:129)

            at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:351)

            at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:336)

            at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:404)

            at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:82)

            at org.jboss.as.weld.services.WeldService.start(WeldService.java:89)

            ... 5 more

     

    Have added the 2nd beans.xml as documentation suggests, all other @Inject-ed components are working in my Arquillian tests so classes are getting scanned for CDI ok, but as soon as I try to @Inject a JSFSession or JSFClientSession I get these weld errors. Believe I am packaging all required dependencies as libraries in shrinkwrap archive, so can't see what is causing this error with JSFUnit tests..

     

    Any suggestions?

     

    Thanks,

     

    Martin.

  • 3. Re: JSFUnit with Arquillian and Jboss7
    Ove Ranheim Novice

    Hi Martin,

     

    Please include your code snipptets and if you can list all your dependencies through a pastebin.com, it's easier to see if you 1) have all the right dependencies in place, and 2) look at what your test method looks like.

     

    Ove

  • 4. Re: JSFUnit with Arquillian and Jboss7
    Martin Dixon Newbie

    Thanks for the reply. Code snippets below. As well as a few other bits of config (web.xml, faces-config.xml etc) I add the following to shrinkwrap WebArchive:

     

    war.addAsWebInfResource("beans.xml").addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));

     

    Test class using JSFUnit:

     

    @RunWith(Arquillian.class)

    public class TestLogin extends TestBase {

     

        private @Inject JSFSession jsfSession;

        private @Inject JSFClientSession client;

        private @Inject JSFServerSession server;

       

        @Test

        @InitialPage("/login")

        @FormAuthentication(userName="user",

                password="pwd",

                submitComponent="login",

                userNameComponent="username",

                passwordComponent="password")

        public void testInitialPage() throws Exception {

            Assert.assertEquals("/securehome", server.getCurrentViewID());

        }

    }

     

    The libraries I'm adding to the archive are here (there are quite a few due to stuff other tests are pulling in) - http://pastebin.com/Ax8RdcmW

     

    Cheers,

     

    Martin.

  • 5. Re: JSFUnit with Arquillian and Jboss7
    Ove Ranheim Novice

    Regarding your dependencies, it's hard to tell scope they are in. Besides, what libraries do you include in your deployment?`

     

    What if you try to write your test method like:

     

     

        @Test
        @InitialPage("/login")
        @FormAuthentication(userName="user",
                password="pwd",
                submitComponent="login",
                userNameComponent="username",
                passwordComponent="password")
        public void testInitialPage(JSFSession jsfSession, JSFClientSession client, JSFServerSession server) throws Exception {
            Assert.assertEquals("/securehome", server.getCurrentViewID());
        }
    

     

    Put your injection of JSFSession etc as params to each test method. That might help.

     

    Ove

  • 6. Re: JSFUnit with Arquillian and Jboss7
    Martin Dixon Newbie

    Thanks for the suggestion. Unfortunately I had already tried the param injection approach and it didn't work - I don't get WELD errors, but all JSFUnit params injected are null.

     

    Is there a list of the minimal dependencies required in the shrinkwrap archive to run a JSFUnit test class with Arquillian 1.0.0.CR1 and a clean JBoss 7 distribution?  The only list I found was on http://www.jboss.org/jsfunit/gettingstarted.html but this appears to be for JSFUnit 1.3.0.Final...

     

    Also, is there sample source code available anywhere showing JSFUnit working with Arquillian / Jboss7? - something similar to the Jboss AS6 example here: http://community.jboss.org/wiki/JSFUnit200GettingStartedExample

     

    Cheers,

     

    Martin.

  • 7. Re: JSFUnit with Arquillian and Jboss7
    Ove Ranheim Novice

    Stan,

     

    Can you advice on this? According to JIRA that are two issues left for 2.0.0.Beta2: https://issues.jboss.org/browse/JSFUNIT/fixforversion/12316240

     

    JSFUNIT-281 says it requires the CR1 SPI to upgraded. Is this the reason why jsfunit and as7 not working properly togheter?

     

    Cheers,

    Ove

  • 8. Re: JSFUnit with Arquillian and Jboss7
    badr elhouari Novice

    Here is an example with JSFUnit2, arquillian and jboss AS7 http://community.jboss.org/wiki/JSFUnit200Beta2GettingStartedExample

     

    it worked fine for me

  • 9. Re: JSFUnit with Arquillian and Jboss7
    Martin Dixon Newbie

    Thanks for the pointer to the new example...

     

    Happy to say JSFUnit 2.0.0.Beta2 has resolved the issues and my JSFUnit tests are running successfully with Arquillian and JBoss7!

  • 10. Re: JSFUnit with Arquillian and Jboss7
    badr elhouari Novice

    Enjoy it ;-)

  • 11. Re: JSFUnit with Arquillian and Jboss7
    Edward Laczynski Newbie

    I tried running the example using "mvn -Pjbossas-remote-7 test", but when I do I get the following error:

     

    "

    [ERROR] Failed to execute goal on project gettingstarted: Could not resolve dependencies for project org.jboss.jsfunit:gettingstarted:war:2.0.0.Beta2: Failed to collect dependencies for [junit:junit:jar:4.8.2 (test), org.jboss.arquillian.junit:arquillian-junit-container:jar:1.0.0.CR4 (test), org.jboss.arquillian.protocol:arquillian-protocol-servlet:jar:1.0.0.CR4 (test), org.jboss.arquillian.container:arquillian-container-spi:jar:1.0.0.CR4 (test), org.jboss.spec.javax.faces:jboss-jsf-api_2.1_spec:jar:2.0.0.Beta1 (provided), org.jboss.spec.javax.servlet:jboss-servlet-api_3.0_spec:jar:1.0.0.Final (provided), org.jboss.jsfunit:jsfunit-arquillian:jar:2.0.0.Beta2 (test), org.jboss.jsfunit:jboss-jsfunit-core:jar:2.0.0.Beta2 (test), org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-impl:jar:1.1.0-alpha-2 (test), org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-api-maven:jar:1.0.0-beta-5 (test), org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-impl-maven:jar:1.0.0-beta-5 (test), org.jboss.as:jboss-as-arquillian-container-remote:jar:7.0.1.Final (test)]: Failed to read artifact descriptor for org.jboss.jsfunit:jsfunit-arquillian:jar:2.0.0.Beta2: Could not transfer artifact org.jboss.jsfunit:jsfunit-arquillian:pom:2.0.0.Beta2 from/to jboss-public-repository-group (https://repository.jboss.org/nexus/content/groups/public): Error transferring file: sun.security.validator.ValidatorException: PKIX path building failed:sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]

    "

     

    The console shows that it's downloading some poms, but I don't see any mention of downloading jars.

     

    I checked the first few dependencies in my ".m2" directory and there were no jars in those directories.  I've tried running the command with " -U" tacked on the end to force a refresh and that didn't fix it.  I also tried clearing out the content in a few of the m2 directories and manually putting the jar in there, followed by running the maven command with -U again.  I would have expected at least those jars to stop showing up in the error, but they still do.  Any ideas on what is going on and what I should try next would be appreciated.

     

    Thanks!