You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by dm...@apache.org on 2019/04/25 19:59:46 UTC

[camel] branch master updated (30d3f67 -> 20c4e02)

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

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


    from 30d3f67  Fix flatpack dataformat tests
     new 422b8dc  CAMEL-13458: Support return of collection properties in Olingo4
     new 20c4e02  CAMEL-13458: Fixed CS Closes #2883

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../component/olingo2/Olingo2ComponentTest.java    |  12 +--
 .../component/olingo4/api/impl/Olingo4AppImpl.java |   6 +-
 .../component/olingo4/Olingo4ComponentTest.java    | 107 +++++++++++++++++----
 3 files changed, 96 insertions(+), 29 deletions(-)


[camel] 02/02: CAMEL-13458: Fixed CS Closes #2883

Posted by dm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 20c4e02a224051f0ce7cd2df03f3d7d3da2f10cf
Author: Dmitry Volodin <dm...@gmail.com>
AuthorDate: Thu Apr 25 22:57:02 2019 +0300

    CAMEL-13458: Fixed CS
    Closes #2883
---
 .../org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java     | 2 +-
 .../java/org/apache/camel/component/olingo4/Olingo4ComponentTest.java   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java
index cb5b64e..c59e562 100644
--- a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java
+++ b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.olingo4.api.impl;
 
-import static org.apache.camel.component.olingo4.api.impl.Olingo4Helper.getContentTypeHeader;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.Closeable;
@@ -108,6 +107,7 @@ import org.apache.olingo.server.api.uri.UriResourceFunction;
 import org.apache.olingo.server.api.uri.UriResourceKind;
 import org.apache.olingo.server.core.uri.parser.Parser;
 
+import static org.apache.camel.component.olingo4.api.impl.Olingo4Helper.getContentTypeHeader;
 /**
  * Application API used by Olingo4 Component.
  */
diff --git a/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentTest.java b/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentTest.java
index 4fa0f5d..87ccdb2 100644
--- a/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentTest.java
+++ b/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentTest.java
@@ -614,7 +614,7 @@ public class Olingo4ComponentTest extends AbstractOlingo4TestSupport {
                     .to("mock:consumer-splitresult-collection-value");
 
                 from("olingo4://read/" + TEST_PEOPLE + "/AddressInfo?consumer.splitResult=false")
-                .to("mock:consumer-nosplitresult-colleciton-value");
+                    .to("mock:consumer-nosplitresult-colleciton-value");
             }
         };
     }


[camel] 01/02: CAMEL-13458: Support return of collection properties in Olingo4

Posted by dm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 422b8dcb025664c2de0f529dd460df857b619d80
Author: phantomjinx <p....@phantomjinx.co.uk>
AuthorDate: Thu Apr 25 10:42:40 2019 +0100

    CAMEL-13458: Support return of collection properties in Olingo4
    
    * Olingo4AppImpl
     * If property has collection then return it.
    
    * Tests to prove fix
    
    * Olingo2ComponentTest
     * Shore up tests to make them more reliable.
---
 .../component/olingo2/Olingo2ComponentTest.java    |  12 +--
 .../component/olingo4/api/impl/Olingo4AppImpl.java |   8 +-
 .../component/olingo4/Olingo4ComponentTest.java    | 107 +++++++++++++++++----
 3 files changed, 97 insertions(+), 30 deletions(-)

diff --git a/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2ComponentTest.java b/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2ComponentTest.java
index cad6ecc..77d6b4e 100644
--- a/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2ComponentTest.java
+++ b/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2ComponentTest.java
@@ -419,7 +419,7 @@ public class Olingo2ComponentTest extends AbstractOlingo2TestSupport {
 
         int expectedMsgCount = 2;
         MockEndpoint mockEndpoint = getMockEndpoint("mock:consumer-splitresult");
-        mockEndpoint.expectedMessageCount(expectedMsgCount);
+        mockEndpoint.expectedMinimumMessageCount(expectedMsgCount);
 
         final ODataFeed odataFeed = (ODataFeed)requestBodyAndHeaders(endpoint, null, headers);
         assertNotNull(odataFeed);
@@ -439,15 +439,7 @@ public class Olingo2ComponentTest extends AbstractOlingo2TestSupport {
 
             Object name = properties.get("Name");
             assertNotNull(name);
-            switch(i) {
-            case 0:
-                assertEquals("Star Powered Racing", name);
-                break;
-            case 1:
-                assertEquals("Horse Powered Racing", name);
-                break;
-            default:
-            }
+            assertTrue(name.toString().contains("Powered Racing"));
         }
     }
 
diff --git a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java
index 7c5ad41..cb5b64e 100644
--- a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java
+++ b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.olingo4.api.impl;
 
+import static org.apache.camel.component.olingo4.api.impl.Olingo4Helper.getContentTypeHeader;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.Closeable;
@@ -29,7 +30,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
-
 import org.apache.camel.component.olingo4.api.Olingo4App;
 import org.apache.camel.component.olingo4.api.Olingo4ResponseHandler;
 import org.apache.camel.component.olingo4.api.batch.Olingo4BatchChangeRequest;
@@ -108,8 +108,6 @@ import org.apache.olingo.server.api.uri.UriResourceFunction;
 import org.apache.olingo.server.api.uri.UriResourceKind;
 import org.apache.olingo.server.core.uri.parser.Parser;
 
-import static org.apache.camel.component.olingo4.api.impl.Olingo4Helper.getContentTypeHeader;
-
 /**
  * Application API used by Olingo4 Component.
  */
@@ -406,6 +404,8 @@ public final class Olingo4AppImpl implements Olingo4App {
                     response = (T)property.getPrimitiveValue();
                 } else if (property.hasComplexValue()) {
                     response = (T)property.getComplexValue();
+                } else if (property.hasCollectionValue()) {
+                    response = (T)property.getCollectionValue();
                 } else {
                     throw new ODataException("Unsupported property: " + property.getName());
                 }
@@ -429,6 +429,8 @@ public final class Olingo4AppImpl implements Olingo4App {
                         response = (T)functionProperty.getPrimitiveValue();
                     } else if (functionProperty.hasComplexValue()) {
                         response = (T)functionProperty.getComplexValue();
+                    } else if (functionProperty.hasCollectionValue()) {
+                        response = (T)functionProperty.getCollectionValue();
                     } else {
                         throw new ODataException("Unsupported property: " + functionProperty.getName());
                     }
diff --git a/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentTest.java b/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentTest.java
index f961cde..4fa0f5d 100644
--- a/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentTest.java
+++ b/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentTest.java
@@ -18,9 +18,9 @@ package org.apache.camel.component.olingo4;
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
@@ -29,6 +29,7 @@ import org.apache.camel.component.olingo4.api.batch.Olingo4BatchQueryRequest;
 import org.apache.camel.component.olingo4.api.batch.Olingo4BatchRequest;
 import org.apache.camel.component.olingo4.api.batch.Olingo4BatchResponse;
 import org.apache.camel.component.olingo4.api.batch.Operation;
+import org.apache.olingo.client.api.domain.ClientCollectionValue;
 import org.apache.olingo.client.api.domain.ClientComplexValue;
 import org.apache.olingo.client.api.domain.ClientEntity;
 import org.apache.olingo.client.api.domain.ClientEntitySet;
@@ -104,6 +105,15 @@ public class Olingo4ComponentTest extends AbstractOlingo4TestSupport {
         assertTrue(complexProperty.isComplex());
         assertEquals("San Francisco", complexProperty.get("City").getComplexValue().get("Name").getValue().toString());
 
+        final ClientCollectionValue<?> collectionProperty = (ClientCollectionValue<?>)requestBodyAndHeaders("direct:readcollectionprop", null, headers);
+        assertTrue(collectionProperty.isCollection());
+        assertEquals(1, collectionProperty.size());
+        Iterator<?> propIter = collectionProperty.iterator();
+        Object propValueObj = propIter.next();
+        assertIsInstanceOf(ClientComplexValue.class, propValueObj);
+        ClientComplexValue propValue = (ClientComplexValue) propValueObj;
+        assertEquals("Boise", propValue.get("City").getComplexValue().get("Name").getValue().toString());
+
         final ClientEntity entity = (ClientEntity)requestBodyAndHeaders("direct:readentitybyid", null, headers);
         assertNotNull(entity);
         assertEquals("Russell", entity.getProperty("FirstName").getValue().toString());
@@ -305,7 +315,7 @@ public class Olingo4ComponentTest extends AbstractOlingo4TestSupport {
     @Test
     public void testConsumerReadFilterAlreadySeen() throws Exception {
         final Map<String, Object> headers = new HashMap<>();
-        String endpoint = "olingo4://read/People?filterAlreadySeen=true&consumer.delay=2&consumer.sendEmptyMessageWhenIdle=true&consumer.splitResult=false";
+        String endpoint = "olingo4://read/" + PEOPLE + "?filterAlreadySeen=true&consumer.delay=2&consumer.sendEmptyMessageWhenIdle=true&consumer.splitResult=false";
         int expectedEntities = 20;
         int expectedMsgCount = 3;
         MockEndpoint mockEndpoint = getMockEndpoint("mock:consumer-alreadyseen");
@@ -420,7 +430,7 @@ public class Olingo4ComponentTest extends AbstractOlingo4TestSupport {
     @Test
     public void testConsumerReadSplitResults() throws Exception {
         final Map<String, Object> headers = new HashMap<>();
-        String endpoint = "olingo4://read/People?consumer.splitResult=true";
+        String endpoint = "olingo4://read/" + PEOPLE + "?consumer.splitResult=true";
         int expectedEntities = 20;
 
         int expectedMsgCount = 3;
@@ -457,6 +467,7 @@ public class Olingo4ComponentTest extends AbstractOlingo4TestSupport {
             }
         }
     }
+
     /**
      * Read value of the People object and split the results
      * into individual messages
@@ -464,7 +475,7 @@ public class Olingo4ComponentTest extends AbstractOlingo4TestSupport {
     @Test
     public void testConsumerReadClientValuesSplitResults() throws Exception {
         final Map<String, Object> headers = new HashMap<>();
-        String endpoint = "olingo4://read/People('russellwhyte')/FavoriteFeature?consumer.splitResult=true";
+        String endpoint = "olingo4://read/" + TEST_PEOPLE + "/FavoriteFeature?consumer.splitResult=true";
 
         MockEndpoint mockEndpoint = getMockEndpoint("mock:consumer-splitresult-value");
         mockEndpoint.expectedMinimumMessageCount(1);
@@ -482,6 +493,61 @@ public class Olingo4ComponentTest extends AbstractOlingo4TestSupport {
         assertEquals("Feature1", value.toString());
     }
 
+    /**
+     * Read value of the People object's AddressInfo collection value
+     * & split the results into individual messages for each address
+     */
+    @Test
+    public void testConsumerReadClientCollectionValuesSplitResults() throws Exception {
+        final Map<String, Object> headers = new HashMap<>();
+        String endpoint = "olingo4://read/" + TEST_PEOPLE + "/AddressInfo?consumer.splitResult=true";
+
+        MockEndpoint mockEndpoint = getMockEndpoint("mock:consumer-splitresult-collection-value");
+        mockEndpoint.expectedMinimumMessageCount(1);
+
+        final ClientValue resultValue = requestBodyAndHeaders(endpoint, null, headers);
+        assertIsInstanceOf(ClientValue.class, resultValue);
+
+        mockEndpoint.assertIsSatisfied();
+        //
+        // 1 individual message in the exchange
+        //
+        Object body = mockEndpoint.getExchanges().get(0).getIn().getBody();
+        assertIsInstanceOf(ClientComplexValue.class, body);
+        ClientComplexValue value = (ClientComplexValue) body;
+        assertEquals("Boise", value.get("City").getComplexValue().get("Name").getValue().toString());
+    }
+
+    /**
+     * Read value of the People object's AddressInfo collection value
+     * & split the results into individual messages for each address
+     */
+    @Test
+    public void testConsumerReadClientCollectionValuesNoSplitResults() throws Exception {
+        final Map<String, Object> headers = new HashMap<>();
+        String endpoint = "olingo4://read/" + TEST_PEOPLE + "/AddressInfo?consumer.splitResult=false";
+
+        MockEndpoint mockEndpoint = getMockEndpoint("mock:consumer-nosplitresult-colleciton-value");
+        mockEndpoint.expectedMinimumMessageCount(1);
+
+        final ClientValue resultValue = requestBodyAndHeaders(endpoint, null, headers);
+        assertIsInstanceOf(ClientValue.class, resultValue);
+
+        mockEndpoint.assertIsSatisfied();
+        //
+        // 1 individual collection value message in the exchange
+        //
+        Object body = mockEndpoint.getExchanges().get(0).getIn().getBody();
+        assertIsInstanceOf(ClientCollectionValue.class, body);
+        ClientCollectionValue<?> value = (ClientCollectionValue<?>) body;
+        assertEquals(1, value.size());
+        Iterator<?> propIter = value.iterator();
+        Object propValueObj = propIter.next();
+        assertIsInstanceOf(ClientComplexValue.class, propValueObj);
+        ClientComplexValue propValue = (ClientComplexValue) propValueObj;
+        assertEquals("Boise", propValue.get("City").getComplexValue().get("Name").getValue().toString());
+    }
+
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
@@ -491,33 +557,35 @@ public class Olingo4ComponentTest extends AbstractOlingo4TestSupport {
 
                 from("direct:readdocument").to("olingo4://read/");
 
-                from("direct:readentities").to("olingo4://read/People?$top=5&$orderby=FirstName asc");
+                from("direct:readentities").to("olingo4://read/" + PEOPLE + "?$top=5&$orderby=FirstName asc");
 
-                from("direct:readcount").to("olingo4://read/People/$count");
+                from("direct:readcount").to("olingo4://read/" + PEOPLE + "/$count");
 
-                from("direct:readvalue").to("olingo4://read/People('russellwhyte')/Gender/$value");
+                from("direct:readvalue").to("olingo4://read/" + TEST_PEOPLE + "/Gender/$value");
 
                 from("direct:readsingleprop").to("olingo4://read/Airports('KSFO')/Name");
 
                 from("direct:readcomplexprop").to("olingo4://read/Airports('KSFO')/Location");
 
-                from("direct:readentitybyid").to("olingo4://read/People('russellwhyte')");
+                from("direct:readcollectionprop").to("olingo4://read/" + TEST_PEOPLE + "/AddressInfo");
+
+                from("direct:readentitybyid").to("olingo4://read/" + TEST_PEOPLE + "");
 
                 from("direct:readwithfilter").to("olingo4://read/Airports?$filter=Name eq 'San Francisco International Airport'");
 
                 from("direct:callunboundfunction").to("olingo4://read/GetNearestAirport(lat=33,lon=-118)");
 
                 // test route for create individual entity
-                from("direct:create-entity").to("olingo4://create/People");
+                from("direct:create-entity").to("olingo4://create/" + PEOPLE);
 
                 // test route for update
-                from("direct:update-entity").to("olingo4://update/People('lewisblack')");
+                from("direct:update-entity").to("olingo4://update/" + PEOPLE + "('lewisblack')");
 
                 // test route for delete
-                from("direct:delete-entity").to("olingo4://delete/People('lewisblack')");
+                from("direct:delete-entity").to("olingo4://delete/" + PEOPLE + "('lewisblack')");
 
                 // test route for delete
-                from("direct:read-deleted-entity").to("olingo4://delete/People('lewisblack')");
+                from("direct:read-deleted-entity").to("olingo4://delete/" + PEOPLE + "('lewisblack')");
 
                 // test route for batch
                 from("direct:batch").to("olingo4://batch");
@@ -526,22 +594,27 @@ public class Olingo4ComponentTest extends AbstractOlingo4TestSupport {
 
                 from("direct:delete-with-etag").to("olingo4://delete/Airlines('AA')");
 
-                from("direct:read-people-nofilterseen").to("olingo4://read/People").to("mock:producer-noalreadyseen");
+                from("direct:read-people-nofilterseen").to("olingo4://read/" + PEOPLE).to("mock:producer-noalreadyseen");
 
-                from("direct:read-people-filterseen").to("olingo4://read/People?filterAlreadySeen=true").to("mock:producer-alreadyseen");
+                from("direct:read-people-filterseen").to("olingo4://read/" + PEOPLE + "?filterAlreadySeen=true").to("mock:producer-alreadyseen");
 
                 //
                 // Consumer endpoint
                 //
-                from("olingo4://read/People?filterAlreadySeen=true&consumer.delay=2&consumer.sendEmptyMessageWhenIdle=true&consumer.splitResult=false")
+                from("olingo4://read/" + PEOPLE + "?filterAlreadySeen=true&consumer.delay=2&consumer.sendEmptyMessageWhenIdle=true&consumer.splitResult=false")
                     .to("mock:consumer-alreadyseen");
 
-                from("olingo4://read/People?consumer.splitResult=true")
+                from("olingo4://read/" + PEOPLE + "?consumer.splitResult=true")
                     .to("mock:consumer-splitresult");
 
-                from("olingo4://read/People('russellwhyte')/FavoriteFeature?consumer.splitResult=true")
+                from("olingo4://read/" + TEST_PEOPLE + "/FavoriteFeature?consumer.splitResult=true")
                     .to("mock:consumer-splitresult-value");
 
+                from("olingo4://read/" + TEST_PEOPLE + "/AddressInfo?consumer.splitResult=true")
+                    .to("mock:consumer-splitresult-collection-value");
+
+                from("olingo4://read/" + TEST_PEOPLE + "/AddressInfo?consumer.splitResult=false")
+                .to("mock:consumer-nosplitresult-colleciton-value");
             }
         };
     }