Seam SVN: r14610 - branches/community/Seam_2_3/seam-reference-guide/src/docbook/en-US.
by seam-commits@lists.jboss.org
Author: maschmid
Date: 2012-04-19 11:48:58 -0400 (Thu, 19 Apr 2012)
New Revision: 14610
Modified:
branches/community/Seam_2_3/seam-reference-guide/src/docbook/en-US/Testing.xml
Log:
update testing docs wrt. MockSeamListener
Modified: branches/community/Seam_2_3/seam-reference-guide/src/docbook/en-US/Testing.xml
===================================================================
--- branches/community/Seam_2_3/seam-reference-guide/src/docbook/en-US/Testing.xml 2012-04-19 15:35:53 UTC (rev …
[View More]14609)
+++ branches/community/Seam_2_3/seam-reference-guide/src/docbook/en-US/Testing.xml 2012-04-19 15:48:58 UTC (rev 14610)
@@ -825,17 +825,20 @@
</note>
<para>
- The changes that still has to be done are:
+ The following changes must be done to run a SeamTest with Arquillian:
</para>
<itemizedlist>
<listitem>
- <para>Creating the <literal>@Deployment</literal> method.</para>
+ <para>Create the <literal>@Deployment</literal> method.</para>
</listitem>
<listitem>
- <para>Converting the test to JUnit. A <literal>JUnitSeamTest</literal>
+ <para>Convert the test to JUnit. A <literal>JUnitSeamTest</literal>
class can now be used instead of the original <literal>SeamTest</literal>.</para>
</listitem>
+ <listitem>
+ <para>Replace the <literal>SeamListener</literal> with <literal>org.jboss.seam.mock.MockSeamListener</literal> in web.xml.</para>
+ </listitem>
</itemizedlist>
@@ -853,6 +856,11 @@
.as(EnterpriseArchive.class);
WebArchive web = er.getAsType(WebArchive.class, "registration-web.war");
web.addClasses(RegisterTest.class);
+
+ // Replacing the SeamListener with MockSeamListener
+ web.delete("/WEB-INF/web.xml");
+ web.addAsWebInfResource("WEB-INF/mock-web.xml", "web.xml");
+
return er;
}
@@ -881,6 +889,25 @@
}]]></programlisting>
</example>
+
+ <example>
+ <title>mock-web.xml</title>
+ <programlisting role="XML"><![CDATA[
+<?xml version="1.0" ?>
+<web-app version="3.0"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+
+ <listener>
+ <listener-class>org.jboss.seam.mock.MockSeamListener</listener-class>
+ </listener>
+
+</web-app>
+]]></programlisting>
+
+ </example>
+
</section>
</section>
[View Less]
12 years, 11 months
Seam SVN: r14609 - in branches/community/Seam_2_3/examples-ee6/tasks: tasks-ear/src/main/application/META-INF and 2 other directories.
by seam-commits@lists.jboss.org
Author: rsmeral
Date: 2012-04-19 11:35:53 -0400 (Thu, 19 Apr 2012)
New Revision: 14609
Modified:
branches/community/Seam_2_3/examples-ee6/tasks/tasks-ear/pom.xml
branches/community/Seam_2_3/examples-ee6/tasks/tasks-ear/src/main/application/META-INF/jboss-deployment-structure.xml
branches/community/Seam_2_3/examples-ee6/tasks/tasks-ejb/src/main/java/org/jboss/seam/example/tasks/entity/Category.java
branches/community/Seam_2_3/examples-ee6/tasks/tasks-ejb/src/main/java/org/jboss/seam/…
[View More]example/tasks/entity/Task.java
branches/community/Seam_2_3/examples-ee6/tasks/tasks-ejb/src/main/resources/import.sql
Log:
tasks-tests modified
Modified: branches/community/Seam_2_3/examples-ee6/tasks/tasks-ear/pom.xml
===================================================================
--- branches/community/Seam_2_3/examples-ee6/tasks/tasks-ear/pom.xml 2012-04-19 15:30:05 UTC (rev 14608)
+++ branches/community/Seam_2_3/examples-ee6/tasks/tasks-ear/pom.xml 2012-04-19 15:35:53 UTC (rev 14609)
@@ -30,6 +30,14 @@
<type>ejb</type>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-atom-provider</artifactId>
+ </dependency>
</dependencies>
@@ -64,6 +72,17 @@
<artifactId>jboss-seam</artifactId>
<bundleFileName>jboss-seam.jar</bundleFileName>
</ejbModule>
+ <jarModule>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <bundleDir>lib</bundleDir>
+ </jarModule>
+ <jarModule>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-atom-provider</artifactId>
+ <bundleDir>lib</bundleDir>
+ </jarModule>
+
</modules>
</configuration>
</plugin>
Modified: branches/community/Seam_2_3/examples-ee6/tasks/tasks-ear/src/main/application/META-INF/jboss-deployment-structure.xml
===================================================================
--- branches/community/Seam_2_3/examples-ee6/tasks/tasks-ear/src/main/application/META-INF/jboss-deployment-structure.xml 2012-04-19 15:30:05 UTC (rev 14608)
+++ branches/community/Seam_2_3/examples-ee6/tasks/tasks-ear/src/main/application/META-INF/jboss-deployment-structure.xml 2012-04-19 15:35:53 UTC (rev 14609)
@@ -1,9 +1,22 @@
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
- <deployment>
- <dependencies>
- <module name="org.dom4j" export="true"/>
- <module name="org.apache.commons.collections" export="true"/>
- <module name="javax.faces.api" export="true"/>
- </dependencies>
- </deployment>
+ <deployment>
+ <dependencies>
+ <module name="org.dom4j" export="true"/>
+ <module name="org.apache.commons.collections" export="true"/>
+ <module name="javax.faces.api" export="true"/>
+ </dependencies>
+ <exclusions>
+ <module name="org.jboss.resteasy.resteasy-jaxrs" slot="main"/>
+ <module name="org.jboss.resteasy.resteasy-jettison-provider" slot="main"/>
+ <module name="org.jboss.resteasy.resteasy-jaxb-provider" slot="main"/>
+ </exclusions>
+ </deployment>
+ <sub-deployment name="tasks-web.war">
+ <exclusions>
+ <module name="org.jboss.resteasy.resteasy-jaxrs" slot="main"/>
+ <module name="org.jboss.resteasy.resteasy-jettison-provider" slot="main"/>
+ <module name="org.jboss.resteasy.resteasy-jaxb-provider" slot="main"/>
+ <module name="org.jboss.resteasy.resteasy-yaml-provider" slot="main"/>
+ </exclusions>
+ </sub-deployment>
</jboss-deployment-structure>
Modified: branches/community/Seam_2_3/examples-ee6/tasks/tasks-ejb/src/main/java/org/jboss/seam/example/tasks/entity/Category.java
===================================================================
--- branches/community/Seam_2_3/examples-ee6/tasks/tasks-ejb/src/main/java/org/jboss/seam/example/tasks/entity/Category.java 2012-04-19 15:30:05 UTC (rev 14608)
+++ branches/community/Seam_2_3/examples-ee6/tasks/tasks-ejb/src/main/java/org/jboss/seam/example/tasks/entity/Category.java 2012-04-19 15:35:53 UTC (rev 14609)
@@ -26,6 +26,7 @@
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
@@ -66,7 +67,7 @@
}
@Id
- @GeneratedValue
+ @GeneratedValue(strategy= GenerationType.IDENTITY)
@XmlTransient
public Long getId()
{
Modified: branches/community/Seam_2_3/examples-ee6/tasks/tasks-ejb/src/main/java/org/jboss/seam/example/tasks/entity/Task.java
===================================================================
--- branches/community/Seam_2_3/examples-ee6/tasks/tasks-ejb/src/main/java/org/jboss/seam/example/tasks/entity/Task.java 2012-04-19 15:30:05 UTC (rev 14608)
+++ branches/community/Seam_2_3/examples-ee6/tasks/tasks-ejb/src/main/java/org/jboss/seam/example/tasks/entity/Task.java 2012-04-19 15:35:53 UTC (rev 14609)
@@ -23,14 +23,7 @@
import java.util.Date;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQuery;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import javax.persistence.Transient;
+import javax.persistence.*;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
@@ -55,7 +48,7 @@
private Category category;
@Id
- @GeneratedValue
+ @GeneratedValue(strategy= GenerationType.IDENTITY)
public Long getId()
{
return id;
Modified: branches/community/Seam_2_3/examples-ee6/tasks/tasks-ejb/src/main/resources/import.sql
===================================================================
--- branches/community/Seam_2_3/examples-ee6/tasks/tasks-ejb/src/main/resources/import.sql 2012-04-19 15:30:05 UTC (rev 14608)
+++ branches/community/Seam_2_3/examples-ee6/tasks/tasks-ejb/src/main/resources/import.sql 2012-04-19 15:35:53 UTC (rev 14609)
@@ -1,24 +1,24 @@
insert into User (username, password, admin) values ('demo', 'demo', false)
insert into User (username, password, admin) values ('admin', 'password', true)
-insert into Category (id, name, owner_username) values (-1, 'School', 'demo')
- insert into Task (id, name, resolved, created, updated, category_id) values (-2, 'Build the Turing machine', false, '2009-04-19 16:11:05', null, -1)
- insert into Task (id, name, resolved, created, updated, category_id) values (-3, 'Finish the RESTEasy-Seam integration example', false, '2009-04-19 16:11:05', null, -1)
- insert into Task (id, name, resolved, created, updated, category_id) values (-4, 'Learn new vocab for English conversations', false, '2009-04-19 16:11:05', null, -1)
- insert into Task (id, name, resolved, created, updated, category_id) values (-5, 'Prepare a presentation for webdesign seminar', false, '2009-04-19 16:11:05', null, -1)
+insert into Category (id, name, owner_username) values (1, 'School', 'demo')
+ insert into Task (id, name, resolved, created, updated, category_id) values (2, 'Build the Turing machine', false, '2009-04-19 16:11:05', null, 1)
+ insert into Task (id, name, resolved, created, updated, category_id) values (3, 'Finish the RESTEasy-Seam integration example', false, '2009-04-19 16:11:05', null, 1)
+ insert into Task (id, name, resolved, created, updated, category_id) values (4, 'Learn new vocab for English conversations', false, '2009-04-19 16:11:05', null, 1)
+ insert into Task (id, name, resolved, created, updated, category_id) values (5, 'Prepare a presentation for webdesign seminar', false, '2009-04-19 16:11:05', null, 1)
-insert into Category (id, name, owner_username) values (-2, 'Work', 'demo')
- insert into Task (id, name, resolved, created, updated, category_id) values (-6, 'Pick up meal tickets', false, '2009-04-19 16:11:05', null, -2)
-insert into Category (id, name, owner_username) values (-3, 'Buy', 'demo')
- insert into Task (id, name, resolved, created, updated, category_id) values (-7, 'Buy milk', false, '2009-04-19 16:11:05', null, -3)
- insert into Task (id, name, resolved, created, updated, category_id) values (-8, 'Buy an infinite tape', false, '2009-04-19 16:11:05', null, -3)
- insert into Task (id, name, resolved, created, updated, category_id) values (-9, 'Order books', false, '2009-04-19 16:11:05', null, -3)
- insert into Task (id, name, resolved, created, updated, category_id) values (-10, 'Buy a turtle', true, '2009-04-19 16:11:05', '2009-04-22 13:15:33', -3)
-insert into Category (id, name, owner_username) values (-4, 'Other stuff', 'demo')
- insert into Task (id, name, resolved, created, updated, category_id) values (-11, 'Learn to fly', false, '2009-04-19 16:11:05', null, -4)
- insert into Task (id, name, resolved, created, updated, category_id) values (-12, 'Visit grandma', false, '2009-04-19 16:11:05', null, -4)
- insert into Task (id, name, resolved, created, updated, category_id) values (-13, 'Extend passport', false, '2009-04-19 16:11:05', null, -4)
- insert into Task (id, name, resolved, created, updated, category_id) values (-14, 'Get a haircut', false, '2009-04-19 16:11:05', null, -4)
+insert into Category (id, name, owner_username) values (2, 'Work', 'demo')
+ insert into Task (id, name, resolved, created, updated, category_id) values (6, 'Pick up meal tickets', false, '2009-04-19 16:11:05', null, 2)
+insert into Category (id, name, owner_username) values (3, 'Buy', 'demo')
+ insert into Task (id, name, resolved, created, updated, category_id) values (7, 'Buy milk', false, '2009-04-19 16:11:05', null, 3)
+ insert into Task (id, name, resolved, created, updated, category_id) values (8, 'Buy an infinite tape', false, '2009-04-19 16:11:05', null, 3)
+ insert into Task (id, name, resolved, created, updated, category_id) values (9, 'Order books', false, '2009-04-19 16:11:05', null, 3)
+ insert into Task (id, name, resolved, created, updated, category_id) values (10, 'Buy a turtle', true, '2009-04-19 16:11:05', '2009-04-22 13:15:33', 3)
+insert into Category (id, name, owner_username) values (4, 'Other stuff', 'demo')
+ insert into Task (id, name, resolved, created, updated, category_id) values (11, 'Learn to fly', false, '2009-04-19 16:11:05', null, 4)
+ insert into Task (id, name, resolved, created, updated, category_id) values (12, 'Visit grandma', false, '2009-04-19 16:11:05', null, 4)
+ insert into Task (id, name, resolved, created, updated, category_id) values (13, 'Extend passport', false, '2009-04-19 16:11:05', null, 4)
+ insert into Task (id, name, resolved, created, updated, category_id) values (14, 'Get a haircut', false, '2009-04-19 16:11:05', null, 4)
-insert into Category (id, name, owner_username) values (-5, 'Administration', 'admin')
-insert into Task (id, name, resolved, created, updated, category_id) values (-15, 'Ban demo user :-)', false, '2009-05-04 12:35:13', null, -5)
+insert into Category (id, name, owner_username) values (5, 'Administration', 'admin')
+insert into Task (id, name, resolved, created, updated, category_id) values (15, 'Ban demo user :-)', false, '2009-05-04 12:35:13', null, 5)
[View Less]
12 years, 11 months
Seam SVN: r14608 - in branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests: src/test/java/org/jboss/seam/example/quartz/test and 2 other directories.
by seam-commits@lists.jboss.org
Author: maschmid
Date: 2012-04-19 11:30:05 -0400 (Thu, 19 Apr 2012)
New Revision: 14608
Added:
branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/Deployments.java
branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/resources-integration/arquillian.xml
branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/resources-integration/web.xml
Modified:
branches/community/Seam_2_3/examples-ee6/quartz/…
[View More]quartz-tests/pom.xml
branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/AccountTest.java
branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/AsynchronousTest.java
branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/CronTest.java
branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/EventsTest.java
branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/OnceTest.java
branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/RepeatingTest.java
branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/TestPaymentController.java
branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/TestPaymentProcessor.java
branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/resources/WEB-INF/components.xml
Log:
quartz example integration test
Modified: branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/pom.xml
===================================================================
--- branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/pom.xml 2012-04-19 15:28:21 UTC (rev 14607)
+++ branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/pom.xml 2012-04-19 15:30:05 UTC (rev 14608)
@@ -57,10 +57,41 @@
<artifactId>functional-tests</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>
+
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-api-maven</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.dbunit</groupId>
<artifactId>dbunit</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.spec.javax.el</groupId>
+ <artifactId>jboss-el-api_2.2_spec</artifactId>
+ </dependency>
+
</dependencies>
<build>
@@ -70,13 +101,8 @@
<filtering>true</filtering>
</testResource>
<testResource>
- <directory>${basedir}/../quartz-ear/src/main/resources</directory>
- <filtering>true</filtering>
+ <directory>src/test/resources-integration</directory>
</testResource>
- <testResource>
- <directory>${basedir}/../quartz-web/src/main/resources</directory>
- <filtering>true</filtering>
- </testResource>
</testResources>
<plugins>
<plugin>
@@ -90,7 +116,45 @@
</build>
<profiles>
+
<profile>
+ <id>integration-tests</id>
+ <activation>
+ <property>
+ <name>arquillian</name>
+ </property>
+ </activation>
+ </profile>
+
+ <profile>
+ <id>arq-jbossas-7-managed</id>
+ <activation>
+ <property>
+ <name>arquillian</name>
+ <value>jbossas-managed-7</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>arq-jbossas-7-remote</id>
+ <activation>
+ <property>
+ <name>arquillian</name>
+ <value>jbossas-remote-7</value>
+ </property>
+ </activation>
+ </profile>
+
+ <profile>
<id>ftest-jbossas</id>
<properties>
<example.context.path>seam-quartz</example.context.path>
Modified: branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/AccountTest.java
===================================================================
--- branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/AccountTest.java 2012-04-19 15:28:21 UTC (rev 14607)
+++ branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/AccountTest.java 2012-04-19 15:30:05 UTC (rev 14608)
@@ -2,24 +2,45 @@
import java.util.List;
+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.quartz.Account;
import org.jboss.seam.example.quartz.Payment;
-import org.jboss.seam.mock.DBUnitSeamTest;
-import org.testng.annotations.Test;
-import org.junit.Ignore;
+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.jboss.shrinkwrap.resolver.api.DependencyResolvers;
+import org.jboss.shrinkwrap.resolver.api.maven.MavenDependencyResolver;
+import org.junit.Test;
+import org.junit.runner.RunWith;
/**
*
* @author Pete Muir
*
*/
-@Ignore
+(a)RunWith(Arquillian.class)
public class AccountTest
- extends DBUnitSeamTest
+ extends DBJUnitSeamTest
{
+ @Deployment(name="AccountTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment()
+ {
+ EnterpriseArchive er = Deployments.quartzDeployment();
+ WebArchive web = er.getAsType(WebArchive.class, "quartz-web.war");
+ web.addClasses(AccountTest.class);
+ return er;
+ }
@Override
protected void prepareDBUnitOperations() {
+
+ setDatabase("HSQL");
+ setDatasourceJndiName("java:jboss/datasources/ExampleDS");
+
beforeTestOperations.add(
new DataSetOperation("BaseData.xml")
);
Modified: branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/AsynchronousTest.java
===================================================================
--- branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/AsynchronousTest.java 2012-04-19 15:28:21 UTC (rev 14607)
+++ branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/AsynchronousTest.java 2012-04-19 15:30:05 UTC (rev 14608)
@@ -4,11 +4,17 @@
import java.math.BigDecimal;
+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.quartz.Account;
import org.jboss.seam.example.quartz.Payment;
-import org.jboss.seam.mock.DBUnitSeamTest;
-import org.testng.annotations.Test;
-import org.junit.Ignore;
+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.Test;
+import org.junit.runner.RunWith;
/**
*
@@ -18,12 +24,25 @@
// Actually this doesn't happen in the example, but lets test it here to keep
// all quartz tests in one place
-@Ignore
-public class AsynchronousTest extends DBUnitSeamTest
+(a)RunWith(Arquillian.class)
+public class AsynchronousTest extends DBJUnitSeamTest
{
+ @Deployment(name="AsynchronousTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment()
+ {
+ EnterpriseArchive er = Deployments.quartzDeployment();
+ WebArchive web = er.getAsType(WebArchive.class, "quartz-web.war");
+ web.addClasses(AsynchronousTest.class);
+ return er;
+ }
@Override
protected void prepareDBUnitOperations() {
+
+ setDatabase("HSQL");
+ setDatasourceJndiName("java:jboss/datasources/ExampleDS");
+
beforeTestOperations.add(
new DataSetOperation("BaseData.xml")
);
Modified: branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/CronTest.java
===================================================================
--- branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/CronTest.java 2012-04-19 15:28:21 UTC (rev 14607)
+++ branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/CronTest.java 2012-04-19 15:30:05 UTC (rev 14608)
@@ -4,29 +4,47 @@
import java.math.BigDecimal;
+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.async.QuartzTriggerHandle;
import org.jboss.seam.example.quartz.Account;
import org.jboss.seam.example.quartz.Payment;
import org.jboss.seam.example.quartz.Payment.Frequency;
-import org.jboss.seam.mock.DBUnitSeamTest;
-import org.testng.annotations.Test;
-import org.junit.Ignore;
+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.Test;
+import org.junit.runner.RunWith;
/**
* @author Pete Muir
*
*/
-@Ignore
-public class CronTest extends DBUnitSeamTest
+(a)RunWith(Arquillian.class)
+public class CronTest extends DBJUnitSeamTest
{
private QuartzTriggerHandle quartzTriggerHandle;
private Long paymentId;
private static final Frequency REPEATING = EVERY_SECOND;
+ @Deployment(name="CronTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment()
+ {
+ EnterpriseArchive er = Deployments.quartzDeployment();
+ WebArchive web = er.getAsType(WebArchive.class, "quartz-web.war");
+ web.addClasses(CronTest.class);
+ return er;
+ }
@Override
protected void prepareDBUnitOperations() {
+ setDatabase("HSQL");
+ setDatasourceJndiName("java:jboss/datasources/ExampleDS");
+
beforeTestOperations.add(
new DataSetOperation("BaseData.xml")
);
@@ -36,7 +54,7 @@
- //@Test
+ @Test
public void scheduleCron() throws Exception
{
@@ -235,7 +253,7 @@
}
}
- //@Test
+ @Test
public void scheduleCronWithStartAndEndTime() throws Exception
{
Added: branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/Deployments.java
===================================================================
--- branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/Deployments.java (rev 0)
+++ branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/Deployments.java 2012-04-19 15:30:05 UTC (rev 14608)
@@ -0,0 +1,38 @@
+package org.jboss.seam.example.quartz.test;
+
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.importer.ZipImporter;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.resolver.api.DependencyResolvers;
+import org.jboss.shrinkwrap.resolver.api.maven.MavenDependencyResolver;
+
+import java.io.File;
+
+public class Deployments {
+ public static EnterpriseArchive quartzDeployment() {
+ EnterpriseArchive ear = ShrinkWrap.create(ZipImporter.class, "seam-quartz.ear").importFrom(new File("../quartz-ear/target/seam-quartz.ear"))
+ .as(EnterpriseArchive.class);
+
+ // Install org.jboss.seam.mock.MockSeamListener
+ WebArchive web = ear.getAsType(WebArchive.class, "quartz-web.war");
+ web.delete("/WEB-INF/web.xml");
+ web.addAsWebInfResource("web.xml");
+
+ web.addAsResource("BaseData.xml", "BaseData.xml");
+
+ web.delete("/WEB-INF/components.xml");
+ web.addAsWebInfResource("WEB-INF/components.xml", "components.xml");
+
+ JavaArchive ejb = ear.getAsType(JavaArchive.class, "quartz-ejb.jar");
+ ejb.addClasses(TestPaymentController.class, TestPaymentProcessor.class, TransactionStatus.class);
+
+ ear.addAsLibraries(DependencyResolvers.use(MavenDependencyResolver.class)
+ .configureFrom("pom.xml")
+ .artifact("org.dbunit:dbunit:jar:2.2")
+ .resolveAsFiles());
+
+ return ear;
+ }
+}
Modified: branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/EventsTest.java
===================================================================
--- branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/EventsTest.java 2012-04-19 15:28:21 UTC (rev 14607)
+++ branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/EventsTest.java 2012-04-19 15:30:05 UTC (rev 14608)
@@ -4,11 +4,17 @@
import java.math.BigDecimal;
+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.quartz.Account;
import org.jboss.seam.example.quartz.Payment;
-import org.jboss.seam.mock.DBUnitSeamTest;
-import org.testng.annotations.Test;
-import org.junit.Ignore;
+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.Test;
+import org.junit.runner.RunWith;
/**
*
@@ -18,12 +24,24 @@
// Actually this doesn't happen in the example, but lets test it here to keep
// all quartz tests in one place
-@Ignore
-public class EventsTest extends DBUnitSeamTest
+(a)RunWith(Arquillian.class)
+public class EventsTest extends DBJUnitSeamTest
{
-
+ @Deployment(name="EventsTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment()
+ {
+ EnterpriseArchive er = Deployments.quartzDeployment();
+ WebArchive web = er.getAsType(WebArchive.class, "quartz-web.war");
+ web.addClasses(EventsTest.class);
+ return er;
+ }
+
@Override
protected void prepareDBUnitOperations() {
+ setDatabase("HSQL");
+ setDatasourceJndiName("java:jboss/datasources/ExampleDS");
+
beforeTestOperations.add(
new DataSetOperation("BaseData.xml")
);
Modified: branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/OnceTest.java
===================================================================
--- branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/OnceTest.java 2012-04-19 15:28:21 UTC (rev 14607)
+++ branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/OnceTest.java 2012-04-19 15:30:05 UTC (rev 14608)
@@ -4,25 +4,45 @@
import java.math.BigDecimal;
+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.async.QuartzTriggerHandle;
import org.jboss.seam.example.quartz.Account;
import org.jboss.seam.example.quartz.Payment;
-import org.jboss.seam.mock.DBUnitSeamTest;
-import org.testng.annotations.Test;
+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.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
/**
*
* @author Pete Muir
*
*/
-@Ignore
-public class OnceTest extends DBUnitSeamTest
+(a)RunWith(Arquillian.class)
+public class OnceTest extends DBJUnitSeamTest
{
+ @Deployment(name="OnceTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment()
+ {
+ EnterpriseArchive er = Deployments.quartzDeployment();
+ WebArchive web = er.getAsType(WebArchive.class, "quartz-web.war");
+ web.addClasses(OnceTest.class);
+ return er;
+ }
+
private QuartzTriggerHandle quartzTriggerHandle;
@Override
protected void prepareDBUnitOperations() {
+ setDatabase("HSQL");
+ setDatasourceJndiName("java:jboss/datasources/ExampleDS");
+
beforeTestOperations.add(
new DataSetOperation("BaseData.xml")
);
@@ -30,7 +50,8 @@
- //@Test
+ @Test
+ @Ignore
public void scheduleOnce() throws Exception
{
try
Modified: branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/RepeatingTest.java
===================================================================
--- branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/RepeatingTest.java 2012-04-19 15:28:21 UTC (rev 14607)
+++ branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/RepeatingTest.java 2012-04-19 15:30:05 UTC (rev 14608)
@@ -4,23 +4,39 @@
import java.math.BigDecimal;
+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.async.QuartzTriggerHandle;
import org.jboss.seam.example.quartz.Account;
import org.jboss.seam.example.quartz.Payment;
import org.jboss.seam.example.quartz.Payment.Frequency;
-import org.jboss.seam.mock.DBUnitSeamTest;
-import org.testng.annotations.Test;
-import org.junit.Ignore;
+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.Test;
+import org.junit.runner.RunWith;
/**
*
* @author Pete Muir
*
*/
-@Ignore
+(a)RunWith(Arquillian.class)
public class RepeatingTest
- extends DBUnitSeamTest
+ extends DBJUnitSeamTest
{
+ @Deployment(name="RepeatingTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment()
+ {
+ EnterpriseArchive er = Deployments.quartzDeployment();
+ WebArchive web = er.getAsType(WebArchive.class, "quartz-web.war");
+ web.addClasses(RepeatingTest.class);
+ return er;
+ }
+
private QuartzTriggerHandle quartzTriggerHandle;
private Long paymentId;
@@ -29,6 +45,9 @@
@Override
protected void prepareDBUnitOperations() {
+ setDatabase("HSQL");
+ setDatasourceJndiName("java:jboss/datasources/ExampleDS");
+
beforeTestOperations.add(
new DataSetOperation("BaseData.xml")
);
Modified: branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/TestPaymentController.java
===================================================================
--- branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/TestPaymentController.java 2012-04-19 15:28:21 UTC (rev 14607)
+++ branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/TestPaymentController.java 2012-04-19 15:30:05 UTC (rev 14608)
@@ -15,7 +15,6 @@
import org.jboss.seam.example.quartz.Payment;
import org.jboss.seam.example.quartz.PaymentHome;
import org.jboss.seam.log.Log;
-import org.junit.Ignore;
/**
* @author Pete Muir
@@ -23,7 +22,6 @@
*/
@Name("paymentHome")
@Install(precedence=MOCK)
-@Ignore
public class TestPaymentController extends PaymentHome
{
Modified: branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/TestPaymentProcessor.java
===================================================================
--- branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/TestPaymentProcessor.java 2012-04-19 15:28:21 UTC (rev 14607)
+++ branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/java/org/jboss/seam/example/quartz/test/TestPaymentProcessor.java 2012-04-19 15:30:05 UTC (rev 14608)
@@ -19,7 +19,6 @@
import org.jboss.seam.example.quartz.Payment;
import org.jboss.seam.example.quartz.PaymentProcessor;
import org.jboss.seam.log.Log;
-import org.junit.Ignore;
/**
* @author Pete Muir
@@ -28,7 +27,6 @@
@Name("processor")
@Install(precedence=MOCK)
@AutoCreate
-@Ignore
public class TestPaymentProcessor extends PaymentProcessor
{
Modified: branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/resources/WEB-INF/components.xml
===================================================================
--- branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/resources/WEB-INF/components.xml 2012-04-19 15:28:21 UTC (rev 14607)
+++ branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/resources/WEB-INF/components.xml 2012-04-19 15:30:05 UTC (rev 14608)
@@ -43,6 +43,8 @@
<!-- Install the QuartzDispatcher -->
<async:quartz-dispatcher/>
- <core:init debug="true" jndi-pattern="seam-quartz/#{ejbName}/local" />
+ <core:init debug="true" jndi-pattern="java:app/quartz-ejb/#{ejbName}" />
+ <component class="org.jboss.seam.transaction.EjbSynchronizations" jndi-name="java:app/jboss-seam/EjbSynchronizations"/>
+
</components>
Added: branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/resources-integration/arquillian.xml
===================================================================
--- branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/resources-integration/arquillian.xml (rev 0)
+++ branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/resources-integration/arquillian.xml 2012-04-19 15:30:05 UTC (rev 14608)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://jboss.org/schema/arquillian"
+ xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
+
+ <engine>
+ <property name="deploymentExportPath">target/</property>
+ </engine>
+
+ <container qualifier="jboss" default="true">
+ <configuration>
+ <property name="javaVmArguments">-Xmx1024m -XX:MaxPermSize=512m</property>
+ <property name="jbossHome">target/jboss-as-${version.jbossas7}</property>
+ </configuration>
+ </container>
+
+</arquillian>
Added: branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/resources-integration/web.xml
===================================================================
--- branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/resources-integration/web.xml (rev 0)
+++ branches/community/Seam_2_3/examples-ee6/quartz/quartz-tests/src/test/resources-integration/web.xml 2012-04-19 15:30:05 UTC (rev 14608)
@@ -0,0 +1,12 @@
+<?xml version="1.0" ?>
+
+<web-app version="3.0"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+
+ <listener>
+ <listener-class>org.jboss.seam.mock.MockSeamListener</listener-class>
+ </listener>
+
+</web-app>
[View Less]
12 years, 11 months
Seam SVN: r14607 - in branches/community/Seam_2_3/examples-ee6/restbay/restbay-tests: src/test/java/org/jboss/seam/example/restbay/test and 1 other directory.
by seam-commits@lists.jboss.org
Author: maschmid
Date: 2012-04-19 11:28:21 -0400 (Thu, 19 Apr 2012)
New Revision: 14607
Modified:
branches/community/Seam_2_3/examples-ee6/restbay/restbay-tests/pom.xml
branches/community/Seam_2_3/examples-ee6/restbay/restbay-tests/src/test/java/org/jboss/seam/example/restbay/test/CategoryServiceDBUnitTest.java
Log:
restbay CategoryServiceDBUnitTest
Modified: branches/community/Seam_2_3/examples-ee6/restbay/restbay-tests/pom.xml
==========================================================…
[View More]=========
--- branches/community/Seam_2_3/examples-ee6/restbay/restbay-tests/pom.xml 2012-04-19 15:27:03 UTC (rev 14606)
+++ branches/community/Seam_2_3/examples-ee6/restbay/restbay-tests/pom.xml 2012-04-19 15:28:21 UTC (rev 14607)
@@ -68,6 +68,18 @@
</dependency>
<dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-api-maven</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.jboss.spec.javax.el</groupId>
<artifactId>jboss-el-api_2.2_spec</artifactId>
</dependency>
Modified: branches/community/Seam_2_3/examples-ee6/restbay/restbay-tests/src/test/java/org/jboss/seam/example/restbay/test/CategoryServiceDBUnitTest.java
===================================================================
--- branches/community/Seam_2_3/examples-ee6/restbay/restbay-tests/src/test/java/org/jboss/seam/example/restbay/test/CategoryServiceDBUnitTest.java 2012-04-19 15:27:03 UTC (rev 14606)
+++ branches/community/Seam_2_3/examples-ee6/restbay/restbay-tests/src/test/java/org/jboss/seam/example/restbay/test/CategoryServiceDBUnitTest.java 2012-04-19 15:28:21 UTC (rev 14607)
@@ -1,15 +1,23 @@
package org.jboss.seam.example.restbay.test;
import org.dbunit.operation.DatabaseOperation;
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeClass;
-import org.jboss.seam.mock.DBUnitSeamTest;
+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.seam.mock.ResourceRequestEnvironment;
import org.jboss.seam.mock.EnhancedMockHttpServletRequest;
import org.jboss.seam.mock.EnhancedMockHttpServletResponse;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.resolver.api.DependencyResolvers;
+import org.jboss.shrinkwrap.resolver.api.maven.MavenDependencyResolver;
-import org.junit.Ignore;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
import static org.jboss.seam.mock.ResourceRequestEnvironment.ResourceRequest;
import static org.jboss.seam.mock.ResourceRequestEnvironment.Method;
@@ -20,14 +28,34 @@
/**
*
*/
-@Ignore
-public class CategoryServiceDBUnitTest extends DBUnitSeamTest
+(a)RunWith(Arquillian.class)
+public class CategoryServiceDBUnitTest extends DBJUnitSeamTest
{
+ @Deployment(name="CategoryServiceDBUnitTest")
+ @OverProtocol("Servlet 3.0")
+ public static Archive<?> createDeployment()
+ {
+ EnterpriseArchive er = Deployments.restbayDeployment();
+ WebArchive web = er.getAsType(WebArchive.class, "restbay-web.war");
+ er.addAsLibraries(DependencyResolvers.use(MavenDependencyResolver.class)
+ .configureFrom("pom.xml")
+ .artifact("org.dbunit:dbunit:jar:2.2")
+ .resolveAsFiles());
+
+ web.addAsResource("org/jboss/seam/example/restbay/test/dbunitdata.xml", "org/jboss/seam/example/restbay/test/dbunitdata.xml");
+
+ web.addClasses(CategoryServiceDBUnitTest.class);
+ return er;
+ }
protected void prepareDBUnitOperations() {
- beforeTestOperations.add(
- new DataSetOperation("org/jboss/seam/example/restbay/test/dbunitdata.xml", DatabaseOperation.CLEAN_INSERT)
- );
+
+ setDatabase("hsql");
+ setDatasourceJndiName("java:/restbayDatasource");
+
+ beforeTestOperations.add(
+ new DataSetOperation("org/jboss/seam/example/restbay/test/dbunitdata.xml", DatabaseOperation.CLEAN_INSERT)
+ );
}
// Or, if you don't want shared headers between test methods, just use
@@ -36,7 +64,7 @@
// new ResourceRequest(new ResourceRequestTest(this), Method.GET, ...).run();
ResourceRequestEnvironment sharedEnvironment;
- @BeforeClass
+ @Before
public void prepareSharedEnvironment() throws Exception
{
sharedEnvironment = new ResourceRequestEnvironment(this)
[View Less]
12 years, 11 months
Seam SVN: r14606 - branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/mock.
by seam-commits@lists.jboss.org
Author: maschmid
Date: 2012-04-19 11:27:03 -0400 (Thu, 19 Apr 2012)
New Revision: 14606
Added:
branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/mock/DBJUnitSeamTest.java
Log:
port DBJUnitSeamTest, a junit version of DBUnitSeamTest
Added: branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/mock/DBJUnitSeamTest.java
===================================================================
--- branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/…
[View More]mock/DBJUnitSeamTest.java (rev 0)
+++ branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/mock/DBJUnitSeamTest.java 2012-04-19 15:27:03 UTC (rev 14606)
@@ -0,0 +1,565 @@
+package org.jboss.seam.mock;
+
+import static org.jboss.seam.mock.DBJUnitSeamTest.Database.HSQL;
+import static org.jboss.seam.mock.DBJUnitSeamTest.Database.MYSQL;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.sql.DataSource;
+
+import org.dbunit.database.DatabaseConfig;
+import org.dbunit.database.DatabaseConnection;
+import org.dbunit.database.IDatabaseConnection;
+import org.dbunit.dataset.IDataSet;
+import org.dbunit.dataset.ReplacementDataSet;
+import org.dbunit.dataset.datatype.DataType;
+import org.dbunit.dataset.datatype.DataTypeException;
+import org.dbunit.dataset.datatype.DefaultDataTypeFactory;
+import org.dbunit.dataset.xml.FlatXmlDataSet;
+import org.dbunit.operation.DatabaseOperation;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+import org.junit.After;
+import org.junit.Before;
+
+/**
+ * Utility for integration testing with Seam and DBUnit datasets.
+ * <p>
+ * Subclass this class instead of <tt>JUnitSeamTest</tt> if you need to insert or clean data in
+ * your database before and after a test. You need to implement <tt>prepareDBUnitOperations()</tt> and
+ * add instances of <tt>DataSetOperation</tt>s to the <tt>beforeTestOperations</tt> and
+ * <tt>afterTestOperations</tt> lists. An example:
+ * <pre>
+ * public class MyTest extends DBJUnitSeamTest {
+ *
+ * protected void prepareDBUnitOperations() {
+ * setDatasourceJndiName("java:/myDatasource");
+ * beforeTestOperations.add(
+ * new DataSetOperation("my/datasets/BaseData.xml")
+ * );
+ * beforeTestOperations.add(
+ * new DataSetOperation("my/datasets/AdditionalData.xml", DatabaseOperation.INSERT)
+ * );
+ * }
+ * ... // Various test methods with @Test annotation
+ * }
+ * </pre>
+ * <p>
+ * Note that <tt>DataSetOperation</tt> defaults to <tt>DatabaseOperation.CLEAN_INSERT</tt> if no
+ * other operation is specified as a constructor argument. The above example cleans all tables defined
+ * in <tt>BaseData.xml</tt>, then inserts all rows declared in <tt>BaseData.xml</tt>, then inserts
+ * all the rows declared in <tt>AdditionalData.xml</tt>. This executes before each test method
+ * is invoked. If you require extra cleanup after a test method executes, add operations to the
+ * <tt>afterTestOperations</tt> list.
+ * </p>
+ * <p>
+ * A test class obtains the database connection for loading and cleaning of datasets in one of the following ways:
+ * </p>
+ * <dl>
+ * <li>An instance of a test class is created manually and the <tt>setDatasourceJndiName()</tt> method is
+ * called after creation and before a test runs.</li>
+ * <p/>
+ * <li>A subclass overrides the <tt>getConnection()</tt> method and returns a custom database connection.</li>
+ * <p/>
+ * </dl>
+ * <p>
+ * Binary files can be imported into the database from a binary directory, configured with the TestNG parameter
+ * <tt>binaryDir</tt> or by calling <tt>setBinaryDir()</tt> before a test runs. The binary directory is a classpath
+ * reference, e.g. <tt>my/org/test/package/binarydir</tt>. In your DBUnit XML flat dataset, declare the path of your file
+ * as follows: <tt><MYTABLE MYCOLUMN="[BINARY_DIR]/mytestfile.png"/></tt>
+ * </p>
+ * <p>
+ * Referential integrity checks (foreign keys) will be or have to be disabled on the database connection
+ * used for DBUnit operations. This makes adding circular references in datasets easier (especially for nullable
+ * foreign key columns). Referential integrity checks are enabled again after the connection has been used.
+ * </p>
+ * <p>
+ * <b>IMPORTANT: The methods <tt>disableReferentialIntegrity()</tt>,
+ * <tt>enableReferentialIntegrity()</tt>, and <tt>editConfig()</tt> are implemented for HSQL and MySQL. You need to
+ * configure the DBMS you are using with the <tt>database</tt> TestNG parameter or by calling <tt>setDatabase()</tt>
+ * before the the test run. If you want to run unit tests on any other DBMS, you need to override the
+ * <tt>disableReferentialIntegrity()</tt> and <tt>enableReferentialIntegrity()</tt> methods and implement them
+ * for your DBMS. Also note that by default, if no <tt>database</tt> TestNG parameter has been set or if the
+ * <tt>setDatabase()</tt> method has not been called before test runs, HSQL DB will be used as the default.</b>
+ * </p>
+ * @author Christian Bauer
+ * @author Marek Schmidt
+ */
+public abstract class DBJUnitSeamTest extends JUnitSeamTest
+{
+
+ public enum Database
+ {
+ HSQL, MYSQL
+ }
+
+ private LogProvider log = Logging.getLogProvider(DBJUnitSeamTest.class);
+
+ protected String datasourceJndiName;
+ protected String binaryDir;
+ protected Database database = HSQL;
+ protected boolean replaceNull = true;
+ protected List<DataSetOperation> beforeTestOperations = new ArrayList<DataSetOperation>();
+ protected List<DataSetOperation> afterTestOperations = new ArrayList<DataSetOperation>();
+
+ private boolean prepared = false;
+
+ public void setDatasourceJndiName(String datasourceJndiName)
+ {
+ if (datasourceJndiName == null) return;
+ log.debug("Setting datasource name: " + datasourceJndiName);
+ this.datasourceJndiName = datasourceJndiName;
+ }
+
+ public String getDatasourceJndiName()
+ {
+ return datasourceJndiName;
+ }
+
+ public void setBinaryDir(String binaryDir)
+ {
+ if (binaryDir == null) return;
+ log.debug("Setting binary directory: " + binaryDir);
+ this.binaryDir = binaryDir;
+ }
+
+ public String getBinaryDir()
+ {
+ return binaryDir;
+ }
+
+ public void setDatabase(String database)
+ {
+ if (database == null) return;
+ log.debug("Setting database: " + database);
+ this.database = Database.valueOf(database.toUpperCase());
+ }
+
+ // We don't have a getDatabase() getter because subclasses might use a different Enum!
+
+ public void setReplaceNull(Boolean replaceNull)
+ {
+ if (replaceNull == null) return;
+ log.debug("Setting replace null: " + replaceNull);
+ this.replaceNull = replaceNull;
+ }
+
+ public Boolean isReplaceNull()
+ {
+ return replaceNull;
+ }
+
+ @Before
+ public void prepareDataBeforeTest()
+ {
+ // This is not pretty but we unfortunately can not have dependencies between @BeforeClass methods.
+ // This was a basic design mistake and we can't change it now because we need to be backwards
+ // compatible. We can only "prepare" the datasets once all @BeforeClass have been executed.
+ if (!prepared) {
+ log.debug("Before test method runs, preparing datasets");
+ prepareDBUnitOperations();
+ for (DataSetOperation beforeTestOperation : beforeTestOperations)
+ {
+ beforeTestOperation.prepare(this);
+ }
+ for (DataSetOperation afterTestOperation : afterTestOperations)
+ {
+ afterTestOperation.prepare(this);
+ }
+ prepared = true;
+ }
+
+ executeOperations(beforeTestOperations);
+ }
+
+ @After
+ public void cleanDataAfterTest()
+ {
+ executeOperations(afterTestOperations);
+ }
+
+ private void executeOperations(List<DataSetOperation> list)
+ {
+ log.debug("Executing DataSetOperations: " + list.size());
+ IDatabaseConnection con = null;
+ try
+ {
+ con = getConnection();
+ disableReferentialIntegrity(con);
+ for (DataSetOperation op : list)
+ {
+ prepareExecution(con, op);
+ op.execute(con);
+ afterExecution(con, op);
+ }
+ enableReferentialIntegrity(con);
+ }
+ finally
+ {
+ if (con != null)
+ {
+ try
+ {
+ con.close();
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace(System.err);
+ }
+ }
+ }
+ }
+
+ protected static class DataSetOperation
+ {
+
+ private LogProvider log = Logging.getLogProvider(DataSetOperation.class);
+
+ String dataSetLocation;
+ ReplacementDataSet dataSet;
+ DatabaseOperation operation;
+
+ protected DataSetOperation()
+ {
+ // Support subclassing
+ }
+
+ /**
+ * Defaults to <tt>DatabaseOperation.CLEAN_INSERT</tt>
+ *
+ * @param dataSetLocation location of DBUnit dataset
+ */
+ public DataSetOperation(String dataSetLocation)
+ {
+ this(dataSetLocation, DatabaseOperation.CLEAN_INSERT);
+ }
+
+ /**
+ * Defaults to <tt>DatabaseOperation.CLEAN_INSERT</tt>
+ *
+ * @param dataSetLocation location of DBUnit dataset
+ * @param dtdLocation optional (can be null) location of XML file DTD on classpath
+ */
+ public DataSetOperation(String dataSetLocation, String dtdLocation)
+ {
+ this(dataSetLocation, dtdLocation, DatabaseOperation.CLEAN_INSERT);
+ }
+
+ /**
+ * @param dataSetLocation location of DBUnit dataset
+ * @param operation operation to execute
+ */
+ public DataSetOperation(String dataSetLocation, DatabaseOperation operation)
+ {
+ this(dataSetLocation, null, operation);
+ }
+
+ public DataSetOperation(String dataSetLocation, String dtdLocation, DatabaseOperation operation)
+ {
+ if (dataSetLocation == null)
+ {
+ this.operation = operation;
+ return;
+ }
+
+ // Load the base dataset file
+ InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream(dataSetLocation);
+ try
+ {
+ InputStream dtdInput = null;
+ if (dtdLocation != null)
+ {
+ dtdInput = Thread.currentThread().getContextClassLoader().getResourceAsStream(dtdLocation);
+ }
+ if (dtdInput == null)
+ {
+ this.dataSet = new ReplacementDataSet(new FlatXmlDataSet(input));
+ }
+ else
+ {
+ this.dataSet = new ReplacementDataSet(new FlatXmlDataSet(input, dtdInput));
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ this.operation = operation;
+ this.dataSetLocation = dataSetLocation;
+ }
+
+ public IDataSet getDataSet()
+ {
+ return dataSet;
+ }
+
+ public DatabaseOperation getOperation()
+ {
+ return operation;
+ }
+
+ public void prepare(DBJUnitSeamTest test)
+ {
+ if (dataSet == null) return;
+ log.debug("Preparing DataSetOperation replacement values");
+
+ if (test.isReplaceNull())
+ {
+ log.debug("Replacing [NULL] placeholder with real null value");
+ dataSet.addReplacementObject("[NULL]", null);
+ }
+ if (test.getBinaryDir() != null)
+ {
+ log.debug("Replacing [BINARY_DIR] placeholder with path: " + test.getBinaryDirFullpath().toString());
+ dataSet.addReplacementSubstring("[BINARY_DIR]", test.getBinaryDirFullpath().toString());
+ }
+ }
+
+ public void execute(IDatabaseConnection connection)
+ {
+ if (dataSet == null || operation == null) return;
+ try
+ {
+ log.debug("Executing: " + this);
+ this.operation.execute(connection, dataSet);
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return getClass().getName() + " with dataset location: " + dataSetLocation;
+ }
+ }
+
+ // Subclasses can/have to override the following methods
+
+ /**
+ * Override this method if you want to provide your own DBUnit <tt>IDatabaseConnection</tt> instance.
+ * <p/>
+ * If you do not override this, default behavior is to use the * configured datasource name and
+ * to obtain a connection with a JNDI lookup.
+ *
+ * @return a DBUnit database connection (wrapped)
+ */
+ protected IDatabaseConnection getConnection()
+ {
+ try
+ {
+ if (getDatasourceJndiName() == null)
+ {
+ throw new RuntimeException("Please set datasourceJndiName");
+ }
+
+ DataSource datasource = ((DataSource) getInitialContext().lookup(getDatasourceJndiName()));
+
+ // Get a JDBC connection from JNDI datasource
+ Connection con = datasource.getConnection();
+ IDatabaseConnection dbUnitCon = new DatabaseConnection(con);
+ editConfig(dbUnitCon.getConfig());
+ return dbUnitCon;
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ /**
+ * Execute whatever statement is necessary to either defer or disable foreign
+ * key constraint checking on the given database connection, which is used by
+ * DBUnit to import datasets.
+ *
+ * @param con A DBUnit connection wrapper, which is used afterwards for dataset operations
+ */
+ protected void disableReferentialIntegrity(IDatabaseConnection con)
+ {
+ try
+ {
+ if (database.equals(HSQL))
+ {
+ con.getConnection().prepareStatement("set referential_integrity FALSE").execute(); // HSQL DB
+ }
+ else if (database.equals(MYSQL))
+ {
+ con.getConnection().prepareStatement("set foreign_key_checks=0").execute(); // MySQL > 4.1.1
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ /**
+ * Execute whatever statement is necessary to enable integrity constraint checks after
+ * dataset operations.
+ *
+ * @param con A DBUnit connection wrapper, before it is used by the application again
+ */
+ protected void enableReferentialIntegrity(IDatabaseConnection con)
+ {
+ try
+ {
+ if (database.equals(HSQL))
+ {
+ con.getConnection().prepareStatement("set referential_integrity TRUE").execute(); // HSQL DB
+ }
+ else if (database.equals(MYSQL))
+ {
+ con.getConnection().prepareStatement("set foreign_key_checks=1").execute(); // MySQL > 4.1.1
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ /**
+ * Override this method if you require DBUnit configuration features or additional properties.
+ * <p/>
+ * Called after a connection has been obtaind and before the connection is used. Can be a
+ * NOOP method if no additional settings are necessary for your DBUnit/DBMS setup.
+ *
+ * @param config A DBUnit <tt>DatabaseConfig</tt> object for setting properties and features
+ */
+ protected void editConfig(DatabaseConfig config)
+ {
+ if (database.equals(HSQL))
+ {
+ // DBUnit/HSQL bugfix
+ // http://www.carbonfive.com/community/archives/2005/07/dbunit_hsql_and.html
+ config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new DefaultDataTypeFactory()
+ {
+ @Override
+ public DataType createDataType(int sqlType, String sqlTypeName)
+ throws DataTypeException
+ {
+ if (sqlType == Types.BOOLEAN)
+ {
+ return DataType.BOOLEAN;
+ }
+ return super.createDataType(sqlType, sqlTypeName);
+ }
+ });
+ }
+ }
+
+ /**
+ * Callback for each operation before DBUnit executes the operation, useful if extra preparation of
+ * data/tables is necessary, e.g. additional SQL commands on a per-operation (per table?) granularity
+ * on the given database connection.
+ *
+ * @param con A DBUnit connection wrapper
+ * @param operation The operation to be executed, call <tt>getDataSet()</tt> to access the data.
+ */
+ protected void prepareExecution(IDatabaseConnection con, DataSetOperation operation)
+ {
+ }
+
+ /**
+ * Callback for each operation, useful if extra preparation of data/tables is necessary.
+ *
+ * @param con A DBUnit connection wrapper
+ * @param operation The operation that was executed, call <tt>getDataSet()</tt> to access the data.
+ */
+ protected void afterExecution(IDatabaseConnection con, DataSetOperation operation)
+ {
+ }
+
+ /**
+ * Resolves the binary dir location with the help of the classloader, we need the
+ * absolute full path of that directory.
+ *
+ * @return URL full absolute path of the binary directory
+ */
+ protected URL getBinaryDirFullpath()
+ {
+ if (getBinaryDir() == null)
+ {
+ throw new RuntimeException("Please set binaryDir TestNG property to location of binary test files");
+ }
+ return getResourceURL(getBinaryDir());
+ }
+
+ protected URL getResourceURL(String resource)
+ {
+ URL url = Thread.currentThread().getContextClassLoader().getResource(resource);
+ if (url == null)
+ {
+ throw new RuntimeException("Could not find resource with classloader: " + resource);
+ }
+ return url;
+ }
+
+ /**
+ * Load a file and return it as a <tt>byte[]</tt>. Useful for comparison operations in an actual
+ * unit test, e.g. to compare an imported database record against a known file state.
+ *
+ * @param filename the path of the file on the classpath, relative to configured <tt>binaryDir</tt> base path
+ * @return the file content as bytes
+ * @throws Exception when the file could not be found or read
+ */
+ protected byte[] getBinaryFile(String filename) throws Exception
+ {
+ if (getBinaryDir() == null)
+ {
+ throw new RuntimeException("Please set binaryDir TestNG property to location of binary test files");
+ }
+ File file = new File(getResourceURL(getBinaryDir() + "/" + filename).toURI());
+ InputStream is = new FileInputStream(file);
+
+ // Get the size of the file
+ long length = file.length();
+
+ if (length > Integer.MAX_VALUE)
+ {
+ // File is too large
+ }
+
+ // Create the byte array to hold the data
+ byte[] bytes = new byte[(int) length];
+
+ // Read in the bytes
+ int offset = 0;
+ int numRead;
+ while (offset < bytes.length
+ && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0)
+ {
+ offset += numRead;
+ }
+
+ // Ensure all the bytes have been read in
+ if (offset < bytes.length)
+ {
+ throw new IOException("Could not completely read file " + file.getName());
+ }
+
+ // Close the input stream and return bytes
+ is.close();
+ return bytes;
+ }
+
+ /**
+ * Implement this in a subclass.
+ * <p/>
+ * Use it to stack DBUnit <tt>DataSetOperation</tt>'s with
+ * the <tt>beforeTestOperations</tt> and <tt>afterTestOperations</tt> lists.
+ */
+ protected abstract void prepareDBUnitOperations();
+
+
+}
[View Less]
12 years, 11 months
[forge/core] 3f4089: FORGE-541
by GitHub
Branch: refs/heads/master
Home: https://github.com/forge/core
Commit: 3f4089cac71fbe5fdb880b0763b03eb790a29efc
https://github.com/forge/core/commit/3f4089cac71fbe5fdb880b0763b03eb790a2...
Author: George Gastaldi <gegastaldi(a)gmail.com>
Date: 2012-04-18 (Wed, 18 Apr 2012)
Changed paths:
A dev-plugins/src/main/java/org/jboss/forge/dev/i18n/BundleCompleter.java
A dev-plugins/src/main/java/org/jboss/forge/dev/i18n/I18nPlugin.java
A dev-plugins/src/main/java/…
[View More]org/jboss/forge/dev/i18n/LsBundlePlugin.java
A dev-plugins/src/test/java/org/jboss/forge/dev/i18n/I18nPluginTest.java
A shell-api/src/main/java/org/jboss/forge/resources/EntryResource.java
A shell-api/src/main/java/org/jboss/forge/resources/PropertiesFileResource.java
M shell-api/src/main/java/org/jboss/forge/shell/util/Streams.java
M shell/src/main/java/org/jboss/forge/shell/completer/OptionAwareCompletionHandler.java
M shell/src/main/java/org/jboss/forge/shell/console/jline/console/ConsoleReader.java
A shell/src/main/resources/org/jboss/forge/shell/console/jline/console/completer/CandidateListCompletionHandler.properties
R shell/src/main/resources/org/jboss/forge/shell/console/jline/console/completer/CandidateListCompletionHandlerBundle.properties
Log Message:
-----------
FORGE-541
Commit: 65aad7e1fdf3cf09b26cf3dabc47b66feef6d97b
https://github.com/forge/core/commit/65aad7e1fdf3cf09b26cf3dabc47b66feef6...
Author: George Gastaldi <gegastaldi(a)gmail.com>
Date: 2012-04-19 (Thu, 19 Apr 2012)
Changed paths:
M shell/src/main/java/org/jboss/forge/shell/completer/OptionAwareCompletionHandler.java
M shell/src/test/java/org/jboss/forge/shell/test/completer/OptionAwareCompletionHandlerTest.java
Log Message:
-----------
Resolved conflict in pull request #145
Commit: e3ee8ad79996426da71d5ac546b0a0b586dd5b44
https://github.com/forge/core/commit/e3ee8ad79996426da71d5ac546b0a0b586dd...
Author: Lincoln Baxter, III <lincolnbaxter(a)gmail.com>
Date: 2012-04-19 (Thu, 19 Apr 2012)
Changed paths:
A dev-plugins/src/main/java/org/jboss/forge/dev/i18n/BundleCompleter.java
A dev-plugins/src/main/java/org/jboss/forge/dev/i18n/I18nPlugin.java
A dev-plugins/src/main/java/org/jboss/forge/dev/i18n/LsBundlePlugin.java
A dev-plugins/src/test/java/org/jboss/forge/dev/i18n/I18nPluginTest.java
A shell-api/src/main/java/org/jboss/forge/resources/EntryResource.java
A shell-api/src/main/java/org/jboss/forge/resources/PropertiesFileResource.java
M shell-api/src/main/java/org/jboss/forge/shell/util/Streams.java
M shell/src/main/java/org/jboss/forge/shell/completer/OptionAwareCompletionHandler.java
M shell/src/main/java/org/jboss/forge/shell/console/jline/console/ConsoleReader.java
A shell/src/main/resources/org/jboss/forge/shell/console/jline/console/completer/CandidateListCompletionHandler.properties
R shell/src/main/resources/org/jboss/forge/shell/console/jline/console/completer/CandidateListCompletionHandlerBundle.properties
Log Message:
-----------
Merge pull request #143 from gastaldi/feature/FORGE-541
FORGE-541
Compare: https://github.com/forge/core/compare/0713b50...e3ee8ad
[View Less]
12 years, 11 months