aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1692872 - in /aries/trunk/jpa/itests: jpa-container-blueprint-testbundle/ jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/ jpa-container-blueprint-testbundle/src/main/resources/OS...
Date Mon, 27 Jul 2015 12:49:51 GMT
Author: cschneider
Date: Mon Jul 27 12:49:51 2015
New Revision: 1692872

URL: http://svn.apache.org/r1692872
Log:
[ARIES-628] Add jta 1.2 testcase

Added:
    aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceEmJtaAnn.java
Modified:
    aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/pom.xml
    aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarLifeCycle.java
    aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/resources/OSGI-INF/blueprint/config.xml
    aries/trunk/jpa/itests/jpa-container-itest/pom.xml
    aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintTest.java
    aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractCarJPAITest.java
    aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractJPAItest.java

Modified: aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/pom.xml?rev=1692872&r1=1692871&r2=1692872&view=diff
==============================================================================
--- aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/pom.xml (original)
+++ aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/pom.xml Mon Jul 27 12:49:51
2015
@@ -20,16 +20,17 @@
             <artifactId>org.osgi.compendium</artifactId>
         </dependency>
         <dependency>
+            <groupId>javax.transaction</groupId>
+            <artifactId>javax.transaction-api</artifactId>
+            <version>1.2</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
             <groupId>org.hibernate.javax.persistence</groupId>
             <artifactId>hibernate-jpa-2.0-api</artifactId>
             <version>1.0.1.Final</version>
         </dependency>
         <dependency>
-            <groupId>org.apache.aries.transaction</groupId>
-            <artifactId>org.apache.aries.transaction.blueprint</artifactId>
-            <version>1.0.2</version>
-        </dependency>
-        <dependency>
             <groupId>org.apache.aries.jpa</groupId>
             <artifactId>org.apache.aries.jpa.api</artifactId>
             <version>${project.version}</version>

Modified: aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarLifeCycle.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarLifeCycle.java?rev=1692872&r1=1692871&r2=1692872&view=diff
==============================================================================
--- aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarLifeCycle.java
(original)
+++ aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarLifeCycle.java
Mon Jul 27 12:49:51 2015
@@ -62,6 +62,9 @@ public class CarLifeCycle implements Run
      */
     private void readAndUpdate(String id) {
         Car car = carService.getCar(id);
+        if (car == null) {
+            throw new IllegalStateException("Expected a car with id " + id);
+        }
         car.setEngineSize(100);
         carService.updateCar(car);
     }

Added: aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceEmJtaAnn.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceEmJtaAnn.java?rev=1692872&view=auto
==============================================================================
--- aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceEmJtaAnn.java
(added)
+++ aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/container/itest/bundle/blueprint/impl/CarServiceEmJtaAnn.java
Mon Jul 27 12:49:51 2015
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIESOR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jpa.container.itest.bundle.blueprint.impl;
+
+import java.util.Collection;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.transaction.Transactional;
+
+import org.apache.aries.jpa.container.itest.entities.Car;
+import org.apache.aries.jpa.container.itest.entities.CarService;
+
+public class CarServiceEmJtaAnn implements CarService {
+    @PersistenceContext(unitName = "xa-test-unit")
+    protected EntityManager em;
+
+    @Override
+    public Car getCar(String id) {
+        return em.find(Car.class, id);
+    }
+
+    @Transactional
+    @Override
+    public void addCar(Car car) {
+        em.persist(car);
+    }
+
+    public Collection<Car> getCars() {
+        return em.createQuery("select c from Car c", Car.class).getResultList();
+    }
+
+    @Transactional
+    @Override
+    public void updateCar(Car car) {
+        em.persist(car);
+    }
+
+    @Transactional
+    @Override
+    public void deleteCar(String id) {
+        em.remove(em.find(Car.class, id));
+    }
+
+    public void setEm(EntityManager em) {
+        this.em = em;
+    }
+
+}

Modified: aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/resources/OSGI-INF/blueprint/config.xml
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/resources/OSGI-INF/blueprint/config.xml?rev=1692872&r1=1692871&r2=1692872&view=diff
==============================================================================
--- aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/resources/OSGI-INF/blueprint/config.xml
(original)
+++ aries/trunk/jpa/itests/jpa-container-blueprint-testbundle/src/main/resources/OSGI-INF/blueprint/config.xml
Mon Jul 27 12:49:51 2015
@@ -10,6 +10,7 @@
     ">
 
     <jpa:enable />
+    <tx:enable-annotations/>
 
     <service ref="carServiceEmf"
         interface="org.apache.aries.jpa.container.itest.entities.CarService">
@@ -35,6 +36,17 @@
         <tx:transaction method="*" value="Required" />
     </bean>
 
+    <service ref="carServiceEmJtaAnn"
+        interface="org.apache.aries.jpa.container.itest.entities.CarService">
+        <service-properties>
+            <entry key="type" value="emJtaAnn" />
+        </service-properties>
+    </service>
+
+    <bean id="carServiceEmJtaAnn"
+        class="org.apache.aries.jpa.container.itest.bundle.blueprint.impl.CarServiceEmJtaAnn">
+    </bean>
+
     <service ref="carServiceEmSupplier"
         interface="org.apache.aries.jpa.container.itest.entities.CarService">
         <service-properties>

Modified: aries/trunk/jpa/itests/jpa-container-itest/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/itests/jpa-container-itest/pom.xml?rev=1692872&r1=1692871&r2=1692872&view=diff
==============================================================================
--- aries/trunk/jpa/itests/jpa-container-itest/pom.xml (original)
+++ aries/trunk/jpa/itests/jpa-container-itest/pom.xml Mon Jul 27 12:49:51 2015
@@ -302,7 +302,7 @@
         <dependency>
             <groupId>org.apache.aries.transaction</groupId>
             <artifactId>org.apache.aries.transaction.blueprint</artifactId>
-            <version>1.0.2</version>
+            <version>1.1.0-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.apache.aries.jndi</groupId>

Modified: aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintTest.java?rev=1692872&r1=1692871&r2=1692872&view=diff
==============================================================================
--- aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintTest.java
(original)
+++ aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintTest.java
Mon Jul 27 12:49:51 2015
@@ -15,9 +15,13 @@
  */
 package org.apache.aries.jpa.blueprint.aries.itest;
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 
 import javax.inject.Inject;
@@ -27,6 +31,7 @@ import org.apache.aries.jpa.container.it
 import org.apache.aries.jpa.itest.AbstractCarJPAITest;
 import org.junit.Assert;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
@@ -91,6 +96,12 @@ public class BlueprintTest extends Abstr
     public void testEmAddQuery() throws Exception {
         carLifecycle(getCarService("em"));
     }
+    
+    @Ignore
+    @Test
+    public void testEmJtaAnn() throws Exception {
+        carLifecycle(getCarService("emJtaAnn"));
+    }
 
     @Test
     public void testSupplierAddQuery() throws Exception {
@@ -98,14 +109,18 @@ public class BlueprintTest extends Abstr
     }
     
     @Test
-    public void testCoordinationLifecycle() throws InterruptedException {
+    public void testCoordinationLifecycle() throws InterruptedException, ExecutionException
{
         Runnable carLifeCycle = getService(Runnable.class, "(type=carCoordinated)");
         ExecutorService exec = Executors.newFixedThreadPool(20);
+        List<Future<?>> futures = new ArrayList<>();
         for (int c=0; c<100; c++) {
-            exec.execute(carLifeCycle);
+            futures.add(exec.submit(carLifeCycle));
         }
         exec.shutdown();
         exec.awaitTermination(30, TimeUnit.SECONDS);
+        for (Future<?> future : futures) {
+            future.get();
+        }
     }
 
     private CarService getCarService(String type) {
@@ -121,6 +136,7 @@ public class BlueprintTest extends Abstr
     public Option[] configuration() {
         return new Option[] {
             baseOptions(), //
+            jta12Bundles(), //
             ariesJpa20(), //
             hibernate(), //
             derbyDSF(), //

Modified: aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractCarJPAITest.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractCarJPAITest.java?rev=1692872&r1=1692871&r2=1692872&view=diff
==============================================================================
--- aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractCarJPAITest.java
(original)
+++ aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractCarJPAITest.java
Mon Jul 27 12:49:51 2015
@@ -21,6 +21,7 @@ import javax.persistence.EntityManager;
 import javax.transaction.UserTransaction;
 
 import org.apache.aries.jpa.container.itest.entities.Car;
+import org.junit.Assert;
 import org.osgi.framework.BundleException;
 
 public abstract class AbstractCarJPAITest extends AbstractJPAItest {
@@ -59,6 +60,7 @@ public abstract class AbstractCarJPAITes
     }
 
     protected void assertBlueCar(Car car) {
+        Assert.assertNotNull("Blue car not found (null)", car);
         assertEquals(5, car.getNumberOfSeats());
         assertEquals(1200, car.getEngineSize());
         assertEquals("blue", car.getColour());

Modified: aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractJPAItest.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractJPAItest.java?rev=1692872&r1=1692871&r2=1692872&view=diff
==============================================================================
--- aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractJPAItest.java
(original)
+++ aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractJPAItest.java
Mon Jul 27 12:49:51 2015
@@ -33,6 +33,7 @@ import javax.transaction.UserTransaction
 
 import org.junit.Before;
 import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.CoreOptions;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
@@ -281,6 +282,16 @@ public abstract class AbstractJPAItest {
                          mvnBundle("org.ops4j.pax.jdbc", "pax-jdbc-config")
             );
     }
+    
+    protected Option jta12Bundles() {
+        return CoreOptions.composite(
+            mavenBundle("javax.interceptor", "javax.interceptor-api", "1.2"),
+            mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.javax-inject",
"1_2"),
+            mavenBundle("javax.el", "javax.el-api", "3.0.0"),
+            mavenBundle("javax.enterprise", "cdi-api", "1.2"),
+            mavenBundle("javax.transaction", "javax.transaction-api", "1.2")
+        );
+    }
 
     protected Option testBundle() {
         return mvnBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.itest.bundle");



Mime
View raw message