[jboss-svn-commits] JBL Code SVN: r37201 - in labs/jbosstm/trunk/ArjunaJTA/quickstarts/integration: src/main/java/org/jboss/narayana/quickstarts/servlet and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Jul 1 10:44:05 EDT 2011


Author: tomjenkinson
Date: 2011-07-01 10:44:04 -0400 (Fri, 01 Jul 2011)
New Revision: 37201

Modified:
   labs/jbosstm/trunk/ArjunaJTA/quickstarts/integration/pom.xml
   labs/jbosstm/trunk/ArjunaJTA/quickstarts/integration/src/main/java/org/jboss/narayana/quickstarts/servlet/SimpleServlet.java
   labs/jbosstm/trunk/ArjunaJTA/quickstarts/integration/src/main/resources/META-INF/persistence.xml
   labs/jbosstm/trunk/ArjunaJTA/quickstarts/integration/src/test/java/TestBusinessLogic.java
Log:
JBTM-854 updated to work with arquillian and AS7

Modified: labs/jbosstm/trunk/ArjunaJTA/quickstarts/integration/pom.xml
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/quickstarts/integration/pom.xml	2011-07-01 13:58:05 UTC (rev 37200)
+++ labs/jbosstm/trunk/ArjunaJTA/quickstarts/integration/pom.xml	2011-07-01 14:44:04 UTC (rev 37201)
@@ -1,4 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!-- JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated by the @authors tag. All rights reserved. See the copyright.txt in the distribution for a full listing of individual contributors. This copyrighted material is made available to anyone wishing to use, modify, copy, or redistribute it subject to the terms and conditions of the GNU Lesser General Public License, v. 2.1. This program is distributed in the hope that it will be useful, but WITHOUT A WARRANTY; without even the implied warranty of MERCHANTABILITY 
+  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License, v.2.1 along with this distribution; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.jboss.narayana.jta.quickstarts</groupId>
@@ -20,6 +22,19 @@
       </snapshots>
     </repository>
   </repositories>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-war-plugin</artifactId>
+        <configuration>
+          <!-- Java EE 6 doesn't require web.xml, Maven needs to catch up! -->
+          <failOnMissingWebXml>false</failOnMissingWebXml>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
   <dependencies>
     <!-- Annotation processor to generate the JPA 2.0 metamodel classes for typesafe criteria queries -->
     <dependency>
@@ -37,6 +52,7 @@
     </dependency>
 
     <!-- Seam Solder provides convenient, portable CDI extensions such as an injectable logger -->
+    <!-- Needed for running tests -->
     <dependency>
       <groupId>org.jboss.seam.solder</groupId>
       <artifactId>seam-solder</artifactId>
@@ -58,8 +74,6 @@
         </exclusion>
       </exclusions>
     </dependency>
-
-    <!-- Needed for running tests (you may also use TestNG) -->
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
@@ -67,7 +81,6 @@
       <scope>test</scope>
     </dependency>
 
-    <!-- Optional, but highly recommended -->
     <!-- Arquillian allows you to test enterprise code such as EJBs and Transactional(JTA) JPA from JUnit/TestNG -->
     <dependency>
       <groupId>org.jboss.arquillian.junit</groupId>
@@ -85,9 +98,6 @@
       <type>pom</type>
       <scope>provided</scope>
     </dependency>
-
-    <!-- <dependency> <groupId>org.jboss.spec.javax.servlet</groupId> <artifactId>jboss-servlet-api_3.0_spec</artifactId> <version>1.0.0.Final</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.jboss.spec.javax.ejb</groupId> <artifactId>jboss-ejb-api_3.1_spec</artifactId> <version>1.0.0.Final</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.jboss.ejb3</groupId> <artifactId>jboss-ejb3-ext-api</artifactId> <version>1.1.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.hibernate.javax.persistence</groupId> 
-      <artifactId>hibernate-jpa-2.0-api</artifactId> <version>1.0.0.Final</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.jboss.arquillian.junit</groupId> <artifactId>arquillian-junit-container</artifactId> <version>1.0.0.CR1</version> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.2</version> <scope>test</scope> </dependency> -->
   </dependencies>
 
   <profiles>

Modified: labs/jbosstm/trunk/ArjunaJTA/quickstarts/integration/src/main/java/org/jboss/narayana/quickstarts/servlet/SimpleServlet.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/quickstarts/integration/src/main/java/org/jboss/narayana/quickstarts/servlet/SimpleServlet.java	2011-07-01 13:58:05 UTC (rev 37200)
+++ labs/jbosstm/trunk/ArjunaJTA/quickstarts/integration/src/main/java/org/jboss/narayana/quickstarts/servlet/SimpleServlet.java	2011-07-01 14:44:04 UTC (rev 37201)
@@ -25,6 +25,7 @@
 
 import javax.ejb.EJB;
 import javax.naming.InitialContext;
+import javax.naming.NamingException;
 import javax.servlet.ServletException;
 import javax.servlet.annotation.WebServlet;
 import javax.servlet.http.HttpServlet;
@@ -37,9 +38,17 @@
 @WebServlet(displayName = "hello", urlPatterns = "/hello")
 public class SimpleServlet extends HttpServlet {
 
-	@EJB
+	@EJB(lookup = "java:module/SimpleEJBImpl")
 	private SimpleEJB simpleEJB;
 
+	public SimpleServlet() throws NamingException {
+		if (simpleEJB == null) {
+			simpleEJB = (SimpleEJB) new InitialContext()
+					.lookup("java:module/SimpleEJBImpl");
+			System.out.println("needed to look up EJB - arq only");
+		}
+	}
+
 	public void doGet(HttpServletRequest request, HttpServletResponse response)
 			throws ServletException, IOException {
 

Modified: labs/jbosstm/trunk/ArjunaJTA/quickstarts/integration/src/main/resources/META-INF/persistence.xml
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/quickstarts/integration/src/main/resources/META-INF/persistence.xml	2011-07-01 13:58:05 UTC (rev 37200)
+++ labs/jbosstm/trunk/ArjunaJTA/quickstarts/integration/src/main/resources/META-INF/persistence.xml	2011-07-01 14:44:04 UTC (rev 37201)
@@ -1,18 +1,17 @@
-<persistence xmlns="http://java.sun.com/xml/ns/persistence"
-	version="1.0">
-	<persistence-unit name="my_persistence_ctx">
-		<jta-data-source>java:/H2DS</jta-data-source>
-		<properties>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+  <persistence-unit name="my_persistence_ctx">
+    <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
+    <properties>
 
-			<property name="hibernate.show_sql" value="false" />
-			<property name="hibernate.format_sql" value="false" />
+      <property name="hibernate.show_sql" value="false" />
+      <property name="hibernate.format_sql" value="false" />
 
-			<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" />
-			<property name="hibernate.connection.url" value="jdbc:hsqldb:mem:mem:aname" />
-			<property name="hibernate.connection.username" value="sa" />
+      <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" />
+      <property name="hibernate.connection.url" value="jdbc:hsqldb:mem:mem:aname" />
+      <property name="hibernate.connection.username" value="sa" />
 
-			<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
-			<property name="hibernate.hbm2ddl.auto" value="create" />
-		</properties>
-	</persistence-unit>
-</persistence>
\ No newline at end of file
+      <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
+      <property name="hibernate.hbm2ddl.auto" value="create" />
+    </properties>
+  </persistence-unit>
+</persistence>

Modified: labs/jbosstm/trunk/ArjunaJTA/quickstarts/integration/src/test/java/TestBusinessLogic.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/quickstarts/integration/src/test/java/TestBusinessLogic.java	2011-07-01 13:58:05 UTC (rev 37200)
+++ labs/jbosstm/trunk/ArjunaJTA/quickstarts/integration/src/test/java/TestBusinessLogic.java	2011-07-01 14:44:04 UTC (rev 37201)
@@ -18,6 +18,8 @@
  * (C) 2011,
  * @author JBoss, by Red Hat.
  */
+import javax.naming.NamingException;
+
 import org.jboss.arquillian.container.test.api.Deployment;
 import org.jboss.arquillian.junit.Arquillian;
 import org.jboss.narayana.quickstarts.ejb.Customer;
@@ -25,28 +27,30 @@
 import org.jboss.narayana.quickstarts.ejb.SimpleEJBImpl;
 import org.jboss.narayana.quickstarts.servlet.SimpleServlet;
 import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
 @RunWith(Arquillian.class)
 public class TestBusinessLogic {
 	@Deployment
-	public static JavaArchive createDeployment() {
+	public static WebArchive createDeployment() {
 		return ShrinkWrap
-				.create(JavaArchive.class, "test.jar")
+				.create(WebArchive.class, "test.war")
 				.addClasses(SimpleEJB.class, SimpleEJBImpl.class,
 						Customer.class)
 				.addClasses(SimpleServlet.class)
-				.addAsManifestResource("META-INF/persistence.xml",
-						"META-INF/persistence.xml");
+				.addAsResource("META-INF/persistence.xml",
+						"META-INF/persistence.xml")
+				.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
 	}
 
 	@Test
-	public void checkThatDoubleCallIncreasesListSize() {
+	public void checkThatDoubleCallIncreasesListSize() throws NamingException {
 		SimpleServlet simpleServlet = new SimpleServlet();
-		simpleServlet.createCustomer("tom");
-		simpleServlet.createCustomer("tom");
+		simpleServlet.createCustomer("tom1");
+		simpleServlet.createCustomer("tom2");
 	}
 
 }



More information about the jboss-svn-commits mailing list