Author: dan.j.allen
Date: 2010-08-27 19:22:54 -0400 (Fri, 27 Aug 2010)
New Revision: 13657
Added:
examples/trunk/javaee-booking/src/test/resources-glassfish-embedded/
examples/trunk/javaee-booking/src/test/resources-glassfish-embedded/test-persistence.xml
examples/trunk/javaee-booking/src/test/resources-jbossas/test-persistence.xml
Removed:
examples/trunk/javaee-booking/src/test/resources-glassfish/
Modified:
examples/trunk/javaee-booking/pom.xml
examples/trunk/javaee-booking/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java
examples/trunk/javaee-booking/src/test/java/org/jboss/seam/examples/booking/booking/BookingAgentTest.java
examples/trunk/javaee-booking/src/test/java/org/jboss/seam/examples/booking/inventory/HotelSearchTest.java
examples/trunk/javaee-booking/src/test/resources-glassfish-embedded/sun-resources.xml
examples/trunk/javaee-booking/src/test/resources/arquillian.xml
Log:
fix arquillian tests
Modified: examples/trunk/javaee-booking/pom.xml
===================================================================
--- examples/trunk/javaee-booking/pom.xml 2010-08-27 21:40:16 UTC (rev 13656)
+++ examples/trunk/javaee-booking/pom.xml 2010-08-27 23:22:54 UTC (rev 13657)
@@ -25,10 +25,10 @@
<jboss.home>${env.JBOSS_HOME}</jboss.home>
<jboss.domain>default</jboss.domain>
<arquillian.version>1.0.0.Alpha3</arquillian.version>
- <glassfish.version>3.0.1-b19</glassfish.version>
+ <glassfish.version>3.0.1-b20</glassfish.version>
<jpamodelgen.version>1.0.0.Final</jpamodelgen.version>
- <jboss-as-client.version>6.0.0.20100216-M2</jboss-as-client.version>
- <jboss-javaee6-spec.version>1.0.0.Beta4</jboss-javaee6-spec.version>
+ <jboss-as-client.version>6.0.0.20100721-M4</jboss-as-client.version>
+ <jboss-javaee6-spec.version>1.0.0.Beta7</jboss-javaee6-spec.version>
<jboss-server-manager.version>1.0.3.GA</jboss-server-manager.version>
<seam-faces.version>3.0.0.Alpha3</seam-faces.version>
</properties>
@@ -273,11 +273,11 @@
</profile>
<profile>
- <id>jbossas-remote-60</id>
+ <id>jbossas-remote-6</id>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
- <artifactId>arquillian-jbossas-remote-60</artifactId>
+ <artifactId>arquillian-jbossas-remote-6</artifactId>
<version>${arquillian.version}</version>
<scope>test</scope>
</dependency>
@@ -310,11 +310,11 @@
</profile>
<profile>
- <id>glassfish-embedded-30</id>
+ <id>glassfish-embedded-3</id>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
- <artifactId>arquillian-glassfish-embedded-30</artifactId>
+ <artifactId>arquillian-glassfish-embedded-3</artifactId>
<version>${arquillian.version}</version>
<scope>test</scope>
</dependency>
@@ -331,18 +331,36 @@
<directory>src/test/resources</directory>
</testResource>
<testResource>
- <directory>src/test/resources-glassfish</directory>
+
<directory>src/test/resources-glassfish-embedded</directory>
</testResource>
</testResources>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <!-- don't use version 2.5 as it creates seperate test suites
per class -->
+ <version>2.4.3</version>
+ <configuration>
+ <systemProperties>
+ <!-- This optional property fixes an annoyance with Glassfish
that puts derby.log in the project root -->
+ <property>
+ <name>derby.stream.error.file</name>
+ <!-- If you save the log in target it is less likely to get
committed in your project -->
+ <value>target/derby.log</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
</build>
</profile>
+ <!--
<profile>
- <id>glassfish-remote-30</id>
+ <id>glassfish-remote-3</id>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
- <artifactId>arquillian-glassfish-remote-30</artifactId>
+ <artifactId>arquillian-glassfish-remote-3</artifactId>
<version>${arquillian.version}</version>
<scope>test</scope>
</dependency>
@@ -359,11 +377,12 @@
<directory>src/test/resources</directory>
</testResource>
<testResource>
- <directory>src/test/resources-glassfish</directory>
+ <directory>src/test/resources-glassfish-remote</directory>
</testResource>
</testResources>
</build>
</profile>
+ -->
</profiles>
<scm>
Modified:
examples/trunk/javaee-booking/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java
===================================================================
---
examples/trunk/javaee-booking/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java 2010-08-27
21:40:16 UTC (rev 13656)
+++
examples/trunk/javaee-booking/src/main/java/org/jboss/seam/examples/booking/booking/BookingAgent.java 2010-08-27
23:22:54 UTC (rev 13657)
@@ -90,8 +90,7 @@
@Begin
public void selectHotel(final Long id)
{
- // NOTE get a fresh reference that's managed by the extended persistence
- // context
+ // NOTE get a fresh reference that's managed by the extended persistence
context
hotelSelection = em.find(Hotel.class, id);
if (hotelSelection != null)
{
Modified:
examples/trunk/javaee-booking/src/test/java/org/jboss/seam/examples/booking/booking/BookingAgentTest.java
===================================================================
---
examples/trunk/javaee-booking/src/test/java/org/jboss/seam/examples/booking/booking/BookingAgentTest.java 2010-08-27
21:40:16 UTC (rev 13656)
+++
examples/trunk/javaee-booking/src/test/java/org/jboss/seam/examples/booking/booking/BookingAgentTest.java 2010-08-27
23:22:54 UTC (rev 13657)
@@ -6,6 +6,7 @@
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
@@ -22,10 +23,12 @@
import org.jboss.seam.examples.booking.support.NoOpLogger;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.weld.context.ConversationContext;
import org.jboss.weld.context.api.ContextualInstance;
import org.jboss.weld.context.api.helpers.AbstractMapBackedBeanStore;
+import org.jboss.weld.manager.BeanManagerImpl;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -36,7 +39,7 @@
@Deployment
public static Archive<?> createTestArchive()
{
- WebArchive war = ShrinkWrap.create(WebArchive.class, "test")
+ WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war")
.addPackage(Hotel.class.getPackage())
.addClasses(BookingAgent.class, BookingAgent.class, Confirmed.class,
Authenticated.class, NoOpLogger.class)
@@ -44,12 +47,15 @@
MavenArtifactResolver.resolve("joda-time:joda-time:1.6"),
MavenArtifactResolver.resolve("org.jboss.seam.international:seam-international-api:3.0.0.Alpha1"),
MavenArtifactResolver.resolve("org.jboss.seam.international:seam-international:3.0.0.Alpha1"))
- .addWebResource("META-INF/persistence.xml",
"classes/META-INF/persistence.xml")
- .addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
+ .addWebResource("test-persistence.xml",
"classes/META-INF/persistence.xml")
+ .addWebResource(new StringAsset(""), "beans.xml");
return war;
}
@Inject
+ BeanManager beanManager;
+
+ @Inject
UserTransaction utx;
@PersistenceContext
@@ -69,7 +75,7 @@
em.createQuery("delete from Hotel").executeUpdate();
em.persist(new Hotel("Doubletree Atlanta-Buckhead", "3342 Peachtree
Road NE", "Atlanta", "GA", "30326", "USA"));
em.createQuery("delete from User").executeUpdate();
- em.persist(new User("Ike", "ike", "incontainer"));
+ em.persist(new User("Ike", "ike",
"ike(a)mailinator.com", "secret"));
utx.commit();
}
@@ -77,10 +83,12 @@
public void testBookHotel() throws Exception
{
prepareSeedData();
- // ConversationContext cc =
- //
Container.instance().services().get(ContextLifecycle.class).getConversationContext();
- // cc.setBeanStore(new HashMapBeanStore());
- // cc.setActive(true);
+
+ // we have to depend on the Weld API to setup the conversation scope
+ ConversationContext cc = new ConversationContext();
+ cc.setBeanStore(new HashMapBeanStore());
+ cc.setActive(true);
+ ((BeanManagerImpl) beanManager).addContext(cc);
bookingAgent.selectHotel(1l);
bookingAgent.bookHotel();
Modified:
examples/trunk/javaee-booking/src/test/java/org/jboss/seam/examples/booking/inventory/HotelSearchTest.java
===================================================================
---
examples/trunk/javaee-booking/src/test/java/org/jboss/seam/examples/booking/inventory/HotelSearchTest.java 2010-08-27
21:40:16 UTC (rev 13656)
+++
examples/trunk/javaee-booking/src/test/java/org/jboss/seam/examples/booking/inventory/HotelSearchTest.java 2010-08-27
23:22:54 UTC (rev 13657)
@@ -15,7 +15,7 @@
import org.jboss.seam.examples.booking.support.NoOpLogger;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert;
import org.junit.Test;
@@ -26,15 +26,15 @@
{
@Deployment
public static Archive<?> createTestArchive() {
- // JavaArchive doesn't work on GlassFish (would work on JBoss AS, but it breaks
because of the EJBs)
-// JavaArchive jar = ShrinkWrap.create("test.jar", JavaArchive.class)
+ // JavaArchive doesn't work on GlassFish
+// JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "test.jar")
// .addPackage(HotelSearch.class.getPackage())
// .addPackage(Hotel.class.getPackage())
// .addManifestResource("META-INF/persistence.xml",
"persistence.xml")
// .addManifestResource(new ByteArrayAsset(new byte[0]),
"beans.xml");
// return jar;
- // WebArchive does work in all cases (except JBoss AS still breaks with EJBs)
- WebArchive war = ShrinkWrap.create(WebArchive.class, "test")
+ // WebArchive works in all cases
+ WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war")
.addPackage(HotelSearch.class.getPackage())
.addPackage(Hotel.class.getPackage())
.addClasses(NoOpLogger.class)
@@ -43,8 +43,8 @@
MavenArtifactResolver.resolve("org.jboss.seam.international:seam-international-api:3.0.0.Alpha1"),
MavenArtifactResolver.resolve("org.jboss.seam.international:seam-international:3.0.0.Alpha1")
)
- .addWebResource("META-INF/persistence.xml",
"classes/META-INF/persistence.xml")
- .addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
+ .addWebResource("test-persistence.xml",
"classes/META-INF/persistence.xml")
+ .addWebResource(new StringAsset(""), "beans.xml");
return war;
}
Modified: examples/trunk/javaee-booking/src/test/resources/arquillian.xml
===================================================================
--- examples/trunk/javaee-booking/src/test/resources/arquillian.xml 2010-08-27 21:40:16
UTC (rev 13656)
+++ examples/trunk/javaee-booking/src/test/resources/arquillian.xml 2010-08-27 23:22:54
UTC (rev 13657)
@@ -1,19 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<arquillian
xmlns="http://jboss.com/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:gfembedded="urn:arq:org.jboss.arquillian.glassfish.embedded30"
-
xmlns:gfremote="urn:arq:org.jboss.arquillian.container.glassfish.remote30">
+
xmlns:jbossas-remote="urn:arq:org.jboss.arquillian.container.jbossas.remote_6"
+
xmlns:glassfish-remote="urn:arq:org.jboss.arquillian.container.glassfish.remote_3"
+
xmlns:glassfish-embedded="urn:arq:org.jboss.arquillian.container.glassfish.embedded_3">
<engine>
<deploymentExportPath>/tmp/</deploymentExportPath>
</engine>
+
+ <jbossas-remote:container>
+
<jbossas-remote:remoteServerHttpPort>8080</jbossas-remote:remoteServerHttpPort>
+ </jbossas-remote:container>
- <gfremote:container>
- <gfremote:remoteServerHttpPort>7070</gfremote:remoteServerHttpPort>
- </gfremote:container>
+ <glassfish-remote:container>
+
<glassfish-remote:remoteServerHttpPort>7070</glassfish-remote:remoteServerHttpPort>
+ </glassfish-remote:container>
- <gfembedded:container>
-
<gfembedded:sunResourcesXml>src/test/resources-glassfish/sun-resources.xml</gfembedded:sunResourcesXml>
- </gfembedded:container>
+ <glassfish-embedded:container>
+
<glassfish-embedded:bindHttpPort>7070</glassfish-embedded:bindHttpPort>
+
<glassfish-embedded:sunResourcesXml>src/test/resources-glassfish-embedded/sun-resources.xml</glassfish-embedded:sunResourcesXml>
+ </glassfish-embedded:container>
</arquillian>
Copied: examples/trunk/javaee-booking/src/test/resources-glassfish-embedded (from rev
13635, examples/trunk/javaee-booking/src/test/resources-glassfish)
Modified:
examples/trunk/javaee-booking/src/test/resources-glassfish-embedded/sun-resources.xml
===================================================================
---
examples/trunk/javaee-booking/src/test/resources-glassfish/sun-resources.xml 2010-08-25
19:15:25 UTC (rev 13635)
+++
examples/trunk/javaee-booking/src/test/resources-glassfish-embedded/sun-resources.xml 2010-08-27
23:22:54 UTC (rev 13657)
@@ -3,7 +3,7 @@
"http://www.sun.com/software/appserver/dtds/sun-resources_1_4.dtd">
<resources>
<jdbc-resource pool-name="ArquillianEmbeddedDerbyPool"
- jndi-name="jdbc/__arquillian"/>
+ jndi-name="jdbc/arquillian"/>
<jdbc-connection-pool name="ArquillianEmbeddedDerbyPool"
res-type="javax.sql.DataSource"
datasource-classname="org.apache.derby.jdbc.EmbeddedDataSource"
@@ -13,7 +13,7 @@
</jdbc-connection-pool>
<!--
<jdbc-resource pool-name="ArquillianEmbeddedH2Pool"
- jndi-name="jdbc/__arquillian"/>
+ jndi-name="jdbc/arquillian"/>
<jdbc-connection-pool name="ArquillianEmbeddedH2Pool"
res-type="javax.sql.DataSource"
datasource-classname="org.h2.jdbcx.JdbcDataSource">
Added:
examples/trunk/javaee-booking/src/test/resources-glassfish-embedded/test-persistence.xml
===================================================================
---
examples/trunk/javaee-booking/src/test/resources-glassfish-embedded/test-persistence.xml
(rev 0)
+++
examples/trunk/javaee-booking/src/test/resources-glassfish-embedded/test-persistence.xml 2010-08-27
23:22:54 UTC (rev 13657)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence
xmlns="http://java.sun.com/xml/ns/persistence"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+ version="2.0">
+ <persistence-unit name="booking">
+ <!-- DataSource configured in adjacent sun-resources.xml -->
+ <jta-data-source>jdbc/arquillian</jta-data-source>
+ <class>org.jboss.seam.examples.booking.model.User</class>
+ <class>org.jboss.seam.examples.booking.model.Hotel</class>
+ <class>org.jboss.seam.examples.booking.model.Booking</class>
+ <exclude-unlisted-classes/>
+ <properties>
+ <!-- Properties for EclipseLink (default provider for GlassFish) -->
+ <property name="eclipselink.ddl-generation"
value="drop-and-create-tables"/>
+ <property name="eclipselink.logging.level"
value="FINE"/>
+ </properties>
+ </persistence-unit>
+</persistence>
Added: examples/trunk/javaee-booking/src/test/resources-jbossas/test-persistence.xml
===================================================================
--- examples/trunk/javaee-booking/src/test/resources-jbossas/test-persistence.xml
(rev 0)
+++
examples/trunk/javaee-booking/src/test/resources-jbossas/test-persistence.xml 2010-08-27
23:22:54 UTC (rev 13657)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence
xmlns="http://java.sun.com/xml/ns/persistence"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+ version="2.0">
+ <persistence-unit name="booking">
+ <jta-data-source>java:/DefaultDS</jta-data-source>
+ <properties>
+ <!-- Properties for Hibernate (default provider for JBoss AS) -->
+ <property name="hibernate.hbm2ddl.auto"
value="create-drop"/>
+ <property name="hibernate.show_sql" value="true"/>
+ <!-- Only format when you need to debug, because it slows things down -->
+ <property name="hibernate.format_sql" value="false"/>
+ </properties>
+ </persistence-unit>
+</persistence>