You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gp...@apache.org on 2011/02/26 03:58:01 UTC

svn commit: r1074783 - in /myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20: ./ src/main/webapp/pages/simple/ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/myfaces/ src/test/ja...

Author: gpetracek
Date: Sat Feb 26 02:58:00 2011
New Revision: 1074783

URL: http://svn.apache.org/viewvc?rev=1074783&view=rev
Log:
simple integration test

Added:
    myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/test/
    myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/test/java/
    myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/test/java/org/
    myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/test/java/org/apache/
    myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/test/java/org/apache/myfaces/
    myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/test/java/org/apache/myfaces/extensions/
    myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/test/java/org/apache/myfaces/extensions/cdi/
    myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/test/java/org/apache/myfaces/extensions/cdi/example/
    myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/test/java/org/apache/myfaces/extensions/cdi/example/test/
    myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/test/java/org/apache/myfaces/extensions/cdi/example/test/BaseCargoTest.java
    myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/test/java/org/apache/myfaces/extensions/cdi/example/test/SimpleTestCase.java
Modified:
    myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/pom.xml
    myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/main/webapp/pages/simple/summary.xhtml

Modified: myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/pom.xml?rev=1074783&r1=1074782&r2=1074783&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/pom.xml (original)
+++ myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/pom.xml Sat Feb 26 02:58:00 2011
@@ -35,6 +35,11 @@
         <version>0.9.3-SNAPSHOT</version>
     </parent>
 
+    <properties>
+        <cargo.context>cargo-test</cargo.context>
+        <cargo.port>8787</cargo.port> <!-- use port 8787 in order to prevent port-already-in-use on hudson -->
+    </properties>
+
     <dependencies>
         <dependency>
             <groupId>org.apache.myfaces.extensions.cdi.core</groupId>
@@ -152,6 +157,27 @@
             <artifactId>dom4j</artifactId>
             <version>1.6.1</version>
         </dependency>
+
+        <!-- test dependencies -->
+        <dependency>
+            <groupId>org.apache.myfaces.extensions.cdi.test</groupId>
+            <artifactId>myfaces-extcdi-base-test-infrastructure</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <version>2.5</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.el</groupId>
+            <artifactId>el-api</artifactId>
+            <version>1.0</version>
+            <scope>provided</scope>
+        </dependency>
     </dependencies>
     
     <build>
@@ -170,6 +196,37 @@
                     </execution>
                 </executions>
             </plugin>
+
+            <!-- override settings -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.7.1</version>
+                <configuration>
+                    <parallel>methods</parallel>
+                    <threadCount>10</threadCount>
+                    <properties>
+                        <property>
+                            <name>junit</name>
+                            <value>true</value>
+                        </property>
+                    </properties>
+                    <excludes>
+                        <!-- we only have cargo test cases -->
+                        <exclude>**/*Test*.java</exclude>
+                        <exclude>**/Abstract*.java</exclude>
+                        <exclude>**/*$*.java</exclude>
+                    </excludes>
+                </configuration>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.apache.maven.surefire</groupId>
+                        <artifactId>surefire-junit47</artifactId>
+                        <version>2.7.1</version>
+                    </dependency>
+                </dependencies>
+            </plugin>
+
         </plugins>
     </build>
     
@@ -244,6 +301,185 @@
                 </plugins>
             </build>
         </profile>
+        <profile>
+            <id>cargo-examples</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <!--This plugin allows to run the example using mvn jetty:run -->
+                        <groupId>org.mortbay.jetty</groupId>
+                        <artifactId>jetty-maven-plugin</artifactId>
+                        <version>${maven.jetty.plugin.version}</version>
+                        <configuration>
+                            <scanIntervalSeconds>10</scanIntervalSeconds>
+                            <webAppConfig>
+                                <contextPath>/${cargo.context}</contextPath>
+                            </webAppConfig>
+                            <connectors>
+                                <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
+                                    <port>${cargo.port}</port>
+                                    <maxIdleTime>60000</maxIdleTime>
+                                </connector>
+                            </connectors>
+                        </configuration>
+                    </plugin>
+
+                    <!-- cargo test -->
+                    <plugin>
+                        <groupId>org.codehaus.cargo</groupId>
+                        <artifactId>cargo-maven2-plugin</artifactId>
+                        <version>1.0.4</version>
+                        <configuration>
+                            <container>
+                                <containerId>jetty7x</containerId>
+                                <type>embedded</type>
+                            </container>
+
+                            <!-- do NOT wait for Ctrl + C to stop -->
+                            <!-- NOTE: set this to true to enable manual testing -->
+                            <wait>false</wait>
+
+                            <configuration>
+                                <properties>
+                                    <cargo.servlet.port>${cargo.port}</cargo.servlet.port>
+                                </properties>
+
+                                <deployables>
+                                    <deployable>
+                                        <groupId>org.apache.myfaces.extensions.cdi.examples</groupId>
+                                        <artifactId>hello-myfaces-codi-jsf20-example</artifactId>
+                                        <type>war</type>
+                                        <properties>
+                                            <context>${cargo.context}</context>
+                                        </properties>
+                                    </deployable>
+                                </deployables>
+                            </configuration>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <id>start-container</id>
+                                <phase>pre-integration-test</phase>
+                                <goals>
+                                    <goal>start</goal>
+                                </goals>
+                            </execution>
+                            <execution>
+                                <id>stop-container</id>
+                                <phase>post-integration-test</phase>
+                                <goals>
+                                    <goal>stop</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+
+                    <plugin>
+                       <groupId>org.apache.maven.plugins</groupId>
+                       <artifactId>maven-failsafe-plugin</artifactId>
+                       <version>2.7.2</version>
+                       <executions>
+                           <execution>
+                               <id>htmlunit-integration-tests</id>
+                               <phase>integration-test</phase>
+                               <goals>
+                                   <goal>integration-test</goal>
+                               </goals>
+                               <configuration>
+                                   <includes>
+                                       <include>
+                                           **/*TestCase.java
+                                       </include>
+                                   </includes>
+                                   <skip>false</skip>
+                                   <testNGArtifactName>none:none</testNGArtifactName>
+                                   <systemPropertyVariables>
+                                       <!-- pass properties to JUnit -->
+                                       <cargo.context>${cargo.context}</cargo.context>
+                                       <cargo.port>${cargo.port}</cargo.port>
+                                   </systemPropertyVariables>
+                               </configuration>
+                           </execution>
+                           <execution>
+                               <id>verify</id>
+                               <goals>
+                                   <goal>verify</goal>
+                               </goals>
+                           </execution>
+                       </executions>
+                    </plugin>
+                </plugins>
+            </build>
+
+            <dependencies>
+                <!-- test dependencies -->
+                <dependency>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                    <scope>test</scope>
+                </dependency>
+
+                <dependency>
+                    <groupId>net.sourceforge.htmlunit</groupId>
+                    <artifactId>htmlunit</artifactId>
+                    <scope>test</scope>
+                </dependency>
+
+                <dependency>
+                    <groupId>org.apache.myfaces.extensions.cdi.test</groupId>
+                    <artifactId>myfaces-extcdi-base-test-infrastructure</artifactId>
+                    <scope>test</scope>
+                </dependency>
+
+                <dependency>
+                    <groupId>org.apache.openwebbeans.test</groupId>
+                    <artifactId>cditest</artifactId>
+                    <scope>test</scope>
+                </dependency>
+
+                <dependency>
+                    <groupId>org.apache.openwebbeans.test</groupId>
+                    <artifactId>cditest-owb</artifactId>
+                    <scope>test</scope>
+                </dependency>
+
+                <dependency>
+                    <groupId>org.apache.myfaces.test</groupId>
+                    <artifactId>myfaces-test12</artifactId>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+
+        <profile>
+		    <!-- just for starting jetty for debugging the junit tests:
+		    mvn clean jetty:run-exploded -Pdebug-cargo-examples -Dmaven.test.skip=true
+		    in the ide enable the cargo-examples and test-infrastructure maven-profile -> start jetty -> run test-case
+		    (tested with intellij 9)
+		    -->
+            <id>debug-cargo-examples</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.mortbay.jetty</groupId>
+                        <artifactId>jetty-maven-plugin</artifactId>
+                        <version>${maven.jetty.plugin.version}</version>
+                        <configuration>
+                            <scanIntervalSeconds>10</scanIntervalSeconds>
+                            <webAppConfig>
+                                <contextPath>/${cargo.context}</contextPath>
+                            </webAppConfig>
+                            <connectors>
+                                <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
+                                    <port>${cargo.port}</port>
+                                    <maxIdleTime>60000</maxIdleTime>
+                                </connector>
+                            </connectors>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
     </profiles>
     
 </project>

Modified: myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/main/webapp/pages/simple/summary.xhtml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/main/webapp/pages/simple/summary.xhtml?rev=1074783&r1=1074782&r2=1074783&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/main/webapp/pages/simple/summary.xhtml (original)
+++ myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/main/webapp/pages/simple/summary.xhtml Sat Feb 26 02:58:00 2011
@@ -30,7 +30,8 @@
 
     <ui:define name="content">
         #{i18n.welcome}<p>
-        #{simpleRegistrationPage.user.loginName}<br/>
+        <ui:remove>the span is just useful for the cargo test</ui:remove>
+        <span id="loginName">#{simpleRegistrationPage.user.loginName}</span><br/>
         #{simpleRegistrationPage.user.firstName}<br/>
         #{simpleRegistrationPage.user.lastName}
         </p>

Added: myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/test/java/org/apache/myfaces/extensions/cdi/example/test/BaseCargoTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/test/java/org/apache/myfaces/extensions/cdi/example/test/BaseCargoTest.java?rev=1074783&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/test/java/org/apache/myfaces/extensions/cdi/example/test/BaseCargoTest.java (added)
+++ myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/test/java/org/apache/myfaces/extensions/cdi/example/test/BaseCargoTest.java Sat Feb 26 02:58:00 2011
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.cdi.example.test;
+
+import org.apache.myfaces.extensions.cdi.test.cargo.AbstractSimpleCargoTest;
+
+abstract class BaseCargoTest extends AbstractSimpleCargoTest
+{
+    @Override
+    protected String getCustomBaseURL()
+    {
+        return "http://localhost:8787/cargo-test/";
+    }
+}
\ No newline at end of file

Added: myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/test/java/org/apache/myfaces/extensions/cdi/example/test/SimpleTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/test/java/org/apache/myfaces/extensions/cdi/example/test/SimpleTestCase.java?rev=1074783&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/test/java/org/apache/myfaces/extensions/cdi/example/test/SimpleTestCase.java (added)
+++ myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf20/src/test/java/org/apache/myfaces/extensions/cdi/example/test/SimpleTestCase.java Sat Feb 26 02:58:00 2011
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.cdi.example.test;
+
+import org.apache.myfaces.extensions.cdi.test.cargo.SimplePageInteraction;
+import org.apache.myfaces.extensions.cdi.test.cargo.runner.JUnit4WithCargo;
+import org.apache.myfaces.extensions.cdi.example.jsf20.view.config.Pages;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(JUnit4WithCargo.class)
+public class SimpleTestCase extends BaseCargoTest
+{
+    // NOTE that new @Test means new WebClient means new WindowContext
+
+    @Test
+    public void testSimpleRegistration() throws Exception
+    {
+        SimplePageInteraction pageInteraction = new SimplePageInteraction(getTestConfiguration())
+                .with(Pages.Simple.Form.class)
+                .with(Pages.Simple.Summary.class);
+
+        pageInteraction
+                .start(Pages.Simple.Form.class)
+                .useForm("mainForm");
+
+        //prependId="false"
+        pageInteraction.setValue("loginName", "codi");
+        pageInteraction
+                .click("register")
+                .checkState(Pages.Simple.Summary.class);
+
+        pageInteraction.checkTextValue("loginName", "codi");
+
+        //close conversation
+        pageInteraction
+                .clickOk()
+                .checkState(Pages.Simple.Form.class);
+
+        pageInteraction.checkTextValue("loginName", "");
+    }
+}
\ No newline at end of file