Author: maschmid
Date: 2013-06-03 13:19:25 -0400 (Mon, 03 Jun 2013)
New Revision: 15531
Added:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/Deployments.java
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/DisplayArtistTest.java
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/DisplayDiscTest.java
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/EditArtistTest.java
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/EditDiscTest.java
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/LoginTest.java
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/TestStrings.java
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/arquillian.xml
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/artist.page.xml
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/artists.page.xml
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/components.xml
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/disc.page.xml
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/discs.page.xml
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/jboss-deployment-structure.xml
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/login.page.xml
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/org/
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/org/jboss/
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/org/jboss/seam/
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/org/jboss/seam/example/
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/org/jboss/seam/example/seamdiscs/
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/org/jboss/seam/example/seamdiscs/test/
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/org/jboss/seam/example/seamdiscs/test/BaseData.xml
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/pages.xml
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/persistence.xml
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/web.xml
Removed:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-tests/
Modified:
branches/enterprise/WFK-2_1/examples/seamdiscs/pom.xml
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ear/pom.xml
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/pom.xml
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-web/pom.xml
Log:
migrated seamdiscs
Modified: branches/enterprise/WFK-2_1/examples/seamdiscs/pom.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/seamdiscs/pom.xml 2013-06-03 17:07:17 UTC (rev
15530)
+++ branches/enterprise/WFK-2_1/examples/seamdiscs/pom.xml 2013-06-03 17:19:25 UTC (rev
15531)
@@ -3,27 +3,49 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.seam.examples</groupId>
<artifactId>seamdiscs</artifactId>
- <parent>
- <groupId>org.jboss.seam</groupId>
- <artifactId>examples</artifactId>
- <version>2.3.1.Final-redhat-2</version>
- </parent>
+ <version>2.3.1.Final-redhat-2</version>
+
<packaging>pom</packaging>
<name>Seamdiscs Example</name>
<properties>
<example.name>seamdiscs</example.name>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <maven.compiler.target>1.6</maven.compiler.target>
+ <maven.compiler.source>1.6</maven.compiler.source>
+
+ <!-- To use jacoco, set jacoco.agent system property to something like
+
-javaagent:/path/to/jacocoagent.jar=append=true,destfile=/path/to/output/jacoco.exec
-->
+ <jacoco.agent />
+
+ <!-- To use custom Maven settings with ShrinkWrap Resolver, uncomment
+ and customize the following property. -->
+
<!--<maven.user.settings>/path/to/custom/settings.xml</maven.user.settings>-->
+
+ <version.commons.logging>1.1.1</version.commons.logging>
+
<version.shrinkwrap.resolver>2.0.0-beta-4</version.shrinkwrap.resolver>
+
+ <!-- Plugin versions -->
+ <version.dependency.plugin>2.5.1</version.dependency.plugin>
+ <version.surefire.plugin>2.10</version.surefire.plugin>
+ <version.resources.plugin>2.6</version.resources.plugin>
+ <version.compiler.plugin>2.3.1</version.compiler.plugin>
+ <version.ear.plugin>2.6</version.ear.plugin>
+ <version.war.plugin>2.1.1</version.war.plugin>
+ <version.ejb.plugin>2.3</version.ejb.plugin>
+ <version.jboss.maven.plugin>7.4.Final</version.jboss.maven.plugin>
</properties>
<modules>
<module>seamdiscs-ear</module>
<module>seamdiscs-ejb</module>
<module>seamdiscs-web</module>
- <module>seamdiscs-tests</module>
+
</modules>
<dependencyManagement>
<dependencies>
+ <!-- Modules -->
<dependency>
<groupId>org.jboss.seam.examples.seamdiscs</groupId>
<artifactId>seamdiscs-ejb</artifactId>
@@ -41,6 +63,94 @@
<artifactId>seamdiscs-ear</artifactId>
<version>${project.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.trinidad</groupId>
+ <artifactId>trinidad-api</artifactId>
+ <version>2.0.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.trinidad</groupId>
+ <artifactId>trinidad-impl</artifactId>
+ <version>2.0.1</version>
+ </dependency>
+
+ <!-- BOMs -->
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-bom</artifactId>
+ <version>${version.shrinkwrap.resolver}</version>
+ <scope>import</scope>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>bom</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+
+ <!-- Common provided dependencies -->
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>${version.commons.logging}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- TestNG is not necessary -->
+ <dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>jboss-seam</artifactId>
+ <version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
</dependencies>
</dependencyManagement>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <!-- Manage plugin versions for build stability -->
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${version.surefire.plugin}</version>
+ <configuration>
+ <systemPropertyVariables>
+
<org.apache.maven.user-settings>${maven.user.settings}</org.apache.maven.user-settings>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>${version.dependency.plugin}</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>${version.resources.plugin}</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>${version.compiler.plugin}</version>
+ <configuration>
+ <source>${maven.compiler.source}</source>
+ <target>${maven.compiler.target}</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
</project>
Modified: branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ear/pom.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ear/pom.xml 2013-06-03
17:07:17 UTC (rev 15530)
+++ branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ear/pom.xml 2013-06-03
17:19:25 UTC (rev 15531)
@@ -48,10 +48,20 @@
<build>
<finalName>seam-seamdiscs</finalName>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.jboss.as.plugins</groupId>
+ <artifactId>jboss-as-maven-plugin</artifactId>
+ <version>${version.jboss.maven.plugin}</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
+ <version>${version.ear.plugin}</version>
<configuration>
<version>6</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
Modified: branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/pom.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/pom.xml 2013-06-03
17:07:17 UTC (rev 15530)
+++ branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/pom.xml 2013-06-03
17:19:25 UTC (rev 15531)
@@ -49,6 +49,117 @@
<groupId>org.apache.myfaces.trinidad</groupId>
<artifactId>trinidad-api</artifactId>
</dependency>
+
+ <!-- Test dependencies -->
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-depchain</artifactId>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.dbunit</groupId>
+ <artifactId>dbunit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.protocol</groupId>
+ <artifactId>arquillian-protocol-servlet</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
-
+
+ <profiles>
+ <profile>
+ <id>integration-tests</id>
+ <activation>
+ <property>
+ <name>arquillian</name>
+ </property>
+ </activation>
+ <properties>
+
<jndiPattern>java:app/seam-seamdiscs/#{ejbName}</jndiPattern>
+ <distributable>false</distributable>
+ </properties>
+ <build>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>arq-jbossas-7-managed</id>
+ <activation>
+ <property>
+ <name>arquillian</name>
+ <value>jbossas-managed-7</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+
<artifactId>jboss-as-arquillian-container-managed</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+
+ <profile>
+ <id>arq-jbossas-7-remote</id>
+ <activation>
+ <property>
+ <name>arquillian</name>
+ <value>jbossas-remote-7</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+
<artifactId>jboss-as-arquillian-container-remote</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+ <build>
+ <plugins>
+ <!-- Skip tests by default -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
Added:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/Deployments.java
===================================================================
---
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/Deployments.java
(rev 0)
+++
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/Deployments.java 2013-06-03
17:19:25 UTC (rev 15531)
@@ -0,0 +1,81 @@
+package org.jboss.seam.example.seamdiscs.test;
+
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.resolver.api.maven.Maven;
+
+import java.io.File;
+
+public class Deployments {
+ public static WebArchive seamdiscsDeployment() {
+ 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();
+
+ File[] dbunitLibs = Maven.resolver().loadPomFromFile("pom.xml")
+ .resolve("org.dbunit:dbunit:jar:2.2")
+ .withoutTransitivity().asFile();
+
+ WebArchive war = ShrinkWrap.create(WebArchive.class,
"seam-seamdiscs.war")
+ .addPackages(true, "org.jboss.seam.example.seamdiscs")
+ .addPackages(true, "org.jboss.seam.trinidad")
+ .addClasses(TestStrings.class)
+
+ // already in EJB module
+ .addAsResource("import.sql", "import.sql")
+ .addAsResource("seam.properties", "seam.properties")
+ .addAsWebInfResource("META-INF/ejb-jar.xml",
"ejb-jar.xml")
+
+ // test specific persistence.xml
+ .addAsResource("persistence.xml",
"META-INF/persistence.xml")
+
+ // manually copied from Web module
+ .addAsWebInfResource("pages.xml", "pages.xml")
+ .addAsWebResource("login.page.xml",
"login.page.xml")
+ .addAsWebResource("artist.page.xml",
"artist.page.xml")
+ .addAsWebResource("artists.page.xml",
"artists.page.xml")
+ .addAsWebResource("disc.page.xml", "disc.page.xml")
+ .addAsWebResource("discs.page.xml",
"discs.page.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-restbay
+
+ // manually copied from EAR module
+ .addAsWebInfResource("jboss-deployment-structure.xml",
"jboss-deployment-structure.xml")
+
+ //
+
.addAsResource("org/jboss/seam/example/seamdiscs/test/BaseData.xml",
"org/jboss/seam/example/seamdiscs/test/BaseData.xml")
+
+ .addAsLibraries(libs)
+ .addAsLibraries(dbunitLibs);
+
+ return war;
+
+/*
+ EnterpriseArchive ear = ShrinkWrap.create(ZipImporter.class,
"seam-seamdiscs.ear").importFrom(new
File("../seamdiscs-ear/target/seam-seamdiscs.ear"))
+ .as(EnterpriseArchive.class);
+
+ // Install org.jboss.seam.mock.MockSeamListener
+ WebArchive web = ear.getAsType(WebArchive.class, "seamdiscs-web.war");
+ web.delete("/WEB-INF/web.xml");
+ web.addAsWebInfResource("web.xml");
+
+ web.delete("/WEB-INF/faces-config.xml");
+
+ web.addAsResource("org/jboss/seam/example/seamdiscs/test/BaseData.xml",
"org/jboss/seam/example/seamdiscs/test/BaseData.xml");
+
+ JavaArchive ejb = ear.getAsType(JavaArchive.class,
"seamdiscs-ejb.jar");
+ ejb.addClasses(TestStrings.class);
+
+ ear.addAsLibraries(DependencyResolvers.use(MavenDependencyResolver.class)
+ .configureFrom("pom.xml")
+ .artifact("org.dbunit:dbunit:jar:2.2")
+ .resolveAsFiles());
+
+ return ear;*/
+ }
+}
Added:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/DisplayArtistTest.java
===================================================================
---
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/DisplayArtistTest.java
(rev 0)
+++
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/DisplayArtistTest.java 2013-06-03
17:19:25 UTC (rev 15531)
@@ -0,0 +1,202 @@
+package org.jboss.seam.example.seamdiscs.test;
+
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.ARTIST1_NAME;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.ARTIST2_NAME;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.ARTIST3_NAME;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.ARTIST4_NAME;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.ARTIST5_NAME;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.ARTIST6_NAME;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.model.DataModel;
+
+import org.apache.myfaces.trinidad.model.CollectionModel;
+import org.apache.myfaces.trinidad.model.SortCriterion;
+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.example.seamdiscs.model.Artist;
+import org.jboss.seam.example.seamdiscs.model.Band;
+import org.jboss.seam.mock.DBJUnitSeamTest;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.runner.RunWith;
+import org.junit.Test;
+
+(a)RunWith(Arquillian.class)
+public class DisplayArtistTest extends DBJUnitSeamTest
+{
+ @Deployment(name="DisplayArtistTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment()
+ {
+ return Deployments.seamdiscsDeployment();
+ }
+
+ @Override
+ protected void prepareDBUnitOperations() {
+
+ setDatabase("HSQL");
+ setDatasourceJndiName("java:/jboss/datasources/ExampleDS");
+
+ beforeTestOperations.add(
+ new
DataSetOperation("org/jboss/seam/example/seamdiscs/test/BaseData.xml")
+ );
+ }
+
+ @Test
+ public void testDisplayArtists() throws Exception
+ {
+ new NonFacesRequest("/artists.xhtml")
+ {
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ Object artists = getValue("#{artists.dataModel}");
+ assert artists instanceof DataModel;
+ DataModel artistsDataModel = (DataModel) artists;
+
+ // Check for the correct number of results
+ assert artistsDataModel.getRowCount() == 6;
+
+ // Check for correct ordering
+ assertArtist(artistsDataModel, 0, ARTIST5_NAME);
+ assertArtist(artistsDataModel, 1, ARTIST6_NAME);
+ assertArtist(artistsDataModel, 2, ARTIST1_NAME);
+ assertArtist(artistsDataModel, 3, ARTIST4_NAME);
+ assertArtist(artistsDataModel, 4, ARTIST2_NAME);
+ assertArtist(artistsDataModel, 5, ARTIST3_NAME);
+ }
+
+ }.run();
+ }
+
+ @Test
+ public void testFilterArtists() throws Exception
+ {
+ new FacesRequest("/artists.xhtml")
+ {
+
+ @Override
+ protected void updateModelValues() throws Exception
+ {
+ setValue("#{exampleArtist.name}", "r");
+ }
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ Object artists = getValue("#{artists.dataModel}");
+ assert artists instanceof DataModel;
+ DataModel artistsDataModel = (DataModel) artists;
+
+ // Check for the correct number of results
+ assert artistsDataModel.getRowCount() == 2;
+
+ // Check for correct ordering
+ assertArtist(artistsDataModel, 0, ARTIST5_NAME);
+ assertArtist(artistsDataModel, 1, ARTIST6_NAME);
+ }
+
+ }.run();
+
+ new FacesRequest("/artists.xhtml")
+ {
+
+ @Override
+ protected void updateModelValues() throws Exception
+ {
+ setValue("#{exampleArtist.name}", "Ri");
+ }
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ Object artists = getValue("#{artists.dataModel}");
+ assert artists instanceof DataModel;
+ DataModel artistsDataModel = (DataModel) artists;
+
+ // Check for the correct number of results
+ assert artistsDataModel.getRowCount() == 1;
+
+ // Check for correct ordering
+ assertArtist(artistsDataModel, 0, ARTIST6_NAME);
+ }
+
+ }.run();
+ }
+
+ @Test
+ public void testSeamCollectionModel() throws Exception
+ {
+ new NonFacesRequest("/artists.xhtml")
+ {
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ Object artists = getValue("#{artists.dataModel}");
+
+ assert artists instanceof CollectionModel;
+ CollectionModel collectionModel = (CollectionModel) artists;
+
+ // Reorder the list
+ List<SortCriterion> criteria = new
ArrayList<SortCriterion>();
+ criteria.add(new SortCriterion("artist.name", true));
+ collectionModel.setSortCriteria(criteria);
+
+ // Check for correct ordering
+ assertArtist(collectionModel, 5, ARTIST5_NAME);
+ assertArtist(collectionModel, 4, ARTIST6_NAME);
+ assertArtist(collectionModel, 3, ARTIST1_NAME);
+ assertArtist(collectionModel, 2, ARTIST4_NAME);
+ assertArtist(collectionModel, 1, ARTIST2_NAME);
+ assertArtist(collectionModel, 0, ARTIST3_NAME);
+ }
+
+ }.run();
+ }
+
+ @Test
+ public void testDisplayArtist() throws Exception
+ {
+ // TODO Test navigation, but need a MockNavigationHandler
+ new NonFacesRequest("/artists.xhtml")
+ {
+ @Override
+ protected void beforeRequest()
+ {
+ setParameter("actionOutcome", "artist");
+ setParameter("artistId", "1");
+ }
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ assert ((Integer) 1).equals(getValue("#{artistHome.id}"));
+ Object object = null;
+ object = getValue("#{artist}");
+ assert object instanceof Band;
+ Band artist1 = (Band) object;
+ assert ARTIST1_NAME.equals(artist1.getName());
+ assert artist1.getBandMembers().size() == 3;
+ }
+ }.run();
+ }
+
+
+
+ private void assertArtist(DataModel dataModel, int row, String name)
+ {
+ dataModel.setRowIndex(row);
+ Object rowData = dataModel.getRowData();
+ assert rowData instanceof Artist;
+ Artist artist = (Artist) rowData;
+ assert name.equals(artist.getName());
+ }
+
+}
Added:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/DisplayDiscTest.java
===================================================================
---
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/DisplayDiscTest.java
(rev 0)
+++
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/DisplayDiscTest.java 2013-06-03
17:19:25 UTC (rev 15531)
@@ -0,0 +1,115 @@
+package org.jboss.seam.example.seamdiscs.test;
+
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.DISC1_ARTIST;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.DISC1_NAME;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.DISC2_ARTIST;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.DISC2_NAME;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.DISC3_ARTIST;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.DISC3_NAME;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.DISC4_ARTIST;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.DISC4_NAME;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.DISC5_ARTIST;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.DISC5_NAME;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.DISC6_ARTIST;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.DISC6_NAME;
+
+import javax.faces.model.DataModel;
+
+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.example.seamdiscs.model.Disc;
+import org.jboss.seam.mock.DBJUnitSeamTest;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.runner.RunWith;
+import org.junit.Test;
+
+(a)RunWith(Arquillian.class)
+public class DisplayDiscTest extends DBJUnitSeamTest
+{
+ @Deployment(name="DisplayDiscTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment()
+ {
+ return Deployments.seamdiscsDeployment();
+ }
+
+ @Override
+ protected void prepareDBUnitOperations() {
+ setDatabase("HSQL");
+ setDatasourceJndiName("java:/jboss/datasources/ExampleDS");
+
+ beforeTestOperations.add(
+ new
DataSetOperation("org/jboss/seam/example/seamdiscs/test/BaseData.xml")
+ );
+ }
+
+ @Test
+ public void testDisplayDiscs() throws Exception
+ {
+ new FacesRequest("/discs.xhtml")
+ {
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ Object discs = getValue("#{discs.dataModel}");
+ assert discs instanceof DataModel;
+ DataModel dataModel = (DataModel) discs;
+
+ // Check for the correct number of results
+ assert dataModel.getRowCount() == 6;
+
+ // Check for correct ordering
+ assertDisc(dataModel, 0, DISC5_NAME, DISC5_ARTIST);
+ assertDisc(dataModel, 1, DISC6_NAME, DISC6_ARTIST);
+ assertDisc(dataModel, 2, DISC1_NAME, DISC1_ARTIST);
+ assertDisc(dataModel, 3, DISC2_NAME, DISC2_ARTIST);
+ assertDisc(dataModel, 4, DISC4_NAME, DISC4_ARTIST);
+ assertDisc(dataModel, 5, DISC3_NAME, DISC3_ARTIST);
+ }
+
+ }.run();
+ }
+
+ @Test
+ public void testDisplayDisc() throws Exception
+ {
+ // TODO Test navigation, but need a MockNavigationHandler
+ new NonFacesRequest("/discs.xhtml")
+ {
+ @Override
+ protected void beforeRequest()
+ {
+ setParameter("actionOutcome", "disc");
+ setParameter("discId", "3");
+ }
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ assert ((Integer) 3).equals(getValue("#{discHome.id}"));
+ Object object = null;
+ object = getValue("#{disc}");
+ assert object instanceof Disc;
+ Disc disc1 = (Disc) object;
+ assert DISC3_NAME.equals(disc1.getName());
+ }
+ }.run();
+ }
+
+
+
+ private void assertDisc(DataModel dataModel, int row, String discName, String
artistName)
+ {
+ dataModel.setRowIndex(row);
+ Object rowData = dataModel.getRowData();
+ assert rowData instanceof Disc;
+ Disc disc = (Disc) rowData;
+ assert discName.equals(disc.getName());
+ assert artistName.equals(disc.getArtist().getName());
+ }
+
+}
Added:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/EditArtistTest.java
===================================================================
---
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/EditArtistTest.java
(rev 0)
+++
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/EditArtistTest.java 2013-06-03
17:19:25 UTC (rev 15531)
@@ -0,0 +1,356 @@
+/**
+ *
+ */
+package org.jboss.seam.example.seamdiscs.test;
+
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.ARTIST1_NAME;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.ARTIST4_NAME;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.ARTIST_NEW_DESCRIPTION;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.BANDMEMBER3_VALUE;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.NEW_ARTIST_NAME;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.NEW_BANDMEMBER_NAME;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.NEW_BAND_NAME;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.PASSWORD;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.PERSISTED;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.UPDATED;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.USERNAME;
+
+import java.util.List;
+
+import javax.el.PropertyNotFoundException;
+
+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.example.seamdiscs.model.BandMember;
+import org.jboss.seam.mock.DBJUnitSeamTest;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.runner.RunWith;
+import org.junit.Test;
+
+/**
+ * @author Pete Muir
+ *
+ */
+(a)RunWith(Arquillian.class)
+public class EditArtistTest extends DBJUnitSeamTest
+{
+ @Deployment(name="EditArtistTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment()
+ {
+ return Deployments.seamdiscsDeployment();
+ }
+
+ @Override
+ protected void prepareDBUnitOperations()
+ {
+ setDatabase("HSQL");
+ setDatasourceJndiName("java:/jboss/datasources/ExampleDS");
+
+ beforeTestOperations.add(
+ new
DataSetOperation("org/jboss/seam/example/seamdiscs/test/BaseData.xml")
+ );
+ }
+
+ @Test
+ public void testEditArtist() throws Exception
+ {
+ final String cid = new FacesRequest("/artist.xhtml")
+ {
+ @Override
+ protected void beforeRequest()
+ {
+ setParameter("artistId", "1");
+ setParameter("conversationPropagation", "join");
+ }
+
+ @Override
+ protected void updateModelValues() throws Exception {
+ setValue("#{identity.username}", USERNAME);
+ setValue("#{identity.password}", PASSWORD);
+ }
+
+ @Override
+ protected void invokeApplication() throws Exception
+ {
+ invokeAction("#{identity.login}");
+ }
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ assert (Boolean) getValue("#{identity.loggedIn}");
+ assert ((Integer) 1).equals(getValue("#{artistHome.id}"));
+ assert ARTIST1_NAME.equals(getValue("#{artist.name}"));
+ assert getValue("#{artist.description}") == null;
+ assert isLongRunningConversation();
+ assert (Boolean) getValue("#{artistHome.managed}");
+
+ }
+ }.run();
+
+ new FacesRequest("/artist.xhtml", cid)
+ {
+
+ @Override
+ protected void updateModelValues() throws Exception
+ {
+ setValue("#{artist.description}", ARTIST_NEW_DESCRIPTION);
+ assert isLongRunningConversation();
+ assert cid.equals(getConversationId());
+ }
+
+ @Override
+ protected void invokeApplication() throws Exception
+ {
+ assert UPDATED.equals(invokeAction("#{artistHome.update}"));
+ }
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ assert
ARTIST_NEW_DESCRIPTION.equals(getValue("#{artist.description"));
+ assert isLongRunningConversation();
+ }
+
+ }.run();
+ }
+
+ @Test
+ public void testAddArtist() throws Exception
+ {
+ final String cid = new FacesRequest("/artist.xhtml")
+ {
+ @Override
+ protected void beforeRequest()
+ {
+ setParameter("conversationPropagation", "join");
+ }
+
+ @Override
+ protected void updateModelValues() throws Exception {
+ setValue("#{identity.username}", USERNAME);
+ setValue("#{identity.password}", PASSWORD);
+ }
+
+ @Override
+ protected void invokeApplication() throws Exception
+ {
+ invokeAction("#{identity.login}");
+ }
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ assert (Boolean) getValue("#{identity.loggedIn}");
+ assert null == getValue("#{artistHome.id}");
+ assert null == getValue("#{artist.name}");
+ assert isLongRunningConversation();
+ assert (!(Boolean) getValue("#{artistHome.managed}"));
+ }
+ }.run();
+
+ new FacesRequest("/artist.xhtml", cid)
+ {
+
+ @Override
+ protected void updateModelValues() throws Exception
+ {
+ setValue("#{artistHome.instance.name}", NEW_ARTIST_NAME);
+ assert isLongRunningConversation();
+ }
+
+ @Override
+ protected void invokeApplication() throws Exception
+ {
+ assert
PERSISTED.equals(invokeAction("#{artistHome.persist}"));
+ }
+
+ }.run();
+
+ new FacesRequest("/artists.xhtml", cid)
+ {
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ assert new
Long("7").equals(getValue("#{artists.resultCount}"));
+ assert
NEW_ARTIST_NAME.equals(getValue("#{artists.resultList[3].name}"));
+ assert
ARTIST4_NAME.equals(getValue("#{artists.resultList[4].name}"));
+ }
+
+ }.run();
+ }
+
+ @Test
+ public void testAddBand() throws Exception
+ {
+ final String cid = new FacesRequest("/artist.xhtml")
+ {
+
+ @Override
+ protected void beforeRequest()
+ {
+ setParameter("conversationPropagation", "join");
+ }
+
+ @Override
+ protected void updateModelValues() throws Exception {
+ setValue("#{identity.username}", USERNAME);
+ setValue("#{identity.password}", PASSWORD);
+ setValue("#{artistHome.type}", "band");
+ }
+
+ @Override
+ protected void invokeApplication() throws Exception
+ {
+ invokeAction("#{identity.login}");
+ }
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ assert (Boolean) getValue("#{identity.loggedIn}");
+ assert null == getValue("#{artistHome.id}");
+ assert null == getValue("#{artist.name}");
+ try
+ {
+ assert ((Integer)
0).equals(getValue("#{artist.bandMembers.size}"));
+ }
+ catch (PropertyNotFoundException e)
+ {
+ assert false;
+ }
+ assert isLongRunningConversation();
+ assert (!(Boolean) getValue("#{artistHome.managed}"));
+ }
+ }.run();
+
+ new FacesRequest("/artist.xhtml", cid)
+ {
+
+ @Override
+ protected void updateModelValues() throws Exception
+ {
+ setValue("#{artistHome.instance.name}", NEW_BAND_NAME);
+ assert isLongRunningConversation();
+ }
+
+ @Override
+ protected void invokeApplication() throws Exception
+ {
+ assert
PERSISTED.equals(invokeAction("#{artistHome.persist}"));
+ assert ((Integer)
0).equals(getValue("#{artistHome.instance.bandMembers.size}"));
+ }
+
+ }.run();
+
+ new FacesRequest("/artists.xhtml", cid)
+ {
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ assert new
Long("7").equals(getValue("#{artists.resultCount}"));
+ assert
NEW_BAND_NAME.equals(getValue("#{artists.resultList[3].name}"));
+ assert
ARTIST4_NAME.equals(getValue("#{artists.resultList[4].name}"));
+ }
+
+ }.run();
+ }
+
+ @Test
+ public void testAddBandMember() throws Exception
+ {
+ final String cid = new FacesRequest("/artist.xhtml")
+ {
+ @Override
+ protected void beforeRequest()
+ {
+ setParameter("artistId", "1");
+ setParameter("conversationPropagation", "join");
+ }
+
+ @Override
+ protected void updateModelValues() throws Exception {
+ setValue("#{identity.username}", USERNAME);
+ setValue("#{identity.password}", PASSWORD);
+ }
+
+ @Override
+ protected void invokeApplication() throws Exception
+ {
+ invokeAction("#{identity.login}");
+ }
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ assert ARTIST1_NAME.equals(getValue("#{artist.name}"));
+ assert ((Integer)
3).equals(getValue("#{artist.bandMembers.size}"));
+ }
+ }.run();
+
+ new FacesRequest("/artist.xhtml", cid)
+ {
+
+ @Override
+ protected void invokeApplication() throws Exception
+ {
+ assert null == invokeAction("#{artistHome.addBandMember}");
+ }
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ assert ((Integer)
4).equals(getValue("#{artist.bandMembers.size}"));
+ }
+
+ }.run();
+
+ new FacesRequest("/artist.xhtml", cid)
+ {
+
+ @Override
+ protected void updateModelValues() throws Exception
+ {
+ setValue("#{artist.bandMembers[3].name}",
NEW_BANDMEMBER_NAME);
+ }
+
+ @Override
+ protected void invokeApplication() throws Exception
+ {
+ assert "updated" ==
invokeAction("#{artistHome.update}");
+ }
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ assert ((Integer) 4).equals(getValue("#{artist.size}"));
+ assert
NEW_BANDMEMBER_NAME.equals(getValue("#{artist.bandMembers[3].name}"));
+ }
+
+ }.run();
+
+ }
+
+ @Test
+ public void testBandMemberFinder() throws Exception
+ {
+ new NonFacesRequest("/artist.xhtml")
+ {
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ List<BandMember> bandMembers = (List<BandMember>)
invokeMethod("#{bandMemberFinder.getBandMembers('R')}");
+ assert bandMembers.size() == 1;
+ assert BANDMEMBER3_VALUE.equals(bandMembers.get(0).getName());
+ }
+
+ }.run();
+ }
+}
Added:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/EditDiscTest.java
===================================================================
---
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/EditDiscTest.java
(rev 0)
+++
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/EditDiscTest.java 2013-06-03
17:19:25 UTC (rev 15531)
@@ -0,0 +1,202 @@
+/**
+ *
+ */
+package org.jboss.seam.example.seamdiscs.test;
+
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.ARTIST6_NAME;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.DISC4_ARTIST;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.DISC4_NAME;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.DISC4_NEW_DESCRIPTION;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.NEW_DISC_NAME;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.PASSWORD;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.USERNAME;
+
+import javax.faces.model.DataModel;
+
+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.example.seamdiscs.model.Artist;
+import org.jboss.seam.example.seamdiscs.model.Disc;
+import org.jboss.seam.mock.DBJUnitSeamTest;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.runner.RunWith;
+import org.junit.Test;
+
+/**
+ * @author Pete Muir
+ *
+ */
+(a)RunWith(Arquillian.class)
+public class EditDiscTest extends DBJUnitSeamTest{
+
+ @Deployment(name="EditDiscTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment()
+ {
+ return Deployments.seamdiscsDeployment();
+ }
+
+ @Override
+ protected void prepareDBUnitOperations() {
+ setDatabase("HSQL");
+ setDatasourceJndiName("java:/jboss/datasources/ExampleDS");
+
+ beforeTestOperations.add(
+ new
DataSetOperation("org/jboss/seam/example/seamdiscs/test/BaseData.xml")
+ );
+ }
+
+ @Test
+ public void testEditDisc() throws Exception
+ {
+ final String cid = new FacesRequest("/disc.xhtml")
+ {
+ @Override
+ protected void beforeRequest()
+ {
+ setParameter("discId", "4");
+ setParameter("conversationPropagation", "join");
+ }
+
+ @Override
+ protected void updateModelValues() throws Exception {
+ setValue("#{identity.username}", USERNAME);
+ setValue("#{identity.password}", PASSWORD);
+ }
+
+ @Override
+ protected void invokeApplication() throws Exception
+ {
+ invokeAction("#{identity.login}");
+ }
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ assert (Boolean) getValue("#{identity.loggedIn}");
+ assert ((Integer) 4).equals(getValue("#{discHome.id}"));
+ assert DISC4_NAME.equals(getValue("#{disc.name}"));
+ assert getValue("#{disc.description}") == null;
+ assert isLongRunningConversation();
+ assert (Boolean) getValue("#{discHome.managed}");
+
+ }
+ }.run();
+
+ new FacesRequest("/disc.xhtml", cid)
+ {
+
+ @Override
+ protected void updateModelValues() throws Exception
+ {
+ setValue("#{disc.description}", DISC4_NEW_DESCRIPTION);
+ // Simulate the entity converter
+ setValue("#{exampleArtist.name}", ARTIST6_NAME);
+ Artist artist = (Artist) getValue("#{artists.singleResult}");
+ setValue("#{disc.artist}", artist);
+ assert isLongRunningConversation();
+ assert cid.equals(getConversationId());
+ }
+
+ @Override
+ protected void invokeApplication() throws Exception
+ {
+ assert
"updated".equals(invokeAction("#{discHome.update}"));
+ }
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ assert
DISC4_NEW_DESCRIPTION.equals(getValue("#{disc.description"));
+ assert DISC4_ARTIST.equals(getValue("#{disc.artist.name}"));
+ assert isLongRunningConversation();
+ }
+
+ }.run();
+ }
+
+ @Test
+ public void testAddDisc() throws Exception
+ {
+ final String cid = new FacesRequest("/disc.xhtml")
+ {
+ @Override
+ protected void beforeRequest()
+ {
+ setParameter("conversationPropagation", "join");
+ }
+
+ @Override
+ protected void updateModelValues() throws Exception {
+ setValue("#{identity.username}", USERNAME);
+ setValue("#{identity.password}", PASSWORD);
+ }
+
+ @Override
+ protected void invokeApplication() throws Exception
+ {
+ invokeAction("#{identity.login}");
+ }
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ assert (Boolean) getValue("#{identity.loggedIn}");
+ assert null == getValue("#{discHome.id}");
+ assert null == getValue("#{disc.name}");
+ assert isLongRunningConversation();
+ assert (!(Boolean) getValue("#{discHome.managed}"));
+ }
+ }.run();
+
+ new FacesRequest("/disc.xhtml", cid)
+ {
+
+ @Override
+ protected void updateModelValues() throws Exception
+ {
+ setValue("#{disc.name}", NEW_DISC_NAME);
+ assert isLongRunningConversation();
+ }
+
+ @Override
+ protected void invokeApplication() throws Exception
+ {
+ assert
"persisted".equals(invokeAction("#{discHome.persist}"));
+ }
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ assert NEW_DISC_NAME.equals(getValue("#{disc.name}"));
+ }
+
+ }.run();
+
+ new FacesRequest("/discs.xhtml", cid)
+ {
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ assert new
Long("7").equals(getValue("#{discs.resultCount}"));
+ assertDisc((DataModel) getValue("#{discs.dataModel}"), 4,
NEW_DISC_NAME);
+ assertDisc((DataModel) getValue("#{discs.dataModel}"), 5,
DISC4_NAME);
+ }
+
+ }.run();
+ }
+
+ private void assertDisc(DataModel dataModel, int row, String discName)
+ {
+ dataModel.setRowIndex(row);
+ Object rowData = dataModel.getRowData();
+ assert rowData instanceof Disc;
+ Disc disc = (Disc) rowData;
+ assert discName.equals(disc.getName());
+ }
+
+}
Added:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/LoginTest.java
===================================================================
---
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/LoginTest.java
(rev 0)
+++
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/LoginTest.java 2013-06-03
17:19:25 UTC (rev 15531)
@@ -0,0 +1,134 @@
+package org.jboss.seam.example.seamdiscs.test;
+
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.PASSWORD;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.USERNAME;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.WRONG_PASSWORD;
+import static org.jboss.seam.example.seamdiscs.test.TestStrings.WRONG_USERNAME;
+
+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.mock.DBJUnitSeamTest;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.runner.RunWith;
+import org.junit.Test;
+
+/**
+ * @author Pete Muir
+ *
+ */
+(a)RunWith(Arquillian.class)
+public class LoginTest extends DBJUnitSeamTest {
+
+ @Deployment(name="LoginTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment()
+ {
+ return Deployments.seamdiscsDeployment();
+ }
+
+ @Override
+ protected void prepareDBUnitOperations() {
+ setDatabase("HSQL");
+ setDatasourceJndiName("java:/jboss/datasources/ExampleDS");
+
+ beforeTestOperations.add(
+ new
DataSetOperation("org/jboss/seam/example/seamdiscs/test/BaseData.xml")
+ );
+ }
+
+ @Test
+ public void testLogin() throws Exception
+ {
+ new FacesRequest("/login.xhtml")
+ {
+
+ @Override
+ protected void updateModelValues() throws Exception {
+ setValue("#{identity.username}", USERNAME);
+ setValue("#{identity.password}", PASSWORD);
+ }
+
+ @Override
+ protected void invokeApplication() throws Exception
+ {
+ invokeAction("#{identity.login}");
+ }
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ assert (Boolean) getValue("#{identity.loggedIn}");
+ }
+ }.run();
+
+ new FacesRequest("/login.xhtml")
+ {
+
+ @Override
+ protected void updateModelValues() throws Exception {
+ setValue("#{identity.username}", USERNAME);
+ setValue("#{identity.password}", WRONG_PASSWORD);
+ }
+
+ @Override
+ protected void invokeApplication() throws Exception
+ {
+ invokeAction("#{identity.login}");
+ }
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ assert !((Boolean) getValue("#{identity.loggedIn}"));
+ }
+ }.run();
+
+ new FacesRequest("/login.xhtml")
+ {
+
+ @Override
+ protected void updateModelValues() throws Exception {
+ setValue("#{identity.username}", WRONG_USERNAME);
+ setValue("#{identity.password}", PASSWORD);
+ }
+
+ @Override
+ protected void invokeApplication() throws Exception
+ {
+ invokeAction("#{identity.login}");
+ }
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ assert !((Boolean) getValue("#{identity.loggedIn}"));
+ }
+ }.run();
+
+ new FacesRequest("/login.xhtml")
+ {
+
+ @Override
+ protected void updateModelValues() throws Exception {
+ setValue("#{identity.username}", WRONG_USERNAME);
+ setValue("#{identity.password}", WRONG_PASSWORD);
+ }
+
+ @Override
+ protected void invokeApplication() throws Exception
+ {
+ invokeAction("#{identity.login}");
+ }
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ assert !((Boolean) getValue("#{identity.loggedIn}"));
+ }
+ }.run();
+ }
+
+}
Added:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/TestStrings.java
===================================================================
---
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/TestStrings.java
(rev 0)
+++
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/java/org/jboss/seam/example/seamdiscs/test/TestStrings.java 2013-06-03
17:19:25 UTC (rev 15531)
@@ -0,0 +1,54 @@
+/**
+ *
+ */
+package org.jboss.seam.example.seamdiscs.test;
+
+/**
+ * @author Pete Muir
+ *
+ */
+public class TestStrings {
+
+ public static final String USERNAME = "administrator";
+ public static final String PASSWORD = "administrator";
+ public static final String WRONG_USERNAME = "wrongUsername";
+ public static final String WRONG_PASSWORD = "wrongPassword";
+
+
+ public static final String ARTIST1_NAME = "Pink Floyd";
+ public static final String ARTIST2_NAME = "Fairport Convention";
+ public static final String ARTIST3_NAME = "Bob Dylan";
+ public static final String ARTIST4_NAME = "Led Zepplin";
+ public static final String ARTIST5_NAME = "Ry Cooder";
+ public static final String ARTIST6_NAME = "Richard Thompson";
+ public static final String ARTIST_NEW_DESCRIPTION = "A great band";
+ public static final String NEW_ARTIST_NAME = "Pete Muir";
+
+
+
+ public static final String NEW_DISC_NAME = "Pete Muir's Debut Album";
+ public static final String DISC1_NAME = "Dark Side of the Moon";
+ public static final String DISC1_ARTIST = ARTIST1_NAME;
+ public static final String DISC2_NAME = "Liege and Lief";
+ public static final String DISC2_ARTIST = ARTIST2_NAME;
+ public static final String DISC3_NAME = "The Wall";
+ public static final String DISC3_ARTIST = ARTIST1_NAME;
+ public static final String DISC4_NAME = "The Freewheelin' Bob Dylan";
+ public static final String DISC4_ARTIST = ARTIST3_NAME;
+ public static final String DISC4_NEW_DESCRIPTION = "A classic album";
+ public static final String DISC5_NAME = "Blood on the Tracks";
+ public static final String DISC5_ARTIST = ARTIST3_NAME;
+ public static final String DISC6_NAME = "Chavez Ravine";
+ public static final String DISC6_ARTIST = ARTIST5_NAME;
+
+ public static final String NEW_BAND_NAME = "Pete Muir's Band";
+ public static final String NEW_BANDMEMBER_NAME = "Gavin King";
+ public static final String BANDMEMBER3_VALUE = "Roger Waters";
+
+ public static final String PERSISTED = "persisted";
+ public static final String UPDATED = "updated";
+
+
+
+
+}
Added:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/arquillian.xml
===================================================================
(Binary files differ)
Property changes on:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/arquillian.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/artist.page.xml
===================================================================
(Binary files differ)
Property changes on:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/artist.page.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/artists.page.xml
===================================================================
(Binary files differ)
Property changes on:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/artists.page.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/components.xml
===================================================================
(Binary files differ)
Property changes on:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/components.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/disc.page.xml
===================================================================
(Binary files differ)
Property changes on:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/disc.page.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/discs.page.xml
===================================================================
(Binary files differ)
Property changes on:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/discs.page.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/jboss-deployment-structure.xml
===================================================================
---
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/jboss-deployment-structure.xml
(rev 0)
+++
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/jboss-deployment-structure.xml 2013-06-03
17:19:25 UTC (rev 15531)
@@ -0,0 +1,12 @@
+<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
+ <deployment>
+ <dependencies>
+ <module name="org.hibernate" export="true"/>
+ <module name="javax.faces.api" export="true"/>
+ <module name="com.sun.jsf-impl" export="true"/>
+ <module name="org.apache.commons.collections"
export="true"/>
+ <module name="org.dom4j" export="true"/>
+ <module name="org.antlr" export="true"/>
+ </dependencies>
+ </deployment>
+</jboss-deployment-structure>
\ No newline at end of file
Added:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/login.page.xml
===================================================================
(Binary files differ)
Property changes on:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/login.page.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/org/jboss/seam/example/seamdiscs/test/BaseData.xml
===================================================================
(Binary files differ)
Property changes on:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/org/jboss/seam/example/seamdiscs/test/BaseData.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/pages.xml
===================================================================
(Binary files differ)
Property changes on:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/pages.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/persistence.xml
===================================================================
(Binary files differ)
Property changes on:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/persistence.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/web.xml
===================================================================
(Binary files differ)
Property changes on:
branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-ejb/src/test/resources/web.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Modified: branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-web/pom.xml
===================================================================
--- branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-web/pom.xml 2013-06-03
17:07:17 UTC (rev 15530)
+++ branches/enterprise/WFK-2_1/examples/seamdiscs/seamdiscs-web/pom.xml 2013-06-03
17:19:25 UTC (rev 15531)
@@ -75,6 +75,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
+ <version>${version.war.plugin}</version>
<configuration>
<webResources>
<resource>