Maven with automated testing using TestNG, JSFUnit 2 and Arquillian
Asked Answered
A

1

6

im currently trying to make a JSFUnit-Test with Arquillian and TestNG, but the JSFServerSession and JSFClientSession-object is NULL. Is there a working EXAMPLE for having JSFUnit and TestNG? Or is something else wrong here?

My testing-class:

package my.beautiful.tests;

import java.io.File;
import java.io.IOException;
import java.net.URL;

import javax.faces.component.UIComponent;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.arquillian.testng.Arquillian;
import org.jboss.jsfunit.api.InitialPage;
import org.jboss.jsfunit.jsfsession.JSFClientSession;
import org.jboss.jsfunit.jsfsession.JSFServerSession;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;

public class JSFUnitTestExample /* Arquillian needs this, not TestNG */extends Arquillian {

    @ArquillianResource URL context;

    @Deployment
    public static WebArchive createDeployment() {
        return ShrinkWrap.create( WebArchive.class, "jsfunit_test.war" ).addClass( JSFUnitBean.class )
                .addAsWebInfResource( new File( "src/main/webapp/WEB-INF", "faces-config.xml" ), "faces-config.xml" )
                .addAsWebInfResource( new File( "src/main/webapp/WEB-INF", "beans.xml" ), "beans.xml" )
                .setWebXML( new File( "src/main/webapp/WEB-INF", "web.xml" ) )
                .addAsWebResource( new File( "src/main/webapp", "index.xhtml" ) );
    }

    @Test(dataProvider = Arquillian.ARQUILLIAN_DATA_PROVIDER, description = "Testet, ob bei dem Klick auf den Button der Text 'Hello World' erscheint und das Bean somit richtig angesprochen wird.")
    @InitialPage("/index.xhtml")
    public void testInitialPage( JSFServerSession server, JSFClientSession client ) throws IOException {
        AssertJUnit.assertNotNull( server );
        AssertJUnit.assertNotNull( client );

        AssertJUnit.assertEquals( "/index.xhtml", server.getCurrentViewID() );
        client.click( "submitButton" );

        UIComponent result = server.findComponent( "result" );
        AssertJUnit.assertTrue( result.isRendered() );

        AssertJUnit.assertEquals( "Hello World", server.getManagedBeanValue( "#{jSFUnitBean.message}" ) );
        AssertJUnit.assertEquals( "/index.xhtml", server.getCurrentViewID() );
    }
}

My pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>my.beautiful.tests</groupId>
    <artifactId>jsfunit-example</artifactId>
    <version>1.0</version>

    <packaging>war</packaging>

    <name>Tests :: JSFUnit-Tests with Arquillian</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>      
        <arquillian.debug>true</arquillian.debug> <!-- tells arquillian to be verbose -->
        <openejb.arquillian.debug>true</openejb.arquillian.debug> <!-- tells arquillian to be verbose -->

        <!-- versions -->
        <tomee.version>1.5.1</tomee.version>
        <arquillian.version>1.0.2.Final</arquillian.version>
        <myfaced.version>2.1.8</myfaced.version>
        <jsfunit.version>2.0.0.Beta2</jsfunit.version>
    </properties>

    <build>
        <finalName>jsfunit_test</finalName>
        <plugins>
            <!-- its Java 7 (1.7) -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <!-- /its Java 7 (1.7) -->
            <!-- <special options for TESTING> -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.12.4</version>
                <configuration>
                    <includes>
                        <include>**/*.java</include><!-- dont just run *Test.java-files, which is default for surefire -->
                    </includes>
                    <!-- for Arquillian -->
                    <parallel>none</parallel> <!-- for NOT spawning servers with the same port/port-colision -->
                    <threadCount>1</threadCount> <!-- for NOT spawning servers with the same port/port-colision -->
                    <systemPropertyVariables>
                        <arquillian.launch>tomee-embedded</arquillian.launch>
                    </systemPropertyVariables>
                    <!-- /for Arquillian -->
                </configuration>
            </plugin>
            <!-- </special options for TESTING> -->
            <!-- <for having better IDE-Support> -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                </configuration>
            </plugin>
            <!-- </for having better IDE-Support> -->
        </plugins>
    </build>
    <dependencies>
        <!-- javaEE (tomEE) -->
        <dependency>
            <groupId>org.apache.openejb</groupId>
            <artifactId>javaee-api</artifactId>
            <version>6.0-4</version>
            <scope>provided</scope>
        </dependency>
        <!-- /javaEE (tomEE) -->

        <!-- javax.faces -->
        <dependency>
            <groupId>org.apache.myfaces.core</groupId>
            <artifactId>myfaces-api</artifactId>
            <version>2.1.8</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.myfaces.core</groupId>
            <artifactId>myfaces-impl</artifactId>
            <version>2.1.8</version>
            <scope>provided</scope>
        </dependency>
        <!-- /javax.faces -->

        <!-- jsfunit -->
        <dependency>
            <groupId>org.jboss.jsfunit</groupId>
            <artifactId>jboss-jsfunit-core</artifactId>
            <version>2.0.0.Beta2</version>
            <scope>compile</scope>
        </dependency>
         <dependency>
             <groupId>org.jboss.jsfunit</groupId>
             <artifactId>jsfunit-arquillian</artifactId>
            <version>2.0.0.Beta2</version>
             <scope>test</scope>
         </dependency>
        <!-- /jsfunit -->

        <!-- Arquilian -->
        <dependency>
            <groupId>org.jboss.arquillian.testng</groupId>
            <artifactId>arquillian-testng-container</artifactId><!-- if JUnit is used, change this container to corresponding one -->
            <version>1.0.2.Final</version>
            <scope>test</scope>
        </dependency>
        <!-- Arquilian Adapter -->
        <dependency>
            <groupId>org.apache.openejb</groupId>
            <artifactId>arquillian-tomee-embedded</artifactId>
            <version>1.5.1</version>
            <scope>test</scope>
        </dependency>
        <!-- /Arquilian Adapter -->
        <!-- ShrinkWrap - Dependency for Arquillian -->
         <dependency>
             <groupId>org.jboss.shrinkwrap</groupId>
             <artifactId>shrinkwrap-api</artifactId>
             <version>1.1.1-alpha-2</version>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.jboss.shrinkwrap.resolver</groupId>
             <artifactId>shrinkwrap-resolver-api-maven</artifactId>
             <version>2.0.0-alpha-6</version>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.jboss.shrinkwrap.resolver</groupId>
             <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
             <version>2.0.0-alpha-6</version>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.jboss.shrinkwrap.descriptors</groupId>
             <artifactId>shrinkwrap-descriptors-impl</artifactId>
             <version>1.1.0-beta-1</version>
             <scope>test</scope>
         </dependency>
         <!-- /ShrinkWrap - Dependency for Arquillian -->
        <!-- /Arquilian -->

        <!-- TestNG -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.8</version>
            <scope>test</scope>
        </dependency>
        <!-- /TestNG -->
    </dependencies>

    <repositories>
        <!-- jsfunit -->
        <repository>
            <id>JBoss Dev</id>
            <url>http://repository.jboss.org/nexus/content/groups/public/</url>
             <releases>
                 <enabled>true</enabled>
                 <updatePolicy>never</updatePolicy>
             </releases>
             <snapshots>
                 <enabled>true</enabled>
                 <updatePolicy>never</updatePolicy>
             </snapshots>
        </repository>
        <!-- /jsfunit -->

        <repository>
            <id>apache-m2-snapshot</id>
            <name>Apache Snapshot Repository</name>
            <url>http://repository.apache.org/snapshots</url>
        </repository>
    </repositories>
</project>

Edit: here my TestNG-result: test

InitialPage (null, null)
"java.lang.AssertionError: at my.beatiful.tests.JSFUnitTestExample.testInitialPage(JSFUnitTestExample.java:35) at org.jboss.arquillian.testng.Arquillian$2.invoke(Arquillian.java:167) at org.jboss.arquillian.container.test.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:60) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115) at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67) at org.jboss.arquillian.container.test.impl.client.protocol.local.LocalContainerMethodExecutor.invoke(LocalContainerMethodExecutor.java:50) at org.jboss.arquillian.container.test.impl.execution.RemoteTestExecuter.execute(RemoteTestExecuter.java:120) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115) at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67) at org.jboss.arquillian.container.test.impl.execution.ClientTestExecuter.execute(ClientTestExecuter.java:57) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81) at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createContext(ContainerEventController.java:142) at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createTestContext(ContainerEventController.java:129) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135) at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:111) at org.jboss.arquillian.testng.Arquillian.run(Arquillian.java:158) at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:77) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:110) at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:106) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165) at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75) ... Removed 63 stack frames

java.lang.AssertionError: at org.testng.AssertJUnit.fail(AssertJUnit.java:59) at org.testng.AssertJUnit.assertTrue(AssertJUnit.java:24) at org.testng.AssertJUnit.assertNotNull(AssertJUnit.java:267) at org.testng.AssertJUnit.assertNotNull(AssertJUnit.java:259) at my.beatiful.tests.JSFUnitTestExample.testInitialPage(JSFUnitTestExample.java:35) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80) at org.testng.internal.MethodInvocationHelper$1.runTestMethod(MethodInvocationHelper.java:182) at org.jboss.arquillian.testng.Arquillian$2.invoke(Arquillian.java:167) at org.jboss.arquillian.container.test.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:60) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115) at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67) at org.jboss.arquillian.container.test.impl.client.protocol.local.LocalContainerMethodExecutor.invoke(LocalContainerMethodExecutor.java:50) at org.jboss.arquillian.container.test.impl.execution.RemoteTestExecuter.execute(RemoteTestExecuter.java:120) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115) at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67) at org.jboss.arquillian.container.test.impl.execution.ClientTestExecuter.execute(ClientTestExecuter.java:57) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81) at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createContext(ContainerEventController.java:142) at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createTestContext(ContainerEventController.java:129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135) at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:111) at org.jboss.arquillian.testng.Arquillian.run(Arquillian.java:158) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.testng.internal.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:194) at org.testng.internal.Invoker.invokeMethod(Invoker.java:707) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) at org.testng.TestRunner.privateRun(TestRunner.java:767) at org.testng.TestRunner.run(TestRunner.java:617) at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at org.testng.SuiteRunner.run(SuiteRunner.java:240) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198) at org.testng.TestNG.runSuitesLocally(TestNG.java:1123) at org.testng.TestNG.run(TestNG.java:1031) at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:77) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:110) at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:106) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165) at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75) "

org.testng.AssertJUnit.fail(AssertJUnit.java:59)
org.testng.AssertJUnit.assertTrue(AssertJUnit.java:24)
org.testng.AssertJUnit.assertNotNull(AssertJUnit.java:267)
org.testng.AssertJUnit.assertNotNull(AssertJUnit.java:259)
my.beatiful.tests.JSFUnitTestExample.testInitialPage(JSFUnitTestExample.java:35)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
org.testng.internal.MethodInvocationHelper$1.runTestMethod(MethodInvocationHelper.java:182)
org.jboss.arquillian.testng.Arquillian$2.invoke(Arquillian.java:167)
org.jboss.arquillian.container.test.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:60)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
org.jboss.arquillian.container.test.impl.client.protocol.local.LocalContainerMethodExecutor.invoke(LocalContainerMethodExecutor.java:50)
org.jboss.arquillian.container.test.impl.execution.RemoteTestExecuter.execute(RemoteTestExecuter.java:120)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
org.jboss.arquillian.container.test.impl.execution.ClientTestExecuter.execute(ClientTestExecuter.java:57)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
org.jboss.arquillian.container.test.impl.client.ContainerEventController.createContext(ContainerEventController.java:142)
org.jboss.arquillian.container.test.impl.client.ContainerEventController.createTestContext(ContainerEventController.java:129)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:111)
org.jboss.arquillian.testng.Arquillian.run(Arquillian.java:158)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.testng.internal.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:194)
org.testng.internal.Invoker.invokeMethod(Invoker.java:707)
org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
org.testng.TestRunner.privateRun(TestRunner.java:767)
org.testng.TestRunner.run(TestRunner.java:617)
org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
org.testng.SuiteRunner.run(SuiteRunner.java:240)
org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
org.testng.TestNG.runSuitesSequentially(TestNG.java:1198)
org.testng.TestNG.runSuitesLocally(TestNG.java:1123)
org.testng.TestNG.run(TestNG.java:1031)
org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:77)
org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:110)(... cut ... )
Armil answered 9/1, 2013 at 11:31 Comment(2)
maybe it would be useful if you provide a reduced, more straight forward program which shows the questionable behaviour thxAssured
@FranzEbner I am having the same issue and I am afraid this is as "straight forward" as it gets. I have attached my sample program that can reproduce this here: community.jboss.org/thread/229186?tstart=0Contumelious
C
1

I have finally found a solution to this problem. JSFUnit expects certain filters to be running. Using Servet 3.0 protocol, these should be added automatically. But they are not. That's why we are not getting injected anything.

I have downloaded JSFUnit Arquillian integration sources and found what needs to be added:

jsfunit-arquillian-2.0.0.Beta2-sources.jar/org/jboss/arquillian/jsfunit/internals/web-fragment.xml

Just add it manually to your web.xml and everything should work as expected. Here is the relevant part:

<filter>
  <filter-name>JSFUnitCleanupTestTreadFilter</filter-name>
  <filter-class>org.jboss.jsfunit.arquillian.container.JSFUnitCleanupTestTreadFilter</filter-class>
</filter>

<filter>
  <filter-name>JSFUnitFilter</filter-name>
  <filter-class>org.jboss.jsfunit.framework.JSFUnitFilter</filter-class>
</filter>

<filter-mapping>
  <filter-name>JSFUnitCleanupTestTreadFilter</filter-name>
  <url-pattern>/ArquillianServletRunner</url-pattern>
</filter-mapping>    

<filter-mapping>
  <filter-name>JSFUnitFilter</filter-name>
  <url-pattern>/ArquillianServletRunner</url-pattern>
</filter-mapping>  

In my case everything works, session is injected.

Contumelious answered 11/6, 2013 at 3:18 Comment(2)
after 5 month finally some interesting response :) i analyzed my generated test-war-file and the filters should already be included, but i will give it a new try. thanks (personally i dont like to modify my web.xml, that was the big thing using jsfunit 2.0, at least i thought)Armil
Let me know what worked for you. There are not many people working with Arq. and now I start to understand why... I think this is not really an issue of JSFUnit, but the arquillian adapter.Contumelious

© 2022 - 2024 — McMap. All rights reserved.