You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by dh...@apache.org on 2014/09/02 21:12:16 UTC

git commit: CAMEL-7773 Minor cleanup in Camel-Olingo2 component and tests

Repository: camel
Updated Branches:
  refs/heads/master 2728b2f1d -> b188ac9c7


CAMEL-7773 Minor cleanup in Camel-Olingo2 component and tests


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

Branch: refs/heads/master
Commit: b188ac9c70beeedf84ad69a92cc3ebde80e8dfe2
Parents: 2728b2f
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Tue Sep 2 12:12:02 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Sep 2 12:12:02 2014 -0700

----------------------------------------------------------------------
 .../olingo2/api/Olingo2AppIntegrationTest.java  | 10 +++--
 .../component/olingo2/Olingo2Consumer.java      |  2 +-
 .../component/olingo2/Olingo2Endpoint.java      |  6 ++-
 .../component/olingo2/Olingo2Producer.java      |  3 +-
 .../olingo2/Olingo2AppIntegrationTest.java      | 39 ++++++++++++++++----
 5 files changed, 45 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b188ac9c/components/camel-olingo2/camel-olingo2-api/src/test/java/org/apache/camel/component/olingo2/api/Olingo2AppIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-olingo2/camel-olingo2-api/src/test/java/org/apache/camel/component/olingo2/api/Olingo2AppIntegrationTest.java b/components/camel-olingo2/camel-olingo2-api/src/test/java/org/apache/camel/component/olingo2/api/Olingo2AppIntegrationTest.java
index 9810be3..aa41056 100644
--- a/components/camel-olingo2/camel-olingo2-api/src/test/java/org/apache/camel/component/olingo2/api/Olingo2AppIntegrationTest.java
+++ b/components/camel-olingo2/camel-olingo2-api/src/test/java/org/apache/camel/component/olingo2/api/Olingo2AppIntegrationTest.java
@@ -61,6 +61,7 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+
 /**
  * Integration test for {@link org.apache.camel.component.olingo2.api.impl.Olingo2AppImpl}.
  * To test run the sample Olingo2 Server as outlined at
@@ -94,8 +95,8 @@ public class Olingo2AppIntegrationTest {
     private static final String COUNT_OPTION = "/$count";
 
     private static final String TEST_SERVICE_URL = "http://localhost:8080/MyFormula.svc";
-    //    private static String TEST_SERVICE_URL = "http://localhost:8080/cars-annotations-sample/MyFormula.svc";
-//    private static ContentType TEST_FORMAT = ContentType.APPLICATION_XML_CS_UTF_8;
+    //    private static final String TEST_SERVICE_URL = "http://localhost:8080/cars-annotations-sample/MyFormula.svc";
+//    private static final ContentType TEST_FORMAT = ContentType.APPLICATION_XML_CS_UTF_8;
     private static final ContentType TEST_FORMAT = ContentType.APPLICATION_JSON_CS_UTF_8;
     private static final String INDEX = "/index.jsp";
 
@@ -119,6 +120,9 @@ public class Olingo2AppIntegrationTest {
 
         edm = responseHandler.await();
         LOG.info("Read default EntityContainer:  {}", responseHandler.await().getDefaultEntityContainer().getName());
+
+        // wait for generated data to be registered in server
+        Thread.sleep(2000);
     }
 
     @AfterClass
@@ -557,4 +561,4 @@ public class Olingo2AppIntegrationTest {
             error = null;
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/b188ac9c/components/camel-olingo2/camel-olingo2-component/src/main/java/org/apache/camel/component/olingo2/Olingo2Consumer.java
----------------------------------------------------------------------
diff --git a/components/camel-olingo2/camel-olingo2-component/src/main/java/org/apache/camel/component/olingo2/Olingo2Consumer.java b/components/camel-olingo2/camel-olingo2-component/src/main/java/org/apache/camel/component/olingo2/Olingo2Consumer.java
index 501ad75..4a46675 100644
--- a/components/camel-olingo2/camel-olingo2-component/src/main/java/org/apache/camel/component/olingo2/Olingo2Consumer.java
+++ b/components/camel-olingo2/camel-olingo2-component/src/main/java/org/apache/camel/component/olingo2/Olingo2Consumer.java
@@ -68,7 +68,7 @@ public class Olingo2Consumer extends AbstractApiConsumer<Olingo2ApiName, Olingo2
 
                 @Override
                 public void onCanceled() {
-                    error[0] = new RuntimeCamelException("Http Request cancelled");
+                    error[0] = new RuntimeCamelException("OData HTTP Request cancelled");
                     latch.countDown();
                 }
             });

http://git-wip-us.apache.org/repos/asf/camel/blob/b188ac9c/components/camel-olingo2/camel-olingo2-component/src/main/java/org/apache/camel/component/olingo2/Olingo2Endpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-olingo2/camel-olingo2-component/src/main/java/org/apache/camel/component/olingo2/Olingo2Endpoint.java b/components/camel-olingo2/camel-olingo2-component/src/main/java/org/apache/camel/component/olingo2/Olingo2Endpoint.java
index 170eb49..d2d52d4 100644
--- a/components/camel-olingo2/camel-olingo2-component/src/main/java/org/apache/camel/component/olingo2/Olingo2Endpoint.java
+++ b/components/camel-olingo2/camel-olingo2-component/src/main/java/org/apache/camel/component/olingo2/Olingo2Endpoint.java
@@ -249,7 +249,7 @@ public class Olingo2Endpoint extends AbstractApiEndpoint<Olingo2ApiName, Olingo2
 
                         @Override
                         public void onCanceled() {
-                            error[0] = new RuntimeCamelException("OData HTTP request cancelled");
+                            error[0] = new RuntimeCamelException("OData HTTP request cancelled!");
                             latch.countDown();
                         }
                     });
@@ -263,7 +263,9 @@ public class Olingo2Endpoint extends AbstractApiEndpoint<Olingo2ApiName, Olingo2
                             if (ex instanceof RuntimeCamelException) {
                                 throw (RuntimeCamelException) ex;
                             } else {
-                                throw new RuntimeCamelException("Error reading EDM " + ex.getMessage(), ex);
+                                final String message = ex.getMessage() != null
+                                    ? ex.getMessage() : ex.getClass().getName();
+                                throw new RuntimeCamelException("Error reading EDM: " + message, ex);
                             }
                         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/b188ac9c/components/camel-olingo2/camel-olingo2-component/src/main/java/org/apache/camel/component/olingo2/Olingo2Producer.java
----------------------------------------------------------------------
diff --git a/components/camel-olingo2/camel-olingo2-component/src/main/java/org/apache/camel/component/olingo2/Olingo2Producer.java b/components/camel-olingo2/camel-olingo2-component/src/main/java/org/apache/camel/component/olingo2/Olingo2Producer.java
index 5286af6..b9e46a4 100644
--- a/components/camel-olingo2/camel-olingo2-component/src/main/java/org/apache/camel/component/olingo2/Olingo2Producer.java
+++ b/components/camel-olingo2/camel-olingo2-component/src/main/java/org/apache/camel/component/olingo2/Olingo2Producer.java
@@ -75,8 +75,7 @@ public class Olingo2Producer extends AbstractApiProducer<Olingo2ApiName, Olingo2
 
             @Override
             public void onCanceled() {
-                exchange.setException(new RuntimeCamelException("HTTP Request cancelled for "
-                    + endpoint.getEndpointUri()));
+                exchange.setException(new RuntimeCamelException("OData HTTP Request cancelled!"));
                 callback.done(false);
             }
         });

http://git-wip-us.apache.org/repos/asf/camel/blob/b188ac9c/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2AppIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2AppIntegrationTest.java b/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2AppIntegrationTest.java
index 2694117..aa96533 100644
--- a/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2AppIntegrationTest.java
+++ b/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2AppIntegrationTest.java
@@ -42,8 +42,14 @@ import org.slf4j.LoggerFactory;
 
 /**
  * Test class for {@link org.apache.camel.component.olingo2.api.Olingo2App} APIs.
+ * <p>
  * The integration test runs against Apache Olingo 2.0 sample server
  * described at http://olingo.apache.org/doc/sample-setup.html
+ * </p>
+ * <p>
+ * Sample data must be first generated by using the sample client described with the server,
+ * or by running test <code>Olingo2AppIntegrationTest</code> in camel-olingo2-api module.
+ * </p>
  */
 public class Olingo2AppIntegrationTest extends AbstractOlingo2TestSupport {
 
@@ -65,6 +71,7 @@ public class Olingo2AppIntegrationTest extends AbstractOlingo2TestSupport {
         final ServiceDocument document = requestBodyAndHeaders("direct://READSERVICEDOC", null, headers);
         assertNotNull(document);
         assertFalse("ServiceDocument entity sets", document.getEntitySetsInfo().isEmpty());
+        LOG.info("Service document has {} entity sets", document.getEntitySetsInfo().size());
 
         // parameter type is java.util.Map
         final HashMap<String, String> queryParams = new HashMap<String, String>();
@@ -74,14 +81,18 @@ public class Olingo2AppIntegrationTest extends AbstractOlingo2TestSupport {
         // read ODataFeed
         final ODataFeed manufacturers = requestBodyAndHeaders("direct://READFEED", null, headers);
         assertNotNull(manufacturers);
-        assertEquals("Manufacturers feed size", 5, manufacturers.getEntries().size());
+        final List<ODataEntry> manufacturersEntries = manufacturers.getEntries();
+        assertFalse("Manufacturers empty entries", manufacturersEntries.isEmpty());
+        LOG.info("Manufacturers feed has {} entries", manufacturersEntries.size());
 
         // read ODataEntry
         headers.clear();
         headers.put(Olingo2Constants.PROPERTY_PREFIX + "keyPredicate", "'1'");
         final ODataEntry manufacturer = requestBodyAndHeaders("direct://READENTRY", null, headers);
         assertNotNull(manufacturer);
-        assertEquals("Manufacturer Id", "1", manufacturer.getProperties().get(ID_PROPERTY));
+        final Map<String, Object> properties = manufacturer.getProperties();
+        assertEquals("Manufacturer Id", "1", properties.get(ID_PROPERTY));
+        LOG.info("Manufacturer: {}", properties.toString());
     }
 
     @Test
@@ -91,7 +102,9 @@ public class Olingo2AppIntegrationTest extends AbstractOlingo2TestSupport {
 
         final ODataEntry manufacturer = requestBody("direct://CREATE", data);
         assertNotNull("Created Manufacturer", manufacturer);
-        assertEquals("Created Manufacturer Id", "123", manufacturer.getProperties().get(ID_PROPERTY));
+        final Map<String, Object> properties = manufacturer.getProperties();
+        assertEquals("Created Manufacturer Id", "123", properties.get(ID_PROPERTY));
+        LOG.info("Created Manufacturer: {}", properties);
 
         // update
         data.put("Name", "MyCarManufacturer Renamed");
@@ -101,11 +114,13 @@ public class Olingo2AppIntegrationTest extends AbstractOlingo2TestSupport {
         HttpStatusCodes status = requestBody("direct://UPDATE", data);
         assertNotNull("Update status", status);
         assertEquals("Update status", HttpStatusCodes.NO_CONTENT.getStatusCode(), status.getStatusCode());
+        LOG.info("Update status: {}", status);
 
         // delete
         status = requestBody("direct://DELETE", null);
         assertNotNull("Delete status", status);
         assertEquals("Delete status", HttpStatusCodes.NO_CONTENT.getStatusCode(), status.getStatusCode());
+        LOG.info("Delete status: {}", status);
     }
 
     private Map<String, Object> getEntityData() {
@@ -168,25 +183,35 @@ public class Olingo2AppIntegrationTest extends AbstractOlingo2TestSupport {
 
         final Edm edm = (Edm) responseParts.get(0).getBody();
         assertNotNull(edm);
+        LOG.info("Edm entity sets: {}", edm.getEntitySets());
 
         final ODataFeed feed = (ODataFeed) responseParts.get(1).getBody();
         assertNotNull(feed);
+        LOG.info("Read feed: {}", feed.getEntries());
 
         ODataEntry dataEntry = (ODataEntry) responseParts.get(2).getBody();
         assertNotNull(dataEntry);
+        LOG.info("Read entry: {}", dataEntry.getProperties());
 
         dataEntry = (ODataEntry) responseParts.get(3).getBody();
         assertNotNull(dataEntry);
+        LOG.info("Read entry with $expand: {}", dataEntry.getProperties());
 
         dataEntry = (ODataEntry) responseParts.get(4).getBody();
         assertNotNull(dataEntry);
+        LOG.info("Created entry: {}", dataEntry.getProperties());
 
-        assertEquals(HttpStatusCodes.NO_CONTENT.getStatusCode(), responseParts.get(5).getStatusCode());
-        assertEquals(HttpStatusCodes.NO_CONTENT.getStatusCode(), responseParts.get(6).getStatusCode());
+        int statusCode = responseParts.get(5).getStatusCode();
+        assertEquals(HttpStatusCodes.NO_CONTENT.getStatusCode(), statusCode);
+        statusCode = responseParts.get(6).getStatusCode();
+        LOG.info("Update status: {}", statusCode);
+        assertEquals(HttpStatusCodes.NO_CONTENT.getStatusCode(), statusCode);
+        LOG.info("Delete status: {}", statusCode);
 
         assertEquals(HttpStatusCodes.NOT_FOUND.getStatusCode(), responseParts.get(7).getStatusCode());
         final Exception exception = (Exception) responseParts.get(7).getBody();
         assertNotNull(exception);
+        LOG.info("Read deleted entry exception: {}", exception);
     }
 
     @Override
@@ -218,11 +243,11 @@ public class Olingo2AppIntegrationTest extends AbstractOlingo2TestSupport {
 /*
                 // test route for merge
                 from("direct://MERGE")
-                  .to("olingo2://merge");
+                    .to("olingo2://merge");
 
                 // test route for patch
                 from("direct://PATCH")
-                  .to("olingo2://patch");
+                    .to("olingo2://patch");
 */
 
                 // test route for batch