7 Replies Latest reply on Sep 3, 2012 4:28 AM by Anthony Patricio

    What is the suggested way to test conversation scoped components?

    Anthony Patricio Master

      There is a big hole in the features, ability to test conversation scoped component.

      I know there are very good reasons for this but you can't tell arquillian is THE testing framework when users can't test a subset of their app.

      There is a way using weld-ee-embedded-1.1, it is not 100% transparent but fair enough, this method really deserves a specific Guide article no?

       

      Cheers,

      Anthony

        • 1. Re: What is the suggested way to test conversation scoped components?
          Bartosz Majsak Master

          I think Bernard wrote small extension to deal with this very problem - http://blog.it-crowd.com.pl/2012/04/mock-contexts-for-arquillian.html

           

          With regards to the Guide - the more, the better, especially that question about Conversation scope is recurring quite frequently. Would you be interested to help us writing this one?

          • 2. Re: What is the suggested way to test conversation scoped components?
            Anthony Patricio Master

            Hi

            the feature is exactly what is needed.

            However I'm still stuck with many maven issues, currently Shrinkwrap is causing problems to just reproduce the use case described in the blog.

            It won't be honest for me to write a guide without a really robust working example.

             

            Things are extremly complicated to setup in this area, I'm close to give up.

            • 3. Re: What is the suggested way to test conversation scoped components?
              Bartosz Majsak Master

              If you have a problem I think it's easier to ask for help than give up. Just provide detailed description and we will see what can be wrong in your case.

               

              After all it's not very complicated to set up imho.

              • 4. Re: What is the suggested way to test conversation scoped components?
                Anthony Patricio Master

                if you try a simple arquillian test -> easy

                if you try the mock stuffs alone -> easy

                if you try warp aside in a separate project -> easy

                if you try drone aside in a separate project -> easy

                 

                If you want to leverage all these features in one project -> hell

                I'm far to be an expert in maven but I'm using it a lot, it's not against arquillian, it's just a general feeling that maven is failling it's main goal and we tend to spend more time setting up a project than coding tests.

                 

                I'll figure this out, thanks for you help.

                • 5. Re: What is the suggested way to test conversation scoped components?
                  Anthony Patricio Master

                  The current issue is that MavenImporter is not available with the current pom.

                  I'm supposed to be using the exact same dependency as the /mock-contexts-extension example, however for some obscur reason, a wrong version is caught.

                   

                  <?xml version="1.0" encoding="UTF-8"?>
                  <project
                            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
                            xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                            <modelVersion>4.0.0</modelVersion>
                            <groupId>com.example.xxx</groupId>
                            <artifactId>xxx</artifactId>
                            <version>1.0.0-SNAPSHOT</version>
                            <packaging>war</packaging>
                            <properties>
                                      <version.junit>4.10</version.junit>
                                      <version.arquillian_core>1.0.2.Final</version.arquillian_core>
                            </properties>
                            <dependencyManagement>
                                      <dependencies>
                                                <dependency>
                                                          <groupId>org.jboss.spec</groupId>
                                                          <artifactId>jboss-javaee-6.0</artifactId>
                                                          <version>3.0.1.Final</version>
                                                          <type>pom</type>
                                                          <scope>import</scope>
                                                </dependency>
                                                <dependency>
                                                          <groupId>org.jboss.arquillian</groupId>
                                                          <artifactId>arquillian-bom</artifactId>
                                                          <version>${version.arquillian_core}</version>
                                                          <type>pom</type>
                                                          <scope>import</scope>
                                                </dependency>
                                                <dependency>
                                                          <groupId>org.jboss.arquillian.extension</groupId>
                                                          <artifactId>arquillian-drone-impl</artifactId>
                                                          <version>1.1.0.CR2</version>
                                                </dependency>
                                                <dependency>
                                                          <groupId>org.jboss.arquillian.extension</groupId>
                                                          <artifactId>arquillian-drone-bom</artifactId>
                                                          <version>1.1.0.CR2</version>
                                                          <scope>pom</scope>
                                                </dependency>
                                                <dependency>
                                                          <groupId>org.jboss.arquillian.extension</groupId>
                                                          <artifactId>arquillian-drone-selenium</artifactId>
                                                          <version>1.1.0.CR2</version>
                                                </dependency>
                                                <dependency>
                                                          <groupId>org.jboss.arquillian.extension</groupId>
                                                          <artifactId>arquillian-drone-selenium-server</artifactId>
                                                          <version>1.1.0.CR2</version>
                                                </dependency>
                                                <dependency>
                                                          <groupId>org.seleniumhq.selenium</groupId>
                                                          <artifactId>selenium-java</artifactId>
                                                          <version>2.25.0</version>
                                                </dependency>
                                                <dependency>
                                                          <groupId>org.seleniumhq.selenium</groupId>
                                                          <artifactId>selenium-server</artifactId>
                                                          <version>2.25.0</version>
                                                </dependency>
                                                <dependency>
                                                          <groupId>org.slf4j</groupId>
                                                          <artifactId>slf4j-simple</artifactId>
                                                          <version>1.6.4</version>
                                                </dependency>
                                      </dependencies>
                            </dependencyManagement>
                            <dependencies>
                                      <dependency>
                                                <groupId>org.hibernate.javax.persistence</groupId>
                                                <artifactId>hibernate-jpa-2.0-api</artifactId>
                                                <scope>provided</scope>
                                      </dependency>
                                      <dependency>
                                                <groupId>org.jboss.spec.javax.ejb</groupId>
                                                <artifactId>jboss-ejb-api_3.1_spec</artifactId>
                                                <scope>provided</scope>
                                      </dependency>
                                      <dependency>
                                                <groupId>javax.enterprise</groupId>
                                                <artifactId>cdi-api</artifactId>
                                                <scope>provided</scope>
                                      </dependency>
                                      <dependency>
                                                <groupId>org.jboss.spec.javax.annotation</groupId>
                                                <artifactId>jboss-annotations-api_1.1_spec</artifactId>
                                                <scope>provided</scope>
                                      </dependency>
                                      <dependency>
                                                <groupId>org.jboss.spec.javax.servlet</groupId>
                                                <artifactId>jboss-servlet-api_3.0_spec</artifactId>
                                                <scope>provided</scope>
                                      </dependency>
                                      <dependency>
                                                <groupId>org.jboss.spec.javax.faces</groupId>
                                                <artifactId>jboss-jsf-api_2.1_spec</artifactId>
                                                <scope>test</scope>
                                      </dependency>
                                      <dependency>
                                                <groupId>junit</groupId>
                                                <artifactId>junit</artifactId>
                                                <version>${version.junit}</version>
                                                <scope>test</scope>
                                      </dependency>
                                      <dependency>
                                                <groupId>org.jboss.arquillian.junit</groupId>
                                                <artifactId>arquillian-junit-container</artifactId>
                                                <scope>test</scope>
                                      </dependency>
                                      <dependency>
                                                <groupId>org.jboss.arquillian.extension</groupId>
                                                <artifactId>arquillian-drone-impl</artifactId>
                                                <scope>test</scope>
                                      </dependency>
                                      <dependency>
                                                <groupId>org.jboss.arquillian.extension</groupId>
                                                <artifactId>arquillian-drone-selenium</artifactId>
                                                <scope>test</scope>
                                      </dependency>
                                      <dependency>
                                                <groupId>org.jboss.arquillian.extension</groupId>
                                                <artifactId>arquillian-drone-selenium-server</artifactId>
                                                <scope>test</scope>
                                      </dependency>
                                      <dependency>
                                                <groupId>org.seleniumhq.selenium</groupId>
                                                <artifactId>selenium-java</artifactId>
                                                <scope>test</scope>
                                      </dependency>
                                      <dependency>
                                                <groupId>org.seleniumhq.selenium</groupId>
                                                <artifactId>selenium-server</artifactId>
                                                <scope>test</scope>
                                      </dependency>
                                      <dependency>
                                                <groupId>org.slf4j</groupId>
                                                <artifactId>slf4j-simple</artifactId>
                                                <scope>test</scope>
                                      </dependency>
                                      <dependency>
                                                <groupId>org.jboss.arquillian.extension</groupId>
                                                <artifactId>arquillian-warp-impl</artifactId>
                                                <version>1.0.0.Alpha2-SNAPSHOT</version>
                                                <scope>test</scope>
                                                <exclusions>
                                                          <exclusion>
                                                                    <groupId>org.slf4j</groupId>
                                                                    <artifactId>slf4j-log4j12</artifactId>
                                                          </exclusion>
                                                          <exclusion>
                                                                    <groupId>log4j</groupId>
                                                                    <artifactId>log4j</artifactId>
                                                          </exclusion>
                                                </exclusions>
                                      </dependency>
                                      <dependency>
                                                <groupId>org.jboss.arquillian.extension</groupId>
                                                <artifactId>arquillian-warp-phaser</artifactId>
                                                <version>1.0.0.Alpha2-SNAPSHOT</version>
                                      </dependency>
                                      <dependency>
                                                <groupId>org.jboss.arquillian.graphene</groupId>
                                                <artifactId>graphene-webdriver</artifactId>
                                                <version>2.0.0.Alpha1</version>
                                                <type>pom</type>
                                                <scope>test</scope>
                                      </dependency>
                                      <dependency>
                                                <groupId>com.opera</groupId>
                                                <artifactId>operadriver</artifactId>
                                                <version>0.14</version>
                                                <scope>test</scope>
                                      </dependency>
                                      <dependency>
                                                <groupId>org.apache.httpcomponents</groupId>
                                                <artifactId>httpclient</artifactId>
                                                <version>4.1.2</version>
                                      </dependency>
                  
                  
                                      <dependency>
                                                <groupId>pl.com.it-crowd.mock-contexts-extension</groupId>
                                                <artifactId>mock-contexts-extension-api</artifactId>
                                                <version>0.1-SNAPSHOT</version>
                                      </dependency>
                                      <dependency>
                                                <groupId>pl.com.it-crowd.mock-contexts-extension</groupId>
                                                <artifactId>mock-contexts-extension-impl</artifactId>
                                                <version>0.1-SNAPSHOT</version>
                                                <scope>runtime</scope>
                                      </dependency>
                                      <dependency>
                                                <groupId>org.jboss.shrinkwrap.resolver</groupId>
                                                <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
                                                <version>2.0.0-alpha-1</version>
                                                <scope>test</scope>
                                      </dependency>
                                      <dependency>
                                                <groupId>org.mockito</groupId>
                                                <artifactId>mockito-all</artifactId>
                                                <version>1.9.0</version>
                                                <scope>test</scope>
                                      </dependency>
                  
                  
                            </dependencies>
                            <repositories>
                                      <repository>
                                                <id>JBOSS_NEXUS</id>
                                                <url>http://repository.jboss.org/nexus/content/groups/public</url>
                                      </repository>
                                      <repository>
                                                <id>it-crowd.com.pl</id>
                                                <url>http://artifactory.it-crowd.com.pl/repo</url>
                                                <snapshots>
                                                          <enabled>true</enabled>
                                                </snapshots>
                                      </repository>
                            </repositories>
                            <build>
                                      <finalName>xxx</finalName>
                                      <plugins>
                                                <plugin>
                                                          <artifactId>maven-compiler-plugin</artifactId>
                                                          <version>2.3.2</version>
                                                          <configuration>
                                                                    <source>1.6</source>
                                                                    <target>1.6</target>
                                                                    <encoding>UTF-8</encoding>
                                                          </configuration>
                                                </plugin>
                                                <plugin>
                                                          <artifactId>maven-war-plugin</artifactId>
                                                          <version>2.1.1</version>
                                                          <extensions>false</extensions>
                                                          <configuration>
                                                                    <failOnMissingWebXml>false</failOnMissingWebXml>
                                                          </configuration>
                                                </plugin>
                                      </plugins>
                            </build>
                            <profiles>
                                      <profile>
                                                <id>JBOSS_AS_REMOTE_7.X</id>
                                                <activation>
                                                          <activeByDefault>true</activeByDefault>
                                                </activation>
                                                <dependencies>
                                                          <dependency>
                                                                    <groupId>org.jboss.arquillian.protocol</groupId>
                                                                    <artifactId>arquillian-protocol-servlet</artifactId>
                                                                    <scope>test</scope>
                                                          </dependency>
                                                          <dependency>
                                                                    <groupId>org.jboss.as</groupId>
                                                                    <artifactId>jboss-as-arquillian-container-remote</artifactId>
                                                                    <version>7.1.1.Final</version>
                                                                    <exclusions>
                                                                              <exclusion>
                                                                                        <groupId>org.jboss.shrinkwrap.resolver</groupId>
                                                                                        <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
                                                                              </exclusion>
                                                                    </exclusions>
                                                          </dependency>
                                                </dependencies>
                                      </profile>
                  
                  
                  
                  
                  
                  
                                      <profile>
                                                <id>weld-ee-embedded-1.1</id>
                                                <dependencies>
                                                          <dependency>
                                                                    <groupId>org.jboss.arquillian.protocol</groupId>
                                                                    <artifactId>arquillian-protocol-servlet</artifactId>
                                                                    <scope>test</scope>
                                                          </dependency>
                                                          <dependency>
                                                                    <groupId>org.jboss.spec</groupId>
                                                                    <artifactId>jboss-javaee-6.0</artifactId>
                                                                    <version>1.0.0.Final</version>
                                                                    <type>pom</type>
                                                                    <scope>provided</scope>
                                                          </dependency>
                                                          <dependency>
                                                                    <groupId>org.jboss.arquillian.container</groupId>
                                                                    <artifactId>arquillian-weld-ee-embedded-1.1</artifactId>
                                                                    <scope>test</scope>
                                                          </dependency>
                                                          <dependency>
                                                                    <groupId>org.jboss.weld</groupId>
                                                                    <artifactId>weld-core</artifactId>
                                                          </dependency>
                                                          <dependency>
                                                                    <groupId>org.slf4j</groupId>
                                                                    <artifactId>slf4j-simple</artifactId>
                                                          </dependency>
                                                </dependencies>
                                                <dependencyManagement>
                                                          <dependencies>
                                                                    <dependency>
                                                                              <groupId>org.jboss.weld</groupId>
                                                                              <artifactId>weld-core-bom</artifactId>
                                                                              <version>1.1.5.Final</version>
                                                                              <type>pom</type>
                                                                              <scope>import</scope>
                                                                    </dependency>
                                                          </dependencies>
                                                </dependencyManagement>
                                      </profile>
                  
                  
                                      <profile>
                                                <id>weld-se-embedded-11</id>
                  
                  
                                                <dependencies>
                                                          <dependency>
                                                                    <groupId>org.jboss.arquillian.container</groupId>
                                                                    <artifactId>arquillian-weld-se-embedded-1.1</artifactId>
                                                                    <version>1.0.0.CR3</version>
                                                          </dependency>
                                                          <dependency>
                                                                    <groupId>org.jboss.arquillian.protocol</groupId>
                                                                    <artifactId>arquillian-protocol-servlet</artifactId>
                                                                    <scope>test</scope>
                                                          </dependency>
                                                          <dependency>
                                                                    <groupId>org.jboss.spec</groupId>
                                                                    <artifactId>jboss-javaee-6.0</artifactId>
                                                                    <version>1.0.0.Final</version>
                                                                    <type>pom</type>
                                                                    <scope>provided</scope>
                                                          </dependency>
                                                          <dependency>
                                                                    <groupId>org.jboss.weld</groupId>
                                                                    <artifactId>weld-core</artifactId>
                                                          </dependency>
                                                          <dependency>
                                                                    <groupId>org.jboss.weld</groupId>
                                                                    <artifactId>weld-api</artifactId>
                                                          </dependency>
                                                          <dependency>
                                                                    <groupId>org.glassfish.web</groupId>
                                                                    <artifactId>el-impl</artifactId>
                                                                    <version>2.2</version>
                                                                    <scope>runtime</scope>
                                                          </dependency>
                                                          <dependency>
                                                                    <groupId>org.slf4j</groupId>
                                                                    <artifactId>slf4j-simple</artifactId>
                                                          </dependency>
                                                </dependencies>
                                                <dependencyManagement>
                                                          <dependencies>
                                                                    <dependency>
                                                                              <groupId>org.jboss.weld</groupId>
                                                                              <artifactId>weld-core-bom</artifactId>
                                                                              <version>1.1.5.Final</version>
                                                                              <type>pom</type>
                                                                              <scope>import</scope>
                                                                    </dependency>
                                                          </dependencies>
                                                </dependencyManagement>
                                      </profile>
                                      <profile>
                                                <id>jbossas-managed</id>
                  
                  
                                                <dependencies>
                                                          <dependency>
                                                                    <groupId>org.jboss.spec</groupId>
                                                                    <artifactId>jboss-javaee-6.0</artifactId>
                                                                    <version>1.0.0.Final</version>
                                                                    <type>pom</type>
                                                                    <scope>provided</scope>
                                                          </dependency>
                                                          <dependency>
                                                                    <groupId>org.jboss.as</groupId>
                                                                    <artifactId>jboss-as-arquillian-container-managed</artifactId>
                                                                    <version>7.1.1.Final</version>
                                                                    <scope>test</scope>
                                                          </dependency>
                                                          <dependency>
                                                                    <groupId>org.jboss.arquillian.protocol</groupId>
                                                                    <artifactId>arquillian-protocol-servlet</artifactId>
                                                                    <scope>test</scope>
                                                          </dependency>
                                                </dependencies>
                                      </profile>
                            </profiles>
                  </project>
                  
                  
                  • 6. Re: What is the suggested way to test conversation scoped components?
                    Anthony Patricio Master

                    Btw, FYI

                    https://community.jboss.org/message/757321#757321

                     

                    I'm going to restart from scratch and see what happens.

                    This must be a maven local issue.

                    • 7. Re: What is the suggested way to test conversation scoped components?
                      Anthony Patricio Master

                      was a maven issue,

                      switched to


                      <dependency>



                      <groupId>org.jboss.shrinkwrap.descriptors</groupId>



                      <artifactId>shrinkwrap-descriptors-api-javaee</artifactId>



                      <version>2.0.0-alpha-4</version>



                      <scope>test</scope>


                      </dependency>

                      and replaced



                      final String beansDescriptor = Descriptors.create(BeansDescriptor.class)

                                  .createAlternatives()

                                  .clazz(MockConversation.class.getCanonicalName())

                                  .up()

                                  .exportAsString();

                      with



                      final String beansDescriptor = Descriptors.create(BeansDescriptor.class)

                                  .getOrCreateAlternatives()

                                  .clazz(MockConversation.class.getCanonicalName())

                                  .up()

                                  .exportAsString();