[weld-dev] WELD-273 Add GlassFish targets to example POMs

Marcin Mieszek marcin.mieszek at gmail.com
Mon Oct 25 20:19:37 EDT 2010


Hi,

I have made some progress with issue WELD-273. Please find diff file
attached for the first example (weld-jsf-login) and let me know if the
apporach is correct.

Originally I planned to use glassfish-embedded server, but maven
plugin does not have the option to run the server in another process
so that integration tests are not blocked by the server processing its
requests (similar thing is done with jetty and daemon parameter). I
also did not have success with cargo plugin so I switched to
glassfish-maven-plugin.

Changes description:

Defining ftest-glassfish profile:
#       modified:   examples/jsf/login/pom.xml
#       modified:   examples/pom.xml

Copy of test suite definition from jboss6x.xml. Do we really need
seperate one for each appserver?
#       new file:   examples/jsf/login/src/ftest/resources/glassfish3x.xml

Making the class implement Serializable interface to avoid Glassfish
deployments errors:
#       modified:
examples/jsf/login/src/main/java/org/jboss/weld/examples/login/Credentials.java

Setting table name to USER_TABLE as USER is reserved word:
#       modified:
examples/jsf/login/src/main/java/org/jboss/weld/examples/login/User.java
#       modified:   examples/jsf/login/src/main/resources/import.sql

Setting to <jta-data-source>jdbc/LoginDS</jta-data-source> so that
this is accepted by Glassfish:
#       modified:
examples/jsf/login/src/main/resources/META-INF/persistence.xml


One final question:

Currently there are several apporaches toward ftest. Tomcat and JBoss
use cargo plugin while Jetty uses maven-jetty-plugin. Moreover each
profile contains the same copy of failsafe plugin configuration. Can I
simplify it somehow? How about using unified apporach to deployments?

Looking forward to feedback from you,

Marcin
-------------- next part --------------
diff --git a/examples/jsf/login/pom.xml b/examples/jsf/login/pom.xml
index 602486b..42f73fa 100644
--- a/examples/jsf/login/pom.xml
+++ b/examples/jsf/login/pom.xml
@@ -90,6 +90,30 @@
             </plugins>
          </build>
       </profile>
+
+      <profile>
+         <id>ftest-glassfish</id>
+         <build>
+            <plugins>
+               <plugin>
+                  <groupId>org.glassfish.maven.plugin</groupId>
+                  <artifactId>maven-glassfish-plugin</artifactId>
+               </plugin>
+               <plugin>
+                  <groupId>org.codehaus.mojo</groupId>
+                  <artifactId>selenium-maven-plugin</artifactId>
+               </plugin>
+               <plugin>
+                  <groupId>org.codehaus.mojo</groupId>
+                  <artifactId>failsafe-maven-plugin</artifactId>
+               </plugin>
+               <plugin>
+                  <groupId>org.apache.maven.plugins</groupId>
+                  <artifactId>maven-antrun-plugin</artifactId>
+               </plugin>
+            </plugins>
+         </build>
+      </profile>       
    </profiles>
 
 
diff --git a/examples/jsf/login/src/ftest/resources/glassfish3x.xml b/examples/jsf/login/src/ftest/resources/glassfish3x.xml
new file mode 100644
index 0000000..9e1bef8
--- /dev/null
+++ b/examples/jsf/login/src/ftest/resources/glassfish3x.xml
@@ -0,0 +1,26 @@
+
+	<!--
+		JBoss, Home of Professional Open Source Copyright 2008, Red Hat
+		Middleware LLC, and individual contributors by the @authors tag. See
+		the copyright.txt in the distribution for a full listing of individual
+		contributors. This is free software; you can redistribute it and/or
+		modify it under the terms of the GNU Lesser General Public License as
+		published by the Free Software Foundation; either version 2.1 of the
+		License, or (at your option) any later version. This software is
+		distributed in the hope that it will be useful, but WITHOUT ANY
+		WARRANTY; without even the implied warranty of MERCHANTABILITY or
+		FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+		License for more details. You should have received a copy of the GNU
+		Lesser General Public License along with this software; if not, write
+		to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+		Boston, MA 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+	--> 
+<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
+<suite name="Weld JSF Login example" verbose="2" parallel="false">
+	<test name="login_glassfish3x">
+		<parameter name="example.context.path" value="/weld-login" />
+		<packages>
+			<package name="org.jboss.weld.examples.login.test.selenium" />
+		</packages>
+	</test>
+</suite>
diff --git a/examples/jsf/login/src/main/java/org/jboss/weld/examples/login/Credentials.java b/examples/jsf/login/src/main/java/org/jboss/weld/examples/login/Credentials.java
index 4804260..00ced35 100644
--- a/examples/jsf/login/src/main/java/org/jboss/weld/examples/login/Credentials.java
+++ b/examples/jsf/login/src/main/java/org/jboss/weld/examples/login/Credentials.java
@@ -3,11 +3,12 @@ package org.jboss.weld.examples.login;
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.inject.Default;
 import javax.inject.Named;
+import java.io.Serializable;
 
 @RequestScoped
 @Named
 @Default
-public class Credentials
+public class Credentials implements Serializable
 {
 
    private String username;
diff --git a/examples/jsf/login/src/main/java/org/jboss/weld/examples/login/User.java b/examples/jsf/login/src/main/java/org/jboss/weld/examples/login/User.java
index e4b6a03..cadec3c 100644
--- a/examples/jsf/login/src/main/java/org/jboss/weld/examples/login/User.java
+++ b/examples/jsf/login/src/main/java/org/jboss/weld/examples/login/User.java
@@ -2,8 +2,10 @@ package org.jboss.weld.examples.login;
 
 import javax.persistence.Entity;
 import javax.persistence.Id;
+import javax.persistence.Table;
 
 @Entity
+ at Table(name = "USER_TABLE")
 public class User
 {
    @Id
diff --git a/examples/jsf/login/src/main/resources/META-INF/persistence.xml b/examples/jsf/login/src/main/resources/META-INF/persistence.xml
index 73db8fd..e381321 100644
--- a/examples/jsf/login/src/main/resources/META-INF/persistence.xml
+++ b/examples/jsf/login/src/main/resources/META-INF/persistence.xml
@@ -5,10 +5,12 @@
              version="1.0">
    <persistence-unit name="loginDatabase">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
-      <jta-data-source>java:/DefaultDS</jta-data-source>
+      <jta-data-source>jdbc/LoginDS</jta-data-source>
       <properties>
          <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
          <property name="hibernate.show_sql" value="true"/>
+         <property name="hibernate.bytecode.provider" value="javassist"/>
+         <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect"/>         
       </properties>
    </persistence-unit>
 </persistence>
diff --git a/examples/jsf/login/src/main/resources/import.sql b/examples/jsf/login/src/main/resources/import.sql
index 2d10622..8ad7d39 100644
--- a/examples/jsf/login/src/main/resources/import.sql
+++ b/examples/jsf/login/src/main/resources/import.sql
@@ -1 +1 @@
-insert into User (username, name, password) values ('demo', 'Demo User', 'demo') 
\ No newline at end of file
+insert into USER_TABLE (username, name, password) values ('demo', 'Demo User', 'demo') 
\ No newline at end of file
diff --git a/examples/pom.xml b/examples/pom.xml
index c07770d..a5a902b 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -1202,5 +1202,256 @@
             </pluginRepository>
          </pluginRepositories>
       </profile>
+
+
+       <profile>
+           <id>ftest-glassfish</id>
+           <properties>
+              <ftest.suite.xml>glassfish3x.xml</ftest.suite.xml>
+           </properties>
+           
+           <activation>
+               <activeByDefault>false</activeByDefault>
+               <property>
+                   <name>profile</name>
+                   <value>glassfish</value>
+               </property>
+           </activation>
+
+
+         <dependencies>
+            <dependency>
+               <groupId>org.seleniumhq.selenium.client-drivers</groupId>
+               <artifactId>selenium-java-client-driver</artifactId>
+               <scope>test</scope>
+            </dependency>
+            <dependency>
+               <groupId>org.jboss.test</groupId>
+               <artifactId>richfaces-selenium</artifactId>
+               <version>${richfaces.selenium.version}</version>
+               <scope>test</scope>
+            </dependency>
+         </dependencies>
+           
+           <build>
+               <pluginManagement>
+                   <plugins>
+
+
+                  <!-- skip unit tests when running functional tests -->
+                  <plugin>
+                     <groupId>org.apache.maven.plugins</groupId>
+                     <artifactId>maven-surefire-plugin</artifactId>
+                     <configuration>
+                        <skip>true</skip>
+                     </configuration>
+                  </plugin>
+
+                  <plugin>
+                     <groupId>org.codehaus.mojo</groupId>
+                     <artifactId>build-helper-maven-plugin</artifactId>
+                     <executions>
+                        <execution>
+                           <id>add-ftest-source</id>
+                           <goals>
+                              <goal>add-test-source</goal>
+                           </goals>
+                           <configuration>
+                              <sources>
+                                 <source>${ftest.sources.directory}</source>
+                              </sources>
+                           </configuration>
+                        </execution>
+                     </executions>
+                  </plugin>                       
+
+                       <plugin>
+                           <groupId>org.glassfish.maven.plugin</groupId>
+                           <artifactId>maven-glassfish-plugin</artifactId>
+                           <version>2.1</version>
+                           <configuration>
+                               <passwordFile>O:/glassfishv3/pass.txt</passwordFile>
+                               <domain>
+                                   <name>domain1</name>
+                                   <adminPort>4848</adminPort>
+                                   <httpPort>8080</httpPort>
+                                   <httpsPort>8443</httpsPort>
+                                   <iiopPort>3700</iiopPort>
+                                   <jmsPort>7676</jmsPort>
+                               </domain>
+                               <glassfishDirectory>O:\glassfishv3</glassfishDirectory>
+                               <user>admin</user>
+                               <components>
+                                   <component>
+                                       <name>${project.build.finalName}</name>
+                                       <artifact>${project.build.directory}/${project.build.finalName}.${project.packaging}</artifact>
+                                   </component>
+                               </components>
+                               
+                            </configuration>                           
+                           <executions>
+                               <execution>
+                                   <phase>pre-integration-test</phase>
+                                   <goals>
+                                       <goal>redeploy</goal>
+                                   </goals>
+                               </execution>
+                           </executions>
+                       </plugin>
+
+
+                  <!--  start Selenium server -->
+                  <plugin>
+                     <groupId>org.codehaus.mojo</groupId>
+                     <artifactId>selenium-maven-plugin</artifactId>
+                     <version>${selenium.maven.plugin.version}</version>
+                     <executions>
+                        <execution>
+                           <id>start-selenium</id>
+                           <phase>pre-integration-test</phase>
+                           <goals>
+                              <goal>start-server</goal>
+                           </goals>
+                           <configuration>
+                              <background>true</background>
+                              <port>${selenium.server.port}</port>
+                              <logOutput>true</logOutput>
+                              <logFile>${selenium.log.dir}/selenium-server.log</logFile>
+                              <browserSideLog>${selenium.debug}</browserSideLog>
+                              <debug>${selenium.debug}</debug>
+                           </configuration>
+                        </execution>
+                     </executions>
+                  </plugin>
+
+                  <!-- run functional tests -->
+                  <plugin>
+                     <groupId>org.codehaus.mojo</groupId>
+                     <artifactId>failsafe-maven-plugin</artifactId>
+                     <configuration>
+                        <suiteXmlFiles>
+                           <suiteXmlFile>${ftest.resources.directory}/${ftest.suite.xml}</suiteXmlFile>
+                        </suiteXmlFiles>
+                        <argLine>-Xmx748m</argLine>
+                        <forkMode>once</forkMode>
+                        <systemProperties>
+                           <property>
+                              <name>method</name>
+                              <value>${method}</value>
+                           </property>
+                           <property>
+                              <name>browser</name>
+                              <value>${selenium.browser}</value>
+                           </property>
+                           <property>
+                              <name>context.root</name>
+                              <value>${context.root}</value>
+                           </property>
+                           <property>
+                              <name>context.path</name>
+                              <value>${context.path}</value>
+                           </property>
+                           <property>
+                              <name>selenium.host</name>
+                              <value>${selenium.server.host}</value>
+                           </property>
+                           <property>
+                              <name>selenium.port</name>
+                              <value>${selenium.server.port}</value>
+                           </property>
+                           <property>
+                              <name>selenium.debug</name>
+                              <value>${selenium.debug}</value>
+                           </property>
+                           <property>
+                              <name>selenium.maximize</name>
+                              <value>${selenium.maximize}</value>
+                           </property>
+                           <property>
+                              <name>maven.resources.dir</name>
+                              <value>${resources.dir}</value>
+                           </property>
+                           <property>
+                              <name>maven.project.build.directory</name>
+                              <value>${project.build.directory}</value>
+                           </property>
+                           <property>
+                              <name>selenium.timeout.default</name>
+                              <value>${selenium.timeout.default}</value>
+                           </property>
+                           <property>
+                              <name>selenium.timeout.gui</name>
+                              <value>${selenium.timeout.gui}</value>
+                           </property>
+                           <property>
+                              <name>selenium.timeout.ajax</name>
+                              <value>${selenium.timeout.ajax}</value>
+                           </property>
+                           <property>
+                              <name>selenium.timeout.model</name>
+                              <value>${selenium.timeout.model}</value>
+                           </property>
+                           <property>
+                              <name>selenium.maximize</name>
+                              <value>${selenium.maximize}</value>
+                           </property>
+                           <property>
+                              <name>maven.resources.dir</name>
+                              <value>${resources.dir}</value>
+                           </property>
+                           <property>
+                              <name>maven.project.build.directory</name>
+                              <value>${project.build.directory}</value>
+                           </property>
+                        </systemProperties>
+                     </configuration>
+                     <executions>
+                        <execution>
+                           <id>verify</id>
+                           <phase>verify</phase>
+                           <goals>
+                              <goal>verify</goal>
+                           </goals>
+                        </execution>
+                        <execution>
+                           <id>integration-test</id>
+                           <phase>integration-test</phase>
+                           <goals>
+                              <goal>integration-test</goal>
+                           </goals>
+                        </execution>
+                     </executions>
+                  </plugin>
+
+                  <!-- stop Selenium -->
+                  <plugin>
+                     <groupId>org.apache.maven.plugins</groupId>
+                     <artifactId>maven-antrun-plugin</artifactId>
+                     <executions>
+                        <execution>
+                           <!-- this ant script runs testng natively -->
+                           <id>stop-selenium</id>
+                           <phase>post-integration-test</phase>
+                           <configuration>
+                              <tasks>
+                                 <echo taskname="selenium-shutdown" message="DGF Errors during shutdown are expected" />
+                                 <get taskname="selenium-shutdown" src="http://${selenium.server.host}:${selenium.server.port}/selenium-server/driver/?cmd=shutDownSeleniumServer" ignoreerrors="true" dest="${selenium.log.dir}/selenium.stop.msg" />
+                              </tasks>
+                           </configuration>
+                           <goals>
+                              <goal>run</goal>
+                           </goals>
+                        </execution>
+                     </executions>
+                  </plugin>                       
+
+
+                   </plugins>
+               </pluginManagement>
+           </build>
+       </profile>
+
+       
+
    </profiles>
 </project>


More information about the weld-dev mailing list