You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bv...@apache.org on 2019/10/30 17:25:58 UTC

[camel] branch master updated: correct typos and polish JpaTest

This is an automated email from the ASF dual-hosted git repository.

bvahdat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 2e212fc  correct typos and polish JpaTest
2e212fc is described below

commit 2e212fcabf3171a0404d0dfbd0d6d88c7e257c39
Author: Babak Vahdat <bv...@apache.org>
AuthorDate: Wed Oct 30 18:25:36 2019 +0100

    correct typos and polish JpaTest
---
 .../apache/camel/component/jpa/JpaProducer.java    |  8 ++---
 .../org/apache/camel/component/jpa/JpaTest.java    | 40 ++++++++--------------
 2 files changed, 18 insertions(+), 30 deletions(-)

diff --git a/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaProducer.java b/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaProducer.java
index 8411e17..e9c00ea 100644
--- a/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaProducer.java
+++ b/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaProducer.java
@@ -85,7 +85,7 @@ public class JpaProducer extends DefaultProducer {
     public void setParameters(Map<String, Object> params) {
         this.parameters = params;
     }
-    
+
     public Map<String, Object> getParameters() {
         return parameters;
     }
@@ -310,7 +310,7 @@ public class JpaProducer extends DefaultProducer {
                 }
 
                 /**
-                 * Save the given entity end return the managed entity
+                 * Save the given entity and return the managed entity
                  *
                  * @return the managed entity
                  */
@@ -323,9 +323,9 @@ public class JpaProducer extends DefaultProducer {
                         return entityManager.merge(entity);
                     }
                 }
-                
+
                 /**
-                 * Remove the given entity end return the managed entity
+                 * Remove the given entity and return the managed entity
                  *
                  * @return the managed entity
                  */
diff --git a/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaTest.java b/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaTest.java
index 2b53c65..b70c65e 100644
--- a/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaTest.java
+++ b/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaTest.java
@@ -58,18 +58,6 @@ public class JpaTest extends Assert {
 
     @Test
     public void testProducerInsertsIntoDatabaseThenConsumerFiresMessageExchange() throws Exception {
-        transactionTemplate.execute(new TransactionCallback<Object>() {
-            public Object doInTransaction(TransactionStatus status) {
-                entityManager.joinTransaction();
-                // lets delete any exiting records before the test
-                entityManager.createQuery("delete from " + entityName).executeUpdate();
-                return null;
-            }
-        });
-
-        List<?> results = entityManager.createQuery(queryText).getResultList();
-        assertEquals("Should have no results: " + results, 0, results.size());
-
         // lets produce some objects
         template.send(endpoint, new Processor() {
             public void process(Exchange exchange) {
@@ -78,7 +66,7 @@ public class JpaTest extends Assert {
         });
 
         // now lets assert that there is a result
-        results = entityManager.createQuery(queryText).getResultList();
+        List<?> results = entityManager.createQuery(queryText).getResultList();
         assertEquals("Should have results: " + results, 1, results.size());
         SendEmail mail = (SendEmail) results.get(0);
         assertEquals("address property", "foo@bar.com", mail.getAddress());
@@ -106,18 +94,6 @@ public class JpaTest extends Assert {
 
     @Test
     public void testProducerInsertsList() throws Exception {
-        transactionTemplate.execute(new TransactionCallback<Object>() {
-            public Object doInTransaction(TransactionStatus status) {
-                entityManager.joinTransaction();
-                // lets delete any exiting records before the test
-                entityManager.createQuery("delete from " + entityName).executeUpdate();
-                return null;
-            }
-        });
-
-        List<?> results = entityManager.createQuery(queryText).getResultList();
-        assertEquals("Should have no results: " + results, 0, results.size());
-
         // lets produce some objects
         template.send(listEndpoint, new Processor() {
             public void process(Exchange exchange) {
@@ -130,7 +106,7 @@ public class JpaTest extends Assert {
         });
 
         // now lets assert that there is a result
-        results = entityManager.createQuery(queryText).getResultList();
+        List<?> results = entityManager.createQuery(queryText).getResultList();
         assertEquals("Should have results: " + results, 2, results.size());
         SendEmail mail = (SendEmail) results.get(0);
         assertEquals("address property", "foo@bar.com", mail.getAddress());
@@ -155,6 +131,18 @@ public class JpaTest extends Assert {
 
         transactionTemplate = endpoint.createTransactionTemplate();
         entityManager = endpoint.createEntityManager();
+
+        transactionTemplate.execute(new TransactionCallback<Object>() {
+            public Object doInTransaction(TransactionStatus status) {
+                entityManager.joinTransaction();
+                // lets delete any exiting records before the test
+                entityManager.createQuery("delete from " + entityName).executeUpdate();
+                return null;
+            }
+        });
+
+        List<?> results = entityManager.createQuery(queryText).getResultList();
+        assertEquals("Should have no results: " + results, 0, results.size());
     }
 
     protected String getEndpointUri() {