You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/09/15 06:28:50 UTC

[1/3] git commit: Fixed OSGi itest build error of JpaRouteTest with Spring4.x

Repository: camel
Updated Branches:
  refs/heads/camel-2.14.x a13209273 -> 9f18e556c


Fixed OSGi itest build error of JpaRouteTest with Spring4.x


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/693168a4
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/693168a4
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/693168a4

Branch: refs/heads/camel-2.14.x
Commit: 693168a4ad0c1dd54ab07f547fde16ab0ece7088
Parents: a132092
Author: Willem Jiang <wi...@gmail.com>
Authored: Mon Sep 15 12:00:57 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Sep 15 12:01:26 2014 +0800

----------------------------------------------------------------------
 .../camel/itest/osgi/jpa/JpaRouteTest.java      | 56 +++++++++++---------
 .../itest/osgi/jpa/springJpaRouteContext.xml    |  4 --
 2 files changed, 30 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/693168a4/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/jpa/JpaRouteTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/jpa/JpaRouteTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/jpa/JpaRouteTest.java
index 74ea5f3..b3ee2fb 100644
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/jpa/JpaRouteTest.java
+++ b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/jpa/JpaRouteTest.java
@@ -19,6 +19,8 @@ package org.apache.camel.itest.osgi.jpa;
 import java.util.List;
 
 import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.component.mock.MockEndpoint;
@@ -26,16 +28,16 @@ import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport;
 import org.apache.camel.spring.SpringCamelContext;
 import org.apache.camel.util.IOHelper;
 import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.osgi.framework.BundleContext;
-import org.springframework.orm.jpa.JpaTemplate;
-import org.springframework.orm.jpa.JpaTransactionManager;
+
+
 import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;
-import org.springframework.transaction.TransactionDefinition;
 import org.springframework.transaction.TransactionStatus;
 import org.springframework.transaction.support.TransactionCallback;
 import org.springframework.transaction.support.TransactionTemplate;
@@ -48,10 +50,23 @@ public class JpaRouteTest extends OSGiIntegrationTestSupport {
     protected static final String SELECT_ALL_STRING = "select x from " + SendEmail.class.getName() + " x";
 
     protected OsgiBundleXmlApplicationContext applicationContext;
+
+    protected TransactionTemplate transactionTemplate;
+    protected EntityManager entityManager;
     
     @Inject
     protected BundleContext bundleContext;
-    protected JpaTemplate jpaTemplate;
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        EntityManagerFactory entityManagerFactory = applicationContext.getBean("entityManagerFactory",
+                EntityManagerFactory.class);
+        transactionTemplate = applicationContext.getBean("transactionTemplate", TransactionTemplate.class);
+        entityManager = entityManagerFactory.createEntityManager();
+        cleanupRepository();
+    }
+
 
     @Test
     public void testRouteJpa() throws Exception {
@@ -61,7 +76,7 @@ public class JpaRouteTest extends OSGiIntegrationTestSupport {
         template.sendBody("direct:start", new SendEmail(1L, "someone@somewhere.org"));
 
         assertMockEndpointsSatisfied();
-        assertEntityInDB();
+        assertEntityInDB(1);
     }
     
     @After
@@ -92,33 +107,22 @@ public class JpaRouteTest extends OSGiIntegrationTestSupport {
         return SpringCamelContext.springCamelContext(applicationContext);
     }
 
-    private void assertEntityInDB() throws Exception {
-        // must type cast with Spring 2.x
-        jpaTemplate = applicationContext.getBean("jpaTemplate", JpaTemplate.class);
+    private void assertEntityInDB(int size) throws Exception {
+        List<?> list = entityManager.createQuery(SELECT_ALL_STRING).getResultList();
+        assertEquals(size, list.size());
 
-        @SuppressWarnings("rawtypes")
-        List list = jpaTemplate.find(SELECT_ALL_STRING);
-        assertEquals(1, list.size());
-        
         assertIsInstanceOf(SendEmail.class, list.get(0));
     }
 
-    protected void cleanupRepository() {
-        // must type cast with Spring 2.x
-        jpaTemplate = applicationContext.getBean("jpaTemplate", JpaTemplate.class);
-
-        TransactionTemplate transactionTemplate = new TransactionTemplate();
-        transactionTemplate.setTransactionManager(new JpaTransactionManager(jpaTemplate.getEntityManagerFactory()));
-        transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
-
-        transactionTemplate.execute(new TransactionCallback<Boolean>() {
-            public Boolean doInTransaction(TransactionStatus arg0) {
-                @SuppressWarnings("rawtypes")
-                List list = jpaTemplate.find(SELECT_ALL_STRING);
+    private void cleanupRepository() {
+        transactionTemplate.execute(new TransactionCallback<Object>() {
+            public Object doInTransaction(TransactionStatus arg0) {
+                entityManager.joinTransaction();
+                List<?> list = entityManager.createQuery(SELECT_ALL_STRING).getResultList();
                 for (Object item : list) {
-                    jpaTemplate.remove(item);
+                    entityManager.remove(item);
                 }
-                jpaTemplate.flush();
+                entityManager.flush();
                 return Boolean.TRUE;
             }
         });

http://git-wip-us.apache.org/repos/asf/camel/blob/693168a4/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/jpa/springJpaRouteContext.xml
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/jpa/springJpaRouteContext.xml b/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/jpa/springJpaRouteContext.xml
index aaca4fc..68ee080 100644
--- a/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/jpa/springJpaRouteContext.xml
+++ b/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/jpa/springJpaRouteContext.xml
@@ -30,10 +30,6 @@
         </property>
     </bean>
 
-    <bean id="jpaTemplate" class="org.springframework.orm.jpa.JpaTemplate">
-        <property name="entityManagerFactory" ref="entityManagerFactory"/>
-    </bean>
-
     <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
         <property name="persistenceUnitName" value="camel"/>
     </bean>


[2/3] git commit: Revert "expand the Spring version range to include Spring 4.0.x after we set Spring 4 as default"

Posted by ni...@apache.org.
Revert "expand the Spring version range to include Spring 4.0.x after we set Spring 4 as default"

This change confuse the karaf and break the OSGi integration tests

This reverts commit 0b55370096efe59f2dc527a214747fd16f38132a.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/5178bda9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5178bda9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5178bda9

Branch: refs/heads/camel-2.14.x
Commit: 5178bda9cb2b43a5e245064c7e8e7795c5c93bf0
Parents: 693168a
Author: Willem Jiang <wi...@gmail.com>
Authored: Mon Sep 15 12:02:04 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Sep 15 12:02:04 2014 +0800

----------------------------------------------------------------------
 parent/pom.xml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/5178bda9/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 7bb8f8f..c35c967 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -404,7 +404,8 @@
     <spring-ldap-version>1.3.1.RELEASE</spring-ldap-version>
     <spring-ldap-bundle-version>1.3.1.RELEASE_2</spring-ldap-bundle-version>
     <spring-retry-version>1.0.3.RELEASE</spring-retry-version>
-    <spring-version-range>[3.2,4.1)</spring-version-range>
+    <!-- spring-dm does not support spring 4.x so import-range must be 3.x only until a solution in karaf exists -->
+    <spring-version-range>[3.2,4)</spring-version-range>
     <spring-version>${spring4-version}</spring-version>
     <spring32-version>3.2.11.RELEASE</spring32-version>
     <spring4-version>4.0.7.RELEASE</spring4-version>


[3/3] git commit: Fixed the NPE of JpaRouteTest

Posted by ni...@apache.org.
Fixed the NPE of JpaRouteTest


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9f18e556
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9f18e556
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9f18e556

Branch: refs/heads/camel-2.14.x
Commit: 9f18e556c13c0a92443d60af698d4c6bc7239bd7
Parents: 5178bda
Author: Willem Jiang <wi...@gmail.com>
Authored: Mon Sep 15 12:28:17 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Sep 15 12:28:17 2014 +0800

----------------------------------------------------------------------
 .../src/test/java/org/apache/camel/itest/osgi/jpa/JpaRouteTest.java | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9f18e556/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/jpa/JpaRouteTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/jpa/JpaRouteTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/jpa/JpaRouteTest.java
index b3ee2fb..3d111b8 100644
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/jpa/JpaRouteTest.java
+++ b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/jpa/JpaRouteTest.java
@@ -103,7 +103,6 @@ public class JpaRouteTest extends OSGiIntegrationTestSupport {
             applicationContext.setBundleContext(bundleContext);
             applicationContext.refresh();
         }
-        cleanupRepository();
         return SpringCamelContext.springCamelContext(applicationContext);
     }