[seam-commits] Seam SVN: r15525 - in branches/enterprise/WFK-2_1: examples/blog and 48 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Mon Jun 3 12:41:12 EDT 2013
Author: rsmeral
Date: 2013-06-03 12:41:11 -0400 (Mon, 03 Jun 2013)
New Revision: 15525
Added:
branches/enterprise/WFK-2_1/build/build.properties
branches/enterprise/WFK-2_1/examples/blog/README.md
branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/
branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/java/
branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/java/org/
branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/java/org/jboss/
branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/java/org/jboss/seam/
branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/java/org/jboss/seam/example/
branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/java/org/jboss/seam/example/blog/
branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/java/org/jboss/seam/example/blog/test/
branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/java/org/jboss/seam/example/blog/test/BlogTest.java
branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/
branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/accessible.properties
branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/arquillian.xml
branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/components.xml
branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/default.properties
branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/infinispan.xml
branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/jboss-deployment-structure.xml
branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/jgroupsConfig.xml
branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/messages.properties
branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/pages.xml
branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/printable.properties
branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/web.xml
branches/enterprise/WFK-2_1/examples/blog/blog-web/src/main/java/
branches/enterprise/WFK-2_1/examples/blog/blog-web/src/test/
branches/enterprise/WFK-2_1/examples/blog/blog-web/src/test/java/
branches/enterprise/WFK-2_1/examples/booking/README.md
branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/
branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/
branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/org/
branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/org/jboss/
branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/org/jboss/seam/
branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/org/jboss/seam/example/
branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/org/jboss/seam/example/booking/
branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/org/jboss/seam/example/booking/test/
branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/org/jboss/seam/example/booking/test/BookingTest.java
branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/org/jboss/seam/example/booking/test/ChangePasswordTest.java
branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/org/jboss/seam/example/booking/test/Deployments.java
branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/org/jboss/seam/example/booking/test/LoginTest.java
branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/resources/
branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/resources/arquillian.xml
branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/resources/components.xml
branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/resources/jboss-deployment-structure.xml
branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/resources/persistence.xml
branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/resources/web.xml
branches/enterprise/WFK-2_1/examples/groovybooking/README.md
branches/enterprise/WFK-2_1/examples/groovybooking/groovybooking-web/src/main/groovy/action/
branches/enterprise/WFK-2_1/examples/hibernate/README.md
branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/
branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/
branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/org/
branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/org/jboss/
branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/org/jboss/seam/
branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/org/jboss/seam/example/
branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/org/jboss/seam/example/hibernate/
branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/org/jboss/seam/example/hibernate/test/
branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/org/jboss/seam/example/hibernate/test/BookingTest.java
branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/org/jboss/seam/example/hibernate/test/ChangePasswordTest.java
branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/org/jboss/seam/example/hibernate/test/Deployments.java
branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/org/jboss/seam/example/hibernate/test/LoginTest.java
branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/resources/
branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/resources/arquillian.xml
branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/resources/web.xml
branches/enterprise/WFK-2_1/examples/jee6/README.md
branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/
branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/
branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/org/
branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/org/jboss/
branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/org/jboss/seam/
branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/org/jboss/seam/example/
branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/org/jboss/seam/example/booking/
branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/org/jboss/seam/example/booking/test/
branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/org/jboss/seam/example/booking/test/BookingTest.java
branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/org/jboss/seam/example/booking/test/ChangePasswordTest.java
branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/org/jboss/seam/example/booking/test/Deployments.java
branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/org/jboss/seam/example/booking/test/LoginTest.java
branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/resources/
branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/resources/arquillian.xml
branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/resources/components.xml
branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/resources/persistence.xml
Log:
blog, booking, groovybooking, hibernate, jee6 converted, more files
Added: branches/enterprise/WFK-2_1/build/build.properties
===================================================================
--- branches/enterprise/WFK-2_1/build/build.properties (rev 0)
+++ branches/enterprise/WFK-2_1/build/build.properties 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,2 @@
+complete.version=2.3.1.Final-redhat-1
+version=2.3
\ No newline at end of file
Added: branches/enterprise/WFK-2_1/examples/blog/README.md
===================================================================
--- branches/enterprise/WFK-2_1/examples/blog/README.md (rev 0)
+++ branches/enterprise/WFK-2_1/examples/blog/README.md 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,60 @@
+Seam Blog Example
+=================
+
+This example demonstrates the use of Seam in a Java EE environment.
+Transaction and persistence context management is handled by the EJB container.
+
+Running the example
+-------------------
+
+To deploy the example to a running JBoss AS instance, follow these steps:
+
+1. In the example root directory run:
+
+ mvn clean install
+
+2. Set JBOSS_HOME environment property.
+
+3. In the blog-ear directory run:
+
+ mvn jboss-as:deploy
+
+4. Open this URL in a web browser: http://localhost:8080/seam-blog
+
+
+Testing the example
+-------------------
+
+This example is covered by integration tests. All tests use the following technologies:
+
+* __Arquillian__ - as the framework for EE testing, for managing of container lifecycle and deployment of test archive,
+* __ShrinkWrap__ - to create the test archive (WAR).
+
+
+### Integration tests
+
+Integration tests cover core application logic and reside in the EJB module. In addition to Arquillian and ShrinkWrap, the integration tests also use:
+
+* __JUnitSeamTest__ - to hook into the JSF lifecycle and assert server-side state,
+* __ShrinkWrap Resolver__ - to resolve dependencies of the project for packaging in the test archive.
+
+The tests are executed in Maven's test phase. By default they are skipped and can be executed on JBoss AS with:
+
+ mvn clean test -Darquillian=jbossas-managed-7
+
+The `JBOSS_HOME` environment variable must be set and point to a JBoss AS instance directory.
+
+To test on a running server, use
+
+ mvn clean test -Darquillian=jbossas-remote-7
+
+
+Testing in JBDS
+---------------
+### Integration tests
+
+1. Open JBDS and start a configured instance of JBoss AS
+2. Import the example project and its submodules
+3. In the _Project Explorer_, select the EJB module project, then
+ 1. Type `Ctrl+Alt+P` (_Select Maven Profiles_) and check `integration-tests` and `arq-jbossas-7-remote`
+ 2. Right-click the module and select _Run As_ - _JUnit Test_
Added: branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/java/org/jboss/seam/example/blog/test/BlogTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/java/org/jboss/seam/example/blog/test/BlogTest.java (rev 0)
+++ branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/java/org/jboss/seam/example/blog/test/BlogTest.java 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,290 @@
+package org.jboss.seam.example.blog.test;
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import javax.faces.model.SelectItem;
+import javax.persistence.EntityManager;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.mock.JUnitSeamTest;
+import org.jboss.seam.security.Identity;
+import org.jboss.seam.theme.Theme;
+import org.jboss.seam.theme.ThemeSelector;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import actions.BlogService;
+import actions.SearchService;
+import domain.Blog;
+import domain.BlogEntry;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.shrinkwrap.resolver.api.maven.Maven;
+
+ at RunWith(Arquillian.class)
+public class BlogTest extends JUnitSeamTest {
+
+ @Deployment(name = "BestSellersTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment() {
+
+ File[] libs = Maven.resolver().loadPomFromFile("pom.xml")
+ .importCompileAndRuntimeDependencies()
+ // force resolve jboss-seam, because it is provided-scoped in the pom, but we need it bundled in the WAR
+ .resolve("org.jboss.seam:jboss-seam")
+ .withTransitivity().asFile();
+
+ WebArchive war = ShrinkWrap.create(WebArchive.class, "seam-blog.war")
+ .addPackages(true, "actions", "domain")
+ // already in EJB module
+ .addAsWebInfResource("import.sql", "classes/import.sql")
+ .addAsWebInfResource("seam.properties", "classes/seam.properties")
+ .addAsWebInfResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml")
+
+ // manually copied from Web module
+ .addAsWebInfResource("pages.xml", "pages.xml")
+ .addAsWebInfResource("accessible.properties", "classes/accessible.properties")
+ .addAsWebInfResource("default.properties", "classes/default.properties")
+ .addAsWebInfResource("printable.properties", "classes/printable.properties")
+ .addAsWebInfResource("infinispan.xml", "classes/infinispan.xml")
+ .addAsWebInfResource("jgroupsConfig.xml", "classes/jgroupsConfig.xml")
+
+ // manually copied from Web module, modified
+ .addAsWebInfResource("web.xml", "web.xml") // only contains MockSeamListener definition
+ .addAsWebInfResource("components.xml", "components.xml") // corrected ejb component jndi-name references from java:app/jboss-seam to java:app/seam-blog
+
+ // manually copied from EAR module
+ .addAsWebInfResource("jboss-deployment-structure.xml", "jboss-deployment-structure.xml")
+ .addAsLibraries(libs);
+
+ war.addClasses(BlogTest.class);
+
+ return war;
+ }
+
+ @Test
+ @InSequence(1)
+ public void testPost() throws Exception {
+ new FacesRequest() {
+ @Override
+ protected void updateModelValues() throws Exception {
+ Identity.instance().setPassword("tokyo");
+ }
+
+ @Override
+ protected void invokeApplication() throws Exception {
+ Identity.instance().authenticate();
+ }
+ }.run();
+
+ new FacesRequest("/post.xhtml") {
+ @Override
+ protected void updateModelValues() throws Exception {
+ BlogEntry entry = (BlogEntry) getInstance("blogEntry");
+ entry.setId("testing");
+ entry.setTitle("Integration testing Seam applications is easy!");
+ entry.setBody("This post is about SeamTest...");
+ }
+
+ @Override
+ protected void invokeApplication() throws Exception {
+ // post now returns void
+ // assert invokeMethod("#{postAction.post}").equals("/index.xhtml");
+ invokeMethod("#{postAction.post}");
+ setOutcome("/index.xhtml");
+ }
+
+ @Override
+ protected void afterRequest() {
+ assert isInvokeApplicationComplete();
+ assert !isRenderResponseBegun();
+ }
+ }.run();
+
+ new NonFacesRequest("/index.xhtml") {
+ @Override
+ protected void renderResponse() throws Exception {
+ List<BlogEntry> blogEntries = ((Blog) getInstance(BlogService.class)).getBlogEntries();
+ assert blogEntries.size() == 4;
+ BlogEntry blogEntry = blogEntries.get(0);
+ assert blogEntry.getId().equals("testing");
+ assert blogEntry.getBody().equals("This post is about SeamTest...");
+ assert blogEntry.getTitle().equals("Integration testing Seam applications is easy!");
+ }
+ }.run();
+
+ new FacesRequest() {
+ @Override
+ protected void invokeApplication() throws Exception {
+ ((EntityManager) getInstance("entityManager")).createQuery("delete from BlogEntry where id='testing'").executeUpdate();
+ }
+ }.run();
+
+ }
+
+ @Test
+ @InSequence(2)
+ public void testLatest() throws Exception {
+ new NonFacesRequest("/index.xhtml") {
+ @Override
+ protected void renderResponse() throws Exception {
+ assert ((Blog) getInstance(BlogService.class)).getBlogEntries().size() == 3;
+ }
+ }.run();
+ }
+
+ @Test
+ @InSequence(3)
+ public void testEntry() throws Exception {
+ new NonFacesRequest("/entry.xhtml") {
+ @Override
+ protected void beforeRequest() {
+ setParameter("blogEntryId", "seamtext");
+ }
+
+ @Override
+ protected void renderResponse() throws Exception {
+ BlogEntry blogEntry = (BlogEntry) Contexts.getEventContext().get("blogEntry");
+ assert blogEntry != null;
+ assert blogEntry.getId().equals("seamtext");
+
+ // make sure the entry is really there
+ assert blogEntry.getBody().length() > 0;
+ assert blogEntry.getTitle().equals("Introducing Seam Text");
+ }
+ }.run();
+ }
+
+ @Test
+ @InSequence(4)
+ public void testSearch() throws Exception {
+ // Some time to allow indexing in the background
+ Thread.sleep(1000);
+
+ String id = new FacesRequest() {
+ @Override
+ protected void updateModelValues() throws Exception {
+ ((SearchService) getInstance(SearchService.class)).setSearchPattern("seam");
+ }
+
+ @Override
+ protected String getInvokeApplicationOutcome() {
+ return "/search.xhtml";
+ }
+
+ @Override
+ protected void afterRequest() {
+ assert !isRenderResponseBegun();
+ }
+ }.run();
+
+ new NonFacesRequest("/search.xhtml", id) {
+ @Override
+ protected void beforeRequest() {
+ setParameter("searchPattern", "\"seam text\"");
+ }
+
+ @Override
+ protected void renderResponse() throws Exception {
+ List<BlogEntry> results = (List<BlogEntry>) getInstance("searchResults");
+ // The hibernate search returns non-precise matches since version 4, so we only check that the expected result is first
+ assert !results.isEmpty();
+ assert "seamtext".equals(results.get(0).getId());
+ }
+ }.run();
+ }
+
+ @Test
+ @InSequence(5)
+ public void testSelectTheme() throws Exception {
+ String id = new NonFacesRequest("/index.xhtml") {
+ @Override
+ protected void renderResponse() throws Exception {
+ List<SelectItem> themes = (List<SelectItem>) getValue("#{themeSelector.themes}");
+ assert themes.size() == 3;
+ assert themes.get(0).getLabel().equals("default");
+ assert themes.get(0).getLabel().equals("default");
+ assert "default".equals(getValue("#{themeSelector.theme}"));
+
+ assert "template.xhtml".equals(getValue("#{theme.template}"));
+ // we can't do interpolate the value correctly in these tests
+ // assert "/screen.css".equals(getValue("#{theme.css}"));
+ assert "foo".equals(getValue("#{theme.foo}"));
+ }
+ }.run();
+
+ new FacesRequest("/index.xhtml", id) {
+ @Override
+ protected void updateModelValues() throws Exception {
+ setValue("#{themeSelector.theme}", "accessible");
+ }
+
+ @Override
+ protected void invokeApplication() throws Exception {
+ invokeAction("#{themeSelector.select}");
+ }
+
+ @Override
+ protected void renderResponse() throws Exception {
+ assert "accessible".equals(getValue("#{themeSelector.theme}"));
+ //assert "/accessible.css".equals(getValue("#{theme.css}"));
+ assert "template.xhtml".equals(getValue("#{theme.template}"));
+ }
+ }.run();
+
+ new FacesRequest("/index.xhtml", id) {
+ @Override
+ protected void invokeApplication() throws Exception {
+ invokeAction("#{themeSelector.selectTheme('printable')}");
+ }
+
+ @Override
+ protected void renderResponse() throws Exception {
+ assert "printable".equals(getValue("#{themeSelector.theme}"));
+ //assert "/printable.css".equals(getValue("#{theme.css}"));
+ assert "print.xhtml".equals(getValue("#{theme.template}"));
+ Map<String, String> theme = Theme.instance();
+ assert theme.entrySet().size() == 2;
+ }
+ }.run();
+
+ new FacesRequest("/index.xhtml", id) {
+ @Override
+ protected void updateModelValues() throws Exception {
+ setValue("#{themeSelector.theme}", "foo");
+ }
+
+ @Override
+ protected void invokeApplication() throws Exception {
+ invokeAction("#{themeSelector.select}");
+ }
+
+ @Override
+ protected void renderResponse() throws Exception {
+ assert "foo".equals(getValue("#{themeSelector.theme}"));
+ Map<String, String> theme = Theme.instance();
+ ResourceBundle themeResources = ThemeSelector.instance().getThemeResourceBundle();
+ assert !themeResources.getKeys().hasMoreElements();
+ assert theme.entrySet().size() == 0;
+ boolean exception = false;
+ try {
+ themeResources.getObject("bar");
+ } catch (MissingResourceException e) {
+ exception = true;
+ }
+ assert exception;
+ assert theme.get("bar").equals("bar");
+ }
+ }.run();
+ }
+}
Added: branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/accessible.properties
===================================================================
--- branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/accessible.properties (rev 0)
+++ branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/accessible.properties 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,2 @@
+css #{request.contextPath}/accessible.css
+template template.xhtml
Added: branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/arquillian.xml
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/arquillian.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added: branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/components.xml
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/components.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added: branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/default.properties
===================================================================
--- branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/default.properties (rev 0)
+++ branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/default.properties 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,2 @@
+css #{request.contextPath}/screen.css
+template template.xhtml
Added: branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/infinispan.xml
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/infinispan.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added: branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/jboss-deployment-structure.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/jboss-deployment-structure.xml (rev 0)
+++ branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/jboss-deployment-structure.xml 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,14 @@
+<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
+ <deployment>
+ <dependencies>
+ <module name="org.antlr" export="true"/>
+ <module name="org.apache.log4j" export="true"/>
+ <module name="org.dom4j" export="true"/>
+ <module name="org.apache.commons.logging" export="true"/>
+ <module name="org.apache.commons.collections" export="true"/>
+ <module name="javax.faces.api" export="true"/>
+ <module name="com.sun.jsf-impl" export="true"/>
+ <module name="org.jgroups" export="true"/>
+ </dependencies>
+ </deployment>
+</jboss-deployment-structure>
Added: branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/jgroupsConfig.xml
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/jgroupsConfig.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added: branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/messages.properties
===================================================================
--- branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/messages.properties (rev 0)
+++ branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/messages.properties 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,2 @@
+javax.faces.component.UIInput.REQUIRED=value is required
+org.jboss.seam.loginSuccessful=
Added: branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/pages.xml
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/pages.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added: branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/printable.properties
===================================================================
--- branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/printable.properties (rev 0)
+++ branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/printable.properties 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,2 @@
+css #{request.contextPath}/printable.css
+template print.xhtml
Added: branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/web.xml
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/WFK-2_1/examples/blog/blog-ejb/src/test/resources/web.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added: branches/enterprise/WFK-2_1/examples/booking/README.md
===================================================================
--- branches/enterprise/WFK-2_1/examples/booking/README.md (rev 0)
+++ branches/enterprise/WFK-2_1/examples/booking/README.md 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,74 @@
+Seam Booking Example
+=================
+
+This example demonstrates the use of Seam in a Java EE 6 environment.
+Transaction and persistence context management is handled by the EJB container. This example runs on JBoss AS as an EAR.
+
+Running the example
+-------------------
+
+### Using Maven
+
+To deploy the example to a running JBoss AS instance, follow these steps:
+
+1. In the example root directory run:
+
+ mvn clean install
+
+2. Set JBOSS_HOME environment property.
+
+3. In the booking-ear directory run:
+
+ mvn jboss-as:deploy
+
+4. Open this URL in a web browser: http://localhost:8080/seam-booking
+
+### Using Ant
+
+1. In the example root directory run:
+
+ ant clean package
+
+2. Copy seam-booking.ear from directory booking-ear/target to the deployment directory of JBoss AS ($JBOSS_HOME/standalone/deployments by default)
+
+3. Open this URL in a web browser: http://localhost:8080/seam-booking
+
+
+Testing the example
+-------------------
+
+This example is covered by integration tests. All tests use the following technologies:
+
+* __Arquillian__ - as the framework for EE testing, for managing of container lifecycle and deployment of test archive,
+* __ShrinkWrap__ - to create the test archive (WAR).
+
+
+### Integration tests
+
+Integration tests cover core application logic and reside in the EJB module. In addition to Arquillian and ShrinkWrap, the integration tests also use:
+
+* __JUnitSeamTest__ - to hook into the JSF lifecycle and assert server-side state,
+* __ShrinkWrap Resolver__ - to resolve dependencies of the project for packaging in the test archive.
+
+The tests are executed in Maven's test phase. By default they are skipped and can be executed on JBoss AS with:
+
+ mvn clean test -Darquillian=jbossas-managed-7
+
+The `JBOSS_HOME` environment variable must be set and point to a JBoss AS instance directory.
+
+To test on a running server, use
+
+ mvn clean test -Darquillian=jbossas-remote-7
+
+
+Testing in JBDS
+---------------
+### Integration tests
+
+1. Open JBDS and start a configured instance of JBoss AS
+
+2. Import the example project and its submodules
+
+3. In the _Project Explorer_, select the EJB module project, then
+ 1. Type `Ctrl+Alt+P` (_Select Maven Profiles_) and check `integration-tests` and `arq-jbossas-7-remote`
+ 2. Right-click the module and select _Run As_ - _JUnit Test_
Added: branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/org/jboss/seam/example/booking/test/BookingTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/org/jboss/seam/example/booking/test/BookingTest.java (rev 0)
+++ branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/org/jboss/seam/example/booking/test/BookingTest.java 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,143 @@
+//$Id: BookingTest.java 5810 2007-07-16 06:46:47Z gavin $
+package org.jboss.seam.example.booking.test;
+
+import java.util.Calendar;
+import java.util.Date;
+
+import javax.faces.model.DataModel;
+import javax.faces.model.ListDataModel;
+
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.Component;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.contexts.Lifecycle;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.example.booking.Booking;
+import org.jboss.seam.example.booking.BookingList;
+import org.jboss.seam.example.booking.Hotel;
+import org.jboss.seam.example.booking.HotelBooking;
+import org.jboss.seam.example.booking.HotelSearching;
+import org.jboss.seam.example.booking.User;
+import org.jboss.seam.security.Identity;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class BookingTest
+{
+ @Deployment(name="BookingTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment()
+ {
+ WebArchive war = Deployments.bookingDeployment();
+
+ war.addClasses(BookingTest.class);
+
+ return war;
+ }
+
+ @Before
+ public void before() {
+ Lifecycle.beginCall();
+ }
+
+ @After
+ public void after() {
+ Lifecycle.endCall();
+ }
+
+ @Test
+ public void testBookHotel() throws Exception
+ {
+ Manager manager = Manager.instance();
+ Identity identity = Identity.instance();
+ HotelSearching hotelSearch = (HotelSearching)Component.getInstance("hotelSearch");
+ HotelBooking hotelBooking = (HotelBooking)Component.getInstance("hotelBooking");
+ BookingList bookingList = (BookingList)Component.getInstance("bookingList");
+
+ manager.initializeTemporaryConversation();
+ Contexts.getSessionContext().set("user", new User("Gavin King", "foobar", "gavin"));
+
+ identity.setUsername("gavin");
+ identity.setPassword("foobar");
+ identity.login();
+
+ hotelSearch.setSearchString("Union Square");
+ hotelSearch.find();
+
+ DataModel hotels = (DataModel) Contexts.getSessionContext().get("hotels");
+
+ assertEquals(1, hotels.getRowCount());
+ assertEquals("NY", ((Hotel) hotels.getRowData() ).getCity());
+ assertEquals("Union Square", hotelSearch.getSearchString());
+ assertFalse(manager.isLongRunningConversation());
+
+ hotels = (DataModel) Contexts.getSessionContext().get("hotels");
+ assertEquals(1, hotels.getRowCount());
+ hotelBooking.selectHotel( (Hotel) hotels.getRowData() );
+
+ Hotel hotel = (Hotel) Contexts.getConversationContext().get("hotel");
+ assertEquals("NY", hotel.getCity());
+ assertEquals("10011", hotel.getZip());
+ assertTrue(manager.isLongRunningConversation());
+
+ hotelBooking.bookHotel();
+
+ Booking booking = (Booking) Contexts.getConversationContext().get("booking");
+ assertNotNull(booking.getUser());
+ assertNotNull(booking.getHotel());
+ assertNull(booking.getCreditCard());
+ assertNull(booking.getCreditCardName());
+
+ assertEquals(Contexts.getConversationContext().get("hotel"), booking.getHotel());
+ assertEquals(Contexts.getSessionContext().get("user"), booking.getUser());
+ assertTrue(Manager.instance().isLongRunningConversation());
+
+ booking.setCreditCard("1234567891021234");
+ booking.setCreditCardName("GAVIN KING");
+ booking.setBeds(2);
+ Date now = new Date();
+ booking.setCheckinDate(now);
+ booking.setCheckoutDate(now);
+
+ hotelBooking.setBookingDetails();
+ assertFalse(hotelBooking.isBookingValid());
+
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.DAY_OF_MONTH, 2);
+ booking.setCheckoutDate(cal.getTime());
+
+ hotelBooking.setBookingDetails();
+ assertTrue(hotelBooking.isBookingValid());
+ assertTrue(manager.isLongRunningConversation());
+
+ hotelBooking.confirm();
+
+ ListDataModel bookings = (ListDataModel) Component.getInstance("bookings");
+ assertEquals(1, bookings.getRowCount());
+ bookings.setRowIndex(0);
+ booking = (Booking) bookings.getRowData();
+ assertEquals("NY", booking.getHotel().getCity());
+ assertEquals("gavin", booking.getUser().getUsername());
+ assertFalse(manager.isLongRunningConversation());
+
+ bookings = (ListDataModel) Contexts.getSessionContext().get("bookings");
+ bookings.setRowIndex(0);
+ bookingList.cancel();
+
+ bookings = (ListDataModel) Contexts.getSessionContext().get("bookings");
+ assertEquals(0, bookings.getRowCount());
+ assertFalse(manager.isLongRunningConversation());
+ }
+
+}
Added: branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/org/jboss/seam/example/booking/test/ChangePasswordTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/org/jboss/seam/example/booking/test/ChangePasswordTest.java (rev 0)
+++ branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/org/jboss/seam/example/booking/test/ChangePasswordTest.java 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,106 @@
+//$Id: ChangePasswordTest.java 5810 2007-07-16 06:46:47Z gavin $
+package org.jboss.seam.example.booking.test;
+
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.Component;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.contexts.Lifecycle;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.example.booking.ChangePassword;
+import org.jboss.seam.example.booking.User;
+import org.jboss.seam.security.Identity;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class ChangePasswordTest
+{
+ @Deployment(name="ChangePasswordTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment()
+ {
+ WebArchive war = Deployments.bookingDeployment();
+
+ war.addClasses(ChangePasswordTest.class);
+
+ return war;
+ }
+
+ @Before
+ public void before() {
+ Lifecycle.beginCall();
+ }
+
+ @After
+ public void after() {
+ Lifecycle.endCall();
+ }
+
+ @Test
+ public void testChangePassword() throws Exception
+ {
+ Identity identity = Identity.instance();
+
+ Contexts.getSessionContext().set("user", new User("Gavin King", "foobar", "gavin"));
+ identity.setUsername("gavin");
+ identity.setPassword("foobar");
+ identity.login();
+
+ User user = (User)Component.getInstance("user");
+ assertEquals("Gavin King", user.getName());
+ assertEquals("gavin", user.getUsername());
+ assertEquals("foobar", user.getPassword());
+ assertFalse(Manager.instance().isLongRunningConversation());
+ assertTrue(identity.isLoggedIn());
+
+ user.setPassword("xxxyyy");
+ ChangePassword changePassword = (ChangePassword)Component.getInstance("changePassword");
+ changePassword.setVerify("xxyyyx");
+ changePassword.changePassword();
+
+ user = (User)Component.getInstance("user");
+ assertEquals("Gavin King", user.getName());
+ assertEquals("gavin", user.getUsername());
+ assertEquals("foobar", user.getPassword());
+ assertFalse(Manager.instance().isLongRunningConversation());
+ assertTrue(identity.isLoggedIn());
+
+ user = (User)Component.getInstance("user");
+ user.setPassword("xxxyyy");
+ changePassword = (ChangePassword)Component.getInstance("changePassword");
+ changePassword.setVerify("xxxyyy");
+ changePassword.changePassword();
+
+ user = (User)Component.getInstance("user");
+ assertEquals("Gavin King", user.getName());
+ assertEquals("gavin", user.getUsername());
+ assertEquals("xxxyyy", user.getPassword());
+ assertFalse(Manager.instance().isLongRunningConversation());
+ assertTrue(identity.isLoggedIn());
+
+ user = (User)Component.getInstance("user");
+ assertEquals("xxxyyy", user.getPassword());
+ user.setPassword("foobar");
+ changePassword = (ChangePassword)Component.getInstance("changePassword");
+ changePassword.setVerify("foobar");
+ changePassword.changePassword();
+
+ user = (User)Component.getInstance("user");
+ assertEquals("Gavin King", user.getName());
+ assertEquals("gavin", user.getUsername());
+ assertEquals("foobar", user.getPassword());
+ assertFalse(Manager.instance().isLongRunningConversation());
+ assertTrue(identity.isLoggedIn());
+ }
+
+}
Added: branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/org/jboss/seam/example/booking/test/Deployments.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/org/jboss/seam/example/booking/test/Deployments.java (rev 0)
+++ branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/org/jboss/seam/example/booking/test/Deployments.java 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,30 @@
+package org.jboss.seam.example.booking.test;
+
+import java.io.File;
+import org.jboss.seam.example.booking.Booking;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.resolver.api.maven.Maven;
+
+public class Deployments {
+
+ public static WebArchive bookingDeployment() {
+
+ File[] libs = Maven.resolver().loadPomFromFile("pom.xml")
+ .importCompileAndRuntimeDependencies()
+ // force resolve jboss-seam, because it is provided-scoped in the pom, but we need it bundled in the WAR
+ .resolve("org.jboss.seam:jboss-seam")
+ .withTransitivity().asFile();
+
+ return ShrinkWrap.create(WebArchive.class, "seam-booking.war")
+ .addPackage(Booking.class.getPackage())
+ .addAsWebInfResource("META-INF/ejb-jar.xml", "ejb-jar.xml")
+ .addAsWebInfResource("import.sql", "classes/import.sql")
+ .addAsWebInfResource("persistence.xml", "classes/META-INF/persistence.xml")
+ .addAsWebInfResource("components.xml", "components.xml")
+ .addAsWebInfResource("jboss-deployment-structure.xml", "jboss-deployment-structure.xml")
+ .addAsWebInfResource("seam.properties", "classes/seam.properties")
+ .addAsWebInfResource("web.xml", "web.xml")
+ .addAsLibraries(libs);
+ }
+}
Added: branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/org/jboss/seam/example/booking/test/LoginTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/org/jboss/seam/example/booking/test/LoginTest.java (rev 0)
+++ branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/java/org/jboss/seam/example/booking/test/LoginTest.java 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,94 @@
+//$Id: LoginTest.java 5810 2007-07-16 06:46:47Z gavin $
+package org.jboss.seam.example.booking.test;
+
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.Component;
+import org.jboss.seam.contexts.Lifecycle;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.example.booking.User;
+import org.jboss.seam.security.Identity;
+import org.jboss.seam.web.Session;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class LoginTest
+{
+ @Deployment(name="LoginTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment()
+ {
+ WebArchive war = Deployments.bookingDeployment();
+
+ war.addClasses(LoginTest.class);
+
+ return war;
+ }
+
+ @Before
+ public void before() {
+ Lifecycle.beginCall();
+ }
+
+ @After
+ public void after() {
+ Lifecycle.endCall();
+ }
+
+ @Test
+ public void testLoginComponent() throws Exception
+ {
+ Identity identity = Identity.instance();
+
+ assertFalse(identity.isLoggedIn());
+ identity.setUsername("gavin");
+ identity.setPassword("foobar");
+ identity.login();
+
+ User user = (User)Component.getInstance("user");
+ assertEquals("Gavin King", user.getName());
+ assertEquals("gavin", user.getUsername());
+ assertEquals("foobar", user.getPassword());
+ assertTrue(identity.isLoggedIn());
+ identity.logout();
+ assertFalse(identity.isLoggedIn());
+ identity.setUsername("gavin");
+ identity.setPassword("tiger");
+ identity.login();
+ assertFalse(identity.isLoggedIn());
+ }
+
+ @Test
+ public void testLogin() throws Exception
+ {
+ Identity identity = Identity.instance();
+
+ assertFalse(identity.isLoggedIn());
+
+ identity.setUsername("gavin");
+ identity.setPassword("foobar");
+ identity.login();
+
+ User user = (User)Component.getInstance("user");
+ assertEquals("Gavin King", user.getName());
+ assertEquals("gavin", user.getUsername());
+ assertEquals("foobar", user.getPassword());
+ assertFalse(Manager.instance().isLongRunningConversation());
+ assertTrue(identity.isLoggedIn());
+
+ identity.logout();
+ assertTrue(Session.instance().isInvalid());
+
+ assertFalse(identity.isLoggedIn());
+ }
+
+}
Added: branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/resources/arquillian.xml
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/resources/arquillian.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added: branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/resources/components.xml
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/resources/components.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added: branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/resources/jboss-deployment-structure.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/resources/jboss-deployment-structure.xml (rev 0)
+++ branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/resources/jboss-deployment-structure.xml 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,12 @@
+<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
+ <deployment>
+ <dependencies>
+ <module name="org.apache.log4j" export="true"/>
+ <module name="org.dom4j" export="true"/>
+ <module name="org.apache.commons.logging" export="true"/>
+ <module name="org.apache.commons.collections" export="true"/>
+ <module name="javax.faces.api" export="true"/>
+ <module name="com.sun.jsf-impl" export="true"/>
+ </dependencies>
+ </deployment>
+</jboss-deployment-structure>
Added: branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/resources/persistence.xml
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/resources/persistence.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added: branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/resources/web.xml
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/WFK-2_1/examples/booking/booking-ejb/src/test/resources/web.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added: branches/enterprise/WFK-2_1/examples/groovybooking/README.md
===================================================================
--- branches/enterprise/WFK-2_1/examples/groovybooking/README.md (rev 0)
+++ branches/enterprise/WFK-2_1/examples/groovybooking/README.md 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,22 @@
+Seam GroovyBooking Example
+=================
+
+This is the Hotel Booking example implemented in Groovy Beans and Hibernate JPA.
+The application is deployed as a WAR rather than an EAR.
+
+Running the example
+-------------------
+
+To deploy the example to a running JBoss AS instance, follow these steps:
+
+1. In the example root directory run:
+
+ mvn clean install
+
+2. Set JBOSS_HOME environment property.
+
+3. In the groovybooking-web directory run:
+
+ mvn jboss-as:deploy
+
+4. Open this URL in a web browser: http://localhost:8080/groovybooking-web
Added: branches/enterprise/WFK-2_1/examples/hibernate/README.md
===================================================================
--- branches/enterprise/WFK-2_1/examples/hibernate/README.md (rev 0)
+++ branches/enterprise/WFK-2_1/examples/hibernate/README.md 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,60 @@
+Seam Hibernate Example
+=================
+
+This is the Hotel Booking example implemented in Seam and Hibernate POJOs.
+
+Running the example
+-------------------
+
+To deploy the example to a running JBoss AS instance, follow these steps:
+
+1. In the example root directory run:
+
+ mvn clean install
+
+2. Set JBOSS_HOME environment property.
+
+3. In the hibernate-web directory run:
+
+ mvn jboss-as:deploy
+
+4. Open this URL in a web browser: http://localhost:8080/hibernate-web
+
+
+Testing the example
+-------------------
+
+This example is covered by integration tests. All tests use the following technologies:
+
+* __Arquillian__ - as the framework for EE testing, for managing of container lifecycle and deployment of test archive,
+* __ShrinkWrap__ - to create the test archive (WAR).
+
+
+### Integration tests
+
+Integration tests cover core application logic and reside in the EJB module. In addition to Arquillian and ShrinkWrap, the integration tests also use:
+
+* __JUnitSeamTest__ - to hook into the JSF lifecycle and assert server-side state,
+* __ShrinkWrap Resolver__ - to resolve dependencies of the project for packaging in the test archive.
+
+_Note: For this test to function properly, it is necessary to run the JBoss AS instance with the **-ea** JVM argument (Enable Assertions)._
+
+The tests are executed in Maven's test phase. By default they are skipped and can be executed on JBoss AS with:
+
+ mvn clean test -Darquillian=jbossas-managed-7
+
+The `JBOSS_HOME` environment variable must be set and point to a JBoss AS instance directory.
+
+To test on a running server, use
+
+ mvn clean test -Darquillian=jbossas-remote-7
+
+Testing in JBDS
+---------------
+### Integration tests
+
+1. Open JBDS and start a configured instance of JBoss AS
+2. Import the example project and its submodules
+3. In the _Project Explorer_, select the Web module project, then
+ 1. Type `Ctrl+Alt+P` (_Select Maven Profiles_) and check `integration-tests` and `arq-jbossas-7-remote`
+ 2. Right-click the module and select _Run As_ - _JUnit Test_
Added: branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/org/jboss/seam/example/hibernate/test/BookingTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/org/jboss/seam/example/hibernate/test/BookingTest.java (rev 0)
+++ branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/org/jboss/seam/example/hibernate/test/BookingTest.java 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,300 @@
+//$Id: BookingTest.java 6987 2007-12-23 19:53:07Z pmuir $
+package org.jboss.seam.example.hibernate.test;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Iterator;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import javax.faces.model.DataModel;
+import javax.faces.model.ListDataModel;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.example.hibernate.Booking;
+import org.jboss.seam.example.hibernate.Hotel;
+import org.jboss.seam.example.hibernate.HotelBookingAction;
+import org.jboss.seam.example.hibernate.User;
+import org.jboss.seam.mock.JUnitSeamTest;
+import org.jboss.shrinkwrap.api.Archive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class BookingTest extends JUnitSeamTest
+{
+ @Deployment(name="BookingTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment()
+ {
+ return Deployments.hibernateDeployment();
+ }
+
+ @Test
+ public void testBookHotel() throws Exception
+ {
+
+ new FacesRequest() {
+
+ @Override
+ protected void invokeApplication() throws Exception
+ {
+ Contexts.getSessionContext().set("user", new User("Gavin King", "foobar", "gavin"));
+ setValue("#{identity.username}", "gavin");
+ setValue("#{identity.password}", "foobar");
+ invokeAction("#{identity.login}");
+ }
+
+ }.run();
+
+ new FacesRequest("/main.xhtml") {
+
+ @Override
+ protected void updateModelValues() throws Exception
+ {
+ setValue("#{hotelSearch.searchString}", "Union Square");
+ }
+
+ @Override
+ protected void invokeApplication()
+ {
+ assert invokeAction("#{hotelSearch.find}")==null;
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ DataModel hotels = (DataModel) Contexts.getSessionContext().get("hotels");
+ assert hotels.getRowCount()==1;
+ assert ( (Hotel) hotels.getRowData() ).getCity().equals("NY");
+ assert getValue("#{hotelSearch.searchString}").equals("Union Square");
+ assert !Manager.instance().isLongRunningConversation();
+ }
+
+ }.run();
+
+ String id = new FacesRequest("/main.xhtml") {
+
+ @Override
+ protected void invokeApplication() throws Exception {
+ HotelBookingAction hotelBooking = (HotelBookingAction) getInstance("hotelBooking");
+ DataModel hotels = (DataModel) Contexts.getSessionContext().get("hotels");
+ assert hotels.getRowCount()==1;
+ hotelBooking.selectHotel( (Hotel) hotels.getRowData() );
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ Hotel hotel = (Hotel) Contexts.getConversationContext().get("hotel");
+ assert hotel.getCity().equals("NY");
+ assert hotel.getZip().equals("10011");
+ assert Manager.instance().isLongRunningConversation();
+ }
+
+ }.run();
+
+ id = new FacesRequest("/hotel.xhtml", id) {
+
+ @Override
+ protected void invokeApplication()
+ {
+ invokeAction("#{hotelBooking.bookHotel}");
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ assert getValue("#{booking.user}")!=null;
+ assert getValue("#{booking.hotel}")!=null;
+ assert getValue("#{booking.creditCard}")==null;
+ assert getValue("#{booking.creditCardName}")==null;
+ Booking booking = (Booking) Contexts.getConversationContext().get("booking");
+ assert booking.getHotel()==Contexts.getConversationContext().get("hotel");
+ assert booking.getUser()==Contexts.getSessionContext().get("user");
+ assert Manager.instance().isLongRunningConversation();
+ }
+
+ }.run();
+
+ new FacesRequest("/book.xhtml", id) {
+
+ @Override
+ protected void processValidations() throws Exception
+ {
+ validateValue("#{booking.creditCard}", "123");
+ assert isValidationFailure();
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ Iterator messages = FacesContext.getCurrentInstance().getMessages();
+ assert messages.hasNext();
+ assert ( (FacesMessage) messages.next() ).getSummary().equals("Credit card number must 16 digits long");
+ assert !messages.hasNext();
+ assert Manager.instance().isLongRunningConversation();
+ }
+
+ @Override
+ protected void afterRequest()
+ {
+ assert !isInvokeApplicationBegun();
+ }
+
+ }.run();
+
+ new FacesRequest("/book.xhtml", id) {
+
+ @Override
+ protected void processValidations() throws Exception
+ {
+ validateValue("#{booking.creditCardName}", "");
+ assert isValidationFailure();
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ Iterator messages = FacesContext.getCurrentInstance().getMessages();
+ assert messages.hasNext();
+ assert ( (FacesMessage) messages.next() ).getSummary().equals("Credit card name is required");
+ assert !messages.hasNext();
+ assert Manager.instance().isLongRunningConversation();
+ }
+
+ @Override
+ protected void afterRequest()
+ {
+ assert !isInvokeApplicationBegun();
+ }
+
+ }.run();
+
+ new FacesRequest("/book.xhtml", id) {
+
+ @Override @SuppressWarnings("deprecation")
+ protected void updateModelValues() throws Exception
+ {
+ setValue("#{booking.creditCard}", "1234567891021234");
+ setValue("#{booking.creditCardName}", "GAVIN KING");
+ setValue("#{booking.beds}", 2);
+ Date now = new Date();
+ setValue("#{booking.checkinDate}", now);
+ setValue("#{booking.checkoutDate}", now);
+ }
+
+ @Override
+ protected void invokeApplication()
+ {
+ assert invokeAction("#{hotelBooking.setBookingDetails}")==null;
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ Iterator messages = FacesContext.getCurrentInstance().getMessages();
+ assert messages.hasNext();
+ FacesMessage message = (FacesMessage) messages.next();
+ assert message.getSummary().equals("Check out date must be later than check in date");
+ assert !messages.hasNext();
+ assert Manager.instance().isLongRunningConversation();
+ }
+
+ @Override
+ protected void afterRequest()
+ {
+ assert isInvokeApplicationComplete();
+ }
+
+ }.run();
+
+ new FacesRequest("/book.xhtml", id) {
+
+ @Override @SuppressWarnings("deprecation")
+ protected void updateModelValues() throws Exception
+ {
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.DAY_OF_MONTH, 2);
+ setValue("#{booking.checkoutDate}", cal.getTime() );
+ }
+
+ @Override
+ protected void invokeApplication()
+ {
+ invokeAction("#{hotelBooking.setBookingDetails}");
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ assert Manager.instance().isLongRunningConversation();
+ }
+
+ @Override
+ protected void afterRequest()
+ {
+ assert isInvokeApplicationComplete();
+ }
+
+ }.run();
+
+ new FacesRequest("/confirm.xhtml", id) {
+
+ @Override
+ protected void invokeApplication()
+ {
+ invokeAction("#{hotelBooking.confirm}");
+ }
+
+ @Override
+ protected void afterRequest()
+ {
+ assert isInvokeApplicationComplete();
+ }
+
+ }.run();
+
+ new NonFacesRequest("/main.xhtml") {
+
+ @Override
+ protected void renderResponse()
+ {
+ ListDataModel bookings = (ListDataModel) getInstance("bookings");
+ assert bookings.getRowCount()==1;
+ bookings.setRowIndex(0);
+ Booking booking = (Booking) bookings.getRowData();
+ assert booking.getHotel().getCity().equals("NY");
+ assert booking.getUser().getUsername().equals("gavin");
+ assert !Manager.instance().isLongRunningConversation();
+ }
+
+ }.run();
+
+ new FacesRequest("/main.xhtml") {
+
+ @Override
+ protected void invokeApplication()
+ {
+ ListDataModel bookings = (ListDataModel) Contexts.getSessionContext().get("bookings");
+ bookings.setRowIndex(0);
+ invokeAction("#{bookingList.cancel}");
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ ListDataModel bookings = (ListDataModel) Contexts.getSessionContext().get("bookings");
+ assert bookings.getRowCount()==0;
+ assert !Manager.instance().isLongRunningConversation();
+ }
+
+ }.run();
+
+ }
+
+}
Added: branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/org/jboss/seam/example/hibernate/test/ChangePasswordTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/org/jboss/seam/example/hibernate/test/ChangePasswordTest.java (rev 0)
+++ branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/org/jboss/seam/example/hibernate/test/ChangePasswordTest.java 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,150 @@
+//$Id: ChangePasswordTest.java 6987 2007-12-23 19:53:07Z pmuir $
+package org.jboss.seam.example.hibernate.test;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.example.hibernate.User;
+import org.jboss.seam.mock.JUnitSeamTest;
+import org.jboss.shrinkwrap.api.Archive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class ChangePasswordTest extends JUnitSeamTest
+{
+ @Deployment(name="ChangePasswordTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment()
+ {
+ return Deployments.hibernateDeployment();
+ }
+
+ @Test
+ public void testChangePassword() throws Exception
+ {
+
+ new FacesRequest() {
+
+ @Override
+ protected void invokeApplication() throws Exception
+ {
+ Contexts.getSessionContext().set("user", new User("Gavin King", "foobar", "gavin"));
+ setValue("#{identity.username}", "gavin");
+ setValue("#{identity.password}", "foobar");
+ invokeMethod("#{identity.login}");
+ }
+
+ }.run();
+
+ new FacesRequest() {
+
+ @Override
+ protected void processValidations() throws Exception
+ {
+ validateValue("#{user.password}", "xxx");
+ assert isValidationFailure();
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ assert getValue("#{user.name}").equals("Gavin King");
+ assert getValue("#{user.username}").equals("gavin");
+ assert getValue("#{user.password}").equals("foobar");
+ assert !Manager.instance().isLongRunningConversation();
+ assert getValue("#{identity.loggedIn}").equals(true);
+
+ }
+
+ }.run();
+
+ new FacesRequest() {
+
+ @Override
+ protected void updateModelValues() throws Exception
+ {
+ setValue("#{user.password}", "xxxyyy");
+ setValue("#{changePassword.verify}", "xxyyyx");
+ }
+
+ @Override
+ protected void invokeApplication()
+ {
+ assert invokeAction("#{changePassword.changePassword}")==null;
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ assert getValue("#{user.name}").equals("Gavin King");
+ assert getValue("#{user.username}").equals("gavin");
+ assert getValue("#{user.password}").equals("foobar");
+ assert !Manager.instance().isLongRunningConversation();
+ assert getValue("#{identity.loggedIn}").equals(true);
+ }
+
+ }.run();
+
+ new FacesRequest() {
+
+ @Override
+ protected void updateModelValues() throws Exception
+ {
+ setValue("#{user.password}", "xxxyyy");
+ setValue("#{changePassword.verify}", "xxxyyy");
+ }
+
+ @Override
+ protected void invokeApplication()
+ {
+ invokeMethod("#{changePassword.changePassword}");
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ assert getValue("#{user.name}").equals("Gavin King");
+ assert getValue("#{user.username}").equals("gavin");
+ assert getValue("#{user.password}").equals("xxxyyy");
+ assert !Manager.instance().isLongRunningConversation();
+ assert getValue("#{identity.loggedIn}").equals(true);
+
+ }
+
+ }.run();
+
+ new FacesRequest() {
+
+ @Override
+ protected void updateModelValues() throws Exception
+ {
+ assert getValue("#{user.password}").equals("xxxyyy");
+ setValue("#{user.password}", "foobar");
+ setValue("#{changePassword.verify}", "foobar");
+ }
+
+ @Override
+ protected void invokeApplication()
+ {
+ invokeMethod("#{changePassword.changePassword}");
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ assert getValue("#{user.name}").equals("Gavin King");
+ assert getValue("#{user.username}").equals("gavin");
+ assert getValue("#{user.password}").equals("foobar");
+ assert !Manager.instance().isLongRunningConversation();
+ assert getValue("#{identity.loggedIn}").equals(true);
+
+ }
+
+ }.run();
+
+ }
+
+}
Added: branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/org/jboss/seam/example/hibernate/test/Deployments.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/org/jboss/seam/example/hibernate/test/Deployments.java (rev 0)
+++ branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/org/jboss/seam/example/hibernate/test/Deployments.java 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,38 @@
+package org.jboss.seam.example.hibernate.test;
+
+import java.io.File;
+import org.jboss.seam.example.hibernate.Booking;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.resolver.api.maven.Maven;
+
+public class Deployments {
+
+ public static WebArchive hibernateDeployment() {
+
+ File[] libs = Maven.resolver().loadPomFromFile("pom.xml")
+ .importCompileAndRuntimeDependencies()
+ .resolve().withTransitivity().asFile();
+
+ // Get File reference to src/main/webapp/WEB-INF, to avoid duplication of resources for the test archive
+ // Depends on shrinkwrap-resolver-maven-plugin to set the property
+ File webInf = new File(new File("pom.xml").getParentFile(), "src/main/webapp/WEB-INF");
+
+ return ShrinkWrap.create(WebArchive.class, "hibernate-web.war")
+ .addPackage(Booking.class.getPackage())
+
+ // copy classpath resources to WAR classpath
+ .addAsWebInfResource("import.sql", "classes/import.sql")
+ .addAsWebInfResource("seam.properties", "classes/seam.properties")
+ .addAsWebInfResource("hibernate.cfg.xml", "classes/hibernate.cfg.xml")
+
+ // copy files from src/main/webapp to test-archive's WEB-INF
+ .addAsWebInfResource(new File(webInf, "components.xml"))
+ .addAsWebInfResource(new File(webInf, "jboss-deployment-structure.xml"))
+ .addAsWebInfResource(new File(webInf, "pages.xml"))
+
+ // modified web.xml, defines only MockSeamListener
+ .addAsWebInfResource("web.xml")
+ .addAsLibraries(libs);
+ }
+}
Added: branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/org/jboss/seam/example/hibernate/test/LoginTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/org/jboss/seam/example/hibernate/test/LoginTest.java (rev 0)
+++ branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/java/org/jboss/seam/example/hibernate/test/LoginTest.java 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,127 @@
+//$Id: LoginTest.java 6987 2007-12-23 19:53:07Z pmuir $
+package org.jboss.seam.example.hibernate.test;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.web.Session;
+import org.jboss.seam.mock.JUnitSeamTest;
+import org.jboss.shrinkwrap.api.Archive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class LoginTest extends JUnitSeamTest
+{
+ @Deployment(name="LoginTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment()
+ {
+ return Deployments.hibernateDeployment();
+ }
+
+ @Test
+ public void testLoginComponent() throws Exception
+ {
+ new ComponentTest() {
+
+ @Override
+ protected void testComponents() throws Exception
+ {
+ assert getValue("#{identity.loggedIn}").equals(false);
+ setValue("#{identity.username}", "gavin");
+ setValue("#{identity.password}", "foobar");
+ invokeMethod("#{identity.login}");
+ assert getValue("#{user.name}").equals("Gavin King");
+ assert getValue("#{user.username}").equals("gavin");
+ assert getValue("#{user.password}").equals("foobar");
+ assert getValue("#{identity.loggedIn}").equals(true);
+ invokeMethod("#{identity.logout}");
+ assert getValue("#{identity.loggedIn}").equals(false);
+ setValue("#{identity.username}", "gavin");
+ setValue("#{identity.password}", "tiger");
+ invokeMethod("#{identity.login}");
+ assert getValue("#{identity.loggedIn}").equals(false);
+ }
+
+ }.run();
+ }
+
+ @Test
+ public void testLogin() throws Exception
+ {
+
+ new FacesRequest() {
+
+ @Override
+ protected void invokeApplication()
+ {
+ assert !isSessionInvalid();
+ assert getValue("#{identity.loggedIn}").equals(false);
+ }
+
+ }.run();
+
+ new FacesRequest() {
+
+ @Override
+ protected void updateModelValues() throws Exception
+ {
+ assert !isSessionInvalid();
+ setValue("#{identity.username}", "gavin");
+ setValue("#{identity.password}", "foobar");
+ }
+
+ @Override
+ protected void invokeApplication()
+ {
+ invokeAction("#{identity.login}");
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ assert getValue("#{user.name}").equals("Gavin King");
+ assert getValue("#{user.username}").equals("gavin");
+ assert getValue("#{user.password}").equals("foobar");
+ assert !Manager.instance().isLongRunningConversation();
+ assert getValue("#{identity.loggedIn}").equals(true);
+ }
+
+ }.run();
+
+ new FacesRequest() {
+
+ @Override
+ protected void invokeApplication()
+ {
+ assert !isSessionInvalid();
+ assert getValue("#{identity.loggedIn}").equals(true);
+ }
+
+ }.run();
+
+ new FacesRequest() {
+
+ @Override
+ protected void invokeApplication()
+ {
+ assert !Manager.instance().isLongRunningConversation();
+ assert !isSessionInvalid();
+ invokeMethod("#{identity.logout}");
+ assert Session.instance().isInvalid();
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ assert getValue("#{identity.loggedIn}").equals(false);
+ assert Session.instance().isInvalid();
+ }
+
+ }.run();
+
+ }
+
+}
Added: branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/resources/arquillian.xml
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/resources/arquillian.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added: branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/resources/web.xml
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/WFK-2_1/examples/hibernate/hibernate-web/src/test/resources/web.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added: branches/enterprise/WFK-2_1/examples/jee6/README.md
===================================================================
--- branches/enterprise/WFK-2_1/examples/jee6/README.md (rev 0)
+++ branches/enterprise/WFK-2_1/examples/jee6/README.md 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,60 @@
+Seam Booking Example
+====================
+
+This example demonstrates the use of Seam in a Java EE 6 environment.
+Transaction and persistence context management is handled by the
+EJB container. This example runs on JBoss AS as a WAR
+
+Running the example
+-------------------
+
+To deploy the example to a running JBoss AS instance, follow these steps:
+
+1. In the example root directory run:
+
+ mvn clean install
+
+2. Set JBOSS_HOME environment property.
+
+3. In the jee6-web directory run:
+
+ mvn jboss-as:deploy
+
+* Open this URL in a web browser: http://localhost:8080/jee6-web
+
+
+Testing the example
+-------------------
+
+This example is covered by integration tests. All tests use the following technologies:
+
+* __Arquillian__ - as the framework for EE testing, for managing of container lifecycle and deployment of test archive,
+* __ShrinkWrap__ - to create the test archive (WAR).
+
+
+### Integration tests
+
+Integration tests cover core application logic and reside in the EJB module. In addition to Arquillian and ShrinkWrap, the integration tests also use:
+
+* __JUnitSeamTest__ - to hook into the JSF lifecycle and assert server-side state,
+* __ShrinkWrap Resolver__ - to resolve dependencies of the project for packaging in the test archive.
+
+The tests are executed in Maven's test phase. By default they are skipped and can be executed on JBoss AS with:
+
+ mvn clean test -Darquillian=jbossas-managed-7
+
+The `JBOSS_HOME` environment variable must be set and point to a JBoss AS instance directory.
+
+To test on a running server, use
+
+ mvn clean test -Darquillian=jbossas-remote-7
+
+Testing in JBDS
+---------------
+### Integration tests
+
+1. Open JBDS and start a configured instance of JBoss AS
+2. Import the example project and its submodules
+3. In the _Project Explorer_, select the Web module project, then
+ 1. Type `Ctrl+Alt+P` (_Select Maven Profiles_) and check `integration-tests` and `arq-jbossas-7-remote`
+ 2. Right-click the module and select _Run As_ - _JUnit Test_
Added: branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/org/jboss/seam/example/booking/test/BookingTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/org/jboss/seam/example/booking/test/BookingTest.java (rev 0)
+++ branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/org/jboss/seam/example/booking/test/BookingTest.java 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,142 @@
+//$Id: BookingTest.java 5810 2007-07-16 06:46:47Z gavin $
+package org.jboss.seam.example.booking.test;
+
+import java.util.Calendar;
+import java.util.Date;
+
+import javax.faces.model.DataModel;
+import javax.faces.model.ListDataModel;
+
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.Component;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.contexts.Lifecycle;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.example.booking.Booking;
+import org.jboss.seam.example.booking.BookingListAction;
+import org.jboss.seam.example.booking.Hotel;
+import org.jboss.seam.example.booking.HotelBookingAction;
+import org.jboss.seam.example.booking.HotelSearchingAction;
+import org.jboss.seam.example.booking.RecentBookingsAction;
+import org.jboss.seam.example.booking.User;
+import org.jboss.seam.security.Identity;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class BookingTest {
+
+ @Deployment(name = "BookingTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment() {
+ return Deployments.bookingDeployment();
+ }
+
+ @Before
+ public void before() {
+ Lifecycle.beginCall();
+ }
+
+ @After
+ public void after() {
+ Lifecycle.endCall();
+ }
+
+ @Test
+ public void testBookHotel() throws Exception {
+ Manager manager = Manager.instance();
+ Identity identity = Identity.instance();
+ HotelSearchingAction hotelSearch = (HotelSearchingAction) Component.getInstance("hotelSearch");
+ HotelBookingAction hotelBooking = (HotelBookingAction) Component.getInstance("hotelBooking");
+ BookingListAction bookingList = (BookingListAction) Component.getInstance("bookingList");
+
+ manager.initializeTemporaryConversation();
+ Contexts.getSessionContext().set("user", new User("Gavin King", "foobar", "gavin"));
+
+ identity.setUsername("gavin");
+ identity.setPassword("foobar");
+ identity.login();
+
+ hotelSearch.setSearchString("Union Square");
+ hotelSearch.find();
+
+ DataModel hotels = (DataModel) Contexts.getSessionContext().get("hotels");
+
+ assertEquals(1, hotels.getRowCount());
+ assertEquals("NY", ((Hotel) hotels.getRowData()).getCity());
+ assertEquals("Union Square", hotelSearch.getSearchString());
+ assertFalse(manager.isLongRunningConversation());
+
+ long hotelId = ((Hotel) hotels.getRowData()).getId();
+ RecentBookingsAction recentBookings = (RecentBookingsAction) Component.getInstance("recentBookings");
+ assertNull(recentBookings.getMostRecentBookingDate(hotelId));
+
+ hotels = (DataModel) Contexts.getSessionContext().get("hotels");
+ assertEquals(1, hotels.getRowCount());
+ hotelBooking.selectHotel((Hotel) hotels.getRowData());
+
+ Hotel hotel = (Hotel) Contexts.getConversationContext().get("hotel");
+ assertEquals("NY", hotel.getCity());
+ assertEquals("10011", hotel.getZip());
+ assertTrue(manager.isLongRunningConversation());
+
+ hotelBooking.bookHotel();
+
+ Booking booking = (Booking) Contexts.getConversationContext().get("booking");
+ assertNotNull(booking.getUser());
+ assertNotNull(booking.getHotel());
+ assertNull(booking.getCreditCard());
+ assertNull(booking.getCreditCardName());
+
+ assertEquals(Contexts.getConversationContext().get("hotel"), booking.getHotel());
+ assertEquals(Contexts.getSessionContext().get("user"), booking.getUser());
+ assertTrue(Manager.instance().isLongRunningConversation());
+
+ booking.setCreditCard("1234567891021234");
+ booking.setCreditCardName("GAVIN KING");
+ booking.setBeds(2);
+ Date now = new Date();
+ booking.setCheckinDate(now);
+ booking.setCheckoutDate(now);
+
+ hotelBooking.setBookingDetails();
+ assertFalse(hotelBooking.isBookingValid());
+
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.DAY_OF_MONTH, 2);
+ booking.setCheckoutDate(cal.getTime());
+
+ hotelBooking.setBookingDetails();
+ assertTrue(hotelBooking.isBookingValid());
+ assertTrue(manager.isLongRunningConversation());
+
+ hotelBooking.confirm();
+
+ ListDataModel bookings = (ListDataModel) Component.getInstance("bookings");
+ assertEquals(1, bookings.getRowCount());
+ bookings.setRowIndex(0);
+ booking = (Booking) bookings.getRowData();
+ assertEquals("NY", booking.getHotel().getCity());
+ assertEquals("gavin", booking.getUser().getUsername());
+ assertFalse(manager.isLongRunningConversation());
+
+ recentBookings = (RecentBookingsAction) Component.getInstance("recentBookings");
+ assertNotNull(recentBookings.getMostRecentBookingDate(hotelId));
+
+ bookings = (ListDataModel) Contexts.getSessionContext().get("bookings");
+ bookings.setRowIndex(0);
+ bookingList.cancel();
+
+ bookings = (ListDataModel) Contexts.getSessionContext().get("bookings");
+ assertEquals(0, bookings.getRowCount());
+ assertFalse(manager.isLongRunningConversation());
+ }
+}
Added: branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/org/jboss/seam/example/booking/test/ChangePasswordTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/org/jboss/seam/example/booking/test/ChangePasswordTest.java (rev 0)
+++ branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/org/jboss/seam/example/booking/test/ChangePasswordTest.java 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,97 @@
+//$Id: ChangePasswordTest.java 5810 2007-07-16 06:46:47Z gavin $
+package org.jboss.seam.example.booking.test;
+
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.Component;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.contexts.Lifecycle;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.example.booking.ChangePasswordAction;
+import org.jboss.seam.example.booking.User;
+import org.jboss.seam.security.Identity;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class ChangePasswordTest {
+
+ @Deployment(name = "ChangePasswordTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment() {
+ return Deployments.bookingDeployment();
+ }
+
+ @Before
+ public void before() {
+ Lifecycle.beginCall();
+ }
+
+ @After
+ public void after() {
+ Lifecycle.endCall();
+ }
+
+ @Test
+ public void testChangePassword() throws Exception {
+ Identity identity = Identity.instance();
+
+ Contexts.getSessionContext().set("user", new User("Gavin King", "foobar", "gavin"));
+ identity.setUsername("gavin");
+ identity.setPassword("foobar");
+ identity.login();
+
+ User user = (User) Component.getInstance("user");
+ assertEquals("Gavin King", user.getName());
+ assertEquals("gavin", user.getUsername());
+ assertEquals("foobar", user.getPassword());
+ assertFalse(Manager.instance().isLongRunningConversation());
+ assertTrue(identity.isLoggedIn());
+
+ user.setPassword("xxxyyy");
+ ChangePasswordAction changePassword = (ChangePasswordAction) Component.getInstance("changePassword");
+ changePassword.setVerify("xxyyyx");
+ changePassword.changePassword();
+
+ user = (User) Component.getInstance("user");
+ assertEquals("Gavin King", user.getName());
+ assertEquals("gavin", user.getUsername());
+ assertEquals("foobar", user.getPassword());
+ assertFalse(Manager.instance().isLongRunningConversation());
+ assertTrue(identity.isLoggedIn());
+
+ user = (User) Component.getInstance("user");
+ user.setPassword("xxxyyy");
+ changePassword = (ChangePasswordAction) Component.getInstance("changePassword");
+ changePassword.setVerify("xxxyyy");
+ changePassword.changePassword();
+
+ user = (User) Component.getInstance("user");
+ assertEquals("Gavin King", user.getName());
+ assertEquals("gavin", user.getUsername());
+ assertEquals("xxxyyy", user.getPassword());
+ assertFalse(Manager.instance().isLongRunningConversation());
+ assertTrue(identity.isLoggedIn());
+
+ user = (User) Component.getInstance("user");
+ assertEquals("xxxyyy", user.getPassword());
+ user.setPassword("foobar");
+ changePassword = (ChangePasswordAction) Component.getInstance("changePassword");
+ changePassword.setVerify("foobar");
+ changePassword.changePassword();
+
+ user = (User) Component.getInstance("user");
+ assertEquals("Gavin King", user.getName());
+ assertEquals("gavin", user.getUsername());
+ assertEquals("foobar", user.getPassword());
+ assertFalse(Manager.instance().isLongRunningConversation());
+ assertTrue(identity.isLoggedIn());
+ }
+}
Added: branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/org/jboss/seam/example/booking/test/Deployments.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/org/jboss/seam/example/booking/test/Deployments.java (rev 0)
+++ branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/org/jboss/seam/example/booking/test/Deployments.java 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,39 @@
+package org.jboss.seam.example.booking.test;
+
+import java.io.File;
+import org.jboss.seam.example.booking.Booking;
+
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.resolver.api.maven.Maven;
+
+public class Deployments {
+
+ public static WebArchive bookingDeployment() {
+
+ File[] libs = Maven.resolver().loadPomFromFile("pom.xml")
+ .importCompileAndRuntimeDependencies()
+ .resolve().withTransitivity().asFile();
+
+ // Get File reference to src/main/webapp/WEB-INF, to avoid duplication of resources for the test archive
+ // Depends on shrinkwrap-resolver-maven-plugin to set the property
+ File webInf = new File(new File("pom.xml").getParentFile(), "src/main/webapp/WEB-INF");
+
+ return ShrinkWrap.create(WebArchive.class, "jee6-web.war")
+ .addPackage(Booking.class.getPackage())
+
+ // copy classpath resources to WAR classpath
+ .addAsWebInfResource("import.sql", "classes/import.sql")
+ .addAsWebInfResource("seam.properties", "classes/seam.properties")
+ .addAsWebInfResource("persistence.xml", "classes/META-INF/persistence.xml")
+ .addAsWebInfResource("components.xml")
+
+ // copy files from src/main/webapp to test-archive's WEB-INF
+ .addAsWebInfResource(new File(webInf, "jboss-deployment-structure.xml"))
+ .addAsWebInfResource(new File(webInf, "pages.xml"))
+ .addAsWebInfResource(new File(webInf, "ejb-jar.xml"))
+ .addAsWebInfResource(new File(webInf, "web.xml"))
+
+ .addAsLibraries(libs);
+ }
+}
Added: branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/org/jboss/seam/example/booking/test/LoginTest.java
===================================================================
--- branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/org/jboss/seam/example/booking/test/LoginTest.java (rev 0)
+++ branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/java/org/jboss/seam/example/booking/test/LoginTest.java 2013-06-03 16:41:11 UTC (rev 15525)
@@ -0,0 +1,85 @@
+//$Id: LoginTest.java 5810 2007-07-16 06:46:47Z gavin $
+package org.jboss.seam.example.booking.test;
+
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.Component;
+import org.jboss.seam.contexts.Lifecycle;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.example.booking.User;
+import org.jboss.seam.security.Identity;
+import org.jboss.seam.web.Session;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class LoginTest {
+
+ @Deployment(name = "LoginTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment() {
+ return Deployments.bookingDeployment();
+ }
+
+ @Before
+ public void before() {
+ Lifecycle.beginCall();
+ }
+
+ @After
+ public void after() {
+ Lifecycle.endCall();
+ }
+
+ @Test
+ public void testLoginComponent() throws Exception {
+ Identity identity = Identity.instance();
+
+ assertFalse(identity.isLoggedIn());
+ identity.setUsername("gavin");
+ identity.setPassword("foobar");
+ identity.login();
+
+ User user = (User) Component.getInstance("user");
+ assertEquals("Gavin King", user.getName());
+ assertEquals("gavin", user.getUsername());
+ assertEquals("foobar", user.getPassword());
+ assertTrue(identity.isLoggedIn());
+ identity.logout();
+ assertFalse(identity.isLoggedIn());
+ identity.setUsername("gavin");
+ identity.setPassword("tiger");
+ identity.login();
+ assertFalse(identity.isLoggedIn());
+ }
+
+ @Test
+ public void testLogin() throws Exception {
+ Identity identity = Identity.instance();
+
+ assertFalse(identity.isLoggedIn());
+
+ identity.setUsername("gavin");
+ identity.setPassword("foobar");
+ identity.login();
+
+ User user = (User) Component.getInstance("user");
+ assertEquals("Gavin King", user.getName());
+ assertEquals("gavin", user.getUsername());
+ assertEquals("foobar", user.getPassword());
+ assertFalse(Manager.instance().isLongRunningConversation());
+ assertTrue(identity.isLoggedIn());
+
+ identity.logout();
+ assertTrue(Session.instance().isInvalid());
+
+ assertFalse(identity.isLoggedIn());
+ }
+}
Added: branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/resources/arquillian.xml
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/resources/arquillian.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added: branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/resources/components.xml
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/resources/components.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added: branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/resources/persistence.xml
===================================================================
(Binary files differ)
Property changes on: branches/enterprise/WFK-2_1/examples/jee6/jee6-web/src/test/resources/persistence.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
More information about the seam-commits
mailing list