You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ra...@apache.org on 2015/04/20 16:28:21 UTC

[01/22] olingo-odata4 git commit: [OLINGO-617] Derserializer and Serializer result refactoring, ExpandBuilder

Repository: olingo-odata4
Updated Branches:
  refs/heads/OLINGO-573 26ec32ad5 -> f262563fa


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
index 841eabe..e105a2f 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
@@ -40,6 +40,7 @@ import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.deserializer.DeserializerException;
+import org.apache.olingo.server.api.deserializer.DeserializerResult;
 import org.apache.olingo.server.api.deserializer.ODataDeserializer;
 import org.apache.olingo.server.api.processor.ActionEntityCollectionProcessor;
 import org.apache.olingo.server.api.processor.ActionEntityProcessor;
@@ -136,7 +137,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
                   getContextUrl(edmEntitySet, edmEntityType, false, expand, select))
               .count(uriInfo.getCountOption())
               .expand(expand).select(select)
-              .build()));
+              .build()).getContent());
       response.setStatusCode(HttpStatusCode.OK.getStatusCode());
       response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
     }
@@ -195,7 +196,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
             .contextURL(format == ODataFormat.JSON_NO_METADATA ? null :
                 getContextUrl(edmEntitySet, edmEntityType, true, expand, select))
             .expand(expand).select(select)
-            .build()));
+            .build()).getContent());
     response.setStatusCode(HttpStatusCode.OK.getStatusCode());
     response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
   }
@@ -231,14 +232,16 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
     final EdmEntityType edmEntityType = edmEntitySet.getEntityType();
 
     Entity entity = dataProvider.create(edmEntitySet);
+    ExpandOption expand = null;
     if (edmEntityType.hasStream()) { // called from createMediaEntity(...), not directly
       dataProvider.setMedia(entity, odata.createFixedFormatDeserializer().binary(request.getBody()),
           requestFormat.toContentTypeString());
     } else {
+      final DeserializerResult deserializerResult = odata.createDeserializer(ODataFormat.fromContentType(requestFormat))
+                                                         .entity(request.getBody(), edmEntityType);
       dataProvider.update(request.getRawBaseUri(), edmEntitySet, entity,
-          odata.createDeserializer(ODataFormat.fromContentType(requestFormat))
-              .entity(request.getBody(), edmEntityType),
-          false, true);
+          deserializerResult.getEntity(), false, true);
+      expand = deserializerResult.getExpandTree();
     }
 
     final ODataFormat format = ODataFormat.fromContentType(responseFormat);
@@ -247,7 +250,8 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
         EntitySerializerOptions.with()
             .contextURL(format == ODataFormat.JSON_NO_METADATA ? null :
                 getContextUrl(edmEntitySet, edmEntityType, true, null, null))
-            .build()));
+            .expand(expand)
+            .build()).getContent());
     response.setStatusCode(HttpStatusCode.CREATED.getStatusCode());
     response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
     response.setHeader(HttpHeader.LOCATION,
@@ -262,7 +266,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
     Entity entity = readEntity(uriInfo);
     checkRequestFormat(requestFormat);
     ODataDeserializer deserializer = odata.createDeserializer(ODataFormat.fromContentType(requestFormat));
-    final Entity changedEntity = deserializer.entity(request.getBody(), edmEntitySet.getEntityType());
+    final Entity changedEntity = deserializer.entity(request.getBody(), edmEntitySet.getEntityType()).getEntity();
     dataProvider.update(request.getRawBaseUri(), edmEntitySet, entity, changedEntity,
         request.getMethod() == HttpMethod.PATCH, false);
     response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
index b853e48..8a9968f 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
@@ -248,13 +248,13 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor
                   .precision(edmProperty == null ? returnType.getPrecision() : edmProperty.getPrecision())
                   .scale(edmProperty == null ? returnType.getScale() : edmProperty.getScale())
                   .unicode(edmProperty == null ? null : edmProperty.isUnicode())
-                  .build()));
+                  .build()).getContent());
           break;
         case COMPLEX:
           response.setContent(serializer.complex(this.serviceMetadata,(EdmComplexType) type, property,
               ComplexSerializerOptions.with().contextURL(contextURL)
                   .expand(expand).select(select)
-                  .build()));
+                  .build()).getContent());
           break;
         case COLLECTION_PRIMITIVE:
           response.setContent(serializer.primitiveCollection((EdmPrimitiveType) type, property,
@@ -264,13 +264,13 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor
                   .precision(edmProperty == null ? returnType.getPrecision() : edmProperty.getPrecision())
                   .scale(edmProperty == null ? returnType.getScale() : edmProperty.getScale())
                   .unicode(edmProperty == null ? null : edmProperty.isUnicode())
-                  .build()));
+                  .build()).getContent());
           break;
         case COLLECTION_COMPLEX:
           response.setContent(serializer.complexCollection(this.serviceMetadata, (EdmComplexType) type, property,
               ComplexSerializerOptions.with().contextURL(contextURL)
                   .expand(expand).select(select)
-                  .build()));
+                  .build()).getContent());
           break;
         default:
           break;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerDeepInsertTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerDeepInsertTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerDeepInsertTest.java
index f2a65cd..0347941 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerDeepInsertTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerDeepInsertTest.java
@@ -41,8 +41,7 @@ public class ODataDeserializerDeepInsertTest extends AbstractODataDeserializerTe
   public void esAllPrimExpandedToOne() throws Exception {
     EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
     InputStream stream = getFileAsStream("EntityESAllPrimExpandedNavPropertyETTwoPrimOne.json");
-    Entity entity = OData.newInstance().createDeserializer(ODataFormat.JSON).entity(stream, edmEntityType);
-
+    Entity entity = OData.newInstance().createDeserializer(ODataFormat.JSON).entity(stream, edmEntityType).getEntity();
     Link navigationLink = entity.getNavigationLink("NavPropertyETTwoPrimOne");
     assertNotNull(navigationLink);
 
@@ -63,7 +62,7 @@ public class ODataDeserializerDeepInsertTest extends AbstractODataDeserializerTe
   public void esAllPrimExpandedToMany() throws Exception {
     EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
     InputStream stream = getFileAsStream("EntityESAllPrimExpandedNavPropertyETTwoPrimMany.json");
-    Entity entity = OData.newInstance().createDeserializer(ODataFormat.JSON).entity(stream, edmEntityType);
+    Entity entity = OData.newInstance().createDeserializer(ODataFormat.JSON).entity(stream, edmEntityType).getEntity();
 
     Link navigationLink = entity.getNavigationLink("NavPropertyETTwoPrimMany");
     assertNotNull(navigationLink);
@@ -130,7 +129,8 @@ public class ODataDeserializerDeepInsertTest extends AbstractODataDeserializerTe
             + "}";
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
     EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETTwoPrim"));
-    final Entity entity = OData.newInstance().createDeserializer(ODataFormat.JSON).entity(stream, edmEntityType);
+    final Entity entity = OData.newInstance().createDeserializer(ODataFormat.JSON).entity(stream, edmEntityType)
+                                                                                  .getEntity();
   
     assertEquals(1, entity.getNavigationLinks().size());
     final Link link = entity.getNavigationLinks().get(0);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerEntityCollectionTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerEntityCollectionTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerEntityCollectionTest.java
index 3a17eae..4864d24 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerEntityCollectionTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerEntityCollectionTest.java
@@ -44,7 +44,8 @@ public class ODataDeserializerEntityCollectionTest extends AbstractODataDeserial
     EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
     InputStream stream = getFileAsStream("ESAllPrim.json");
     EntitySet entitySet =
-        OData.newInstance().createDeserializer(ODataFormat.JSON).entityCollection(stream, edmEntityType);
+        OData.newInstance().createDeserializer(ODataFormat.JSON).entityCollection(stream, edmEntityType)
+                           .getEntityCollection();
 
     assertNotNull(entitySet);
     assertEquals(3, entitySet.getEntities().size());
@@ -78,7 +79,8 @@ public class ODataDeserializerEntityCollectionTest extends AbstractODataDeserial
     EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETCompCollComp"));
     InputStream stream = getFileAsStream("ESCompCollComp.json");
     EntitySet entitySet =
-        OData.newInstance().createDeserializer(ODataFormat.JSON).entityCollection(stream, edmEntityType);
+        OData.newInstance().createDeserializer(ODataFormat.JSON).entityCollection(stream, edmEntityType)
+                                                                .getEntityCollection();
 
     assertNotNull(entitySet);
     assertEquals(2, entitySet.getEntities().size());
@@ -99,7 +101,8 @@ public class ODataDeserializerEntityCollectionTest extends AbstractODataDeserial
     InputStream stream = new ByteArrayInputStream(entityCollectionString.getBytes());
     EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
     EntitySet entityCollection =
-        OData.newInstance().createDeserializer(ODataFormat.JSON).entityCollection(stream, edmEntityType);
+        OData.newInstance().createDeserializer(ODataFormat.JSON).entityCollection(stream, edmEntityType)
+                                                                .getEntityCollection();
     assertNotNull(entityCollection.getEntities());
     assertTrue(entityCollection.getEntities().isEmpty());
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java
index 58777ab..80c7c47 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java
@@ -98,7 +98,7 @@ public class ODataJsonDeserializerActionParametersTest extends AbstractODataDese
   private List<Parameter> deserialize(final String input, final String actionName) throws DeserializerException {
     return OData.newInstance().createDeserializer(ODataFormat.JSON)
         .actionParameters(new ByteArrayInputStream(input.getBytes()),
-            edm.getUnboundAction(new FullQualifiedName("Namespace1_Alias", actionName)));
+            edm.getUnboundAction(new FullQualifiedName("Namespace1_Alias", actionName))).getActionParameter();
   }
 
   private List<Parameter> deserialize(final String input, final String actionName, final String typeName)
@@ -106,6 +106,6 @@ public class ODataJsonDeserializerActionParametersTest extends AbstractODataDese
     return OData.newInstance().createDeserializer(ODataFormat.JSON)
         .actionParameters(new ByteArrayInputStream(input.getBytes()),
             edm.getBoundAction(new FullQualifiedName("Namespace1_Alias", actionName),
-                new FullQualifiedName("Namespace1_Alias", typeName), false));
+                new FullQualifiedName("Namespace1_Alias", typeName), false)).getActionParameter();
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
index 870f7c3..4a433c3 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
@@ -64,7 +64,8 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
     Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
+        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")))
+                                       .getEntity();
     assertNotNull(entity);
     List<Property> properties = entity.getProperties();
     assertNotNull(properties);
@@ -93,7 +94,8 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
     Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
+        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")))
+                    .getEntity();
     assertNotNull(entity);
     List<Property> properties = entity.getProperties();
     assertNotNull(properties);
@@ -139,7 +141,8 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
     Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
+        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")))
+                    .getEntity();
     assertNotNull(entity);
     List<Property> properties = entity.getProperties();
     assertNotNull(properties);
@@ -159,7 +162,8 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
     Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
+        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")))
+                    .getEntity();
     assertNotNull(entity);
     List<Property> properties = entity.getProperties();
     assertNotNull(properties);
@@ -188,7 +192,8 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
     Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
+        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")))
+                    .getEntity();
     assertNotNull(entity);
     List<Property> properties = entity.getProperties();
     assertNotNull(properties);
@@ -222,7 +227,8 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
     Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETCompAllPrim")));
+        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETCompAllPrim")))
+        .getEntity();
     assertNotNull(entity);
     List<Property> properties = entity.getProperties();
     assertNotNull(properties);
@@ -263,7 +269,8 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
     Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETCollAllPrim")));
+        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETCollAllPrim")))
+                    .getEntity();
     assertNotNull(entity);
     List<Property> properties = entity.getProperties();
     assertNotNull(properties);
@@ -300,7 +307,8 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
     Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")));
+        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")))
+        .getEntity();
     assertNotNull(entity);
     List<Property> properties = entity.getProperties();
     assertNotNull(properties);
@@ -332,7 +340,8 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
     Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")));
+        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")))
+                    .getEntity();
     assertNotNull(entity);
     List<Property> properties = entity.getProperties();
     assertNotNull(properties);
@@ -380,7 +389,8 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
     Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
+        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")))
+                    .getEntity();
     assertNotNull(entity);
   }
 
@@ -437,7 +447,8 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
     Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
+        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")))
+                    .getEntity();
     assertNotNull(entity);
     List<Property> properties = entity.getProperties();
     assertNotNull(properties);
@@ -455,7 +466,8 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
     Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
+        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")))
+                    .getEntity();
     assertNotNull(entity);
 
     Link bindingToOne = entity.getNavigationBinding("NavPropertyETTwoPrimOne");
@@ -488,7 +500,8 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
     Entity entity =
-        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")));
+        deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim")))
+                    .getEntity();
     Link bindingToMany = entity.getNavigationBinding("NavPropertyETTwoPrimMany");
     assertNotNull(bindingToMany);
     assertTrue(bindingToMany.getBindingLinks().isEmpty());
@@ -500,7 +513,8 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
     Entity entity =
         deserializer.entity(stream, edm
-            .getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixEnumDefCollComp")));
+            .getEntityType(new FullQualifiedName("Namespace1_Alias", "ETMixEnumDefCollComp")))
+            .getEntity();
 
     assertEquals(6, entity.getProperties().size());
 
@@ -545,7 +559,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
     Entity e = deserializer.entity(stream, edm.getEntityType(
-        new FullQualifiedName("Namespace1_Alias", "ETCollAllPrim")));
+        new FullQualifiedName("Namespace1_Alias", "ETCollAllPrim"))).getEntity();
 
     assertTrue((Boolean) e.getProperty("CollPropertyBoolean").asCollection().get(0));
     assertNull(e.getProperty("CollPropertyBoolean").asCollection().get(1));
@@ -560,7 +574,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
     Entity entity = deserializer.entity(stream, edm.getEntityType(new FullQualifiedName("Namespace1_Alias",
-        "ETMixPrimCollComp")));
+        "ETMixPrimCollComp"))).getEntity();
 
     assertNull(entity.getProperty("PropertyComp").getValue());
   }
@@ -575,7 +589,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
 
     Entity entity = deserializer.entity(stream, edm.getEntityType(
-        new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp")));
+        new FullQualifiedName("Namespace1_Alias", "ETMixPrimCollComp"))).getEntity();
     List<?> collPropertyComp = entity.getProperty("CollPropertyComp").asCollection();
     assertNull(collPropertyComp.get(0));
     List<Property> complexPropertyProperties = ((ComplexValue) collPropertyComp.get(1)).getValue();
@@ -591,7 +605,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
     Entity entity = deserializer.entity(stream, edm.getEntityType(
-        new FullQualifiedName("Namespace1_Alias", "ETCompAllPrim")));
+        new FullQualifiedName("Namespace1_Alias", "ETCompAllPrim"))).getEntity();
 
     assertEquals("TEST A", entity.getProperty("PropertyComp").asComplex().getValue().get(0).getValue());
     assertNull(entity.getProperty("PropertyComp").asComplex().getValue().get(1).getValue());
@@ -608,7 +622,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
     Entity e = deserializer.entity(stream, edm.getEntityType(
-        new FullQualifiedName("Namespace1_Alias", "ETMixEnumDefCollComp")));
+        new FullQualifiedName("Namespace1_Alias", "ETMixEnumDefCollComp"))).getEntity();
 
     assertEquals((short) 2, e.getProperty("PropertyEnumString").getValue());
     Property propertyCompMixedEnumDef = e.getProperty("PropertyCompMixedEnumDef");
@@ -624,7 +638,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
     Entity e = deserializer.entity(stream, edm.getEntityType(
-        new FullQualifiedName("Namespace1_Alias", "ETMixEnumDefCollComp")));
+        new FullQualifiedName("Namespace1_Alias", "ETMixEnumDefCollComp"))).getEntity();
 
     assertEquals((short) 3, e.getProperty("PropertyEnumString").getValue());
   }
@@ -662,7 +676,7 @@ public class ODataJsonDeserializerEntityTest extends AbstractODataDeserializerTe
     InputStream stream = new ByteArrayInputStream(entityString.getBytes());
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
     Entity entity =
-        deserializer.entity(stream, entityType);
+        deserializer.entity(stream, entityType).getEntity();
     assertNotNull(entity);
     List<Property> properties = entity.getProperties();
     assertNotNull(properties);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
index ee38684..f8b1dab 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
@@ -81,7 +81,7 @@ public class ODataJsonSerializerTest {
     InputStream result = serializer.entity(metadata, edmEntitySet.getEntityType(), entity,
         EntitySerializerOptions.with()
             .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
-            .build());
+            .build()).getContent();
     final String resultString = IOUtils.toString(result);
     final String expectedResult = "{"
         + "\"@odata.context\":\"$metadata#ESAllPrim/$entity\","
@@ -114,7 +114,7 @@ public class ODataJsonSerializerTest {
         entity,
         EntitySerializerOptions.with()
             .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
-            .build()));
+            .build()).getContent());
     final String expectedResult = "{\"@odata.context\":\"$metadata#ESAllPrim/$entity\","
         + "\"PropertyInt16\":32767,"
         + "\"PropertyString\":null,\"PropertyBoolean\":null,"
@@ -169,7 +169,7 @@ public class ODataJsonSerializerTest {
         EntityCollectionSerializerOptions.with()
             .contextURL(ContextURL.with().entitySet(edmEntitySet).build())
             .count(countOption)
-            .build());
+            .build()).getContent();
     final String resultString = IOUtils.toString(result);
 
     Assert.assertThat(resultString, CoreMatchers.startsWith("{"
@@ -194,7 +194,7 @@ public class ODataJsonSerializerTest {
         EntitySerializerOptions.with()
             .contextURL(ContextURL.with().serviceRoot(URI.create("http://host/service/"))
                 .entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
-            .build());
+            .build()).getContent();
     final String resultString = IOUtils.toString(result);
     final String expectedResult = "{"
         + "\"@odata.context\":\"http://host/service/$metadata#ESCollAllPrim/$entity\","
@@ -229,7 +229,7 @@ public class ODataJsonSerializerTest {
     InputStream result = serializer.entity(metadata, edmEntitySet.getEntityType(), entity,
         EntitySerializerOptions.with()
             .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
-            .build());
+            .build()).getContent();
     final String resultString = IOUtils.toString(result);
     final String expectedResult = "{"
         + "\"@odata.context\":\"$metadata#ESCompAllPrim/$entity\","
@@ -262,7 +262,7 @@ public class ODataJsonSerializerTest {
     InputStream result = serializer.entity(metadata, edmEntitySet.getEntityType(), entity,
         EntitySerializerOptions.with()
             .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
-            .build());
+            .build()).getContent();
     final String resultString = IOUtils.toString(result);
     final String expectedResult = "{"
         + "\"@odata.context\":\"$metadata#ESMixPrimCollComp/$entity\","
@@ -285,7 +285,7 @@ public class ODataJsonSerializerTest {
     final String resultString = IOUtils.toString(serializer.entity(metadata, edmEntitySet.getEntityType(), entity,
         EntitySerializerOptions.with()
             .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
-            .build()));
+            .build()).getContent());
     final String expectedResult = "{\"@odata.context\":\"$metadata#ESMixPrimCollComp/$entity\","
         + "\"PropertyInt16\":32767,"
         + "\"CollPropertyString\":null,\"PropertyComp\":null,\"CollPropertyComp\":null}";
@@ -297,7 +297,7 @@ public class ODataJsonSerializerTest {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim");
     final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
     InputStream result = new ODataJsonSerializer(ODataFormat.JSON_NO_METADATA)
-        .entity(metadata, edmEntitySet.getEntityType(), entity, null);
+        .entity(metadata, edmEntitySet.getEntityType(), entity, null).getContent();
     final String resultString = IOUtils.toString(result);
     final String expectedResult = "{\"PropertyInt16\":32766,\"PropertyString\":\"Test String1\"}";
     Assert.assertEquals(expectedResult, resultString);
@@ -310,7 +310,7 @@ public class ODataJsonSerializerTest {
     InputStream result = new ODataJsonSerializer(ODataFormat.JSON_NO_METADATA)
         .entityCollection(metadata, edmEntitySet.getEntityType(), entitySet,
             EntityCollectionSerializerOptions.with()
-                .contextURL(ContextURL.with().entitySet(edmEntitySet).build()).build());
+                .contextURL(ContextURL.with().entitySet(edmEntitySet).build()).build()).getContent();
     final String resultString = IOUtils.toString(result);
     final String expectedResult = "{\"value\":["
         + "{\"PropertyInt16\":32766,\"PropertyString\":\"Test String1\"},"
@@ -329,7 +329,7 @@ public class ODataJsonSerializerTest {
         entity,
         EntitySerializerOptions.with()
             .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
-            .build()));
+            .build()).getContent());
     final String expectedResult = "{\"@odata.context\":\"$metadata#ESMedia/$entity\","
         + "\"@odata.mediaEtag\":\"theMediaETag\",\"@odata.mediaContentType\":\"image/svg+xml\","
         + "\"PropertyInt16\":1}";
@@ -343,7 +343,7 @@ public class ODataJsonSerializerTest {
     final String resultString = IOUtils.toString(serializer.entityCollection(metadata,
         edmEntitySet.getEntityType(), entitySet,
         EntityCollectionSerializerOptions.with()
-            .contextURL(ContextURL.with().entitySet(edmEntitySet).build()).build()));
+            .contextURL(ContextURL.with().entitySet(edmEntitySet).build()).build()).getContent());
     final String expectedResult = "{\"@odata.context\":\"$metadata#ESMedia\",\"value\":["
         + "{\"@odata.mediaContentType\":\"image/svg+xml\",\"PropertyInt16\":1},"
         + "{\"@odata.mediaContentType\":\"image/svg+xml\",\"PropertyInt16\":2},"
@@ -368,7 +368,7 @@ public class ODataJsonSerializerTest {
                     .selectList(helper.buildContextURLSelectList(entityType, null, select))
                     .suffix(Suffix.ENTITY).build())
                 .select(select)
-                .build());
+                .build()).getContent();
     final String resultString = IOUtils.toString(result);
     final String expectedResult = "{"
         + "\"@odata.context\":\"$metadata#ESAllPrim(PropertyBoolean,PropertyDate)/$entity\","
@@ -388,7 +388,7 @@ public class ODataJsonSerializerTest {
         EntitySerializerOptions.with()
             .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
             .select(select)
-            .build());
+            .build()).getContent();
     final String resultString = IOUtils.toString(result);
     final String expectedResult = "{\"@odata.context\":\"$metadata#ESTwoPrim/$entity\","
         + "\"PropertyInt16\":32766,\"PropertyString\":\"Test String1\"}";
@@ -409,7 +409,7 @@ public class ODataJsonSerializerTest {
                     .selectList(helper.buildContextURLSelectList(entityType, null, select))
                     .build())
                 .select(select)
-                .build());
+                .build()).getContent();
     final String resultString = IOUtils.toString(result);
     Assert.assertEquals("{"
             + "\"@odata.context\":\"$metadata#ESCompComp(PropertyComp/PropertyComp/PropertyString)\","
@@ -434,7 +434,7 @@ public class ODataJsonSerializerTest {
                     .selectList(helper.buildContextURLSelectList(entityType, null, select))
                     .build())
                 .select(select)
-                .build()));
+                .build()).getContent());
     Assert.assertEquals("{"
             + "\"@odata.context\":\"$metadata#ESCompComp(PropertyComp/PropertyComp)\","
             + "\"value\":["
@@ -453,7 +453,7 @@ public class ODataJsonSerializerTest {
         EntitySerializerOptions.with()
             .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
             .expand(expand)
-            .build());
+            .build()).getContent();
     final String resultString = IOUtils.toString(result);
     Assert.assertEquals("{\"@odata.context\":\"$metadata#ESTwoPrim/$entity\","
             + "\"PropertyInt16\":32767,\"PropertyString\":\"Test String4\","
@@ -494,7 +494,7 @@ public class ODataJsonSerializerTest {
                     .selectList(helper.buildContextURLSelectList(entityType, expand, select))
                     .suffix(Suffix.ENTITY).build())
                 .expand(expand)
-                .build()));
+                .build()).getContent());
     Assert.assertEquals("{"
             + "\"@odata.context\":\"$metadata#ESTwoPrim(NavPropertyETAllPrimOne(PropertyDate))/$entity\","
             + "\"PropertyInt16\":32767,\"PropertyString\":\"Test String4\","
@@ -522,7 +522,7 @@ public class ODataJsonSerializerTest {
                     .suffix(Suffix.ENTITY).build())
                 .expand(expand)
                 .select(select)
-                .build()));
+                .build()).getContent());
     Assert.assertEquals("{"
             + "\"@odata.context\":\"$metadata#ESAllPrim(PropertySByte)/$entity\","
             + "\"PropertySByte\":127,"
@@ -549,7 +549,7 @@ public class ODataJsonSerializerTest {
                     .suffix(Suffix.ENTITY).build())
                 .expand(expand)
                 .select(select)
-                .build()));
+                .build()).getContent());
     Assert.assertEquals("{"
             + "\"@odata.context\":\"$metadata#ESAllPrim(PropertyTimeOfDay)/$entity\","
             + "\"PropertyTimeOfDay\":\"23:49:14\","
@@ -579,7 +579,7 @@ public class ODataJsonSerializerTest {
                     .selectList(helper.buildContextURLSelectList(entityType, expand, select))
                     .suffix(Suffix.ENTITY).build())
                 .expand(expand)
-                .build()));
+                .build()).getContent());
     Assert.assertEquals("{"
             + "\"@odata.context\":\"$metadata#ESTwoPrim(NavPropertyETAllPrimMany(PropertyInt32))/$entity\","
             + "\"PropertyInt16\":-365,\"PropertyString\":\"Test String2\","
@@ -604,7 +604,7 @@ public class ODataJsonSerializerTest {
                 .contextURL(ContextURL.with()
                     .entitySet(edmEntitySet).keyPath("32767").navOrPropertyPath(edmProperty.getName())
                     .build())
-                .build()));
+                .build()).getContent());
     Assert.assertEquals("{"
             + "\"@odata.context\":\"$metadata#ESAllPrim(32767)/PropertyString\","
             + "\"value\":\"First Resource - positive values\"}",
@@ -636,7 +636,7 @@ public class ODataJsonSerializerTest {
                 .contextURL(ContextURL.with()
                     .entitySet(edmEntitySet).keyPath("1").navOrPropertyPath(edmProperty.getName())
                     .build())
-                .build()));
+                .build()).getContent());
     Assert.assertEquals("{"
             + "\"@odata.context\":\"$metadata#ESCollAllPrim(1)/CollPropertyString\","
             + "\"value\":[\"Employee1@company.example\",\"Employee2@company.example\",\"Employee3@company.example\"]}",
@@ -655,7 +655,7 @@ public class ODataJsonSerializerTest {
                 .contextURL(ContextURL.with()
                     .entitySet(edmEntitySet).keyPath("32767").navOrPropertyPath(edmProperty.getName())
                     .build())
-                .build()));
+                .build()).getContent());
     Assert.assertEquals("{"
             + "\"@odata.context\":\"$metadata#ESMixPrimCollComp(32767)/PropertyComp\","
             + "\"PropertyInt16\":111,\"PropertyString\":\"TEST A\"}",
@@ -674,7 +674,7 @@ public class ODataJsonSerializerTest {
                 .contextURL(ContextURL.with()
                     .entitySet(edmEntitySet).keyPath("32767").navOrPropertyPath(edmProperty.getName())
                     .build())
-                .build()));
+                .build()).getContent());
     Assert.assertEquals("{"
             + "\"@odata.context\":\"$metadata#ESMixPrimCollComp(32767)/CollPropertyComp\","
             + "\"value\":[{\"PropertyInt16\":123,\"PropertyString\":\"TEST 1\"},"

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
index de03327..08baea0 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ServiceDocumentTest.java
@@ -114,7 +114,7 @@ public class ServiceDocumentTest {
     ODataSerializer serializer = server.createSerializer(ODataFormat.JSON);
     assertNotNull(serializer);
 
-    InputStream result = serializer.serviceDocument(edm, serviceRoot);
+    InputStream result = serializer.serviceDocument(edm, serviceRoot).getContent();
     assertNotNull(result);
     String jsonString = IOUtils.toString(result);
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
index dce6589..df7dd79 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
@@ -48,7 +48,7 @@ public class MetadataDocumentTest {
         new EdmTechProvider(references), references);
 
     final String metadata = IOUtils.toString(
-        odata.createSerializer(ODataFormat.XML).metadataDocument(serviceMetadata));
+        odata.createSerializer(ODataFormat.XML).metadataDocument(serviceMetadata).getContent());
     assertNotNull(metadata);
 
     assertThat(metadata,

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
----------------------------------------------------------------------
diff --git a/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java b/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
index 71b827d..90df224 100644
--- a/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
+++ b/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
@@ -113,7 +113,7 @@ public class CarsProcessor implements EntityCollectionProcessor, EntityProcessor
                 getContextUrl(edmEntitySet, false, expand, select, null))
             .count(uriInfo.getCountOption())
             .expand(expand).select(select)
-            .build());
+            .build()).getContent();
 
     // Finally we set the response data, headers and status code
     response.setContent(serializedContent);
@@ -150,7 +150,7 @@ public class CarsProcessor implements EntityCollectionProcessor, EntityProcessor
               .contextURL(format == ODataFormat.JSON_NO_METADATA ? null :
                   getContextUrl(edmEntitySet, true, expand, select, null))
               .expand(expand).select(select)
-              .build());
+              .build()).getContent();
       response.setContent(serializedContent);
       response.setStatusCode(HttpStatusCode.OK.getStatusCode());
       response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
@@ -259,7 +259,7 @@ public class CarsProcessor implements EntityCollectionProcessor, EntityProcessor
               getContextUrl(edmEntitySet, true, null, null, edmProperty.getName());
           InputStream serializerContent = complex ?
               serializer.complex(edm, (EdmComplexType) edmProperty.getType(), property,
-                  ComplexSerializerOptions.with().contextURL(contextURL).build()) :
+                  ComplexSerializerOptions.with().contextURL(contextURL).build()).getContent() :
               serializer.primitive((EdmPrimitiveType) edmProperty.getType(), property,
                                     PrimitiveSerializerOptions.with()
                                     .contextURL(contextURL)
@@ -267,7 +267,7 @@ public class CarsProcessor implements EntityCollectionProcessor, EntityProcessor
                                     .nullable(edmProperty.isNullable())
                                     .precision(edmProperty.getPrecision())
                                     .maxLength(edmProperty.getMaxLength())
-                                    .unicode(edmProperty.isUnicode()).build());
+                                    .unicode(edmProperty.isUnicode()).build()).getContent();
           response.setContent(serializerContent);
           response.setStatusCode(HttpStatusCode.OK.getStatusCode());
           response.setHeader(HttpHeader.CONTENT_TYPE, contentType.toContentTypeString());


[10/22] olingo-odata4 git commit: [OLINGO-603] Delete core dependecies in Tec Scenario

Posted by ra...@apache.org.
[OLINGO-603] Delete core dependecies in Tec Scenario


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/05935a0c
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/05935a0c
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/05935a0c

Branch: refs/heads/OLINGO-573
Commit: 05935a0c3d9141995cdf6547aefc0517360ee94d
Parents: d4c2b89
Author: Christian Amend <ch...@apache.org>
Authored: Tue Apr 7 13:47:26 2015 +0200
Committer: Christian Amend <ch...@apache.org>
Committed: Tue Apr 7 14:15:17 2015 +0200

----------------------------------------------------------------------
 .../org/apache/olingo/fit/AbstractServices.java |  34 ++--
 .../java/org/apache/olingo/fit/V4Services.java  |  99 +++++----
 .../core/serialization/ODataBinderImpl.java     |  30 ++-
 .../apache/olingo/client/core/v4/JSONTest.java  |   2 +-
 .../commons/api/data/AbstractODataObject.java   |  68 +++++++
 .../olingo/commons/api/data/Annotatable.java    |  29 ++-
 .../olingo/commons/api/data/Annotation.java     |  12 +-
 .../olingo/commons/api/data/ComplexValue.java   |   9 +-
 .../olingo/commons/api/data/DeletedEntity.java  |  22 +-
 .../apache/olingo/commons/api/data/Delta.java   |  19 +-
 .../olingo/commons/api/data/DeltaLink.java      |  30 ++-
 .../apache/olingo/commons/api/data/Entity.java  | 138 ++++++++-----
 .../olingo/commons/api/data/EntitySet.java      |  59 +++---
 .../apache/olingo/commons/api/data/Link.java    | 129 ++++++++----
 .../apache/olingo/commons/api/data/Linked.java  |  43 +++-
 .../olingo/commons/api/data/Parameter.java      |  41 +++-
 .../olingo/commons/api/data/Property.java       |  29 ++-
 .../olingo/commons/api/data/Valuable.java       | 142 ++++++++++---
 .../core/data/AbstractAnnotatedObject.java      |  54 -----
 .../commons/core/data/AbstractODataObject.java  |  57 ------
 .../commons/core/data/AbstractValuable.java     | 166 ---------------
 .../commons/core/data/AnnotationImpl.java       |  36 ----
 .../commons/core/data/ComplexValueImpl.java     |  88 --------
 .../commons/core/data/DeletedEntityImpl.java    |  48 -----
 .../olingo/commons/core/data/DeltaImpl.java     |  48 -----
 .../olingo/commons/core/data/DeltaLinkImpl.java |  61 ------
 .../olingo/commons/core/data/EntityImpl.java    | 204 -------------------
 .../olingo/commons/core/data/EntitySetImpl.java |  73 -------
 .../olingo/commons/core/data/LinkImpl.java      | 129 ------------
 .../olingo/commons/core/data/ParameterImpl.java |  47 -----
 .../olingo/commons/core/data/PropertyImpl.java  |  54 -----
 .../core/serialization/AtomDeserializer.java    |  44 ++--
 .../core/serialization/AtomSerializer.java      |  21 +-
 .../serialization/JsonDeltaDeserializer.java    |  13 +-
 .../core/serialization/JsonDeserializer.java    |  26 +--
 .../serialization/JsonEntityDeserializer.java   |  13 +-
 .../JsonEntitySetDeserializer.java              |   6 +-
 .../serialization/JsonPropertyDeserializer.java |   6 +-
 .../core/serialization/JsonSerializer.java      |  24 +--
 .../org/apache/olingo/server/api/OData.java     |  14 ++
 .../apache/olingo/server/core/ODataImpl.java    |   8 +
 .../json/ODataJsonDeserializer.java             |  66 +++---
 .../json/ODataJsonSerializerTest.java           |  10 +-
 lib/server-tecsvc/pom.xml                       |   1 +
 .../apache/olingo/server/tecsvc/Encoder.java    | 132 ++++++++++++
 .../olingo/server/tecsvc/data/DataCreator.java  | 131 ++++++------
 .../olingo/server/tecsvc/data/DataProvider.java |  23 +--
 .../olingo/server/tecsvc/data/FunctionData.java |  24 +--
 .../processor/TechnicalEntityProcessor.java     |   8 +-
 .../TechnicalPrimitiveComplexProcessor.java     |  14 +-
 .../tecsvc/processor/TechnicalProcessor.java    |   5 +
 .../ExpandSystemQueryOptionHandler.java         |  11 +-
 .../expression/operand/TypedOperand.java        |  58 +++---
 .../expression/operand/UntypedOperand.java      |  70 +++----
 .../expression/operand/VisitorOperand.java      |  57 ++++--
 .../expression/operation/BinaryOperator.java    | 124 ++++++-----
 .../operation/MethodCallOperator.java           |  91 ++++++---
 .../expression/operation/UnaryOperator.java     |  20 +-
 .../expression/primitive/EdmNull.java           | 112 +++++++++-
 .../queryoptions/options/FilterHandler.java     |  32 ++-
 .../options/ServerSidePagingHandler.java        |   2 +-
 .../json/ODataJsonSerializerTest.java           |   3 +-
 .../olingo/server/sample/data/DataProvider.java |  25 +--
 63 files changed, 1397 insertions(+), 1797 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
index de8c10e..a57f11b 100644
--- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
+++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
@@ -81,10 +81,6 @@ import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.serialization.ODataDeserializer;
 import org.apache.olingo.commons.api.serialization.ODataSerializer;
-import org.apache.olingo.commons.core.data.EntityImpl;
-import org.apache.olingo.commons.core.data.EntitySetImpl;
-import org.apache.olingo.commons.core.data.LinkImpl;
-import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 import org.apache.olingo.commons.core.serialization.AtomSerializer;
 import org.apache.olingo.commons.core.serialization.JsonDeserializer;
@@ -231,14 +227,14 @@ public abstract class AbstractServices {
   @GET
   @Path("/StoredPIs(1000)")
   public Response getStoredPI(@Context final UriInfo uriInfo) {
-    final Entity entity = new EntityImpl();
+    final Entity entity = new Entity();
     entity.setType("Microsoft.Test.OData.Services.ODataWCFService.StoredPI");
-    final Property id = new PropertyImpl();
+    final Property id = new Property();
     id.setType("Edm.Int32");
     id.setName("StoredPIID");
     id.setValue(ValueType.PRIMITIVE, 1000);
     entity.getProperties().add(id);
-    final Link edit = new LinkImpl();
+    final Link edit = new Link();
     edit.setHref(uriInfo.getRequestUri().toASCIIString());
     edit.setRel("edit");
     edit.setTitle("StoredPI");
@@ -622,7 +618,7 @@ public abstract class AbstractServices {
       final Entity entry;
       final String entityKey;
       if (xml.isMediaContent(entitySetName)) {
-        entry = new EntityImpl();
+        entry = new Entity();
         entry.setMediaContentType(ContentType.APPLICATION_OCTET_STREAM.toContentTypeString());
         entry.setType(entitySet.getType());
 
@@ -632,7 +628,7 @@ public abstract class AbstractServices {
 
         final Pair<String, EdmPrimitiveTypeKind> id = Commons.getMediaContent().get(entitySetName);
         if (id != null) {
-          final Property prop = new PropertyImpl();
+          final Property prop = new Property();
           prop.setName(id.getKey());
           prop.setType(id.getValue().toString());
           prop.setValue(ValueType.PRIMITIVE,
@@ -644,7 +640,7 @@ public abstract class AbstractServices {
           entry.getProperties().add(prop);
         }
 
-        final Link editLink = new LinkImpl();
+        final Link editLink = new Link();
         editLink.setHref(Commons.getEntityURI(entitySetName, entityKey));
         editLink.setRel("edit");
         editLink.setTitle(entitySetName);
@@ -691,7 +687,7 @@ public abstract class AbstractServices {
       if ((this instanceof V4KeyAsSegment)) {
         location = uriInfo.getRequestUri().toASCIIString() + "/" + entityKey;
 
-        final Link editLink = new LinkImpl();
+        final Link editLink = new Link();
         editLink.setRel("edit");
         editLink.setTitle(entitySetName);
         editLink.setHref(location);
@@ -1207,7 +1203,7 @@ public abstract class AbstractServices {
       final Entity entry = container.getPayload();
 
       if ((this instanceof V4KeyAsSegment)) {
-        final Link editLink = new LinkImpl();
+        final Link editLink = new Link();
         editLink.setRel("edit");
         editLink.setTitle(entitySetName);
         editLink.setHref(Constants.get(ConstantKey.DEFAULT_SERVICE_URL) + entitySetName + "/" + entityId);
@@ -1248,7 +1244,7 @@ public abstract class AbstractServices {
         for (Link link : entry.getNavigationLinks()) {
           if (links.contains(link.getTitle())) {
             // expand link
-            final Link rep = new LinkImpl();
+            final Link rep = new Link();
             rep.setHref(link.getHref());
             rep.setRel(link.getRel());
             rep.setTitle(link.getTitle());
@@ -1904,7 +1900,7 @@ public abstract class AbstractServices {
 
     for (Property property : entity.getProperties()) {
       if (navProperties.containsKey(property.getName())) {
-        Link alink = new LinkImpl();
+        Link alink = new Link();
         alink.setTitle(property.getName());
         alink.getAnnotations().addAll(property.getAnnotations());
 
@@ -1915,9 +1911,9 @@ public abstract class AbstractServices {
         alink.setRel(Constants.get(ConstantKey.ATOM_LINK_REL) + property.getName());
 
         if (property.isCollection()) {
-          EntitySet inline = new EntitySetImpl();
+          EntitySet inline = new EntitySet();
           for (Object value : property.asCollection()) {
-            Entity inlineEntity = new EntityImpl();
+            Entity inlineEntity = new Entity();
             inlineEntity.setType(navProperties.get(property.getName()).getType());
             for (Property prop : ((ComplexValue) value).getValue()) {
               inlineEntity.getProperties().add(prop);
@@ -1926,7 +1922,7 @@ public abstract class AbstractServices {
           }
           alink.setInlineEntitySet(inline);
         } else if (property.isComplex()) {
-          Entity inline = new EntityImpl();
+          Entity inline = new Entity();
           inline.setType(navProperties.get(property.getName()).getType());
           for (Property prop : property.asComplex().getValue()) {
             inline.getProperties().add(prop);
@@ -1946,7 +1942,7 @@ public abstract class AbstractServices {
     final EntityType entityType = metadata.getEntityOrComplexType(entitySet.getType());
     for (Map.Entry<String, org.apache.olingo.fit.metadata.Property> property : entityType.getPropertyMap().entrySet()) {
       if (entry.getProperty(property.getKey()) == null && property.getValue().isNullable()) {
-        final PropertyImpl prop = new PropertyImpl();
+        final Property prop = new Property();
         prop.setName(property.getKey());
         prop.setValue(ValueType.PRIMITIVE, null);
         entry.getProperties().add(prop);
@@ -1962,7 +1958,7 @@ public abstract class AbstractServices {
       }
 
       if (!found) {
-        final LinkImpl link = new LinkImpl();
+        final Link link = new Link();
         link.setTitle(property.getKey());
         link.setType(property.getValue().isEntitySet()
             ? Constants.get(ConstantKey.ATOM_LINK_FEED)

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/fit/src/main/java/org/apache/olingo/fit/V4Services.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/V4Services.java b/fit/src/main/java/org/apache/olingo/fit/V4Services.java
index fe9465e..6c1038d 100644
--- a/fit/src/main/java/org/apache/olingo/fit/V4Services.java
+++ b/fit/src/main/java/org/apache/olingo/fit/V4Services.java
@@ -18,6 +18,43 @@
  */
 package org.apache.olingo.fit;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.regex.Pattern;
+
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMultipart;
+import javax.ws.rs.BadRequestException;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriInfo;
+
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -34,10 +71,6 @@ import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.data.ValueType;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.commons.core.data.EntityImpl;
-import org.apache.olingo.commons.core.data.EntitySetImpl;
-import org.apache.olingo.commons.core.data.LinkImpl;
-import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.commons.core.edm.provider.EdmTypeInfo;
 import org.apache.olingo.fit.metadata.Metadata;
 import org.apache.olingo.fit.methods.PATCH;
@@ -52,44 +85,6 @@ import org.apache.olingo.fit.utils.FSManager;
 import org.apache.olingo.fit.utils.LinkInfo;
 import org.springframework.stereotype.Service;
 
-import javax.mail.internet.MimeBodyPart;
-import javax.mail.internet.MimeMultipart;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.NotFoundException;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import javax.ws.rs.core.UriInfo;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.regex.Pattern;
-
-import javax.ws.rs.BadRequestException;
-
 @Service
 @Path("/V40/Static.svc")
 @InInterceptors(classes = { XHTTPMethodInterceptor.class, ResolvingReferencesInterceptor.class })
@@ -504,7 +499,7 @@ public class V4Services extends AbstractServices {
         acceptType = Accept.parse(accept);
       }
 
-      final Property property = new PropertyImpl();
+      final Property property = new Property();
       property.setType("Edm.Int32");
       property.setValue(ValueType.PRIMITIVE, 2);
       final ResWrap<Property> container = new ResWrap<Property>(
@@ -565,27 +560,27 @@ public class V4Services extends AbstractServices {
         acceptType = Accept.parse(accept);
       }
 
-      final EntityImpl entry = new EntityImpl();
+      final Entity entry = new Entity();
       entry.setType("Microsoft.Test.OData.Services.ODataWCFService.ProductDetail");
-      final Property productId = new PropertyImpl();
+      final Property productId = new Property();
       productId.setName("ProductID");
       productId.setType("Edm.Int32");
       productId.setValue(ValueType.PRIMITIVE, Integer.valueOf(entityId));
       entry.getProperties().add(productId);
-      final Property productDetailId = new PropertyImpl();
+      final Property productDetailId = new Property();
       productDetailId.setName("ProductDetailID");
       productDetailId.setType("Edm.Int32");
       productDetailId.setValue(ValueType.PRIMITIVE, 2);
       entry.getProperties().add(productDetailId);
 
-      final Link link = new LinkImpl();
+      final Link link = new Link();
       link.setRel("edit");
       link.setHref(URI.create(
           Constants.get(ConstantKey.DEFAULT_SERVICE_URL)
               + "ProductDetails(ProductID=6,ProductDetailID=1)").toASCIIString());
       entry.setEditLink(link);
 
-      final EntitySetImpl feed = new EntitySetImpl();
+      final EntitySet feed = new EntitySet();
       feed.getEntities().add(entry);
 
       final ResWrap<EntitySet> container = new ResWrap<EntitySet>(
@@ -736,7 +731,7 @@ public class V4Services extends AbstractServices {
         acceptType = Accept.parse(accept);
       }
 
-      final Property property = new PropertyImpl();
+      final Property property = new Property();
       property.setType("Edm.Double");
       property.setValue(ValueType.PRIMITIVE, 41.79);
 
@@ -1144,7 +1139,7 @@ public class V4Services extends AbstractServices {
         acceptType = Accept.parse(accept);
       }
 
-      final PropertyImpl property = new PropertyImpl();
+      final Property property = new Property();
       property.setType("Microsoft.Test.OData.Services.ODataWCFService.Color");
       property.setValue(ValueType.ENUM, "Red");
       final ResWrap<Property> container = new ResWrap<Property>(
@@ -1236,7 +1231,7 @@ public class V4Services extends AbstractServices {
         acceptType = Accept.parse(accept);
       }
 
-      final PropertyImpl property = new PropertyImpl();
+      final Property property = new Property();
       property.setType("Collection(String)");
       final List<String> value = Arrays.asList("Cheetos", "Mushrooms", "Apple", "Car", "Computer");
       property.setValue(ValueType.COLLECTION_PRIMITIVE, value);
@@ -1268,7 +1263,7 @@ public class V4Services extends AbstractServices {
         acceptType = Accept.parse(accept);
       }
 
-      final PropertyImpl property = new PropertyImpl();
+      final Property property = new Property();
       property.setType("Collection(Edm.String)");
       property.setValue(ValueType.COLLECTION_PRIMITIVE,
           Arrays.asList("first@olingo.apache.org", "second@olingo.apache.org"));

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
index 2ae47f1..54823e0 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
@@ -87,12 +87,6 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.edm.geo.Geospatial;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.serialization.ODataSerializerException;
-import org.apache.olingo.commons.core.data.AnnotationImpl;
-import org.apache.olingo.commons.core.data.ComplexValueImpl;
-import org.apache.olingo.commons.core.data.EntityImpl;
-import org.apache.olingo.commons.core.data.EntitySetImpl;
-import org.apache.olingo.commons.core.data.LinkImpl;
-import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.commons.core.domain.ODataAnnotationImpl;
 import org.apache.olingo.commons.core.domain.ODataDeletedEntityImpl;
 import org.apache.olingo.commons.core.domain.ODataDeltaLinkImpl;
@@ -187,7 +181,7 @@ public class ODataBinderImpl implements ODataBinder {
 
   private void annotations(final ODataAnnotatable odataAnnotatable, final Annotatable annotatable) {
     for (ODataAnnotation odataAnnotation : odataAnnotatable.getAnnotations()) {
-      final Annotation annotation = new AnnotationImpl();
+      final Annotation annotation = new Annotation();
 
       annotation.setTerm(odataAnnotation.getTerm());
       annotation.setType(odataAnnotation.getValue().getTypeName());
@@ -199,7 +193,7 @@ public class ODataBinderImpl implements ODataBinder {
 
   @Override
   public EntitySet getEntitySet(final ODataEntitySet odataEntitySet) {
-    final EntitySet entitySet = new EntitySetImpl();
+    final EntitySet entitySet = new EntitySet();
 
     entitySet.setCount(odataEntitySet.getCount());
 
@@ -248,7 +242,7 @@ public class ODataBinderImpl implements ODataBinder {
 
   @Override
   public Entity getEntity(final ODataEntity odataEntity) {
-    final Entity entity = new EntityImpl();
+    final Entity entity = new Entity();
 
     entity.setType(odataEntity.getTypeName() == null ? null : odataEntity.getTypeName().toString());
 
@@ -257,7 +251,7 @@ public class ODataBinderImpl implements ODataBinder {
     // -------------------------------------------------------------
     final URI odataEditLink = odataEntity.getEditLink();
     if (odataEditLink != null) {
-      final LinkImpl editLink = new LinkImpl();
+      final Link editLink = new Link();
       editLink.setTitle(entity.getType());
       editLink.setHref(odataEditLink.toASCIIString());
       editLink.setRel(Constants.EDIT_LINK_REL);
@@ -265,7 +259,7 @@ public class ODataBinderImpl implements ODataBinder {
     }
 
     if (odataEntity.isReadOnly()) {
-      final LinkImpl selfLink = new LinkImpl();
+      final Link selfLink = new Link();
       selfLink.setTitle(entity.getType());
       selfLink.setHref(odataEntity.getLink().toASCIIString());
       selfLink.setRel(Constants.SELF_LINK_REL);
@@ -301,7 +295,7 @@ public class ODataBinderImpl implements ODataBinder {
 
   @Override
   public Link getLink(final ODataLink link) {
-    final Link linkResource = new LinkImpl();
+    final Link linkResource = new Link();
     linkResource.setRel(link.getRel());
     linkResource.setTitle(link.getName());
     linkResource.setHref(link.getLink() == null ? null : link.getLink().toASCIIString());
@@ -328,7 +322,7 @@ public class ODataBinderImpl implements ODataBinder {
   @Override
   public Property getProperty(final ODataProperty property) {
 
-    final Property propertyResource = new PropertyImpl();
+    final Property propertyResource = new Property();
     propertyResource.setName(property.getName());
     updateValuable(propertyResource, property);
     annotations(property, propertyResource);
@@ -350,7 +344,7 @@ public class ODataBinderImpl implements ODataBinder {
       for (final ODataProperty propertyValue : value.asComplex()) {
         complexProperties.add(getProperty(propertyValue));
       }
-      final ComplexValue lcValueResource = new ComplexValueImpl();
+      final ComplexValue lcValueResource = new ComplexValue();
       lcValueResource.getValue().addAll(complexProperties);
       annotations(value.asComplex(), lcValueResource);
       links(value.asComplex(), lcValueResource);
@@ -573,16 +567,16 @@ public class ODataBinderImpl implements ODataBinder {
 
   private ODataLink createLinkFromNavigationProperty(final Property property, final String propertyTypeName) {
     if (property.isCollection()) {
-      EntitySet inlineEntitySet = new EntitySetImpl();
+      EntitySet inlineEntitySet = new EntitySet();
       for (final Object inlined : property.asCollection()) {
-        Entity inlineEntity = new EntityImpl();
+        Entity inlineEntity = new Entity();
         inlineEntity.setType(propertyTypeName);
         inlineEntity.getProperties().addAll(((ComplexValue) inlined).getValue());
         inlineEntitySet.getEntities().add(inlineEntity);
       }
       return createODataInlineEntitySet(inlineEntitySet, null, property.getName(), null);
     } else {
-      Entity inlineEntity = new EntityImpl();
+      Entity inlineEntity = new Entity();
       inlineEntity.setType(propertyTypeName);
       inlineEntity.getProperties().addAll(property.asComplex().getValue());
       return createODataInlineEntity(inlineEntity, null, property.getName(), null);
@@ -751,7 +745,7 @@ public class ODataBinderImpl implements ODataBinder {
       value = client.getObjectFactory().newCollectionValue(type == null ? null : "Collection(" + type.toString() + ")");
 
       for (Object _value : valuable.asCollection()) {
-        final Property fake = new PropertyImpl();
+        final Property fake = new Property();
         fake.setValue(valuable.getValueType().getBaseType(), _value);
         value.asCollection().add(getODataValue(type, fake, contextURL, metadataETag));
       }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
index 19f39e6..0f6cb19 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JSONTest.java
@@ -146,7 +146,7 @@ public class JSONTest extends AbstractTest {
     final StringWriter writer = new StringWriter();
     getClient().getSerializer(format).write(writer, getClient().getDeserializer(format).toEntity(
         getClass().getResourceAsStream(filename + "." + getSuffix(format))).getPayload());
-
+    
     assertSimilar(filename + "." + getSuffix(format), writer.toString());
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/AbstractODataObject.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/AbstractODataObject.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/AbstractODataObject.java
new file mode 100644
index 0000000..2904bfd
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/AbstractODataObject.java
@@ -0,0 +1,68 @@
+/*
+ * 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 WARRANTIES OR 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.olingo.commons.api.data;
+
+import java.net.URI;
+import java.text.ParseException;
+
+public abstract class AbstractODataObject extends Annotatable {
+
+  private URI baseURI;
+  private URI id;
+  private String title;
+
+  /**
+   * Gets base URI.
+   * 
+   * @return base URI.
+   */
+  public URI getBaseURI() {
+    return baseURI;
+  }
+
+  public void setBaseURI(final String baseURI) {
+    this.baseURI = baseURI == null ? null : URI.create(baseURI);
+  }
+
+
+  /**
+   * Gest ID.
+   * 
+   * @return ID.
+   */
+  public URI getId() {
+    return id;
+  }
+
+  public void setId(final URI id) {
+    this.id = id;
+  }
+
+  public String getTitle() {
+    return title;
+  }
+
+  public void setCommonProperty(final String key, final String value) throws ParseException {
+    if ("id".equals(key)) {
+      id = URI.create(value);
+    } else if ("title".equals(key)) {
+      title = value;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Annotatable.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Annotatable.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Annotatable.java
index b2e3583..b43002f 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Annotatable.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Annotatable.java
@@ -18,12 +18,37 @@
  */
 package org.apache.olingo.commons.api.data;
 
+import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
 /**
  * An element with instance annotations.
  */
-public interface Annotatable {
+public abstract class Annotatable {
+
+  private final List<Annotation> annotations = new ArrayList<Annotation>();
+
+  public List<Annotation> getAnnotations() {
+    return annotations;
+  }
+
+  @Override
+  public boolean equals(final Object obj) {
+    return EqualsBuilder.reflectionEquals(this, obj);
+  }
+
+  @Override
+  public int hashCode() {
+    return HashCodeBuilder.reflectionHashCode(this);
+  }
 
-  List<Annotation> getAnnotations();
+  @Override
+  public String toString() {
+    return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Annotation.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Annotation.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Annotation.java
index f4e9d90..1b1741a 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Annotation.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Annotation.java
@@ -21,9 +21,15 @@ package org.apache.olingo.commons.api.data;
 /**
  * Represents an instance annotation.
  */
-public interface Annotation extends Valuable {
+public class Annotation extends Valuable {
 
-  String getTerm();
+  private String term;
 
-  void setTerm(String term);
+  public String getTerm() {
+    return term;
+  }
+
+  public void setTerm(final String term) {
+    this.term = term;
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ComplexValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ComplexValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ComplexValue.java
index ea5b528..d2611b3 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ComplexValue.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/ComplexValue.java
@@ -18,9 +18,14 @@
  */
 package org.apache.olingo.commons.api.data;
 
+import java.util.ArrayList;
 import java.util.List;
 
-public interface ComplexValue extends Linked, Annotatable {
+public class ComplexValue extends Linked {
 
-  List<Property> getValue();
+  private final List<Property> value = new ArrayList<Property>();
+
+  public List<Property> getValue() {
+    return value;
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeletedEntity.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeletedEntity.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeletedEntity.java
index 77993c0..e51abfc 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeletedEntity.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeletedEntity.java
@@ -20,17 +20,31 @@ package org.apache.olingo.commons.api.data;
 
 import java.net.URI;
 
-public interface DeletedEntity {
+public class DeletedEntity {
 
-  enum Reason {
+  public enum Reason {
 
     deleted,
     changed
 
   }
 
-  URI getId();
+  private URI id;
+  private Reason reason;
 
-  Reason getReason();
+  public URI getId() {
+    return id;
+  }
+
+  public void setId(final URI id) {
+    this.id = id;
+  }
 
+  public Reason getReason() {
+    return reason;
+  }
+
+  public void setReason(final Reason reason) {
+    this.reason = reason;
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java
index 4309325..5fe36f7 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java
@@ -18,14 +18,25 @@
  */
 package org.apache.olingo.commons.api.data;
 
+import java.util.ArrayList;
 import java.util.List;
 
-public interface Delta extends EntitySet {
+public class Delta extends EntitySet {
 
-  List<DeletedEntity> getDeletedEntities();
+  private final List<DeletedEntity> deletedEntities = new ArrayList<DeletedEntity>();
+  private final List<DeltaLink> addedLinks = new ArrayList<DeltaLink>();
+  private final List<DeltaLink> deletedLinks = new ArrayList<DeltaLink>();
 
-  List<DeltaLink> getAddedLinks();
+  public List<DeletedEntity> getDeletedEntities() {
+    return deletedEntities;
+  }
 
-  List<DeltaLink> getDeletedLinks();
+  public List<DeltaLink> getAddedLinks() {
+    return addedLinks;
+  }
+
+  public List<DeltaLink> getDeletedLinks() {
+    return deletedLinks;
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeltaLink.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeltaLink.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeltaLink.java
index 6c09fc8..335863e 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeltaLink.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/DeltaLink.java
@@ -20,17 +20,33 @@ package org.apache.olingo.commons.api.data;
 
 import java.net.URI;
 
-public interface DeltaLink extends Annotatable {
+public class DeltaLink extends Annotatable {
 
-  URI getSource();
+  private URI source;
+  private String relationship;
+  private URI target;
 
-  void setSource(URI source);
+  public URI getSource() {
+    return source;
+  }
 
-  String getRelationship();
+  public void setSource(final URI source) {
+    this.source = source;
+  }
 
-  void setRelationship(String relationship);
+  public String getRelationship() {
+    return relationship;
+  }
 
-  URI getTarget();
+  public void setRelationship(final String relationship) {
+    this.relationship = relationship;
+  }
 
-  void setTarget(URI target);
+  public URI getTarget() {
+    return target;
+  }
+
+  public void setTarget(final URI target) {
+    this.target = target;
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entity.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entity.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entity.java
index 4029cc3..acd3022 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entity.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Entity.java
@@ -21,93 +21,110 @@ package org.apache.olingo.commons.api.data;
 import org.apache.olingo.commons.api.domain.ODataOperation;
 
 import java.net.URI;
+import java.util.ArrayList;
 import java.util.List;
 
-public interface Entity extends Linked, Annotatable {
+public class Entity extends Linked {
+
+  private String eTag;
+  private String type;
+
+  private Link readLink;
+  private Link editLink;
+
+  private final List<Link> mediaEditLinks = new ArrayList<Link>();
+  private final List<ODataOperation> operations = new ArrayList<ODataOperation>();
+
+  private final List<Property> properties = new ArrayList<Property>();
+
+  private URI mediaContentSource;
+  private String mediaContentType;
+  private String mediaETag;
 
   /**
    * Gets ETag.
    * 
    * @return ETag.
    */
-  String getETag();
+  public String getETag() {
+    return eTag;
+  }
 
-  /**
-   * Gets base URI.
-   * 
-   * @return base URI.
-   */
-  URI getBaseURI();
+  public void setETag(final String eTag) {
+    this.eTag = eTag;
+  }
 
   /**
    * Gets entity type.
    * 
    * @return entity type.
    */
-  String getType();
+  public String getType() {
+    return type;
+  }
 
   /**
    * Sets entity type.
    * 
    * @param type entity type.
    */
-  void setType(String type);
-
-  /**
-   * Gets entity ID.
-   * 
-   * @return entity ID.
-   */
-  URI getId();
-
-  /**
-   * Sets entity ID.
-   * 
-   * @param id entity ID.
-   */
-  void setId(URI id);
+  public void setType(final String type) {
+    this.type = type;
+  }
 
   /**
    * Gets entity self link.
    * 
    * @return self link.
    */
-  Link getSelfLink();
+  public Link getSelfLink() {
+    return readLink;
+  }
 
   /**
    * Sets entity self link.
    * 
    * @param selfLink self link.
    */
-  void setSelfLink(Link selfLink);
+  public void setSelfLink(final Link selfLink) {
+    this.readLink = selfLink;
+  }
 
   /**
    * Gets entity edit link.
    * 
    * @return edit link.
    */
-  Link getEditLink();
+  public Link getEditLink() {
+    return editLink;
+  }
 
   /**
    * Sets entity edit link.
    * 
    * @param editLink edit link.
    */
-  void setEditLink(Link editLink);
+  public void setEditLink(final Link editLink) {
+    this.editLink = editLink;
+  }
 
   /**
    * Gets media entity links.
    * 
    * @return links.
    */
-  List<Link> getMediaEditLinks();
+  public List<Link> getMediaEditLinks() {
+    return mediaEditLinks;
+  }
 
   /**
    * Gets operations.
    * 
    * @return operations.
    */
-  List<ODataOperation> getOperations();
+  public List<ODataOperation> getOperations() {
+    return operations;
+  }
 
   /**
    * Add property to this Entity.
@@ -115,14 +132,19 @@ public interface Entity extends Linked, Annotatable {
    * @param property property which is added
    * @return this Entity for fluid/flow adding
    */
-  Entity addProperty(Property property);
+  public Entity addProperty(final Property property) {
+    properties.add(property);
+    return this;
+  }
 
   /**
    * Gets properties.
    * 
    * @return properties.
    */
-  List<Property> getProperties();
+  public List<Property> getProperties() {
+    return properties;
+  }
 
   /**
    * Gets property with given name.
@@ -130,54 +152,78 @@ public interface Entity extends Linked, Annotatable {
    * @param name property name
    * @return property with given name if found, null otherwise
    */
-  Property getProperty(String name);
+  public Property getProperty(final String name) {
+    Property result = null;
+
+    for (Property property : properties) {
+      if (name.equals(property.getName())) {
+        result = property;
+      }
+    }
+
+    return result;
+  }
 
   /**
    * Gets media content type.
    * 
    * @return media content type.
    */
-  String getMediaContentType();
+  public String getMediaContentType() {
+    return mediaContentType;
+  }
 
   /**
-   * Gets media content resource.
+   * Set media content type.
    * 
-   * @return media content resource.
+   * @param mediaContentType media content type.
    */
-  URI getMediaContentSource();
+  public void setMediaContentType(final String mediaContentType) {
+    this.mediaContentType = mediaContentType;
+  }
 
   /**
-   * Set media content source.
+   * Gets media content resource.
    * 
-   * @param mediaContentSource media content source.
+   * @return media content resource.
    */
-  void setMediaContentSource(URI mediaContentSource);
+  public URI getMediaContentSource() {
+    return mediaContentSource;
+  }
 
   /**
-   * Set media content type.
+   * Set media content source.
    * 
-   * @param mediaContentType media content type.
+   * @param mediaContentSource media content source.
    */
-  void setMediaContentType(String mediaContentType);
+  public void setMediaContentSource(final URI mediaContentSource) {
+    this.mediaContentSource = mediaContentSource;
+  }
 
   /**
    * ETag of the binary stream represented by this media entity or named stream property.
    * 
    * @return media ETag value
    */
-  String getMediaETag();
+  public String getMediaETag() {
+    return mediaETag;
+  }
 
   /**
    * Set media ETag.
    * 
    * @param eTag media ETag value
    */
-  void setMediaETag(String eTag);
+  public void setMediaETag(final String eTag) {
+    mediaETag = eTag;
+  }
 
   /**
    * Checks if the current entity is a media entity.
    * 
    * @return 'TRUE' if is a media entity; 'FALSE' otherwise.
    */
-  boolean isMediaEntity();
+  public boolean isMediaEntity() {
+    return mediaContentSource != null;
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.java
index ad7e4fb..8f2cfb7 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.java
@@ -19,70 +19,79 @@
 package org.apache.olingo.commons.api.data;
 
 import java.net.URI;
+import java.util.ArrayList;
 import java.util.List;
 
-public interface EntitySet extends Annotatable {
+public class EntitySet extends AbstractODataObject {
 
-  /**
-   * Gets base URI.
-   * 
-   * @return base URI.
-   */
-  URI getBaseURI();
+  private Integer count;
+
+  private final List<Entity> entities = new ArrayList<Entity>();
+
+  private URI next;
+
+  private URI deltaLink;
 
   /**
    * Sets number of entries.
    * 
    * @param count number of entries
    */
-  void setCount(Integer count);
+  public void setCount(final Integer count) {
+    this.count = count;
+  }
 
   /**
    * Gets number of entries - if it was required.
    * 
    * @return number of entries into the entity set.
    */
-  Integer getCount();
-
-  /**
-   * Gest ID.
-   * 
-   * @return ID.
-   */
-  URI getId();
+  public Integer getCount() {
+    return count;
+  }
 
   /**
    * Gets entities.
    * 
    * @return entries.
    */
-  List<Entity> getEntities();
+  public List<Entity> getEntities() {
+    return entities;
+  }
 
   /**
-   * Gets next link if exists.
+   * Sets next link.
    * 
-   * @return next link if exists; null otherwise.
+   * @param next next link.
    */
-  URI getNext();
+  public void setNext(final URI next) {
+    this.next = next;
+  }
 
   /**
-   * Sets next link.
+   * Gets next link if exists.
    * 
-   * @param next next link.
+   * @return next link if exists; null otherwise.
    */
-  void setNext(URI next);
+  public URI getNext() {
+    return next;
+  }
 
   /**
    * Gets delta link if exists.
    * 
    * @return delta link if exists; null otherwise.
    */
-  URI getDeltaLink();
+  public URI getDeltaLink() {
+    return deltaLink;
+  }
 
   /**
    * Sets delta link.
    * 
    * @param deltaLink delta link.
    */
-  void setDeltaLink(URI deltaLink);
+  public void setDeltaLink(final URI deltaLink) {
+    this.deltaLink = deltaLink;
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Link.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Link.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Link.java
index 88742f5..dff1069 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Link.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Link.java
@@ -18,130 +18,177 @@
  */
 package org.apache.olingo.commons.api.data;
 
+import java.util.ArrayList;
 import java.util.List;
 
-public interface Link extends Annotatable {
+public class Link extends Annotatable {
+
+  private String title;
+  private String rel;
+  private String href;
+  private String type;
+  private String mediaETag;
+  private Entity entity;
+  private EntitySet entitySet;
+  private String bindingLink;
+  private List<String> bindingLinks = new ArrayList<String>();
 
   /**
-   * Gets rel info.
+   * Gets title.
    * 
-   * @return rel info.
+   * @return title.
    */
-  String getRel();
+  public String getTitle() {
+    return title;
+  }
 
   /**
-   * Sets rel info.
+   * Sets title.
    * 
-   * @param rel rel info.
+   * @param title title.
    */
-  void setRel(String rel);
+  public void setTitle(final String title) {
+    this.title = title;
+  }
 
   /**
-   * Gets type.
+   * Gets rel info.
    * 
-   * @return type.
+   * @return rel info.
    */
-  String getType();
+  public String getRel() {
+    return rel;
+  }
 
   /**
-   * Sets type.
+   * Sets rel info.
    * 
-   * @param type type.
+   * @param rel rel info.
    */
-  void setType(String type);
+  public void setRel(final String rel) {
+    this.rel = rel;
+  }
 
   /**
-   * Gets title.
+   * Gets href.
    * 
-   * @return title.
+   * @return href.
    */
-  String getTitle();
+  public String getHref() {
+    return href;
+  }
 
   /**
-   * Sets title.
+   * Sets href.
    * 
-   * @param title title.
+   * @param href href.
    */
-  void setTitle(String title);
+  public void setHref(final String href) {
+    this.href = href;
+  }
 
   /**
-   * Gets href.
+   * Gets type.
    * 
-   * @return href.
+   * @return type.
    */
-  String getHref();
+  public String getType() {
+    return type;
+  }
 
   /**
-   * Sets href.
+   * Sets type.
    * 
-   * @param href href.
+   * @param type type.
    */
-  void setHref(String href);
+  public void setType(final String type) {
+    this.type = type;
+  }
 
   /**
    * Gets Media ETag.
    * 
    * @return media ETag
    */
-  String getMediaETag();
+  public String getMediaETag() {
+    return mediaETag;
+  }
 
   /**
    * Sets Media ETag.
    * 
-   * @param etag media ETag
+   * @param mediaETag media ETag
    */
-  void setMediaETag(String etag);
+  public void setMediaETag(final String mediaETag) {
+    this.mediaETag = mediaETag;
+  }
 
   /**
    * Gets in-line entity.
    * 
    * @return in-line entity.
    */
-  Entity getInlineEntity();
+  public Entity getInlineEntity() {
+    return entity;
+  }
 
   /**
    * Sets in-line entity.
    * 
    * @param entity entity.
    */
-  void setInlineEntity(Entity entity);
+  public void setInlineEntity(final Entity entity) {
+    this.entity = entity;
+  }
+
 
   /**
    * Gets in-line entity set.
    * 
    * @return in-line entity set.
    */
-  EntitySet getInlineEntitySet();
+  public EntitySet getInlineEntitySet() {
+    return entitySet;
+  }
 
   /**
    * Sets in-line entity set.
    * 
    * @param entitySet entity set.
    */
-  void setInlineEntitySet(EntitySet entitySet);
+  public void setInlineEntitySet(final EntitySet entitySet) {
+    this.entitySet = entitySet;
+  }
 
   /**
    * If this is a "toOne" relationship this method delivers the binding link or <tt>null</tt> if not set.
    * @return String the binding link.
    */
-  String getBindingLink();
+  public String getBindingLink() {
+    return bindingLink;
+  }
 
   /**
-   * Sets the binding link.
-   * @param bindingLink
+   * If this is a "toMany" relationship this method delivers the binding links or <tt>emptyList</tt> if not set.
+   * @return a list of binding links.
    */
-  void setBindingLink(String bindingLink);
+  public List<String> getBindingLinks() {
+    return bindingLinks;
+  }
 
   /**
-   * If this is a "toMany" relationship this method delivers the binding links or <tt>emptyList</tt> if not set.
-   * @return a list of binding links.
+   * Sets the binding link.
+   * @param bindingLink
    */
-  List<String> getBindingLinks();
+  public void setBindingLink(String bindingLink) {
+    this.bindingLink = bindingLink;
+  }
 
   /**
    * Sets the binding links. List MUST NOT be <tt>null</tt>.
    * @param bindingLinks
    */
-  void setBindingLinks(List<String> bindingLinks);
-
+  public void setBindingLinks(List<String> bindingLinks) {
+    this.bindingLinks = bindingLinks;
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Linked.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Linked.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Linked.java
index 1c28507..c136d55 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Linked.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Linked.java
@@ -18,9 +18,26 @@
  */
 package org.apache.olingo.commons.api.data;
 
+import java.util.ArrayList;
 import java.util.List;
 
-public interface Linked {
+public abstract class Linked extends AbstractODataObject {
+
+  private final List<Link> associationLinks = new ArrayList<Link>();
+  private final List<Link> navigationLinks = new ArrayList<Link>();
+  private final List<Link> bindingLinks = new ArrayList<Link>();
+
+  protected Link getOneByTitle(final String name, final List<Link> links) {
+    Link result = null;
+
+    for (Link link : links) {
+      if (name.equals(link.getTitle())) {
+        result = link;
+      }
+    }
+
+    return result;
+  }
 
   /**
    * Gets association link with given name, if available, otherwise <tt>null</tt>.
@@ -28,14 +45,18 @@ public interface Linked {
    * @param name candidate link name
    * @return association link with given name, if available, otherwise <tt>null</tt>
    */
-  Link getAssociationLink(String name);
+  public Link getAssociationLink(final String name) {
+    return getOneByTitle(name, associationLinks);
+  }
 
   /**
    * Gets association links.
    * 
    * @return association links.
    */
-  List<Link> getAssociationLinks();
+  public List<Link> getAssociationLinks() {
+    return associationLinks;
+  }
 
   /**
    * Gets navigation link with given name, if available, otherwise <tt>null</tt>.
@@ -43,26 +64,34 @@ public interface Linked {
    * @param name candidate link name
    * @return navigation link with given name, if available, otherwise <tt>null</tt>
    */
-  Link getNavigationLink(String name);
+  public Link getNavigationLink(final String name) {
+    return getOneByTitle(name, navigationLinks);
+  }
 
   /**
    * Gets navigation links.
    * 
    * @return links.
    */
-  List<Link> getNavigationLinks();
+  public List<Link> getNavigationLinks() {
+    return navigationLinks;
+  }
 
   /**
    * Gets binding link with given name, if available, otherwise <tt>null</tt>.
    * @param name candidate link name
    * @return binding link with given name, if available, otherwise <tt>null</tt>
    */
-  Link getNavigationBinding(String name);
+  public Link getNavigationBinding(String name) {
+    return getOneByTitle(name, bindingLinks);
+  }
 
   /**
    * Gets binding links.
    * 
    * @return links.
    */
-  List<Link> getNavigationBindings();
+  public List<Link> getNavigationBindings() {
+    return bindingLinks;
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Parameter.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Parameter.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Parameter.java
index 87058ec..a5443c7 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Parameter.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Parameter.java
@@ -18,15 +18,46 @@
  */
 package org.apache.olingo.commons.api.data;
 
-public interface Parameter extends Valuable {
+public class Parameter extends Valuable {
+
+  String name;
 
   /**
    * @return name of the parameter
    */
-  String getName();
+  public String getName() {
+    return name;
+  }
 
-  boolean isEntity();
-  
-  Entity asEntity();
+  /**
+   * @param name of the parameter
+   */
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  /**
+   * Check if Valuable contains a ENTITY or COLLECTION_ENTITY ValueType
+   *
+   * @return true if ValueType is a ENTITY or COLLECTION_ENTITY, otherwise false
+   */
+  public boolean isEntity() {
+    if (isCollection()) {
+      return getValueType().getBaseType() == ValueType.ENTITY;
+    }
+    return getValueType() == ValueType.ENTITY;
+  }
+
+  /**
+   * Get the value in its entity representation or null if it is not based on an entity ValueType
+   *
+   * @return entity representation or null if it is not based on an entity ValueType
+   */
+  public Entity asEntity() {
+    if (isCollection()) {
+      return null;
+    }
+    return isEntity() ? (Entity) getValue() : null;
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Property.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Property.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Property.java
index 28163dd..ef0adbd 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Property.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Property.java
@@ -18,9 +18,32 @@
  */
 package org.apache.olingo.commons.api.data;
 
-public interface Property extends Valuable, Annotatable {
+public class Property extends Valuable {
 
-  String getName();
+  private String name;
 
-  void setName(String name);
+  public Property() {}
+
+  public Property(final String type, final String name) {
+    this.name = name;
+    super.setType(type);
+  }
+
+  public Property(String type, String name, ValueType valueType, Object value) {
+    this(type, name);
+    setValue(valueType, value);
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(final String name) {
+    this.name = name;
+  }
+
+  @Override
+  public boolean isNull() {
+    return getValue() == null || "Edm.Null".equals(getType());
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Valuable.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Valuable.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Valuable.java
index 78989b3..f982aab 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Valuable.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Valuable.java
@@ -18,96 +18,178 @@
  */
 package org.apache.olingo.commons.api.data;
 
-import org.apache.olingo.commons.api.edm.geo.Geospatial;
-
 import java.util.List;
 
-public interface Valuable {
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+
+public abstract class Valuable extends Annotatable {
 
-  String getType();
+  private ValueType valueType = null;
+  private Object value = null;
+  private String type;
 
-  void setType(String type);
+  public boolean isNull() {
+    return value == null;
+  }
 
-  boolean isNull();
+  public String getType() {
+    return type;
+  }
 
+  public void setType(final String type) {
+    this.type = type;
+  }
+  
   /**
    * Check if Valuable contains a PRIMITIVE or COLLECTION_PRIMITIVE ValueType
    *
    * @return true if ValueType is a PRIMITIVE or COLLECTION_PRIMITIVE, otherwise false
    */
-  boolean isPrimitive();
+  public boolean isPrimitive() {
+    if(isCollection()) {
+      return valueType.getBaseType() == ValueType.PRIMITIVE;
+    }
+    return valueType == ValueType.PRIMITIVE;
+  }
 
   /**
    * Check if Valuable contains a GEOSPATIAL or COLLECTION_GEOSPATIAL ValueType
    *
    * @return true if ValueType is a GEOSPATIAL or COLLECTION_GEOSPATIAL, otherwise false
    */
-  boolean isGeospatial();
+  public boolean isGeospatial() {
+    if(isCollection()) {
+      return valueType.getBaseType() == ValueType.GEOSPATIAL;
+    }
+    return valueType == ValueType.GEOSPATIAL;
+  }
+
 
   /**
    * Check if Valuable contains a ENUM or COLLECTION_ENUM ValueType
    *
    * @return true if ValueType is a ENUM or COLLECTION_ENUM, otherwise false
    */
-  boolean isEnum();
+  public boolean isEnum() {
+    if(isCollection()) {
+      return valueType.getBaseType() == ValueType.ENUM;
+    }
+    return valueType == ValueType.ENUM;
+  }
 
   /**
    * Check if Valuable contains a COMPLEX or COLLECTION_COMPLEX ValueType
    *
    * @return true if ValueType is a COMPLEX or COLLECTION_COMPLEX, otherwise false
    */
-  boolean isComplex();
+  public boolean isComplex() {
+    if(isCollection()) {
+      return valueType.getBaseType() == ValueType.COMPLEX;
+    }
+    return valueType == ValueType.COMPLEX;
+  }
 
   /**
    * Check if Valuable contains a COLLECTION_* ValueType
    *
    * @return true if ValueType is a COLLECTION_*, otherwise false
    */
-  boolean isCollection();
-
-  /**
-   * Get the value
-   *
-   * @return the value
-   */
-  Object getValue();
+  public boolean isCollection() {
+    return valueType != null && valueType != valueType.getBaseType();
+  }
 
   /**
    * Get the value in its primitive representation or null if it is not based on a primitive ValueType
    *
    * @return primitive representation or null if it is not based on a primitive ValueType
    */
-  Object asPrimitive();
+  public Object asPrimitive() {
+    if(isCollection()) {
+      return null;
+    }
+    return isPrimitive() ? value : null;
+  }
 
   /**
-   * Get the value in its enum representation or null if it is not based on a enum ValueType
+   * Get the value in its geospatial representation or null if it is not based on a geospatial ValueType
    *
-   * @return enum representation or null if it is not based on a enum ValueType
+   * @return geospatial representation or null if it is not based on a geospatial ValueType
    */
-  Object asEnum();
+  public Geospatial asGeospatial() {
+    if(isCollection()) {
+      return null;
+    }
+    return isGeospatial() ? (Geospatial) value : null;
+  }
 
   /**
-   * Get the value in its geospatial representation or null if it is not based on a geospatial ValueType
+   * Get the value in its enum representation or null if it is not based on a enum ValueType
    *
-   * @return geospatial representation or null if it is not based on a geospatial ValueType
+   * @return enum representation or null if it is not based on a enum ValueType
    */
-  Geospatial asGeospatial();
+  public Object asEnum() {
+    if(isCollection()) {
+      return null;
+    }
+    return isEnum() ? value : null;
+  }
 
   /**
    * Get the value in its complex representation or null if it is not based on a complex ValueType
    *
    * @return primitive complex or null if it is not based on a complex ValueType
    */
-  ComplexValue asComplex();
+  public ComplexValue asComplex() {
+    if(isCollection()) {
+      return null;
+    }
+    return isComplex() ? (ComplexValue) value : null;
+  }
 
   /**
    * Get the value as collection or null if it is not a collection ValueType
    *
    * @return collection or null if it is not a collection ValueType
    */
-  List<?> asCollection();
+  public List<?> asCollection() {
+    return isCollection() ? (List<?>) value : null;
+  }
 
-  void setValue(ValueType valuetype, Object value);
-
-  ValueType getValueType();
+  /**
+   * Get the value
+   *
+   * @return the value
+   */
+  public Object getValue() {
+    return value;
+  }
+
+  public void setValue(final ValueType valueType, final Object value) {
+    this.valueType = valueType;
+    this.value = value;
+  }
+
+  public ValueType getValueType() {
+    return valueType;
+  }
+
+
+  @Override
+  public boolean equals(final Object obj) {
+    return EqualsBuilder.reflectionEquals(this, obj);
+  }
+
+  @Override
+  public int hashCode() {
+    return HashCodeBuilder.reflectionHashCode(this);
+  }
+
+  @Override
+  public String toString() {
+    return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAnnotatedObject.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAnnotatedObject.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAnnotatedObject.java
deleted file mode 100644
index d8cdf05..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractAnnotatedObject.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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 WARRANTIES OR 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.olingo.commons.core.data;
-
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-import org.apache.olingo.commons.api.data.Annotatable;
-import org.apache.olingo.commons.api.data.Annotation;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public abstract class AbstractAnnotatedObject implements Annotatable {
-
-  private final List<Annotation> annotations = new ArrayList<Annotation>();
-
-  @Override
-  public List<Annotation> getAnnotations() {
-    return annotations;
-  }
-
-  @Override
-  public boolean equals(final Object obj) {
-    return EqualsBuilder.reflectionEquals(this, obj);
-  }
-
-  @Override
-  public int hashCode() {
-    return HashCodeBuilder.reflectionHashCode(this);
-  }
-
-  @Override
-  public String toString() {
-    return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractODataObject.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractODataObject.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractODataObject.java
deleted file mode 100644
index 6a3c46f..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractODataObject.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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 WARRANTIES OR 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.olingo.commons.core.data;
-
-import java.net.URI;
-import java.text.ParseException;
-
-public abstract class AbstractODataObject extends AbstractAnnotatedObject {
-
-  private URI baseURI;
-  private URI id;
-  private String title;
-
-  public URI getBaseURI() {
-    return baseURI;
-  }
-
-  public void setBaseURI(final String baseURI) {
-    this.baseURI = baseURI == null ? null : URI.create(baseURI);
-  }
-
-  public URI getId() {
-    return id;
-  }
-
-  public void setId(final URI id) {
-    this.id = id;
-  }
-
-  public String getTitle() {
-    return title;
-  }
-
-  public void setCommonProperty(final String key, final String value) throws ParseException {
-    if ("id".equals(key)) {
-      id = URI.create(value);
-    } else if ("title".equals(key)) {
-      title = value;
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValuable.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValuable.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValuable.java
deleted file mode 100644
index 3a06511..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractValuable.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * 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 WARRANTIES OR 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.olingo.commons.core.data;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-import org.apache.olingo.commons.api.data.Annotatable;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.ComplexValue;
-import org.apache.olingo.commons.api.data.Valuable;
-import org.apache.olingo.commons.api.data.ValueType;
-import org.apache.olingo.commons.api.edm.geo.Geospatial;
-
-public abstract class AbstractValuable implements Valuable, Annotatable {
-
-  private ValueType valueType = null;
-  private Object value = null;
-  private final List<Annotation> annotations = new ArrayList<Annotation>();
-  private String type;
-
-  @Override
-  public boolean isNull() {
-    return value == null;
-  }
-
-  @Override
-  public String getType() {
-    return type;
-  }
-
-  @Override
-  public void setType(final String type) {
-    this.type = type;
-  }
-  
-  @Override
-  public boolean isPrimitive() {
-    if(isCollection()) {
-      return valueType.getBaseType() == ValueType.PRIMITIVE;
-    }
-    return valueType == ValueType.PRIMITIVE;
-  }
-
-  @Override
-  public boolean isGeospatial() {
-    if(isCollection()) {
-      return valueType.getBaseType() == ValueType.GEOSPATIAL;
-    }
-    return valueType == ValueType.GEOSPATIAL;
-  }
-
-  @Override
-  public boolean isEnum() {
-    if(isCollection()) {
-      return valueType.getBaseType() == ValueType.ENUM;
-    }
-    return valueType == ValueType.ENUM;
-  }
-
-  @Override
-  public boolean isComplex() {
-    if(isCollection()) {
-      return valueType.getBaseType() == ValueType.COMPLEX;
-    }
-    return valueType == ValueType.COMPLEX;
-  }
-
-  @Override
-  public boolean isCollection() {
-    return valueType != null && valueType != valueType.getBaseType();
-  }
-
-  @Override
-  public Object asPrimitive() {
-    if(isCollection()) {
-      return null;
-    }
-    return isPrimitive() ? value : null;
-  }
-
-  @Override
-  public Geospatial asGeospatial() {
-    if(isCollection()) {
-      return null;
-    }
-    return isGeospatial() ? (Geospatial) value : null;
-  }
-
-  @Override
-  public Object asEnum() {
-    if(isCollection()) {
-      return null;
-    }
-    return isEnum() ? value : null;
-  }
-
-  @Override
-  public ComplexValue asComplex() {
-    if(isCollection()) {
-      return null;
-    }
-    return isComplex() ? (ComplexValue) value : null;
-  }
-
-  @Override
-  public List<?> asCollection() {
-    return isCollection() ? (List<?>) value : null;
-  }
-
-  @Override
-  public Object getValue() {
-    return value;
-  }
-
-  @Override
-  public void setValue(final ValueType valueType, final Object value) {
-    this.valueType = valueType;
-    this.value = value;
-  }
-
-  @Override
-  public ValueType getValueType() {
-    return valueType;
-  }
-
-  @Override
-  public List<Annotation> getAnnotations() {
-    return annotations;
-  }
-
-  @Override
-  public boolean equals(final Object obj) {
-    return EqualsBuilder.reflectionEquals(this, obj);
-  }
-
-  @Override
-  public int hashCode() {
-    return HashCodeBuilder.reflectionHashCode(this);
-  }
-
-  @Override
-  public String toString() {
-    return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java
deleted file mode 100644
index 4e9953b..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AnnotationImpl.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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 WARRANTIES OR 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.olingo.commons.core.data;
-
-import org.apache.olingo.commons.api.data.Annotation;
-
-public class AnnotationImpl extends AbstractValuable implements Annotation {
-
-  private String term;
-
-  @Override
-  public String getTerm() {
-    return term;
-  }
-
-  @Override
-  public void setTerm(final String term) {
-    this.term = term;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ComplexValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ComplexValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ComplexValueImpl.java
deleted file mode 100644
index c50f51a..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ComplexValueImpl.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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 WARRANTIES OR 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.olingo.commons.core.data;
-
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.Link;
-import org.apache.olingo.commons.api.data.ComplexValue;
-import org.apache.olingo.commons.api.data.Property;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ComplexValueImpl implements ComplexValue {
-
-  private final List<Property> value = new ArrayList<Property>();
-  private final List<Link> associationLinks = new ArrayList<Link>();
-  private final List<Link> navigationLinks = new ArrayList<Link>();
-  private final List<Link> bindingLinks = new ArrayList<Link>();
-  private final List<Annotation> annotations = new ArrayList<Annotation>();
-
-  @Override
-  public List<Property> getValue() {
-    return value;
-  }
-
-  private Link getOneByTitle(final String name, final List<Link> links) {
-    Link result = null;
-
-    for (Link link : links) {
-      if (name.equals(link.getTitle())) {
-        result = link;
-      }
-    }
-
-    return result;
-  }
-
-  @Override
-  public Link getAssociationLink(final String name) {
-    return getOneByTitle(name, associationLinks);
-  }
-
-  @Override
-  public List<Link> getAssociationLinks() {
-    return associationLinks;
-  }
-
-  @Override
-  public Link getNavigationLink(final String name) {
-    return getOneByTitle(name, navigationLinks);
-  }
-
-  @Override
-  public List<Link> getNavigationLinks() {
-    return navigationLinks;
-  }
-
-  @Override
-  public List<Annotation> getAnnotations() {
-    return annotations;
-  }
-
-  @Override
-  public Link getNavigationBinding(String name) {
-    return getOneByTitle(name, bindingLinks);
-  }
-
-  @Override
-  public List<Link> getNavigationBindings() {
-    return bindingLinks;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java
deleted file mode 100644
index 657e652..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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 WARRANTIES OR 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.olingo.commons.core.data;
-
-import org.apache.olingo.commons.api.data.DeletedEntity;
-
-import java.net.URI;
-
-public class DeletedEntityImpl extends AbstractAnnotatedObject implements DeletedEntity {
-
-  private URI id;
-  private Reason reason;
-
-  @Override
-  public URI getId() {
-    return id;
-  }
-
-  public void setId(final URI id) {
-    this.id = id;
-  }
-
-  @Override
-  public Reason getReason() {
-    return reason;
-  }
-
-  public void setReason(final Reason reason) {
-    this.reason = reason;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaImpl.java
deleted file mode 100644
index 3165bd4..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaImpl.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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 WARRANTIES OR 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.olingo.commons.core.data;
-
-import org.apache.olingo.commons.api.data.DeletedEntity;
-import org.apache.olingo.commons.api.data.Delta;
-import org.apache.olingo.commons.api.data.DeltaLink;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class DeltaImpl extends EntitySetImpl implements Delta {
-
-  private final List<DeletedEntity> deletedEntities = new ArrayList<DeletedEntity>();
-  private final List<DeltaLink> addedLinks = new ArrayList<DeltaLink>();
-  private final List<DeltaLink> deletedLinks = new ArrayList<DeltaLink>();
-
-  @Override
-  public List<DeletedEntity> getDeletedEntities() {
-    return deletedEntities;
-  }
-
-  @Override
-  public List<DeltaLink> getAddedLinks() {
-    return addedLinks;
-  }
-
-  @Override
-  public List<DeltaLink> getDeletedLinks() {
-    return deletedLinks;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java
deleted file mode 100644
index 91a1569..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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 WARRANTIES OR 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.olingo.commons.core.data;
-
-import org.apache.olingo.commons.api.data.DeltaLink;
-
-import java.net.URI;
-
-public class DeltaLinkImpl extends AbstractAnnotatedObject implements DeltaLink {
-
-  private URI source;
-  private String relationship;
-  private URI target;
-
-  @Override
-  public URI getSource() {
-    return source;
-  }
-
-  @Override
-  public void setSource(final URI source) {
-    this.source = source;
-  }
-
-  @Override
-  public String getRelationship() {
-    return relationship;
-  }
-
-  @Override
-  public void setRelationship(final String relationship) {
-    this.relationship = relationship;
-  }
-
-  @Override
-  public URI getTarget() {
-    return target;
-  }
-
-  @Override
-  public void setTarget(final URI target) {
-    this.target = target;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntityImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntityImpl.java
deleted file mode 100755
index 38dd748..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntityImpl.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * 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 WARRANTIES OR 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.olingo.commons.core.data;
-
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.Link;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.domain.ODataOperation;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Class implementing an OData entity.
- */
-public class EntityImpl extends AbstractODataObject implements Entity {
-
-  private String eTag;
-
-  private String type;
-
-  private Link readLink;
-  private Link editLink;
-
-  private final List<Link> associationLinks = new ArrayList<Link>();
-  private final List<Link> navigationLinks = new ArrayList<Link>();
-  private final List<Link> mediaEditLinks = new ArrayList<Link>();
-  private final List<Link> bindingLinks = new ArrayList<Link>();
-
-  private final List<ODataOperation> operations = new ArrayList<ODataOperation>();
-
-  private final List<Property> properties = new ArrayList<Property>();
-
-  private URI mediaContentSource;
-  private String mediaContentType;
-  private String mediaETag;
-
-  @Override
-  public String getETag() {
-    return eTag;
-  }
-
-  public void setETag(final String eTag) {
-    this.eTag = eTag;
-  }
-
-  @Override
-  public String getType() {
-    return type;
-  }
-
-  @Override
-  public void setType(final String type) {
-    this.type = type;
-  }
-
-  @Override
-  public Link getSelfLink() {
-    return readLink;
-  }
-
-  @Override
-  public void setSelfLink(final Link readLink) {
-    this.readLink = readLink;
-  }
-
-  @Override
-  public Link getEditLink() {
-    return editLink;
-  }
-
-  @Override
-  public void setEditLink(final Link editLink) {
-    this.editLink = editLink;
-  }
-
-  private Link getOneByTitle(final String name, final List<Link> links) {
-    Link result = null;
-
-    for (Link link : links) {
-      if (name.equals(link.getTitle())) {
-        result = link;
-      }
-    }
-
-    return result;
-  }
-
-  @Override
-  public Link getAssociationLink(final String name) {
-    return getOneByTitle(name, associationLinks);
-  }
-
-  @Override
-  public List<Link> getAssociationLinks() {
-    return associationLinks;
-  }
-
-  @Override
-  public Link getNavigationLink(final String name) {
-    return getOneByTitle(name, navigationLinks);
-  }
-
-  @Override
-  public List<Link> getNavigationLinks() {
-    return navigationLinks;
-  }
-
-  @Override
-  public List<Link> getMediaEditLinks() {
-    return mediaEditLinks;
-  }
-  
-  @Override
-  public Link getNavigationBinding(String name) {
-    return getOneByTitle(name, bindingLinks);
-  }
-
-  @Override
-  public List<Link> getNavigationBindings() {
-    return bindingLinks;
-  }
-
-  @Override
-  public List<ODataOperation> getOperations() {
-    return operations;
-  }
-
-  @Override
-  public Entity addProperty(final Property property) {
-    properties.add(property);
-    return this;
-  }
-
-  @Override
-  public List<Property> getProperties() {
-    return properties;
-  }
-
-  @Override
-  public Property getProperty(final String name) {
-    Property result = null;
-
-    for (Property property : properties) {
-      if (name.equals(property.getName())) {
-        result = property;
-      }
-    }
-
-    return result;
-  }
-
-  @Override
-  public String getMediaContentType() {
-    return mediaContentType;
-  }
-
-  @Override
-  public void setMediaContentType(final String mediaContentType) {
-    this.mediaContentType = mediaContentType;
-  }
-
-  @Override
-  public URI getMediaContentSource() {
-    return mediaContentSource;
-  }
-
-  @Override
-  public void setMediaContentSource(final URI mediaContentSource) {
-    this.mediaContentSource = mediaContentSource;
-  }
-
-  @Override
-  public String getMediaETag() {
-    return mediaETag;
-  }
-
-  @Override
-  public void setMediaETag(final String eTag) {
-    mediaETag = eTag;
-  }
-
-  @Override
-  public boolean isMediaEntity() {
-    return mediaContentSource != null;
-  }
-}


[20/22] olingo-odata4 git commit: OLINGO-573: making tests work with tomcat and making it 1.6 compatible

Posted by ra...@apache.org.
OLINGO-573: making tests work with tomcat and making it 1.6 compatible


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/547725d7
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/547725d7
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/547725d7

Branch: refs/heads/OLINGO-573
Commit: 547725d754a16093c1881002a5f4e7bef4f25df8
Parents: b6da769
Author: Ramesh Reddy <ra...@jboss.org>
Authored: Sun Apr 5 17:54:44 2015 -0500
Committer: Ramesh Reddy <ra...@jboss.org>
Committed: Thu Apr 16 09:13:14 2015 -0500

----------------------------------------------------------------------
 .../server/core/SchemaBasedEdmProvider.java     |    2 +-
 .../server/core/ServiceDispatcherTest.java      |  781 ++++++-----
 .../olingo/server/example/TripPinHandler.java   |    2 +-
 .../server/example/TripPinServiceTest.java      | 1316 ++++++++----------
 4 files changed, 1036 insertions(+), 1065 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/547725d7/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/SchemaBasedEdmProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/SchemaBasedEdmProvider.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/SchemaBasedEdmProvider.java
index 8641a69..cc811c0 100644
--- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/SchemaBasedEdmProvider.java
+++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/SchemaBasedEdmProvider.java
@@ -46,7 +46,7 @@ import org.apache.olingo.commons.api.edm.provider.TypeDefinition;
 public class SchemaBasedEdmProvider implements EdmProvider {
   private final List<Schema> edmSchemas = new ArrayList<Schema>();
 
-  protected void addSchema(Schema schema) {
+  public void addSchema(Schema schema) {
     this.edmSchemas.add(schema);
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/547725d7/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/ServiceDispatcherTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/ServiceDispatcherTest.java b/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/ServiceDispatcherTest.java
index c918134..faabafc 100644
--- a/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/ServiceDispatcherTest.java
+++ b/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/ServiceDispatcherTest.java
@@ -18,359 +18,432 @@
  */
 package org.apache.olingo.server.core;
 
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Collections;
+import java.util.List;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.startup.Tomcat;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.olingo.commons.api.edm.provider.EdmProvider;
+import org.apache.olingo.commons.api.http.HttpMethod;
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataHttpHandler;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.edmx.EdmxReference;
+import org.apache.olingo.server.core.requests.ActionRequest;
+import org.apache.olingo.server.core.requests.DataRequest;
+import org.apache.olingo.server.core.requests.FunctionRequest;
+import org.apache.olingo.server.core.requests.MediaRequest;
+import org.apache.olingo.server.core.requests.MetadataRequest;
+import org.apache.olingo.server.core.responses.CountResponse;
+import org.apache.olingo.server.core.responses.EntityResponse;
+import org.apache.olingo.server.core.responses.EntitySetResponse;
+import org.apache.olingo.server.core.responses.MetadataResponse;
+import org.apache.olingo.server.core.responses.NoContentResponse;
+import org.apache.olingo.server.core.responses.PrimitiveValueResponse;
+import org.apache.olingo.server.core.responses.PropertyResponse;
+import org.apache.olingo.server.core.responses.StreamResponse;
+import org.apache.olingo.server.example.TripPinServiceTest;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mockito;
+
 public class ServiceDispatcherTest {
-//  private Server server;
-//
-//  public class SampleODataServlet extends HttpServlet {
-//    private final ServiceHandler handler; // must be stateless
-//    private final EdmProvider provider; // must be stateless
-//
-//    public SampleODataServlet(ServiceHandler handler, EdmProvider provider) {
-//      this.handler = handler;
-//      this.provider = provider;
-//    }
-//
-//    @Override
-//    public void service(HttpServletRequest request, HttpServletResponse response)
-//        throws IOException {
-//      OData odata = OData4Impl.newInstance();
-//      ServiceMetadata metadata = odata.createServiceMetadata(this.provider, Collections.EMPTY_LIST);
-//
-//      ODataHttpHandler handler = odata.createHandler(metadata);
-//
-//      handler.register(this.handler);
-//      handler.process(request, response);
-//    }
-//  }
-//
-//  public int beforeTest(ServiceHandler serviceHandler) throws Exception {
-//    MetadataParser parser = new MetadataParser();
-//    EdmProvider edmProvider = parser.buildEdmProvider(new FileReader(
-//        "src/test/resources/trippin.xml"));
-//
-//    this.server = new Server();
-//
-//    ServerConnector connector = new ServerConnector(this.server);
-//    this.server.setConnectors(new Connector[] { connector });
-//
-//    ServletContextHandler context = new ServletContextHandler();
-//    context.setContextPath("/trippin");
-//    context
-//        .addServlet(new ServletHolder(new SampleODataServlet(serviceHandler, edmProvider)), "/*");
-//    this.server.setHandler(context);
-//    this.server.start();
-//
-//    return connector.getLocalPort();
-//  }
-//
-//  public void afterTest() throws Exception {
-//    this.server.stop();
-//  }
-//
-//  interface TestResult {
-//    void validate() throws Exception;
-//  }
-//
-//  private void helpGETTest(ServiceHandler handler, String path, TestResult validator)
-//      throws Exception {
-//    int port = beforeTest(handler);
-//    HttpClient http = new HttpClient();
-//    http.start();
-//    http.GET("http://localhost:" + port + "/" + path);
-//    validator.validate();
-//    afterTest();
-//  }
-//
-//  private void helpTest(ServiceHandler handler, String path, String method, String payload,
-//      TestResult validator) throws Exception {
-//    int port = beforeTest(handler);
-//    HttpClient http = new HttpClient();
-//    http.start();
-//    String editUrl = "http://localhost:" + port + "/" + path;
-//    http.newRequest(editUrl).method(method)
-//        .header("Content-Type", "application/json;odata.metadata=minimal")
-//        .content(TripPinServiceTest.content(payload)).send();
-//    validator.validate();
-//    afterTest();
-//  }
-//
-//  @Test
-//  public void testMetadata() throws Exception {
-//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-//    helpGETTest(handler, "trippin/$metadata", new TestResult() {
-//      @Override
-//      public void validate() throws Exception {
-//        ArgumentCaptor<MetadataRequest> arg1 = ArgumentCaptor.forClass(MetadataRequest.class);
-//        ArgumentCaptor<MetadataResponse> arg2 = ArgumentCaptor.forClass(MetadataResponse.class);
-//        Mockito.verify(handler).readMetadata(arg1.capture(), arg2.capture());
-//      }
-//    });
-//  }
-//
-//  @Test
-//  public void testEntitySet() throws Exception {
-//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-//    helpGETTest(handler, "trippin/Airports", new TestResult() {
-//      @Override
-//      public void validate() throws Exception {
-//        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
-//        ArgumentCaptor<EntityResponse> arg2 = ArgumentCaptor.forClass(EntityResponse.class);
-//        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
-//
-//        DataRequest request = arg1.getValue();
-//        // Need toString on ContextURL class
-//        // assertEquals("",
-//        // request.getContextURL(request.getOdata()).toString());
-//        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
-//            .toContentTypeString());
-//      }
-//    });
-//  }
-//
-//  @Test
-//  public void testEntitySetCount() throws Exception {
-//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-//    helpGETTest(handler, "trippin/Airports/$count", new TestResult() {
-//      @Override
-//      public void validate() throws Exception {
-//        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
-//        ArgumentCaptor<CountResponse> arg2 = ArgumentCaptor.forClass(CountResponse.class);
-//        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
-//
-//        DataRequest request = arg1.getValue();
-//        // Need toString on ContextURL class
-//        // assertEquals("",
-//        // request.getContextURL(request.getOdata()).toString());
-//        assertEquals("text/plain", request.getResponseContentType().toContentTypeString());
-//      }
-//    });
-//  }
-//
-//  @Test
-//  public void testEntity() throws Exception {
-//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-//    helpGETTest(handler, "trippin/Airports('0')", new TestResult() {
-//      @Override
-//      public void validate() throws Exception {
-//        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
-//        ArgumentCaptor<EntityResponse> arg2 = ArgumentCaptor.forClass(EntityResponse.class);
-//        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
-//
-//        DataRequest request = arg1.getValue();
-//        assertEquals(1, request.getUriResourceEntitySet().getKeyPredicates().size());
-//        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
-//            .toContentTypeString());
-//      }
-//    });
-//  }
-//
-//  @Test
-//  public void testReadProperty() throws Exception {
-//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-//    helpGETTest(handler, "trippin/Airports('0')/IataCode", new TestResult() {
-//      @Override
-//      public void validate() throws Exception {
-//        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
-//        ArgumentCaptor<PropertyResponse> arg2 = ArgumentCaptor.forClass(PropertyResponse.class);
-//        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
-//
-//        DataRequest request = arg1.getValue();
-//        assertEquals(true, request.isPropertyRequest());
-//        assertEquals(false, request.isPropertyComplex());
-//        assertEquals(1, request.getUriResourceEntitySet().getKeyPredicates().size());
-//        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
-//            .toContentTypeString());
-//      }
-//    });
-//  }
-//
-//  @Test
-//  public void testReadComplexProperty() throws Exception {
-//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-//    helpGETTest(handler, "trippin/Airports('0')/Location", new TestResult() {
-//      @Override
-//      public void validate() throws Exception {
-//        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
-//        ArgumentCaptor<PropertyResponse> arg2 = ArgumentCaptor.forClass(PropertyResponse.class);
-//        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
-//
-//        DataRequest request = arg1.getValue();
-//        assertEquals(true, request.isPropertyRequest());
-//        assertEquals(true, request.isPropertyComplex());
-//        assertEquals(1, request.getUriResourceEntitySet().getKeyPredicates().size());
-//        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
-//            .toContentTypeString());
-//      }
-//    });
-//  }
-//
-//  @Test
-//  public void testReadProperty$Value() throws Exception {
-//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-//    helpGETTest(handler, "trippin/Airports('0')/IataCode/$value", new TestResult() {
-//      @Override
-//      public void validate() throws Exception {
-//        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
-//        ArgumentCaptor<PrimitiveValueResponse> arg2 = ArgumentCaptor
-//            .forClass(PrimitiveValueResponse.class);
-//        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
-//
-//        DataRequest request = arg1.getValue();
-//        assertEquals(true, request.isPropertyRequest());
-//        assertEquals(false, request.isPropertyComplex());
-//        assertEquals(1, request.getUriResourceEntitySet().getKeyPredicates().size());
-//        assertEquals("text/plain", request.getResponseContentType().toContentTypeString());
-//      }
-//    });
-//  }
-//
-//  @Test
-//  public void testReadPropertyRef() throws Exception {
-//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-//    helpGETTest(handler, "trippin/Airports('0')/IataCode/$value", new TestResult() {
-//      @Override
-//      public void validate() throws Exception {
-//        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
-//        ArgumentCaptor<PrimitiveValueResponse> arg2 = ArgumentCaptor
-//            .forClass(PrimitiveValueResponse.class);
-//        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
-//
-//        DataRequest request = arg1.getValue();
-//        assertEquals(true, request.isPropertyRequest());
-//        assertEquals(false, request.isPropertyComplex());
-//        assertEquals(1, request.getUriResourceEntitySet().getKeyPredicates().size());
-//        assertEquals("text/plain", request.getResponseContentType().toContentTypeString());
-//      }
-//    });
-//  }
-//
-//  @Test
-//  public void testFunctionImport() throws Exception {
-//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-//    helpGETTest(handler, "trippin/GetNearestAirport(lat=12.11,lon=34.23)", new TestResult() {
-//      @Override
-//      public void validate() throws Exception {
-//        ArgumentCaptor<FunctionRequest> arg1 = ArgumentCaptor.forClass(FunctionRequest.class);
-//        ArgumentCaptor<PropertyResponse> arg3 = ArgumentCaptor.forClass(PropertyResponse.class);
-//        ArgumentCaptor<HttpMethod> arg2 = ArgumentCaptor.forClass(HttpMethod.class);
-//        Mockito.verify(handler).invoke(arg1.capture(), arg2.capture(), arg3.capture());
-//
-//        FunctionRequest request = arg1.getValue();
-//      }
-//    });
-//  }
-//
-//  @Test
-//  public void testActionImport() throws Exception {
-//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-//    helpTest(handler, "trippin/ResetDataSource", "POST", "", new TestResult() {
-//      @Override
-//      public void validate() throws Exception {
-//        ArgumentCaptor<ActionRequest> arg1 = ArgumentCaptor.forClass(ActionRequest.class);
-//        ArgumentCaptor<NoContentResponse> arg2 = ArgumentCaptor.forClass(NoContentResponse.class);
-//        Mockito.verify(handler).invoke(arg1.capture(), Mockito.anyString(), arg2.capture());
-//
-//        ActionRequest request = arg1.getValue();
-//      }
-//    });
-//  }
-//
-//  @Test
-//  public void testReadMedia() throws Exception {
-//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-//    helpGETTest(handler, "trippin/Photos(1)/$value", new TestResult() {
-//      @Override
-//      public void validate() throws Exception {
-//        ArgumentCaptor<MediaRequest> arg1 = ArgumentCaptor.forClass(MediaRequest.class);
-//        ArgumentCaptor<StreamResponse> arg2 = ArgumentCaptor.forClass(StreamResponse.class);
-//        Mockito.verify(handler).readMediaStream(arg1.capture(), arg2.capture());
-//
-//        MediaRequest request = arg1.getValue();
-//        assertEquals("application/octet-stream", request.getResponseContentType()
-//            .toContentTypeString());
-//      }
-//    });
-//  }
-//
-//  @Test
-//  public void testReadNavigation() throws Exception {
-//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-//    helpGETTest(handler, "trippin/People('russelwhyte')/Friends", new TestResult() {
-//      @Override
-//      public void validate() throws Exception {
-//        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
-//        ArgumentCaptor<EntitySetResponse> arg2 = ArgumentCaptor.forClass(EntitySetResponse.class);
-//        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
-//
-//        DataRequest request = arg1.getValue();
-//        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
-//            .toContentTypeString());
-//      }
-//    });
-//  }
-//
-//  @Test
-//  public void testReadReference() throws Exception {
-//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-//    helpGETTest(handler, "trippin/People('russelwhyte')/Friends/$ref", new TestResult() {
-//      @Override
-//      public void validate() throws Exception {
-//        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
-//        ArgumentCaptor<EntitySetResponse> arg2 = ArgumentCaptor.forClass(EntitySetResponse.class);
-//        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
-//
-//        DataRequest request = arg1.getValue();
-//        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
-//            .toContentTypeString());
-//      }
-//    });
-//  }
-//
-//  @Test
-//  public void testWriteReferenceCollection() throws Exception {
-//    String payload = "{\n" + "\"@odata.id\": \"/Photos(11)\"\n" + "}";
-//
-//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-//    helpTest(handler, "trippin/People('russelwhyte')/Friends/$ref", "POST", payload,
-//        new TestResult() {
-//          @Override
-//          public void validate() throws Exception {
-//            ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
-//            ArgumentCaptor<String> arg2 = ArgumentCaptor.forClass(String.class);
-//            ArgumentCaptor<List> arg3 = ArgumentCaptor.forClass(List.class);
-//            ArgumentCaptor<NoContentResponse> arg4 = ArgumentCaptor
-//                .forClass(NoContentResponse.class);
-//            Mockito.verify(handler).addReference(arg1.capture(), arg2.capture(), arg3.capture(),
-//                arg4.capture());
-//
-//            DataRequest request = arg1.getValue();
-//            assertEquals("application/json;odata.metadata=minimal", request
-//                .getResponseContentType().toContentTypeString());
-//          }
-//        });
-//  }
-//
-//  @Test
-//  public void testWriteReference() throws Exception {
-//    String payload = "{\n" + "\"@odata.id\": \"/Photos(11)\"\n" + "}";
-//
-//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-//    helpTest(handler, "trippin/People('russelwhyte')/Friends('someone')/Photo/$ref", "PUT", payload,
-//        new TestResult() {
-//          @Override
-//          public void validate() throws Exception {
-//            ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
-//            ArgumentCaptor<String> arg2 = ArgumentCaptor.forClass(String.class);
-//            ArgumentCaptor<URI> arg3 = ArgumentCaptor.forClass(URI.class);
-//            ArgumentCaptor<NoContentResponse> arg4 = ArgumentCaptor
-//                .forClass(NoContentResponse.class);
-//            Mockito.verify(handler).updateReference(arg1.capture(), arg2.capture(), arg3.capture(),
-//                arg4.capture());
-//
-//            DataRequest request = arg1.getValue();
-//            assertEquals("application/json;odata.metadata=minimal", request
-//                .getResponseContentType().toContentTypeString());
-//          }
-//        });
-//  }
+  private static final int TOMCAT_PORT = 9900;
+  private Tomcat tomcat = new Tomcat();
+  private String baseURL;
+  
+  public class SampleODataServlet extends HttpServlet {
+    private final ServiceHandler handler; // must be stateless
+    private final EdmProvider provider; // must be stateless
+
+    public SampleODataServlet(ServiceHandler handler, EdmProvider provider) {
+      this.handler = handler;
+      this.provider = provider;
+    }
+
+    @Override
+    public void service(HttpServletRequest request, HttpServletResponse response)
+        throws IOException {
+      OData odata = OData4Impl.newInstance();
+      ServiceMetadata metadata = odata.createServiceMetadata(this.provider, Collections.<EdmxReference> emptyList());
+
+      ODataHttpHandler handler = odata.createHandler(metadata);
+
+      handler.register(this.handler);
+      handler.process(request, response);
+    }
+  }
+  
+  public void beforeTest(ServiceHandler serviceHandler) throws Exception {
+    MetadataParser parser = new MetadataParser();
+    EdmProvider edmProvider = parser.buildEdmProvider(new FileReader(
+        "src/test/resources/trippin.xml"));
+
+    File baseDir = new File(System.getProperty("java.io.tmpdir"));
+    Context cxt = tomcat.addContext("/trippin", baseDir.getAbsolutePath());
+    Tomcat.addServlet(cxt, "trippin", new SampleODataServlet(serviceHandler, edmProvider));
+    cxt.addServletMapping("/*", "trippin");
+    baseURL = "http://" + tomcat.getHost().getName() + ":"+ TOMCAT_PORT;
+    tomcat.setPort(TOMCAT_PORT);
+    tomcat.start();
+  }
+
+  public void afterTest() throws Exception {
+    tomcat.stop();
+    tomcat.destroy();
+  }
+
+  interface TestResult {
+    void validate() throws Exception;
+  }
+
+  private HttpHost getLocalhost() {
+    return new HttpHost(tomcat.getHost().getName(), 9900);
+  }
+  
+  private HttpResponse httpGET(String url) throws Exception{
+    HttpRequest request = new HttpGet(url);
+    return httpSend(request);
+  }
+
+  private HttpResponse httpSend(HttpRequest request) throws Exception{
+    DefaultHttpClient http = new DefaultHttpClient();
+    HttpResponse response = http.execute(getLocalhost(), request);
+    return response;
+  }
+  
+  private void helpGETTest(ServiceHandler handler, String path, TestResult validator)
+      throws Exception {
+    beforeTest(handler);
+    httpGET("http://localhost:" + TOMCAT_PORT + "/" + path);
+    validator.validate();
+    afterTest();
+  }
+
+  private void helpTest(ServiceHandler handler, String path, String method, String payload,
+      TestResult validator) throws Exception {
+    beforeTest(handler);
+
+    DefaultHttpClient http = new DefaultHttpClient();
+    
+    String editUrl = "http://localhost:" + TOMCAT_PORT + "/" + path;
+    HttpRequest request = new HttpGet(editUrl);
+    if (method.equals("POST")) {
+      HttpPost post = new HttpPost(editUrl);
+      post.setEntity(new StringEntity(payload));
+      request = post;
+    } else if (method.equals("PUT")) {
+      HttpPut put = new HttpPut(editUrl);
+      put.setEntity(new StringEntity(payload));
+      request = put;
+    } else if (method.equals("DELETE")) {
+      HttpDelete delete = new HttpDelete(editUrl);
+      request = delete;
+    }
+    request.setHeader("Content-Type", "application/json;odata.metadata=minimal");
+    HttpResponse response = http.execute(getLocalhost(), request);
+
+    validator.validate();
+    afterTest();
+  }
+
+  @Test
+  public void testMetadata() throws Exception {
+    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+    helpGETTest(handler, "trippin/$metadata", new TestResult() {
+      @Override
+      public void validate() throws Exception {
+        ArgumentCaptor<MetadataRequest> arg1 = ArgumentCaptor.forClass(MetadataRequest.class);
+        ArgumentCaptor<MetadataResponse> arg2 = ArgumentCaptor.forClass(MetadataResponse.class);
+        Mockito.verify(handler).readMetadata(arg1.capture(), arg2.capture());
+      }
+    });
+  }
+
+  @Test
+  public void testEntitySet() throws Exception {
+    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+    helpGETTest(handler, "trippin/Airports", new TestResult() {
+      @Override
+      public void validate() throws Exception {
+        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
+        ArgumentCaptor<EntityResponse> arg2 = ArgumentCaptor.forClass(EntityResponse.class);
+        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
+
+        DataRequest request = arg1.getValue();
+        // Need toString on ContextURL class
+        // assertEquals("",
+        // request.getContextURL(request.getOdata()).toString());
+        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
+            .toContentTypeString());
+      }
+    });
+  }
+
+  @Test
+  public void testEntitySetCount() throws Exception {
+    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+    helpGETTest(handler, "trippin/Airports/$count", new TestResult() {
+      @Override
+      public void validate() throws Exception {
+        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
+        ArgumentCaptor<CountResponse> arg2 = ArgumentCaptor.forClass(CountResponse.class);
+        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
+
+        DataRequest request = arg1.getValue();
+        // Need toString on ContextURL class
+        // assertEquals("",
+        // request.getContextURL(request.getOdata()).toString());
+        assertEquals("text/plain", request.getResponseContentType().toContentTypeString());
+      }
+    });
+  }
+
+  @Test
+  public void testEntity() throws Exception {
+    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+    helpGETTest(handler, "trippin/Airports('0')", new TestResult() {
+      @Override
+      public void validate() throws Exception {
+        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
+        ArgumentCaptor<EntityResponse> arg2 = ArgumentCaptor.forClass(EntityResponse.class);
+        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
+
+        DataRequest request = arg1.getValue();
+        assertEquals(1, request.getUriResourceEntitySet().getKeyPredicates().size());
+        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
+            .toContentTypeString());
+      }
+    });
+  }
+
+  @Test
+  public void testReadProperty() throws Exception {
+    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+    helpGETTest(handler, "trippin/Airports('0')/IataCode", new TestResult() {
+      @Override
+      public void validate() throws Exception {
+        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
+        ArgumentCaptor<PropertyResponse> arg2 = ArgumentCaptor.forClass(PropertyResponse.class);
+        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
+
+        DataRequest request = arg1.getValue();
+        assertEquals(true, request.isPropertyRequest());
+        assertEquals(false, request.isPropertyComplex());
+        assertEquals(1, request.getUriResourceEntitySet().getKeyPredicates().size());
+        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
+            .toContentTypeString());
+      }
+    });
+  }
+
+  @Test
+  public void testReadComplexProperty() throws Exception {
+    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+    helpGETTest(handler, "trippin/Airports('0')/Location", new TestResult() {
+      @Override
+      public void validate() throws Exception {
+        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
+        ArgumentCaptor<PropertyResponse> arg2 = ArgumentCaptor.forClass(PropertyResponse.class);
+        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
+
+        DataRequest request = arg1.getValue();
+        assertEquals(true, request.isPropertyRequest());
+        assertEquals(true, request.isPropertyComplex());
+        assertEquals(1, request.getUriResourceEntitySet().getKeyPredicates().size());
+        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
+            .toContentTypeString());
+      }
+    });
+  }
+
+  @Test
+  public void testReadProperty$Value() throws Exception {
+    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+    helpGETTest(handler, "trippin/Airports('0')/IataCode/$value", new TestResult() {
+      @Override
+      public void validate() throws Exception {
+        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
+        ArgumentCaptor<PrimitiveValueResponse> arg2 = ArgumentCaptor
+            .forClass(PrimitiveValueResponse.class);
+        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
+
+        DataRequest request = arg1.getValue();
+        assertEquals(true, request.isPropertyRequest());
+        assertEquals(false, request.isPropertyComplex());
+        assertEquals(1, request.getUriResourceEntitySet().getKeyPredicates().size());
+        assertEquals("text/plain", request.getResponseContentType().toContentTypeString());
+      }
+    });
+  }
+
+  @Test
+  public void testReadPropertyRef() throws Exception {
+    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+    helpGETTest(handler, "trippin/Airports('0')/IataCode/$value", new TestResult() {
+      @Override
+      public void validate() throws Exception {
+        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
+        ArgumentCaptor<PrimitiveValueResponse> arg2 = ArgumentCaptor
+            .forClass(PrimitiveValueResponse.class);
+        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
+
+        DataRequest request = arg1.getValue();
+        assertEquals(true, request.isPropertyRequest());
+        assertEquals(false, request.isPropertyComplex());
+        assertEquals(1, request.getUriResourceEntitySet().getKeyPredicates().size());
+        assertEquals("text/plain", request.getResponseContentType().toContentTypeString());
+      }
+    });
+  }
+
+  @Test
+  public void testFunctionImport() throws Exception {
+    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+    helpGETTest(handler, "trippin/GetNearestAirport(lat=12.11,lon=34.23)", new TestResult() {
+      @Override
+      public void validate() throws Exception {
+        ArgumentCaptor<FunctionRequest> arg1 = ArgumentCaptor.forClass(FunctionRequest.class);
+        ArgumentCaptor<PropertyResponse> arg3 = ArgumentCaptor.forClass(PropertyResponse.class);
+        ArgumentCaptor<HttpMethod> arg2 = ArgumentCaptor.forClass(HttpMethod.class);
+        Mockito.verify(handler).invoke(arg1.capture(), arg2.capture(), arg3.capture());
+
+        FunctionRequest request = arg1.getValue();
+      }
+    });
+  }
+
+  @Test
+  public void testActionImport() throws Exception {
+    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+    helpTest(handler, "trippin/ResetDataSource", "POST", "", new TestResult() {
+      @Override
+      public void validate() throws Exception {
+        ArgumentCaptor<ActionRequest> arg1 = ArgumentCaptor.forClass(ActionRequest.class);
+        ArgumentCaptor<NoContentResponse> arg2 = ArgumentCaptor.forClass(NoContentResponse.class);
+        Mockito.verify(handler).invoke(arg1.capture(), Mockito.anyString(), arg2.capture());
+
+        ActionRequest request = arg1.getValue();
+      }
+    });
+  }
+
+  @Test
+  public void testReadMedia() throws Exception {
+    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+    helpGETTest(handler, "trippin/Photos(1)/$value", new TestResult() {
+      @Override
+      public void validate() throws Exception {
+        ArgumentCaptor<MediaRequest> arg1 = ArgumentCaptor.forClass(MediaRequest.class);
+        ArgumentCaptor<StreamResponse> arg2 = ArgumentCaptor.forClass(StreamResponse.class);
+        Mockito.verify(handler).readMediaStream(arg1.capture(), arg2.capture());
+
+        MediaRequest request = arg1.getValue();
+        assertEquals("application/octet-stream", request.getResponseContentType()
+            .toContentTypeString());
+      }
+    });
+  }
+
+  @Test
+  public void testReadNavigation() throws Exception {
+    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+    helpGETTest(handler, "trippin/People('russelwhyte')/Friends", new TestResult() {
+      @Override
+      public void validate() throws Exception {
+        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
+        ArgumentCaptor<EntitySetResponse> arg2 = ArgumentCaptor.forClass(EntitySetResponse.class);
+        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
+
+        DataRequest request = arg1.getValue();
+        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
+            .toContentTypeString());
+      }
+    });
+  }
+
+  @Test
+  public void testReadReference() throws Exception {
+    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+    helpGETTest(handler, "trippin/People('russelwhyte')/Friends/$ref", new TestResult() {
+      @Override
+      public void validate() throws Exception {
+        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
+        ArgumentCaptor<EntitySetResponse> arg2 = ArgumentCaptor.forClass(EntitySetResponse.class);
+        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
+
+        DataRequest request = arg1.getValue();
+        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
+            .toContentTypeString());
+      }
+    });
+  }
+
+  @Test
+  public void testWriteReferenceCollection() throws Exception {
+    String payload = "{\n" + "\"@odata.id\": \"/Photos(11)\"\n" + "}";
+
+    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+    helpTest(handler, "trippin/People('russelwhyte')/Friends/$ref", "POST", payload,
+        new TestResult() {
+          @Override
+          public void validate() throws Exception {
+            ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
+            ArgumentCaptor<String> arg2 = ArgumentCaptor.forClass(String.class);
+            ArgumentCaptor<List> arg3 = ArgumentCaptor.forClass(List.class);
+            ArgumentCaptor<NoContentResponse> arg4 = ArgumentCaptor
+                .forClass(NoContentResponse.class);
+            Mockito.verify(handler).addReference(arg1.capture(), arg2.capture(), arg3.capture(),
+                arg4.capture());
+
+            DataRequest request = arg1.getValue();
+            assertEquals("application/json;odata.metadata=minimal", request
+                .getResponseContentType().toContentTypeString());
+          }
+        });
+  }
+
+  @Test
+  public void testWriteReference() throws Exception {
+    String payload = "{\n" + "\"@odata.id\": \"/Photos(11)\"\n" + "}";
+
+    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+    helpTest(handler, "trippin/People('russelwhyte')/Friends('someone')/Photo/$ref", "PUT", payload,
+        new TestResult() {
+          @Override
+          public void validate() throws Exception {
+            ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
+            ArgumentCaptor<String> arg2 = ArgumentCaptor.forClass(String.class);
+            ArgumentCaptor<URI> arg3 = ArgumentCaptor.forClass(URI.class);
+            ArgumentCaptor<NoContentResponse> arg4 = ArgumentCaptor
+                .forClass(NoContentResponse.class);
+            Mockito.verify(handler).updateReference(arg1.capture(), arg2.capture(), arg3.capture(),
+                arg4.capture());
+
+            DataRequest request = arg1.getValue();
+            assertEquals("application/json;odata.metadata=minimal", request
+                .getResponseContentType().toContentTypeString());
+          }
+        });
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/547725d7/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinHandler.java b/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinHandler.java
index 19a0387..040a7da 100644
--- a/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinHandler.java
+++ b/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinHandler.java
@@ -203,7 +203,7 @@ public class TripPinHandler implements ServiceHandler {
       public void visit(EntitySetResponse response) throws ODataTranslatedException,
           ODataApplicationException {
         if (request.getPreference("odata.maxpagesize") != null) {
-          response.writeHeader("Preference-Applied", request.getPreference("odata.maxpagesize"));
+          response.writeHeader("Preference-Applied", "odata.maxpagesize="+request.getPreference("odata.maxpagesize"));
         }
         if (details.entity == null && !request.getNavigations().isEmpty()) {
           response.writeReadEntitySet(details.entityType, new EntitySetImpl());


[07/22] olingo-odata4 git commit: [OLINGO-545] TecSvc: Test added for deep insets to navigation properties in complex values

Posted by ra...@apache.org.
[OLINGO-545] TecSvc: Test added for deep insets to navigation properties in complex values


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

Branch: refs/heads/OLINGO-573
Commit: d4c2b89e46dcb067272ea370ae4d965c48f101b1
Parents: 518a3a4
Author: Christian Holzer <c....@sap.com>
Authored: Mon Apr 6 08:25:00 2015 +0200
Committer: Christian Holzer <c....@sap.com>
Committed: Tue Apr 7 08:26:17 2015 +0200

----------------------------------------------------------------------
 .../fit/tecsvc/client/DeepInsertITCase.java     | 62 +++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d4c2b89e/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
index 5255712..22f56f5 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
@@ -20,6 +20,7 @@ package org.apache.olingo.fit.tecsvc.client;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.net.URI;
@@ -37,10 +38,12 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySe
 import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
 import org.apache.olingo.client.core.ODataClientFactory;
+import org.apache.olingo.commons.api.domain.ODataComplexValue;
 import org.apache.olingo.commons.api.domain.ODataEntity;
 import org.apache.olingo.commons.api.domain.ODataEntitySet;
 import org.apache.olingo.commons.api.domain.ODataInlineEntity;
 import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
+import org.apache.olingo.commons.api.domain.ODataLink;
 import org.apache.olingo.commons.api.domain.ODataObjectFactory;
 import org.apache.olingo.commons.api.domain.ODataProperty;
 import org.apache.olingo.commons.api.domain.ODataValue;
@@ -79,6 +82,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
   private static final String NAV_PROPERTY_ET_TWO_KEY_NAV_ONE = "NavPropertyETTwoKeyNavOne";
   private static final String NAV_PROPERTY_ET_TWO_KEY_NAV_MANY = "NavPropertyETTwoKeyNavMany";
   private static final String COL_PROPERTY_STRING = "CollPropertyString";
+  private static final String COL_PROPERTY_COMP_NAV = "CollPropertyCompNav";
   private static final String EDM_STRING = "Edm.String";
 
   @Test
@@ -601,7 +605,63 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
 
     validateSet(targetURI, cookie, (short) 1, (short) 2, (short) 3);
   }
-
+  
+  @Test
+  @org.junit.Ignore
+  public void testDeepInsertOnNavigationPropertyInComplexProperty() {
+    final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+    final ODataObjectFactory of = client.getObjectFactory();
+    
+    final ODataEntity inlineEntity = of.newEntity(ET_TWO_KEY_NAV);
+    inlineEntity.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
+    inlineEntity.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
+    inlineEntity.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
+            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 1)))
+            .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("1")))));
+    
+    final ODataEntity entity = of.newEntity(ET_TWO_KEY_NAV);
+    entity.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
+    entity.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
+    entity.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
+            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 2)))
+            .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("2")))));
+    
+    final ODataLink link = of.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, inlineEntity);
+    final ODataComplexValue complexValueCreate = of.newComplexValue(CT_NAV_FIVE_PROP);
+    complexValueCreate.getNavigationLinks().add(link);
+    
+    entity.getProperties().add(
+        of.newCollectionProperty(COL_PROPERTY_COMP_NAV, of.newCollectionValue(CT_NAV_FIVE_PROP)
+                                                          .add(complexValueCreate)));
+    
+    final URI targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).build();
+    final ODataEntityCreateResponse<ODataEntity> response = client.getCUDRequestFactory()
+                                                                  .getEntityCreateRequest(targetURI, entity)
+                                                                  .execute();
+    
+    assertEquals(HttpStatusCode.CREATED.getStatusCode(), response.getStatusCode());
+    final Iterator<ODataValue> iter = response.getBody()
+                                              .getProperty(COL_PROPERTY_COMP_NAV)
+                                              .getCollectionValue()
+                                              .iterator();
+    
+    assertTrue(iter.hasNext());
+    final ODataComplexValue complexValue = iter.next().asComplex();
+    final ODataLink linkedEntity = complexValue.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE);
+    assertNotNull(linkedEntity);
+    assertEquals(1, linkedEntity.asInlineEntity()
+                                .getEntity()
+                                .getProperty(PROPERTY_INT16)
+                                .getPrimitiveValue()
+                                .toValue());
+  }
+  
   private String getCookie() {
     final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
     final ODataRetrieveResponse<ODataEntitySet> response = client.getRetrieveRequestFactory()


[06/22] olingo-odata4 git commit: [OLINGO-545] TecSvc: Support of cyclic expands and filtering on arbitrary level

Posted by ra...@apache.org.
[OLINGO-545] TecSvc: Support of cyclic expands and filtering on arbitrary
level


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/518a3a41
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/518a3a41
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/518a3a41

Branch: refs/heads/OLINGO-573
Commit: 518a3a418e9e79e2a3ce5feb61e175083812c2d8
Parents: 583c4bd
Author: Christian Holzer <c....@sap.com>
Authored: Mon Apr 6 08:25:00 2015 +0200
Committer: Christian Holzer <c....@sap.com>
Committed: Tue Apr 7 08:26:05 2015 +0200

----------------------------------------------------------------------
 .../ExpandWithSystemQueryOptionsITCase.java     | 160 +++++++++++++-
 .../processor/TechnicalEntityProcessor.java     |   6 +-
 .../ExpandSystemQueryOptionHandler.java         | 208 +++++++++++++------
 .../expression/ExpressionVisitorImpl.java       |  10 +-
 .../queryoptions/options/FilterHandler.java     |   6 +-
 .../queryoptions/options/OrderByHandler.java    |  12 +-
 6 files changed, 320 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/518a3a41/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandWithSystemQueryOptionsITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandWithSystemQueryOptionsITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandWithSystemQueryOptionsITCase.java
index 2db9535..1a6b411 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandWithSystemQueryOptionsITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandWithSystemQueryOptionsITCase.java
@@ -19,6 +19,7 @@
 package org.apache.olingo.fit.tecsvc.client;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 
 import java.net.URI;
@@ -119,7 +120,7 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
       }
     }
   }
-
+  
   @Test
   public void testSkip() {
     final Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
@@ -290,7 +291,162 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
     assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
     assertEquals(4, entities.size());
   }
-
+  
+  @Test
+  public void testCyclicExpand() {
+    // Expand entity in the following order
+    // 1 => 2 => 1
+    // Entity with Key (PropertyInt16=1, PrroperyString='1') holds references to (PropertyInt16=1, PropertyString='1') 
+    // and (PropertyInt16=1, PropertyString='2')
+    // Entity with Key (PropertyInt16=1, PropertyString='2') holds references to (PropertyInt16=1, PropertyString='1')
+    // Define filters to select explicit the entities at any level => Circle
+    
+    final ODataClient client = getClient();
+    final Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
+    options.put(QueryOption.EXPAND, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY 
+                                  + "($expand=" + NAV_PROPERTY_ET_TWO_KEY_NAV_MANY 
+                                  + "($expand=" + NAV_PROPERTY_ET_TWO_KEY_NAV_MANY + "))");
+    options.put(QueryOption.FILTER, "PropertyString eq '2'");
+    
+    final Map<String, Object> keys = new HashMap<String, Object>();
+    keys.put(PROPERTY_INT16, 1);
+    keys.put(PROPERTY_STRING, "1");
+    
+    final URI uri = client.newURIBuilder(SERVICE_URI)
+                          .appendEntitySetSegment(ES_TWO_KEY_NAV)
+                          .appendKeySegment(keys)
+                          .expandWithOptions(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, options)
+                          .build();
+    
+    final ODataRetrieveResponse<ODataEntity> response = client.getRetrieveRequestFactory()
+                                                              .getEntityRequest(uri)
+                                                              .execute();
+    
+    assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
+    assertNotNull(response.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
+    assertEquals(1, response.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
+                                      .asInlineEntitySet()
+                                      .getEntitySet()
+                                      .getEntities()
+                                      .size());
+    
+    final ODataEntity entitySecondLevel = response.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
+                                                            .asInlineEntitySet()
+                                                            .getEntitySet()
+                                                            .getEntities()
+                                                            .get(0);
+    
+    assertEquals(1, entitySecondLevel.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertEquals("2", entitySecondLevel.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
+    
+    assertNotNull(entitySecondLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
+    assertEquals(1, entitySecondLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
+                                     .asInlineEntitySet()
+                                     .getEntitySet()
+                                     .getEntities()
+                                     .size());
+    
+    final ODataEntity entityThirdLevel = entitySecondLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
+                                                          .asInlineEntitySet()
+                                                          .getEntitySet()
+                                                          .getEntities()
+                                                          .get(0);
+    
+    assertEquals(1, entityThirdLevel.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertEquals("1", entityThirdLevel.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
+    
+    assertNotNull(entityThirdLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
+    assertEquals(2, entityThirdLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
+                                    .asInlineEntitySet()
+                                    .getEntitySet()
+                                    .getEntities()
+                                    .size());
+    
+    final List<ODataEntity> fourthLevelEntites = entityThirdLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
+                                                                 .asInlineEntitySet()
+                                                                 .getEntitySet()
+                                                                 .getEntities();
+    
+    assertEquals(1, fourthLevelEntites.get(0).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertEquals("1", fourthLevelEntites.get(0).getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
+
+    assertEquals(1, fourthLevelEntites.get(1).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertEquals("2", fourthLevelEntites.get(1).getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
+  }
+  
+  @Test
+  public void testSystemQueryOptionOnThirdLevel() {
+    final ODataClient client = getClient();
+    final Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
+    options.put(QueryOption.EXPAND, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY 
+                                  + "($expand=" + NAV_PROPERTY_ET_TWO_KEY_NAV_MANY 
+                                  + "($expand=" + NAV_PROPERTY_ET_TWO_KEY_NAV_MANY 
+                                  + ";$filter=PropertyString eq '1'))");
+    options.put(QueryOption.FILTER, "PropertyString eq '2'");
+    
+    final Map<String, Object> keys = new HashMap<String, Object>();
+    keys.put(PROPERTY_INT16, 1);
+    keys.put(PROPERTY_STRING, "1");
+    
+    final URI uri = client.newURIBuilder(SERVICE_URI)
+                          .appendEntitySetSegment(ES_TWO_KEY_NAV)
+                          .appendKeySegment(keys)
+                          .expandWithOptions(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, options)
+                          .build();
+    
+    final ODataRetrieveResponse<ODataEntity> response = client.getRetrieveRequestFactory()
+                                                              .getEntityRequest(uri)
+                                                              .execute();
+    
+    assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
+    assertNotNull(response.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
+    assertEquals(1, response.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
+                                      .asInlineEntitySet()
+                                      .getEntitySet()
+                                      .getEntities()
+                                      .size());
+    
+    final ODataEntity entitySecondLevel = response.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
+                                                            .asInlineEntitySet()
+                                                            .getEntitySet()
+                                                            .getEntities()
+                                                            .get(0);
+    
+    assertEquals(1, entitySecondLevel.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertEquals("2", entitySecondLevel.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
+    
+    assertNotNull(entitySecondLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
+    assertEquals(1, entitySecondLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
+                                     .asInlineEntitySet()
+                                     .getEntitySet()
+                                     .getEntities()
+                                     .size());
+    
+    final ODataEntity entityThirdLevel = entitySecondLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
+                                                          .asInlineEntitySet()
+                                                          .getEntitySet()
+                                                          .getEntities()
+                                                          .get(0);
+    
+    assertEquals(1, entityThirdLevel.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertEquals("1", entityThirdLevel.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
+    
+    assertNotNull(entityThirdLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
+    assertEquals(1, entityThirdLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
+                                    .asInlineEntitySet()
+                                    .getEntitySet()
+                                    .getEntities()
+                                    .size());
+    
+    final List<ODataEntity> fourthLevelEntites = entityThirdLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
+                                                                 .asInlineEntitySet()
+                                                                 .getEntitySet()
+                                                                 .getEntities();
+    
+    assertEquals(1, fourthLevelEntites.get(0).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertEquals("1", fourthLevelEntites.get(0).getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
+  }
+  
   private ODataRetrieveResponse<ODataEntitySet> buildRequest(final String entitySet, final String navigationProperty,
       final Map<QueryOption, Object> expandOptions) {
     return buildRequest(entitySet, navigationProperty, expandOptions, null);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/518a3a41/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
index ed120b9..a2774e3 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
@@ -125,7 +125,9 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
       // Create a shallow copy of each entity. So the expanded navigation properties can be modified for serialization,
       // without affecting the data stored in the database.
       final ExpandSystemQueryOptionHandler expandHandler = new ExpandSystemQueryOptionHandler();
-      final EntitySet entitySetSerialization = expandHandler.copyEntitySetShallowRekursive(entitySet);
+      final EntitySet entitySetSerialization = expandHandler.transformEntitySetGraphToTree(entitySet, 
+                                                                                           edmEntitySet, 
+                                                                                           expand);
       expandHandler.applyExpandQueryOptions(entitySetSerialization, edmEntitySet, expand);
 
       // Serialize
@@ -186,7 +188,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
     final SelectOption select = uriInfo.getSelectOption();
 
     final ExpandSystemQueryOptionHandler expandHandler = new ExpandSystemQueryOptionHandler();
-    final Entity entitySerialization = expandHandler.copyEntityShallowRekursive(entity);
+    final Entity entitySerialization = expandHandler.transformEntityGraphToTree(entity, edmEntitySet, expand);
     expandHandler.applyExpandQueryOptions(entitySerialization, edmEntitySet, expand);
 
     response.setContent(serializer.entity(

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/518a3a41/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java
index 3ae3b3a..ce1b774 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java
@@ -18,15 +18,18 @@
  */
 package org.apache.olingo.server.tecsvc.processor.queryoptions;
 
-import java.util.IdentityHashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Locale;
+import java.util.Set;
 
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.edm.EdmBindingTarget;
 import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.commons.core.data.EntityImpl;
 import org.apache.olingo.commons.core.data.EntitySetImpl;
@@ -47,8 +50,6 @@ import org.apache.olingo.server.tecsvc.processor.queryoptions.options.SkipHandle
 import org.apache.olingo.server.tecsvc.processor.queryoptions.options.TopHandler;
 
 public class ExpandSystemQueryOptionHandler {
-  private IdentityHashMap<Entity, Entity> copiedEntities = new IdentityHashMap<Entity, Entity>();
-  private IdentityHashMap<EntitySet, EntitySet> copiedEntitySets = new IdentityHashMap<EntitySet, EntitySet>();
 
   public void applyExpandQueryOptions(final EntitySet entitySet, final EdmEntitySet edmEntitySet,
       final ExpandOption expandOption) throws ODataApplicationException {
@@ -70,20 +71,26 @@ public class ExpandSystemQueryOptionHandler {
     applyExpandOptionToEntity(entity, edmEntitySet, expandOption);
   }
 
-  private void applyExpandOptionToEntity(final Entity entity, final EdmEntitySet edmEntitySet,
+  private void applyExpandOptionToEntity(final Entity entity, final EdmBindingTarget edmBindingTarget,
       final ExpandOption expandOption) throws ODataApplicationException {
-    final EdmEntityType entityType = edmEntitySet.getEntityType();
+    final EdmEntityType entityType = edmBindingTarget.getEntityType();
 
     for (ExpandItem item : expandOption.getExpandItems()) {
       final List<UriResource> uriResourceParts = item.getResourcePath().getUriResourceParts();
       if (uriResourceParts.size() == 1 && uriResourceParts.get(0) instanceof UriResourceNavigation) {
         final String navPropertyName = ((UriResourceNavigation) uriResourceParts.get(0)).getProperty().getName();
-        final EdmEntitySet targetEdmEntitySet = (EdmEntitySet) edmEntitySet.getRelatedBindingTarget(navPropertyName);
+        final EdmBindingTarget targetEdmEntitySet = edmBindingTarget.getRelatedBindingTarget(navPropertyName);
 
         final Link link = entity.getNavigationLink(navPropertyName);
         if (link != null && entityType.getNavigationProperty(navPropertyName).isCollection()) {
-          applyOptionsToEntityCollection(link.getInlineEntitySet(), targetEdmEntitySet, item.getFilterOption(),
-              item.getOrderByOption(), item.getCountOption(), item.getSkipOption(), item.getTopOption());
+          applyOptionsToEntityCollection(link.getInlineEntitySet(), 
+                                         targetEdmEntitySet, 
+                                         item.getFilterOption(),
+                                         item.getOrderByOption(), 
+                                         item.getCountOption(), 
+                                         item.getSkipOption(), 
+                                         item.getTopOption(), 
+                                         item.getExpandOption());
         }
       } else {
         throw new ODataApplicationException("Not supported resource part in expand system query option",
@@ -92,77 +99,150 @@ public class ExpandSystemQueryOptionHandler {
     }
   }
 
-  private void applyOptionsToEntityCollection(final EntitySet entitySet, final EdmEntitySet edmEntitySet,
+  private void applyOptionsToEntityCollection(final EntitySet entitySet, final EdmBindingTarget edmBindingTarget,
       final FilterOption filterOption, final OrderByOption orderByOption, final CountOption countOption,
-      final SkipOption skipOption, final TopOption topOption) throws ODataApplicationException {
+      final SkipOption skipOption, final TopOption topOption, final ExpandOption expandOption) 
+          throws ODataApplicationException {
 
-    FilterHandler.applyFilterSystemQuery(filterOption, entitySet, edmEntitySet);
-    OrderByHandler.applyOrderByOption(orderByOption, entitySet, edmEntitySet);
+    FilterHandler.applyFilterSystemQuery(filterOption, entitySet, edmBindingTarget);
+    OrderByHandler.applyOrderByOption(orderByOption, entitySet, edmBindingTarget);
     // TODO Add CountHandler
     SkipHandler.applySkipSystemQueryHandler(skipOption, entitySet);
     TopHandler.applyTopSystemQueryOption(topOption, entitySet);
+    
+    // Apply nested expand system query options to remaining entities
+    if(expandOption != null) {
+      for(final Entity entity : entitySet.getEntities()) {
+        applyExpandOptionToEntity(entity, edmBindingTarget, expandOption);
+      }
+    }
   }
 
-  public EntitySet copyEntitySetShallowRekursive(final EntitySet entitySet) {
-    if (!copiedEntitySets.containsKey(entitySet)) {
-      final EntitySet copiedEntitySet = new EntitySetImpl();
-      copiedEntitySet.setCount(entitySet.getCount());
-      copiedEntitySet.setDeltaLink(entitySet.getDeltaLink());
-      copiedEntitySet.setNext(entitySet.getNext());
-
-      copiedEntitySets.put(entitySet, copiedEntitySet);
-      copiedEntitySets.put(copiedEntitySet, copiedEntitySet);
-
-      for (Entity entity : entitySet.getEntities()) {
-        copiedEntitySet.getEntities().add(copyEntityShallowRekursive(entity));
-      }
-      return copiedEntitySet;
+  public EntitySet transformEntitySetGraphToTree(final EntitySet entitySet, final EdmBindingTarget edmBindingTarget, 
+      final ExpandOption expand) throws ODataApplicationException {
+    
+    final EntitySet newEntitySet = newEntitySet(entitySet);
+    
+    for(final Entity entity : entitySet.getEntities()) {
+      newEntitySet.getEntities().add(transformEntityGraphToTree(entity, edmBindingTarget, expand));
     }
-    return copiedEntitySets.get(entitySet);
+    
+    return newEntitySet;
   }
+  
+  public Entity transformEntityGraphToTree(final Entity entity, EdmBindingTarget edmEntitySet, 
+      final ExpandOption expand) throws ODataApplicationException {
 
-  public Entity copyEntityShallowRekursive(final Entity entity) {
-    if (!copiedEntities.containsKey(entity)) {
-      final Entity copiedEntity = new EntityImpl();
-      copiedEntity.getProperties().addAll(entity.getProperties());
-      copiedEntity.getAnnotations().addAll(entity.getAnnotations());
-      copiedEntity.getAssociationLinks().addAll(entity.getAssociationLinks());
-      copiedEntity.setEditLink(entity.getEditLink());
-      copiedEntity.setId(entity.getId());
-      copiedEntity.setMediaContentSource(entity.getMediaContentSource());
-      copiedEntity.setMediaContentType(entity.getMediaContentType());
-      copiedEntity.setMediaETag(entity.getMediaETag());
-      copiedEntity.getOperations().addAll(entity.getOperations());
-      copiedEntity.setSelfLink(entity.getSelfLink());
-      copiedEntity.setType(entity.getType());
-      copiedEntity.getNavigationBindings().addAll(entity.getNavigationBindings());
-
-      copiedEntities.put(entity, copiedEntity);
-      copiedEntities.put(copiedEntity, copiedEntity);
-
-      // The system query options change the amount and sequence of inline entities (feeds)
-      // So we have to make a shallow copy of all navigation link lists
-      // Make sure, that each entity is only copied once.
-      // Otherwise an infinite loop can occur caused by cyclic navigation relationships.
+    final Entity newEntity = newEntity(entity);
 
+    if (hasExpandItems(expand)) {
+      final boolean expandAll = expandAll(expand);
+      final Set<String> expanded = expandAll ? null : getExpandedPropertyNames(expand.getExpandItems());
+      final EdmEntityType edmType = edmEntitySet.getEntityType();
+      
       for (final Link link : entity.getNavigationLinks()) {
-        final Link newLink = new LinkImpl();
-        newLink.setMediaETag(link.getMediaETag());
-        newLink.setTitle(link.getTitle());
-        newLink.setType(link.getType());
-        newLink.setRel(link.getRel());
-
-        final EntitySet inlineEntitySet = link.getInlineEntitySet();
-        if (inlineEntitySet != null) {
-          newLink.setInlineEntitySet(copyEntitySetShallowRekursive(inlineEntitySet));
-        } else if (link.getInlineEntity() != null) {
-          newLink.setInlineEntity(copyEntityShallowRekursive(link.getInlineEntity()));
+        final String propertyName = link.getTitle();
+        
+        if (expandAll || expanded.contains(propertyName)) {
+          final EdmNavigationProperty edmNavigationProperty = edmType.getNavigationProperty(propertyName);
+          final EdmBindingTarget edmBindingTarget = edmEntitySet.getRelatedBindingTarget(propertyName);
+          final Link newLink = newLink(link);
+          newEntity.getNavigationLinks().add(newLink);
+          final ExpandOption innerExpandOption = getInnerExpandOption(expand, propertyName);
+          
+          if(edmNavigationProperty.isCollection()) {
+            newLink.setInlineEntitySet(transformEntitySetGraphToTree(link.getInlineEntitySet(), 
+                                                                     edmBindingTarget, 
+                                                                     innerExpandOption));
+          } else {
+            newLink.setInlineEntity(transformEntityGraphToTree(link.getInlineEntity(), 
+                                                               edmBindingTarget, 
+                                                               innerExpandOption));  
+          }
         }
-        copiedEntity.getNavigationLinks().add(newLink);
       }
+      
+    }
+    return newEntity;
+  }
+  
+  public EntitySet newEntitySet(final EntitySet entitySet) {
+    final EntitySet newEntitySet = new EntitySetImpl();
+    newEntitySet.setCount(entitySet.getCount());
+    newEntitySet.setDeltaLink(entitySet.getDeltaLink());
+    newEntitySet.setNext(entitySet.getNext());
+    
+    return newEntitySet;
+  }
+  
+  private Entity newEntity(final Entity entity) {
+    final Entity newEntity = new EntityImpl();
+    
+    newEntity.getProperties().addAll(entity.getProperties());
+    newEntity.getAnnotations().addAll(entity.getAnnotations());
+    newEntity.getAssociationLinks().addAll(entity.getAssociationLinks());
+    newEntity.setEditLink(entity.getEditLink());
+    newEntity.setId(entity.getId());
+    newEntity.setMediaContentSource(entity.getMediaContentSource());
+    newEntity.setMediaContentType(entity.getMediaContentType());
+    newEntity.setMediaETag(entity.getMediaETag());
+    newEntity.getOperations().addAll(entity.getOperations());
+    newEntity.setSelfLink(entity.getSelfLink());
+    newEntity.setType(entity.getType());
+    newEntity.getNavigationBindings().addAll(entity.getNavigationBindings());
+    
+    return newEntity;
+  }
+  
+  private Link newLink(Link link) {
+    final Link newLink = new LinkImpl();
+    newLink.setMediaETag(link.getMediaETag());
+    newLink.setTitle(link.getTitle());
+    newLink.setType(link.getType());
+    newLink.setRel(link.getRel());
+    
+    return newLink;
+  }
+  
+  private boolean hasExpandItems(ExpandOption expand) {
+    return expand != null && expand.getExpandItems() != null && !expand.getExpandItems().isEmpty();
+  }
+  
+  private boolean expandAll(ExpandOption expand) {
+    for (final ExpandItem item : expand.getExpandItems()) {
+      if (item.isStar()) {
+        return true;
+      }
+    }
+    return false;
+  }
+  
+  private Set<String> getExpandedPropertyNames(List<ExpandItem> expandItems) throws ODataApplicationException {
+    Set<String> expanded = new HashSet<String>();
+    for (final ExpandItem item : expandItems) {
+      final List<UriResource> resourceParts = item.getResourcePath().getUriResourceParts();
+      if (resourceParts.size() == 1) {
+        final UriResource resource = resourceParts.get(0);
+        if (resource instanceof UriResourceNavigation) {
+          expanded.add(((UriResourceNavigation) resource).getProperty().getName());
+        }
+      } else {
+        throw new ODataApplicationException("Expand is not supported within complex properties.",
+            HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
+      }
+    }
+    return expanded;
+  }
 
-      return copiedEntity;
+  private ExpandOption getInnerExpandOption(final ExpandOption expand, final String propertyName) {
+    for(final ExpandItem item : expand.getExpandItems()) {
+      final UriResource resource = item.getResourcePath().getUriResourceParts().get(0);
+      if(resource instanceof UriResourceNavigation 
+          && propertyName.equals(((UriResourceNavigation) resource).getProperty().getName())) {
+        return item.getExpandOption();
+      }
     }
-    return copiedEntities.get(entity);
+    
+    return null;
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/518a3a41/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
index 3a91f49..ab0eca3 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
@@ -23,8 +23,8 @@ import java.util.Locale;
 
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.edm.EdmBindingTarget;
 import org.apache.olingo.commons.api.edm.EdmComplexType;
-import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.edm.EdmEnumType;
 import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.commons.api.edm.EdmType;
@@ -49,11 +49,11 @@ import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.operati
 public class ExpressionVisitorImpl implements ExpressionVisitor<VisitorOperand> {
 
   final private Entity entity;
-  final private EdmEntitySet edmEntitySet;
+  final private EdmBindingTarget bindingTarget;
 
-  public ExpressionVisitorImpl(Entity entity, EdmEntitySet edmEntitySet) {
+  public ExpressionVisitorImpl(Entity entity, EdmBindingTarget bindingTarget) {
     this.entity = entity;
-    this.edmEntitySet = edmEntitySet;
+    this.bindingTarget = bindingTarget;
   }
 
   @Override
@@ -183,7 +183,7 @@ public class ExpressionVisitorImpl implements ExpressionVisitor<VisitorOperand>
     Property currentProperty = entity.getProperty(uriResourceParts.get(0).toString());
     EdmType currentType = ((UriResourcePartTyped) uriResourceParts.get(0)).getType();
 
-    EdmProperty currentEdmProperty = edmEntitySet.getEntityType()
+    EdmProperty currentEdmProperty = bindingTarget.getEntityType()
         .getStructuralProperty(uriResourceParts.get(0).toString());
 
     for (int i = 1; i < uriResourceParts.size(); i++) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/518a3a41/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/FilterHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/FilterHandler.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/FilterHandler.java
index f1ba4ee..d4068a1 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/FilterHandler.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/FilterHandler.java
@@ -23,7 +23,7 @@ import java.util.Locale;
 
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmBindingTarget;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmBoolean;
 import org.apache.olingo.server.api.ODataApplicationException;
@@ -53,8 +53,8 @@ import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.operand
 
 public class FilterHandler {
 
-  public static void applyFilterSystemQuery(FilterOption filterOption, EntitySet entitySet, EdmEntitySet edmEntitySet)
-      throws ODataApplicationException {
+  public static void applyFilterSystemQuery(FilterOption filterOption, EntitySet entitySet, 
+      EdmBindingTarget edmEntitySet) throws ODataApplicationException {
 
     if (filterOption == null) {
       return;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/518a3a41/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/OrderByHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/OrderByHandler.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/OrderByHandler.java
index 71b9a81..d166c4e 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/OrderByHandler.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/OrderByHandler.java
@@ -24,7 +24,7 @@ import java.util.Locale;
 
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmBindingTarget;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.uri.queryoption.OrderByItem;
@@ -35,14 +35,14 @@ import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.operand
 
 public class OrderByHandler {
   public static void applyOrderByOption(final OrderByOption orderByOption, final EntitySet entitySet,
-      final EdmEntitySet edmEntitySet) throws ODataApplicationException {
+      final EdmBindingTarget edmBindingTarget) throws ODataApplicationException {
 
     if (orderByOption == null) {
       return;
     }
 
     try {
-      applyOrderByOptionInternal(orderByOption, entitySet, edmEntitySet);
+      applyOrderByOptionInternal(orderByOption, entitySet, edmBindingTarget);
     } catch (SystemQueryOptionsRuntimeException e) {
       if (e.getCause() instanceof ODataApplicationException) {
         // Throw the nested exception, to send the correct HTTP status code in the HTTP response
@@ -55,7 +55,7 @@ public class OrderByHandler {
   }
 
   private static void applyOrderByOptionInternal(final OrderByOption orderByOption, final EntitySet entitySet,
-      final EdmEntitySet edmEntitySet) throws ODataApplicationException {
+      final EdmBindingTarget edmBindingTarget) throws ODataApplicationException {
     Collections.sort(entitySet.getEntities(), new Comparator<Entity>() {
       @Override
       @SuppressWarnings({ "unchecked", "rawtypes" })
@@ -69,9 +69,9 @@ public class OrderByHandler {
           try {
             final OrderByItem item = orderByOption.getOrders().get(i);
             final TypedOperand op1 =
-                item.getExpression().accept(new ExpressionVisitorImpl(e1, edmEntitySet)).asTypedOperand();
+                item.getExpression().accept(new ExpressionVisitorImpl(e1, edmBindingTarget)).asTypedOperand();
             final TypedOperand op2 =
-                item.getExpression().accept(new ExpressionVisitorImpl(e2, edmEntitySet)).asTypedOperand();
+                item.getExpression().accept(new ExpressionVisitorImpl(e2, edmBindingTarget)).asTypedOperand();
 
             if (op1.isNull() || op2.isNull()) {
               if (op1.isNull() && op2.isNull()) {


[13/22] olingo-odata4 git commit: [OLINGO-545] TecSvc: Allow upserts

Posted by ra...@apache.org.
[OLINGO-545] TecSvc: Allow upserts


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/62214d2d
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/62214d2d
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/62214d2d

Branch: refs/heads/OLINGO-573
Commit: 62214d2d87ca4bcdb5505d71a243527315a25380
Parents: d692d12
Author: Christian Holzer <c....@sap.com>
Authored: Tue Apr 7 12:14:38 2015 +0200
Committer: Christian Holzer <c....@sap.com>
Committed: Tue Apr 7 15:27:16 2015 +0200

----------------------------------------------------------------------
 .../processor/TechnicalEntityProcessor.java     | 21 ++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/62214d2d/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
index 01f2c90..623d22d 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
@@ -117,9 +117,10 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
       ODataSerializer serializer = odata.createSerializer(format);
       final ExpandOption expand = uriInfo.getExpandOption();
       final SelectOption select = uriInfo.getSelectOption();
-
-      // Create a shallow copy of each entity. So the expanded navigation properties can be modified for serialization,
-      // without affecting the data stored in the database.
+      
+      // Transform the entity graph to a tree. The construction is controlled by the expand tree.
+      // Apply all expand system query options to the tree.So the expanded navigation properties can be modified 
+      // for serialization,without affecting the data stored in the database.
       final ExpandSystemQueryOptionHandler expandHandler = new ExpandSystemQueryOptionHandler();
       final EntityCollection entitySetSerialization = expandHandler.transformEntitySetGraphToTree(entitySet, 
                                                                                            edmEntitySet, 
@@ -270,7 +271,19 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
       final ContentType requestFormat, final ContentType responseFormat)
       throws ODataApplicationException, DeserializerException, SerializerException {
     final EdmEntitySet edmEntitySet = getEdmEntitySet(uriInfo);
-    Entity entity = readEntity(uriInfo);
+    Entity entity;
+    
+    try {
+      entity = readEntity(uriInfo);
+    } catch(ODataApplicationException e) {
+      if(e.getStatusCode() == HttpStatusCode.NOT_FOUND.getStatusCode()) {
+        // Perform upsert
+        createEntity(request, response, uriInfo, requestFormat, responseFormat);
+        return;
+      } else {
+        throw e;
+      }
+    }
     checkRequestFormat(requestFormat);
     final ODataDeserializer deserializer = odata.createDeserializer(ODataFormat.fromContentType(requestFormat));
     final Entity changedEntity = deserializer.entity(request.getBody(), edmEntitySet.getEntityType()).getEntity();


[14/22] olingo-odata4 git commit: [OLINGO-545] Tests for batch changesets, update and insert requests added

Posted by ra...@apache.org.
[OLINGO-545] Tests for batch changesets, update and insert requests added


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

Branch: refs/heads/OLINGO-573
Commit: 9e232a2d748b74ae12ee9fb64b87665d53124e99
Parents: 62214d2
Author: Christian Holzer <c....@sap.com>
Authored: Tue Apr 7 12:22:02 2015 +0200
Committer: Christian Holzer <c....@sap.com>
Committed: Tue Apr 7 17:20:52 2015 +0200

----------------------------------------------------------------------
 .../olingo/fit/tecsvc/client/BasicITCase.java   | 324 ++++++++++++++++++-
 .../fit/tecsvc/client/BatchClientITCase.java    | 262 ++++++++-------
 .../fit/tecsvc/client/DeepInsertITCase.java     | 203 +++++++++++-
 .../olingo/server/tecsvc/data/DataCreator.java  |   5 +
 .../server/tecsvc/data/RequestValidator.java    |  27 +-
 .../processor/TechnicalEntityProcessor.java     |   4 +-
 6 files changed, 668 insertions(+), 157 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9e232a2d/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
index 5b8949a..5beec7b 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
@@ -21,6 +21,7 @@ package org.apache.olingo.fit.tecsvc.client;
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.CoreMatchers.hasItem;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertThat;
@@ -64,6 +65,7 @@ import org.apache.olingo.commons.api.domain.ODataProperty;
 import org.apache.olingo.commons.api.domain.ODataServiceDocument;
 import org.apache.olingo.commons.api.domain.ODataValue;
 import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.format.ODataFormat;
@@ -461,7 +463,11 @@ public class BasicITCase extends AbstractBaseTestITCase {
           .add(of.newComplexValue("CTPrimComp")
               .add(of.newPrimitiveProperty("PropertyInt16", of.newPrimitiveValueBuilder().buildInt16((short)42)))
               .add(of.newComplexProperty("PropertyComp", of.newComplexValue("CTAllPrim")
-                  .add(of.newPrimitiveProperty("PropertyString", of.newPrimitiveValueBuilder().buildString("42"))))))));
+                  .add(of.newPrimitiveProperty("PropertyString", of.newPrimitiveValueBuilder().buildString("42"))))))
+          .add(of.newComplexValue("CTPrimComp")
+              .add(of.newPrimitiveProperty("PropertyInt16", of.newPrimitiveValueBuilder().buildInt16((short)43)))
+              .add(of.newComplexProperty("PropertyComp", of.newComplexValue("CTAllPrim")
+                  .add(of.newPrimitiveProperty("PropertyString", of.newPrimitiveValueBuilder().buildString("43"))))))));
     
     final URI uri = getClient().newURIBuilder(SERVICE_URI)
                                .appendEntitySetSegment("ESKeyNav")
@@ -484,19 +490,26 @@ public class BasicITCase extends AbstractBaseTestITCase {
     
     assertEquals(HttpStatusCode.OK.getStatusCode(), entityResponse.getStatusCode());
     assertNotNull(entityResponse.getBody().getProperty("CollPropertyComp"));
-    assertEquals(1, entityResponse.getBody().getProperty("CollPropertyComp").getCollectionValue().size());
-    
-    ODataComplexValue complexProperty = entityResponse.getBody()
-                                                      .getProperty("CollPropertyComp")
-                                                      .getCollectionValue()
-                                                      .iterator()
-                                                      .next()
-                                                      .asComplex();
+    assertEquals(2, entityResponse.getBody().getProperty("CollPropertyComp").getCollectionValue().size());
+    
+    final Iterator<ODataValue> collectionIterator = entityResponse.getBody()
+                                                                  .getProperty("CollPropertyComp")
+                                                                  .getCollectionValue()
+                                                                  .iterator();
+    
+    ODataComplexValue complexProperty = collectionIterator.next().asComplex();
     assertEquals(42, complexProperty.get("PropertyInt16").getPrimitiveValue().toValue());
     assertNotNull(complexProperty.get("PropertyComp"));
     
-    final ODataComplexValue innerComplexProperty = complexProperty.get("PropertyComp").getComplexValue();
+    ODataComplexValue innerComplexProperty = complexProperty.get("PropertyComp").getComplexValue();
     assertEquals("42", innerComplexProperty.get("PropertyString").getPrimitiveValue().toValue());
+    
+    complexProperty = collectionIterator.next().asComplex();
+    assertEquals(43, complexProperty.get("PropertyInt16").getPrimitiveValue().toValue());
+    assertNotNull(complexProperty.get("PropertyComp"));
+    
+    innerComplexProperty = complexProperty.get("PropertyComp").getComplexValue();
+    assertEquals("43", innerComplexProperty.get("PropertyString").getPrimitiveValue().toValue());
   }
   
   @Test
@@ -614,6 +627,297 @@ public class BasicITCase extends AbstractBaseTestITCase {
     }
   }
   
+  @Test
+  public void testUpsert() throws EdmPrimitiveTypeException {
+    final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+    final ODataObjectFactory of = client.getObjectFactory();
+  
+    final ODataEntity entity = of.newEntity(new FullQualifiedName("olingo.odata.test1", "ETTwoPrim"));
+    entity.getProperties().add(of.newPrimitiveProperty("PropertyString", of.newPrimitiveValueBuilder()
+                                                                           .buildString("Test")));
+    
+    final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESTwoPrim").appendKeySegment(33).build();
+    final ODataEntityUpdateResponse<ODataEntity> updateResponse = 
+        client.getCUDRequestFactory().getEntityUpdateRequest(uri, UpdateType.PATCH, entity).execute();
+    
+    assertEquals(HttpStatusCode.CREATED.getStatusCode(), updateResponse.getStatusCode());
+    assertEquals("Test", updateResponse.getBody().getProperty("PropertyString").getPrimitiveValue().toValue());
+    
+    final String cookie = updateResponse.getHeader(HttpHeader.SET_COOKIE).iterator().next();
+    final Short key = updateResponse.getBody().getProperty("PropertyInt16")
+                                              .getPrimitiveValue()
+                                              .toCastValue(Short.class);
+    
+    final ODataEntityRequest<ODataEntity> entityRequest = client.getRetrieveRequestFactory()
+                                                                .getEntityRequest(client.newURIBuilder()
+                                                                    .appendEntitySetSegment("ESTwoPrim")
+                                                                    .appendKeySegment(key)
+                                                                    .build());
+    entityRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
+    final ODataRetrieveResponse<ODataEntity> responseEntityRequest = entityRequest.execute();
+    assertEquals(HttpStatusCode.OK.getStatusCode(), responseEntityRequest.getStatusCode());
+    assertEquals("Test", responseEntityRequest.getBody().getProperty("PropertyString").getPrimitiveValue().toValue());
+  }
+  
+  @Test
+  public void testUpdatePropertyWithNull() {
+    final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+    final ODataObjectFactory of = client.getObjectFactory();
+  
+    final URI targetURI = client.newURIBuilder(SERVICE_URI)
+                                .appendEntitySetSegment("ESAllPrim")
+                                .appendKeySegment(32767)
+                                .build();
+    
+    final ODataEntity entity = of.newEntity(new FullQualifiedName("olingo.odata.test1", "ETAllPrim"));
+    entity.getProperties().add(of.newPrimitiveProperty("PropertyString", of.newPrimitiveValueBuilder()
+                                                                            .buildString(null)));
+    
+    final ODataEntityUpdateResponse<ODataEntity> updateResponse = client.getCUDRequestFactory()
+        .getEntityUpdateRequest(targetURI,  UpdateType.PATCH, entity)
+        .execute();
+    
+    assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), updateResponse.getStatusCode());
+    final String cookie = updateResponse.getHeader(HttpHeader.SET_COOKIE).iterator().next();
+    
+    final ODataEntityRequest<ODataEntity> entityRequest = client.getRetrieveRequestFactory()
+                                                                .getEntityRequest(targetURI);
+    entityRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
+    final ODataRetrieveResponse<ODataEntity> entityResponse = entityRequest.execute();
+    assertEquals(HttpStatusCode.OK.getStatusCode(), entityResponse.getStatusCode());
+    
+    assertTrue(entityResponse.getBody().getProperty("PropertyString").hasNullValue());
+    assertEquals(34, entityResponse.getBody().getProperty("PropertyDecimal").getPrimitiveValue().toValue());
+  }
+  
+  @Test(expected=ODataClientErrorException.class)
+  public void testUpdatePropertyWithNullNotAllowed() {
+    final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+    final ODataObjectFactory of = client.getObjectFactory();
+  
+    final URI targetURI = client.newURIBuilder(SERVICE_URI)
+                                .appendEntitySetSegment("ESKeyNav")
+                                .appendKeySegment(32767)
+                                .build();
+    
+    final ODataEntity entity = of.newEntity(new FullQualifiedName("olingo.odata.test1", "ETKeyNav"));
+    entity.getProperties().add(of.newPrimitiveProperty("PropertyString", of.newPrimitiveValueBuilder()
+                                                                            .buildString(null)));
+    
+    client.getCUDRequestFactory().getEntityUpdateRequest(targetURI,  UpdateType.PATCH, entity).execute();
+  }
+  
+  @Test
+  public void testUpdateMerge() {
+    final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+    final ODataObjectFactory of = client.getObjectFactory();
+  
+    final URI targetURI = client.newURIBuilder(SERVICE_URI)
+                                .appendEntitySetSegment("ESKeyNav")
+                                .appendKeySegment(1)
+                                .build();
+
+    final ODataEntity entity = of.newEntity(new FullQualifiedName("olingo.odata.test1", "ETKeyNav"));
+    entity.addLink(of.newEntityNavigationLink("NavPropertyETKeyNavOne", targetURI));
+    entity.addLink(of.newEntitySetNavigationLink("NavPropertyETKeyNavMany", client.newURIBuilder(SERVICE_URI)
+        .appendEntitySetSegment("ESKeyNav").appendKeySegment(3).build()));
+    entity.getProperties().add(of.newCollectionProperty("CollPropertyString", of.newCollectionValue("Edm.String")
+        .add(of.newPrimitiveValueBuilder().buildString("Single entry!"))));
+    entity.getProperties().add(of.newComplexProperty("PropertyCompAllPrim", 
+        of.newComplexValue("CTAllPrim")
+          .add(of.newPrimitiveProperty("PropertyString", 
+              of.newPrimitiveValueBuilder().buildString("Changed")))));
+    
+    final ODataEntityUpdateResponse<ODataEntity> response = client.getCUDRequestFactory()
+                                                .getEntityUpdateRequest(targetURI,UpdateType.PATCH, entity)
+                                                .execute();
+    
+    assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
+    final String cookie = response.getHeader(HttpHeader.SET_COOKIE).iterator().next();
+    
+    final ODataEntityRequest<ODataEntity> entityRequest = client.getRetrieveRequestFactory()
+                                                      .getEntityRequest(
+                                                          client.newURIBuilder()
+                                                          .appendEntitySetSegment("ESKeyNav")
+                                                          .appendKeySegment(1)
+                                                          .expand("NavPropertyETKeyNavOne", "NavPropertyETKeyNavMany")
+                                                          .build());
+    entityRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
+    final ODataRetrieveResponse<ODataEntity> entitytResponse = entityRequest.execute();
+    
+    assertEquals(HttpStatusCode.OK.getStatusCode(), entitytResponse.getStatusCode());
+    assertEquals(1, entitytResponse.getBody().getNavigationLink("NavPropertyETKeyNavOne")
+                                             .asInlineEntity()
+                                             .getEntity()
+                                             .getProperty("PropertyInt16")
+                                             .getPrimitiveValue()
+                                             .toValue());
+    
+    assertEquals(3, entitytResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
+        .asInlineEntitySet()
+        .getEntitySet()
+        .getEntities()
+        .size());
+    
+    assertEquals(1, entitytResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
+                                             .asInlineEntitySet()
+                                             .getEntitySet()
+                                             .getEntities()
+                                             .get(0)
+                                             .getProperty("PropertyInt16")
+                                             .getPrimitiveValue()
+                                             .toValue());
+    
+    assertEquals(2, entitytResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
+                                              .asInlineEntitySet()
+                                              .getEntitySet()
+                                              .getEntities()
+                                              .get(1)
+                                              .getProperty("PropertyInt16")
+                                              .getPrimitiveValue()
+                                              .toValue());
+    
+    assertEquals(3, entitytResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
+                                              .asInlineEntitySet()
+                                              .getEntitySet()
+                                              .getEntities()
+                                              .get(2)
+                                              .getProperty("PropertyInt16")
+                                              .getPrimitiveValue()
+                                              .toValue());
+    
+    final Iterator<ODataValue> collectionIterator = entitytResponse.getBody()
+                                                                   .getProperty("CollPropertyString")
+                                                                   .getCollectionValue()
+                                                                   .iterator();
+    assertTrue(collectionIterator.hasNext());
+    assertEquals("Single entry!", collectionIterator.next().asPrimitive().toValue());
+    assertFalse(collectionIterator.hasNext());
+    
+    final ODataComplexValue complexValue = entitytResponse.getBody()
+                                                          .getProperty("PropertyCompAllPrim")
+                                                          .getComplexValue();
+    
+    assertEquals("Changed", complexValue.get("PropertyString").getPrimitiveValue().toValue());
+  }
+  
+  @Test
+  public void testUpdateReplace() {
+    final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+    final ODataObjectFactory of = client.getObjectFactory();
+  
+    final URI targetURI = client.newURIBuilder(SERVICE_URI)
+                                .appendEntitySetSegment("ESKeyNav")
+                                .appendKeySegment(1)
+                                .build();
+
+    final ODataEntity entity = of.newEntity(new FullQualifiedName("olingo.odata.test1", "ETKeyNav"));
+    entity.addLink(of.newEntityNavigationLink("NavPropertyETKeyNavOne", targetURI));
+    entity.addLink(of.newEntitySetNavigationLink("NavPropertyETKeyNavMany", client.newURIBuilder(SERVICE_URI)
+        .appendEntitySetSegment("ESKeyNav").appendKeySegment(3).build()));
+    entity.getProperties().add(of.newPrimitiveProperty("PropertyString", of.newPrimitiveValueBuilder()
+        .buildString("Must not be null")));
+    entity.getProperties().add(of.newComplexProperty("PropertyCompTwoPrim", of.newComplexValue("CTTwoPrim")
+        .add(of.newPrimitiveProperty("PropertyString", of.newPrimitiveValueBuilder()
+                                                          .buildString("Must not be null")))
+        .add(of.newPrimitiveProperty("PropertyInt16", of.newPrimitiveValueBuilder().buildInt16((short) 42)))));
+    entity.getProperties().add(of.newCollectionProperty("CollPropertyString", of.newCollectionValue("Edm.String")
+        .add(of.newPrimitiveValueBuilder().buildString("Single entry!"))));
+    entity.getProperties().add(of.newComplexProperty("PropertyCompAllPrim", 
+        of.newComplexValue("CTAllPrim")
+          .add(of.newPrimitiveProperty("PropertyString", 
+              of.newPrimitiveValueBuilder().buildString("Changed")))));
+    
+    final ODataEntityUpdateResponse<ODataEntity> response = client.getCUDRequestFactory()
+                                                .getEntityUpdateRequest(targetURI,UpdateType.REPLACE, entity)
+                                                .execute();
+    
+    assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
+    final String cookie = response.getHeader(HttpHeader.SET_COOKIE).iterator().next();
+    
+    final ODataEntityRequest<ODataEntity> entityRequest = client.getRetrieveRequestFactory()
+                                                      .getEntityRequest(
+                                                          client.newURIBuilder()
+                                                          .appendEntitySetSegment("ESKeyNav")
+                                                          .appendKeySegment(1)
+                                                          .expand("NavPropertyETKeyNavOne", "NavPropertyETKeyNavMany")
+                                                          .build());
+    entityRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
+    final ODataRetrieveResponse<ODataEntity> entitytResponse = entityRequest.execute();
+    
+    assertEquals(HttpStatusCode.OK.getStatusCode(), entitytResponse.getStatusCode());
+    assertEquals(1, entitytResponse.getBody().getNavigationLink("NavPropertyETKeyNavOne")
+                                             .asInlineEntity()
+                                             .getEntity()
+                                             .getProperty("PropertyInt16")
+                                             .getPrimitiveValue()
+                                             .toValue());
+    
+    assertEquals(3, entitytResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
+        .asInlineEntitySet()
+        .getEntitySet()
+        .getEntities()
+        .size());
+    
+    assertEquals(1, entitytResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
+                                             .asInlineEntitySet()
+                                             .getEntitySet()
+                                             .getEntities()
+                                             .get(0)
+                                             .getProperty("PropertyInt16")
+                                             .getPrimitiveValue()
+                                             .toValue());
+    
+    assertEquals(2, entitytResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
+                                              .asInlineEntitySet()
+                                              .getEntitySet()
+                                              .getEntities()
+                                              .get(1)
+                                              .getProperty("PropertyInt16")
+                                              .getPrimitiveValue()
+                                              .toValue());
+    
+    assertEquals(3, entitytResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
+                                              .asInlineEntitySet()
+                                              .getEntitySet()
+                                              .getEntities()
+                                              .get(2)
+                                              .getProperty("PropertyInt16")
+                                              .getPrimitiveValue()
+                                              .toValue());
+    
+    final Iterator<ODataValue> collectionIterator = entitytResponse.getBody()
+                                                                   .getProperty("CollPropertyString")
+                                                                   .getCollectionValue()
+                                                                   .iterator();
+    assertTrue(collectionIterator.hasNext());
+    assertEquals("Single entry!", collectionIterator.next().asPrimitive().toValue());
+    assertFalse(collectionIterator.hasNext());
+    
+    final ODataComplexValue propCompAllPrim = entitytResponse.getBody()
+                                                          .getProperty("PropertyCompAllPrim")
+                                                          .getComplexValue();
+    
+    assertEquals("Changed", propCompAllPrim.get("PropertyString").getPrimitiveValue().toValue());
+    assertTrue(propCompAllPrim.get("PropertyInt16").hasNullValue());
+    assertTrue(propCompAllPrim.get("PropertyDate").hasNullValue());
+    
+   final ODataComplexValue propCompTwoPrim = entitytResponse.getBody()
+                                                            .getProperty("PropertyCompTwoPrim")
+                                                            .getComplexValue();
+   
+   assertEquals("Must not be null", propCompTwoPrim.get("PropertyString").getPrimitiveValue().toValue());
+   assertEquals(42, propCompTwoPrim.get("PropertyInt16").getPrimitiveValue().toValue());
+   
+   assertNotNull(entitytResponse.getBody().getProperty("PropertyCompNav").getComplexValue());
+   assertTrue(entitytResponse.getBody()
+                             .getProperty("PropertyCompNav")
+                             .getComplexValue()
+                             .get("PropertyInt16")
+                             .hasNullValue());
+  }
+
+  
   @Override
   protected ODataClient getClient() {
     ODataClient odata = ODataClientFactory.getClient();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9e232a2d/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
index a46644c..55fa57f 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
@@ -22,14 +22,11 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.util.HashMap;
 import java.util.Iterator;
 
-import org.apache.olingo.client.api.ODataBatchConstants;
 import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.communication.request.batch.BatchManager;
 import org.apache.olingo.client.api.communication.request.batch.ODataBatchRequest;
@@ -44,9 +41,10 @@ import org.apache.olingo.client.api.communication.response.ODataBatchResponse;
 import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
 import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
 import org.apache.olingo.client.api.communication.response.ODataResponse;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.http.HttpClientException;
 import org.apache.olingo.client.api.uri.URIBuilder;
 import org.apache.olingo.client.core.communication.request.batch.ODataChangesetResponseItem;
-import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.commons.api.domain.ODataEntity;
 import org.apache.olingo.commons.api.domain.ODataEntitySet;
 import org.apache.olingo.commons.api.domain.ODataObjectFactory;
@@ -54,11 +52,11 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.fit.tecsvc.TecSvcConst;
 import org.apache.olingo.fit.v4.AbstractTestITCase;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
 public class BatchClientITCase extends AbstractTestITCase {
@@ -66,8 +64,8 @@ public class BatchClientITCase extends AbstractTestITCase {
   private static final String SERVICE_URI = TecSvcConst.BASE_URI;
   private static final String SERVICE_NAMESPACE = "olingo.odata.test1";
   private static final String ES_NOT_AVAILABLE_NAME = "ESNotAvailable";
-  private static final FullQualifiedName ES_NOT_AVAILABLE = new FullQualifiedName(SERVICE_NAMESPACE, 
-                                                                                  ES_NOT_AVAILABLE_NAME);
+  private static final FullQualifiedName ES_NOT_AVAILABLE = new FullQualifiedName(SERVICE_NAMESPACE,
+      ES_NOT_AVAILABLE_NAME);
   private static final String PROPERTY_STRING = "PropertyString";
 
   @Before
@@ -107,7 +105,7 @@ public class BatchClientITCase extends AbstractTestITCase {
         .appendEntitySetSegment(ES_NOT_AVAILABLE_NAME)
         .build();
     final ODataEntityCreateRequest<ODataEntity> createRequest = client.getCUDRequestFactory()
-                                                                      .getEntityCreateRequest(targetURI, entity);
+        .getEntityCreateRequest(targetURI, entity);
     changeset.addRequest(createRequest);
 
     final ODataBatchResponse response = payloadManager.getResponse();
@@ -277,8 +275,7 @@ public class BatchClientITCase extends AbstractTestITCase {
     assertEquals(400, oDataResponse.getStatusCode());
   }
 
-  @Test
-  @Ignore
+  @Test(expected = HttpClientException.class)
   public void testInvalidHost() throws URISyntaxException {
     final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(SERVICE_URI);
     request.setAccept(ACCEPT);
@@ -290,12 +287,10 @@ public class BatchClientITCase extends AbstractTestITCase {
     payload.addRequest(queryReq);
 
     // Fetch result
-    final ODataBatchResponse response = payload.getResponse();
-    assertEquals(400, response.getStatusCode());
+    payload.getResponse();
   }
 
-  @Test
-  @Ignore
+  @Test(expected = HttpClientException.class)
   public void testInvalidAbsoluteRequest() throws URISyntaxException {
     final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(SERVICE_URI);
     request.setAccept(ACCEPT);
@@ -307,8 +302,7 @@ public class BatchClientITCase extends AbstractTestITCase {
     payload.addRequest(queryReq);
 
     // Fetch result
-    final ODataBatchResponse response = payload.getResponse();
-    assertEquals(400, response.getStatusCode());
+    payload.getResponse();
   }
 
   @Test
@@ -367,111 +361,92 @@ public class BatchClientITCase extends AbstractTestITCase {
     assertEquals("application/json;odata.metadata=minimal", oDataResonse.getContentType());
   }
 
-  @SuppressWarnings("unchecked")
   @Test
-  @Ignore("Not implemented")
-  public void changesetWithReferences() throws EdmPrimitiveTypeException {
+  @SuppressWarnings("unchecked")
+  public void changesetWithReferences() throws EdmPrimitiveTypeException, URISyntaxException {
     // create your request
     final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(SERVICE_URI);
+    final ODataObjectFactory of = client.getObjectFactory();
     request.setAccept(ACCEPT);
     final BatchManager streamManager = request.payloadManager();
 
     final ODataChangeset changeset = streamManager.addChangeset();
-    ODataEntity esAllPrim = newESAllPrim((short) 23);
+    final ODataEntity entityESAllPrim = getClient().getObjectFactory().
+        newEntity(new FullQualifiedName("olingo.odata.test1.ESAllPrim"));
 
+    entityESAllPrim.getProperties().add(client.getObjectFactory().newPrimitiveProperty(
+        "PropertyDouble",
+        client.getObjectFactory().newPrimitiveValueBuilder().buildDouble(3.1415)));
+    
+    entityESAllPrim.addLink(
+        of.newEntityNavigationLink("NavPropertyETTwoPrimOne", client.newURIBuilder(SERVICE_URI)
+                                                                    .appendEntitySetSegment("ESTwoPrim")
+                                                                    .appendKeySegment(-365)
+                                                                    .build()));
+    
+    
     final URIBuilder uriBuilder = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESAllPrim");
 
     // add create request
     final ODataEntityCreateRequest<ODataEntity> createReq =
-        client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), esAllPrim);
-
+        client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), entityESAllPrim);
+    createReq.setFormat(ODataFormat.JSON);
     changeset.addRequest(createReq);
 
     // retrieve request reference
     int createRequestRef = changeset.getLastContentId();
 
     // add update request
-    final ODataEntity customerChanges = client.getObjectFactory().newEntity(esAllPrim.getTypeName());
-    customerChanges.addLink(client.getObjectFactory().newEntitySetNavigationLink(
+    final ODataEntity entityUpdate = client.getObjectFactory().newEntity(entityESAllPrim.getTypeName());
+    entityUpdate.addLink(client.getObjectFactory().newEntitySetNavigationLink(
         "NavPropertyETTwoPrimMany",
-        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("NavPropertyETTwoPrimMany").
-            appendKeySegment(new HashMap<String, Object>() {
-              private static final long serialVersionUID = 3109256773218160485L;
-
-              {
-                put("PropertyInt16", 4242);
-                put("PropertyString", "Test");
-              }
-            }).build()));
+        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESTwoPrim").appendKeySegment(32767).build()));
 
     final ODataEntityUpdateRequest<ODataEntity> updateReq = client.getCUDRequestFactory().getEntityUpdateRequest(
-        URI.create("$" + createRequestRef), UpdateType.PATCH, customerChanges);
-
+        URI.create("$" + createRequestRef), UpdateType.PATCH, entityUpdate);
+    updateReq.setFormat(ODataFormat.JSON);
+    
     changeset.addRequest(updateReq);
 
     final ODataBatchResponse response = streamManager.getResponse();
-    assertEquals(200, response.getStatusCode());
-    assertEquals("OK", response.getStatusMessage());
-
+    assertEquals(HttpStatusCode.ACCEPTED.getStatusCode(), response.getStatusCode());
+    final String cookie = response.getHeader(HttpHeader.SET_COOKIE).iterator().next();
+    
     // verify response payload ...
-    final Iterator<ODataBatchResponseItem> iter = response.getBody();
+    final Iterator<ODataBatchResponseItem> bodyIterator = response.getBody();
+    final ODataBatchResponseItem item = bodyIterator.next();
 
-    final ODataBatchResponseItem item = iter.next();
     assertTrue(item instanceof ODataChangesetResponseItem);
-
     final ODataChangesetResponseItem chgitem = (ODataChangesetResponseItem) item;
-
+    assertTrue(chgitem.hasNext());
     ODataResponse res = chgitem.next();
-    assertEquals(201, res.getStatusCode());
+    assertEquals(HttpStatusCode.CREATED.getStatusCode(), res.getStatusCode());
     assertTrue(res instanceof ODataEntityCreateResponse);
-
-    esAllPrim = ((ODataEntityCreateResponse<ODataEntity>) res).getBody();
-    final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest(
-        URIUtils.getURI(SERVICE_URI, esAllPrim.getEditLink().toASCIIString() + "/NavPropertyETTwoPrimMany"));
-
-    assertEquals(Integer.valueOf(4242),
-        req.execute().getBody().getEntities().get(0).getProperty("PropertyInt16").getPrimitiveValue().
-            toCastValue(Integer.class));
-
+    final ODataEntityCreateResponse<ODataEntity> createResponse = ((ODataEntityCreateResponse<ODataEntity>) res);
+    
     res = chgitem.next();
-    assertEquals(204, res.getStatusCode());
+    assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), res.getStatusCode());
     assertTrue(res instanceof ODataEntityUpdateResponse);
+    
+    final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest(
+        new URI(createResponse.getHeader(HttpHeader.LOCATION).iterator().next() + "/NavPropertyETTwoPrimMany"));
+    req.setFormat(ODataFormat.JSON);
+    req.addCustomHeader(HttpHeader.COOKIE, cookie);
+    final ODataRetrieveResponse<ODataEntitySet> getResponse = req.execute();
+    
+    assertEquals(32767, getResponse.getBody()
+                               .getEntities()
+                               .get(0)
+                               .getProperty("PropertyInt16")
+                               .getPrimitiveValue()
+                               .toValue());
+  } 
 
-    // clean ...
-    assertEquals(204, client.getCUDRequestFactory().getDeleteRequest(
-        URIUtils.getURI(SERVICE_URI, esAllPrim.getEditLink().toASCIIString())).execute().
-        getStatusCode());
-
-    try {
-      client.getRetrieveRequestFactory().getEntityRequest(
-          URIUtils.getURI(SERVICE_URI, esAllPrim.getEditLink().toASCIIString())).
-          execute().getBody();
-      fail("Entity not deleted");
-    } catch (Exception e) {
-      // ignore
-    }
-  }
-
-  private ODataEntity newESAllPrim(short id) {
-    final ODataEntity entity = getClient().getObjectFactory().
-        newEntity(new FullQualifiedName("olingo.odata.test1.ESAllPrim"));
-
-    entity.getProperties().add(client.getObjectFactory().newPrimitiveProperty(
-        "PropertyInt16",
-        client.getObjectFactory().newPrimitiveValueBuilder().buildInt16(id)));
-
-    entity.getProperties().add(client.getObjectFactory().newPrimitiveProperty(
-        "PropertyDouble",
-        client.getObjectFactory().newPrimitiveValueBuilder().buildDouble(3.1415)));
-
-    return entity;
-  }
-
-  // TODO If write support is implemented, remove ignore tag
   @Test
-  @Ignore("Not implemented")
+  @SuppressWarnings("unchecked")
   public void changesetBatchRequest() throws URISyntaxException {
     final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(SERVICE_URI);
+    final ODataObjectFactory of = client.getObjectFactory();
     request.setAccept(ACCEPT);
 
     final BatchManager payload = request.payloadManager();
@@ -491,21 +466,20 @@ public class BatchClientITCase extends AbstractTestITCase {
         client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESAllPrim");
     URI editLink = targetURI.build();
 
-    ODataEntity post = client.getObjectFactory().newEntity(
+    ODataEntity postEntity = client.getObjectFactory().newEntity(
         new FullQualifiedName("olingo.odata.test1.ESAllPrim"));
+    postEntity.addLink(of.newEntityNavigationLink("NavPropertyETTwoPrimOne", client.newURIBuilder(SERVICE_URI)
+                                                                             .appendEntitySetSegment("ESTwoPrim")
+                                                                             .appendKeySegment(32766)
+                                                                             .build()));
 
-    post.getProperties().add(client.getObjectFactory().newPrimitiveProperty(
-        "PropertyInt16",
-        client.getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) 15)));
-
-    post.getProperties().add(client.getObjectFactory().newPrimitiveProperty(
+    postEntity.getProperties().add(client.getObjectFactory().newPrimitiveProperty(
         "PropertyDouble",
         client.getObjectFactory().newPrimitiveValueBuilder().buildDouble(3.1415)));
 
     final ODataEntityCreateRequest<ODataEntity> createRequest =
-        client.getCUDRequestFactory().getEntityCreateRequest(editLink, post);
-    createRequest.setFormat(ODataFormat.JSON_FULL_METADATA);
-    createRequest.setContentType("1");
+        client.getCUDRequestFactory().getEntityCreateRequest(editLink, postEntity);
+    createRequest.setFormat(ODataFormat.JSON);
 
     changeset.addRequest(createRequest);
 
@@ -514,40 +488,44 @@ public class BatchClientITCase extends AbstractTestITCase {
     targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESAllPrim").appendKeySegment(0);
     editLink = targetURI.build();
 
-    ODataEntity patch = client.getObjectFactory().newEntity(new FullQualifiedName("olingo.odata.test1.ESAllPrim"));
-    patch.setEditLink(editLink);
+    ODataEntity patchEntity = client.getObjectFactory()
+              .newEntity(new FullQualifiedName("olingo.odata.test1.ESAllPrim"));
+    patchEntity.setEditLink(editLink);
 
-    patch.getProperties().add(client.getObjectFactory().newPrimitiveProperty(
+    patchEntity.getProperties().add(client.getObjectFactory().newPrimitiveProperty(
         "PropertyDouble",
         client.getObjectFactory().newPrimitiveValueBuilder().buildDouble(3.1415)));
 
     ODataEntityUpdateRequest<ODataEntity> changeReq =
-        client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patch);
-    changeReq.setFormat(ODataFormat.JSON_FULL_METADATA);
-    changeReq.setContentType("2");
+        client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patchEntity);
+    changeReq.setFormat(ODataFormat.JSON);
     changeset.addRequest(changeReq);
 
     // ------------------------
     // Patch request (Upsert)
-    targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESAllPrim").appendKeySegment(35);
+    targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESAllPrim").appendKeySegment(15);
     editLink = targetURI.build();
 
-    patch = client.getObjectFactory().newEntity(new FullQualifiedName("olingo.odata.test1.ESAllPrim"));
-    patch.setEditLink(editLink);
+    patchEntity = client.getObjectFactory().newEntity(new FullQualifiedName("olingo.odata.test1.ESAllPrim"));
+    patchEntity.setEditLink(editLink);
 
-    patch.getProperties().add(client.getObjectFactory().newPrimitiveProperty(
+    patchEntity.getProperties().add(client.getObjectFactory().newPrimitiveProperty(
         "PropertyDouble",
         client.getObjectFactory().newPrimitiveValueBuilder().buildDouble(3.1415)));
-
-    changeReq = client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patch);
-    changeReq.setFormat(ODataFormat.JSON_FULL_METADATA);
-    changeReq.setContentType("3");
+    
+    patchEntity.addLink(of.newEntityNavigationLink("NavPropertyETTwoPrimOne", client.newURIBuilder(SERVICE_URI)
+        .appendEntitySetSegment("ESTwoPrim")
+        .appendKeySegment(32766)
+        .build()));
+    
+    changeReq = client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patchEntity);
+    changeReq.setFormat(ODataFormat.JSON);
     changeset.addRequest(changeReq);
 
     // -----------------------------
     // - Append get request
     // -----------------------------
-    appendGetRequest(payload, "ESAllPrim", 32767, false); // Without error
+    appendGetRequest(payload, "ESAllPrim", 0, false); // Without error
 
     // -----------------------------
     // - Fetch result
@@ -560,42 +538,54 @@ public class BatchClientITCase extends AbstractTestITCase {
     assertTrue(bodyIterator.hasNext());
     ODataBatchResponseItem item = bodyIterator.next();
     assertFalse(item.isChangeset());
-
+    assertTrue(item.hasNext());
+    final ODataResponse response0 = item.next();
+    assertTrue(response0 instanceof ODataRetrieveResponse);
+    assertEquals(34, ((ODataRetrieveResponse<ODataEntity>)response0).getBody()
+                                                                    .getProperty("PropertyDecimal")
+                                                                    .getPrimitiveValue()
+                                                                    .toValue());
+    
     // Check change set
     assertTrue(bodyIterator.hasNext());
     item = bodyIterator.next();
     assertTrue(item.isChangeset());
-
-    for (int i = 0; i < 3; i++) {
-      assertTrue(item.hasNext());
-      assertTrue(item instanceof ODataChangesetResponseItem);
-      ODataChangesetResponseItem changeSetResponseItem = (ODataChangesetResponseItem) item.next();
-      assertNotNull(changeSetResponseItem);
-
-      ODataResponse chgRequest = changeSetResponseItem.next();
-      final String contentId = chgRequest.getHeader(ODataBatchConstants.CHANGESET_CONTENT_ID_NAME).iterator().next();
-
-      if (contentId == "1") {
-        // Insert
-        assertEquals(HttpStatusCode.CREATED.getStatusCode(), chgRequest.getStatusCode());
-      } else if (contentId == "2") {
-        // Update
-        assertEquals(HttpStatusCode.OK.getStatusCode(), chgRequest.getStatusCode());
-      } else if (contentId == "3") {
-        // Upsert
-        assertEquals(HttpStatusCode.CREATED.getStatusCode(), chgRequest.getStatusCode());
-      } else {
-        fail("Unkonwn content id " + contentId);
-      }
-    }
-    assertFalse(item.hasNext());
-
+    
+    // Insert
+    assertTrue(item.hasNext());
+    final ODataResponse response1 = item.next();
+    assertEquals(HttpStatusCode.CREATED.getStatusCode(), response1.getStatusCode());
+    assertTrue(response1 instanceof ODataEntityCreateResponse);
+    assertEquals(3.1415, ((ODataEntityCreateResponse<ODataEntity>) response1).getBody().getProperty("PropertyDouble")
+                                                                                       .getPrimitiveValue()
+                                                                                       .toValue());
+    // Update
+    assertTrue(item.hasNext());
+    final ODataResponse response2 = item.next();
+    assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response2.getStatusCode());
+    assertTrue(response2 instanceof ODataEntityUpdateResponse);
+
+    // Upsert
+    assertTrue(item.hasNext());
+    final ODataResponse response3 = item.next();
+    assertEquals(HttpStatusCode.CREATED.getStatusCode(),response3.getStatusCode());
+    assertTrue(response3 instanceof ODataEntityUpdateResponse);
+    assertEquals(3.1415, ((ODataEntityUpdateResponse<ODataEntity>) response3).getBody().getProperty("PropertyDouble")
+                                                                                       .getPrimitiveValue()
+                                                                                       .toValue());
+    
     // Check second get request
     assertTrue(bodyIterator.hasNext());
     item = bodyIterator.next();
     assertFalse(item.isChangeset());
+    assertTrue(item.hasNext());
+    final ODataResponse response4 = item.next();
+    assertTrue(response4 instanceof ODataRetrieveResponse);
+    assertEquals(3.1415, ((ODataRetrieveResponse<ODataEntity>)response4).getBody()
+                                                                        .getProperty("PropertyDouble")
+                                                                        .getPrimitiveValue()
+                                                                        .toValue());
   }
-
   private void appendGetRequest(final BatchManager manager, final String segment, final Object key, boolean isRelative)
       throws URISyntaxException {
     final URIBuilder targetURI = client.newURIBuilder(SERVICE_URI);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9e232a2d/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
index 22f56f5..b043a02 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
@@ -33,9 +33,11 @@ import org.apache.olingo.client.api.EdmEnabledODataClient;
 import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.communication.ODataClientErrorException;
 import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
+import org.apache.olingo.client.api.communication.request.cud.UpdateType;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
 import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
+import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
 import org.apache.olingo.client.core.ODataClientFactory;
 import org.apache.olingo.commons.api.domain.ODataComplexValue;
@@ -54,6 +56,7 @@ import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.fit.AbstractBaseTestITCase;
 import org.apache.olingo.fit.tecsvc.TecSvcConst;
+import org.junit.Ignore;
 import org.junit.Test;
 
 public class DeepInsertITCase extends AbstractBaseTestITCase {
@@ -567,7 +570,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
     // Entity must not be created
     validateSet(targetURI, cookie, (short) 1, (short) 2, (short) 3);
   }
-
+  
   @Test
   public void testInvalidType() throws EdmPrimitiveTypeException {
     final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
@@ -607,7 +610,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
   }
   
   @Test
-  @org.junit.Ignore
+  @Ignore
   public void testDeepInsertOnNavigationPropertyInComplexProperty() {
     final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
     final ODataObjectFactory of = client.getObjectFactory();
@@ -662,6 +665,202 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
                                 .toValue());
   }
   
+  @Test
+  public void testDeepUpsert() {
+    final ODataClient client = getClient();
+    final URI updateURI = client.newURIBuilder(SERVICE_URI)
+                                .appendEntitySetSegment(ES_KEY_NAV)
+                                .appendKeySegment(815)
+                                .build();
+    final ODataObjectFactory of = client.getObjectFactory();
+    final ODataEntity entity = client.getObjectFactory().newEntity(ET_KEY_NAV);
+
+    // Prepare entity(EntitySet: ESKeyNav, Type: ETKeyNav)
+    entity.getProperties()
+        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)));
+    entity.getProperties()
+        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")));
+    entity.getProperties()
+        .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_NAV_FIVE_PROP)
+            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))));
+    entity.getProperties()
+        .add(of.newComplexProperty(PROPERTY_COMP_ALL_PRIM, of.newComplexValue(CT_ALL_PRIM)
+            .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")))));
+    entity.getProperties()
+        .add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
+            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))
+            .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")))));
+    entity.getProperties()
+        .add(of.newComplexProperty(PROPERTY_COMP_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
+            .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")))
+            .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_NAV_FIVE_PROP)
+                .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))))));
+
+    // Non collection navigation property
+    // Create related entity(EntitySet: ESTwoKeyNav, Type: ETTwoKeyNav, Nav. Property: NavPropertyETTwoKeyNavOne)
+    final ODataEntity inlineEntitySingle = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
+    inlineEntitySingle.getProperties()
+        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 43)));
+    inlineEntitySingle.getProperties()
+        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("43")));
+    inlineEntitySingle.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
+    inlineEntitySingle.getProperties()
+        .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
+            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 431)))));
+    inlineEntitySingle.getProperties()
+        .add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
+            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 432)))
+            .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("432")))));
+
+    // Collection navigation property
+    // The navigation property has a partner navigation property named "NavPropertyETKeyNavOne"
+    // Create related entity(EntitySet: ESTwoKeyNav, Type: NavPropertyETTwoKeyNavMany
+    final ODataEntity inlineEntityCol1 = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
+    inlineEntityCol1.getProperties()
+        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 44)));
+    inlineEntityCol1.getProperties()
+        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("44")));
+    inlineEntityCol1.getProperties()
+        .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
+            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 441)))));
+    inlineEntityCol1.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
+    inlineEntityCol1.getProperties()
+        .add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
+            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 442)))
+            .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("442")))));
+
+    final ODataEntity inlineEntityCol2 = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
+    inlineEntityCol2.getProperties()
+        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 45)));
+    inlineEntityCol2.getProperties()
+        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("45")));
+    inlineEntityCol2.getProperties()
+        .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
+            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 451)))));
+    inlineEntityCol2.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
+    inlineEntityCol2.getProperties()
+        .add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
+            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 452)))
+            .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("452")))));
+
+    final ODataInlineEntity newDeepInsertEntityLink =
+        of.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, inlineEntitySingle);
+    final ODataEntitySet newDeepInsertEntitySet = of.newEntitySet();
+    newDeepInsertEntitySet.getEntities().add(inlineEntityCol1);
+    newDeepInsertEntitySet.getEntities().add(inlineEntityCol2);
+    final ODataInlineEntitySet newDeepInsertEntitySetLink =
+        of.newDeepInsertEntitySet(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, newDeepInsertEntitySet);
+
+    entity.addLink(newDeepInsertEntityLink);
+    entity.addLink(newDeepInsertEntitySetLink);
+
+    // Perform update request (upsert)
+    final ODataEntityUpdateResponse<ODataEntity> responseCreate = client.getCUDRequestFactory()
+        .getEntityUpdateRequest(updateURI, UpdateType.PATCH, entity)
+        .execute();
+    assertEquals(HttpStatusCode.CREATED.getStatusCode(), responseCreate.getStatusCode());
+
+    final String cookie = responseCreate.getHeader(HttpHeader.SET_COOKIE).toString();
+
+    // Fetch ESKeyNav entity with expand of NavPropertyETTwoKeyNavOne nav. property
+    ODataProperty propertyInt16 = responseCreate.getBody().getProperty(PROPERTY_INT16);
+    final URI esKeyNavURI =
+        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(
+            propertyInt16.getPrimitiveValue().toValue()).expand(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE,
+            NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).build();
+
+    final ODataEntityRequest<ODataEntity> esKeyNavRequest = client.getRetrieveRequestFactory()
+        .getEntityRequest(esKeyNavURI);
+    esKeyNavRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
+    final ODataRetrieveResponse<ODataEntity> esKeyNavResponse = esKeyNavRequest.execute();
+
+    // Check nav. property NavPropertyETTwoKeyNavOne
+    assertNotNull(esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE));
+    assertEquals(431, esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE).getComplexValue().get(
+        PROPERTY_COMP_NAV).getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
+
+    // Check nav. property NavPropertyETTwoKeyNavMany
+    assertNotNull(esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
+    assertEquals(2, esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).getCollectionValue()
+        .size());
+    Iterator<ODataValue> twoKeyNavManyIterator =
+        esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).getCollectionValue().iterator();
+    final ODataValue firstTwoKeyNavEnity = twoKeyNavManyIterator.next(); // First entity
+    assertEquals(441, firstTwoKeyNavEnity.asComplex().get(PROPERTY_COMP_NAV).getValue().asComplex().get(
+        PROPERTY_INT16).getPrimitiveValue().toValue());
+    final ODataValue secondTwoKeyNavEnity = twoKeyNavManyIterator.next(); // Second entity
+    assertEquals(451, secondTwoKeyNavEnity.asComplex().get(PROPERTY_COMP_NAV).getValue().asComplex().get(
+        PROPERTY_INT16).getPrimitiveValue().toValue());
+
+    // Fetch ESTwoKeyNav entities and check if available and the partner relation have been set up
+    // Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavOne)
+    Map<String, Object> composedKey = new HashMap<String, Object>();
+    composedKey.put(PROPERTY_INT16, esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE)
+        .getComplexValue().get(PROPERTY_INT16)
+        .getPrimitiveValue().toValue());
+    composedKey.put(PROPERTY_STRING, esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE)
+        .getComplexValue().get(PROPERTY_STRING)
+        .getPrimitiveValue().toValue());
+
+    final URI esTwoKeyNavEntitySingleURI = client.newURIBuilder(SERVICE_URI)
+        .appendEntitySetSegment(ES_TWO_KEY_NAV)
+        .appendKeySegment(composedKey)
+        .build();
+
+    final ODataEntityRequest<ODataEntity> esTwoKeyNavSingleRequest = client.getRetrieveRequestFactory()
+        .getEntityRequest(esTwoKeyNavEntitySingleURI);
+    esTwoKeyNavSingleRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
+    final ODataRetrieveResponse<ODataEntity> esTwoKeyNavSingleResponse = esTwoKeyNavSingleRequest.execute();
+    assertEquals(431, esTwoKeyNavSingleResponse.getBody().getProperty(PROPERTY_COMP_NAV).getComplexValue().get(
+        PROPERTY_INT16).getPrimitiveValue().toValue());
+
+    // Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavMany(0))
+    composedKey.clear();
+    composedKey.put(PROPERTY_INT16, firstTwoKeyNavEnity.asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue());
+    composedKey.put(PROPERTY_STRING, firstTwoKeyNavEnity.asComplex().get(PROPERTY_STRING).getPrimitiveValue()
+        .toValue());
+
+    URI esTwoKeyNavEntityManyOneURI =
+        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey)
+            .expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build();
+
+    final ODataEntityRequest<ODataEntity> esTwoKeyNavManyOneRequest =
+        client.getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyOneURI);
+    esTwoKeyNavManyOneRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
+    final ODataRetrieveResponse<ODataEntity> esTwoKeyNavManyOneResponse = esTwoKeyNavManyOneRequest.execute();
+
+    assertEquals(441, esTwoKeyNavManyOneResponse.getBody().getProperty(PROPERTY_COMP_NAV).getComplexValue().get(
+        PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertNotNull(esTwoKeyNavManyOneResponse.getBody().getProperty(NAV_PROPERTY_ET_KEY_NAV_ONE).getComplexValue());
+    assertEquals(propertyInt16.getPrimitiveValue().toValue(), esTwoKeyNavManyOneResponse.getBody().getProperty(
+        NAV_PROPERTY_ET_KEY_NAV_ONE).getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
+
+    // Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavMany(1))
+    composedKey.clear();
+    composedKey.put(PROPERTY_INT16, secondTwoKeyNavEnity.asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue());
+    composedKey.put(PROPERTY_STRING, secondTwoKeyNavEnity.asComplex().get(PROPERTY_STRING).getPrimitiveValue()
+        .toValue());
+
+    URI esTwoKeyNavEntityManyTwoURI =
+        client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey)
+            .expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build();
+
+    final ODataEntityRequest<ODataEntity> esTwoKeyNavManyTwoRequest =
+        client.getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyTwoURI);
+    esTwoKeyNavManyTwoRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
+    final ODataRetrieveResponse<ODataEntity> esTwoKeyNavManyTwoResponse = esTwoKeyNavManyTwoRequest.execute();
+
+    assertEquals(451, esTwoKeyNavManyTwoResponse.getBody().getProperty(PROPERTY_COMP_NAV).getComplexValue().get(
+        PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertNotNull(esTwoKeyNavManyTwoResponse.getBody().getProperty(NAV_PROPERTY_ET_KEY_NAV_ONE).getComplexValue());
+    assertEquals(propertyInt16.getPrimitiveValue().toValue(), esTwoKeyNavManyTwoResponse.getBody().getProperty(
+        NAV_PROPERTY_ET_KEY_NAV_ONE).getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
+  
+  }
+  
   private String getCookie() {
     final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
     final ODataRetrieveResponse<ODataEntitySet> response = client.getRetrieveRequestFactory()

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9e232a2d/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
index b48d051..3cef7e6 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
@@ -522,6 +522,11 @@ public class DataCreator {
     setLink(entitySet.getEntities().get(0), "NavPropertyETMediaOne", esMediaTargets.get(0));
     setLink(entitySet.getEntities().get(1), "NavPropertyETMediaOne", esMediaTargets.get(1));
     setLink(entitySet.getEntities().get(2), "NavPropertyETMediaOne", esMediaTargets.get(2));
+    
+    // NavPropertyETMediaMany
+    setLinks(entitySet.getEntities().get(0), "NavPropertyETMediaMany", esMediaTargets.get(0), esMediaTargets.get(2));
+    setLinks(entitySet.getEntities().get(1), "NavPropertyETMediaMany", esMediaTargets.get(2));
+    setLinks(entitySet.getEntities().get(2), "NavPropertyETMediaMany", esMediaTargets.get(0), esMediaTargets.get(1));
   }
 
   private void linkESTwoKeyNav(Map<String, EntityCollection> data) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9e232a2d/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/RequestValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/RequestValidator.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/RequestValidator.java
index c2e9da4..92bb5ce 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/RequestValidator.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/RequestValidator.java
@@ -44,19 +44,30 @@ import org.apache.olingo.server.tecsvc.data.DataProvider.DataProviderException;
 public class RequestValidator {
   private DataProvider provider;
   private boolean isInsert;
+  private boolean isPatch;
   private UriHelper uriHelper;
   private Edm edm;
   private String rawServiceRoot;
 
-  public RequestValidator(final DataProvider provider, final boolean isInsert, final UriHelper uriHelper,
+  public RequestValidator(final DataProvider provider, final UriHelper uriHelper,
       final Edm edm, final String rawServiceRoot) {
     this.provider = provider;
-    this.isInsert = isInsert;
+    this.isInsert = true;
     this.uriHelper = uriHelper;
     this.edm = edm;
     this.rawServiceRoot = rawServiceRoot;
   }
 
+  public RequestValidator(final DataProvider provider, final boolean isUpdate, final boolean isPatch, 
+      final UriHelper uriHelper, final Edm edm, final String rawServiceRoot) {
+    this.provider = provider;
+    this.isInsert = !isUpdate;
+    this.isPatch = isPatch;
+    this.uriHelper = uriHelper;
+    this.edm = edm;
+    this.rawServiceRoot = rawServiceRoot;
+  }
+  
   public void validate(final EdmBindingTarget edmBindingTarget, final Entity entity) 
       throws DataProviderException {
     final List<String> path = new ArrayList<String>();
@@ -84,9 +95,10 @@ public class RequestValidator {
                                                                   edmProperty, 
                                                                   target);
   
-        if ((   isInsert  && !edmProperty.isNullable() && (bindingResult != ValidatioResult.FOUND 
-                                                        && linkResult != ValidatioResult.FOUND))
-            || (!isInsert && !edmProperty.isNullable() && linkResult == ValidatioResult.EMPTY)) {
+        if ((     isInsert && !edmProperty.isNullable() 
+                           && (bindingResult != ValidatioResult.FOUND 
+                           && linkResult != ValidatioResult.FOUND))
+            || (!(isInsert && isPatch) && !edmProperty.isNullable() && linkResult == ValidatioResult.EMPTY)) {
           throw new DataProviderException("Navigation property " + navPropertyName + " must not be null",
               HttpStatusCode.BAD_REQUEST);
         }
@@ -192,8 +204,9 @@ public class RequestValidator {
         
         // Check if all "not nullable" properties are set
         if(!edmProperty.isNullable()) {
-          if((property != null && property.isNull())    // Update,insert; Property is explicit set to null
-            || (isInsert && property == null) ) {       // Insert; Property not provided
+          if((property != null && property.isNull())            // Update,insert; Property is explicit set to null
+            || (isInsert && property == null)                   // Insert; Property not provided
+            || (!isInsert && !isPatch && property == null)) {   // Insert(Put); Property not provided     
             throw new DataProviderException("Property " + propertyName + " must not be null", 
                 HttpStatusCode.BAD_REQUEST);
           }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9e232a2d/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
index 623d22d..6d7d928 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
@@ -241,7 +241,6 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
       final DeserializerResult deserializerResult = odata.createDeserializer(ODataFormat.fromContentType(requestFormat))
                                                          .entity(request.getBody(), edmEntityType);
       new RequestValidator(dataProvider, 
-                           true,        // Insert
                            odata.createUriHelper(), 
                            serviceMetadata.getEdm(), 
                            request.getRawBaseUri()
@@ -289,7 +288,8 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
     final Entity changedEntity = deserializer.entity(request.getBody(), edmEntitySet.getEntityType()).getEntity();
     
     new RequestValidator(dataProvider, 
-                         false,        // Update
+                         true,        // Update
+                         request.getMethod() == HttpMethod.PATCH,
                          odata.createUriHelper(), 
                          serviceMetadata.getEdm(), 
                          request.getRawBaseUri()


[17/22] olingo-odata4 git commit: [OLINGO-573] Start replacement of Jetty with Tomcat

Posted by ra...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b6da769a/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinServiceTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinServiceTest.java b/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinServiceTest.java
index 4b26b8e..6af2b29 100644
--- a/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinServiceTest.java
+++ b/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinServiceTest.java
@@ -19,28 +19,19 @@
 package org.apache.olingo.server.example;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
+import java.io.File;
 import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.Iterator;
 
-import org.apache.olingo.commons.core.Encoder;
-import org.eclipse.jetty.client.HttpClient;
-import org.eclipse.jetty.client.api.ContentProvider;
-import org.eclipse.jetty.client.api.ContentResponse;
-import org.eclipse.jetty.http.HttpMethod;
-import org.eclipse.jetty.server.Connector;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.ServerConnector;
-import org.eclipse.jetty.servlet.ServletContextHandler;
-import org.eclipse.jetty.servlet.ServletHolder;
+import org.apache.catalina.Context;
+import org.apache.catalina.startup.Tomcat;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.DefaultHttpClient;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
@@ -55,37 +46,38 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
  * of service developer.
  */
 public class TripPinServiceTest {
-  private static Server server = new Server();
+  private static Tomcat tomcat = new Tomcat();
   private static String baseURL;
-  private static HttpClient http = new HttpClient();
+  private static DefaultHttpClient http = new DefaultHttpClient();
+  private static final int TOMCAT_PORT = 9900;
 
   @BeforeClass
   public static void beforeTest() throws Exception {
-    ServerConnector connector = new ServerConnector(server);
-    server.setConnectors(new Connector[] { connector });
-
-    ServletContextHandler context = new ServletContextHandler();
-    context.setContextPath("/trippin");
-    context.addServlet(new ServletHolder(new TripPinServlet()), "/*");
-    server.setHandler(context);
-    server.start();
-    int port = connector.getLocalPort();
-    http.start();
-    baseURL = "http://localhost:"+port+"/trippin";
+    tomcat.setPort(TOMCAT_PORT);
+    File baseDir = new File(System.getProperty("java.io.tmpdir"));
+    Context cxt = tomcat.addContext("/", baseDir.getAbsolutePath());
+    Tomcat.addServlet(cxt, "trippin", new TripPinServlet());
+    cxt.addServletMapping("/*", "trippin");
+    baseURL = "http://" + tomcat.getHost().getName() + ":"+ TOMCAT_PORT;
+    tomcat.start();
   }
 
   @AfterClass
   public static void afterTest() throws Exception {
-    server.stop();
+    tomcat.stop();
+  }
+
+  private HttpHost getLocalhost() {
+    return new HttpHost(tomcat.getHost().getName(), 9900);
   }
 
   @Test
   public void testEntitySet() throws Exception {
-    ContentResponse response = http.newRequest(baseURL + "/People")
-    .header("Content-Type", "application/json;odata.metadata=minimal")
-    .method(HttpMethod.GET)
-    .send();
-    assertEquals(200, response.getStatus());
+    HttpRequest req = new HttpGet("/People");
+    req.setHeader("Content-Type", "application/json;odata.metadata=minimal");
+
+    HttpResponse response = http.execute(getLocalhost(), req);
+    assertEquals(200, response.getStatusLine().getStatusCode());
 
     JsonNode node = getJSONNode(response);
 
@@ -96,661 +88,710 @@ public class TripPinServiceTest {
     assertEquals("russellwhyte", person.get("UserName").asText());
   }
 
-  private JsonNode getJSONNode(ContentResponse response) throws IOException,
+
+  private JsonNode getJSONNode(HttpResponse response) throws IOException,
       JsonProcessingException {
     ObjectMapper objectMapper = new ObjectMapper();
-    JsonNode node = objectMapper.readTree(response.getContent());
+    JsonNode node = objectMapper.readTree(response.getEntity().getContent());
     return node;
   }
 
-  @Test
-  public void testReadEntitySetWithPaging() throws Exception {
-    ContentResponse response = http.newRequest(baseURL + "/People")
-        .header("Prefer", "odata.maxpagesize=10").send();
-
-    assertEquals(200, response.getStatus());
-
-    JsonNode node = getJSONNode(response);
-    assertEquals("$metadata#People", node.get("@odata.context").asText());
-    assertEquals(baseURL+"/People?$skiptoken=10", node.get("@odata.nextLink").asText());
-
-    JsonNode person = ((ArrayNode)node.get("value")).get(0);
-    assertEquals("russellwhyte", person.get("UserName").asText());
-
-    assertNotNull(response.getHeaders().get("Preference-Applied"));
-  }
-
-  @Test
-  public void testReadEntityWithKey() throws Exception {
-    ContentResponse response = http.GET(baseURL + "/Airlines('AA')");
-    assertEquals(200, response.getStatus());
-    JsonNode node = getJSONNode(response);
-    assertEquals("$metadata#Airlines/$entity", node.get("@odata.context").asText());
-    assertEquals("American Airlines", node.get("Name").asText());
-  }
-
-  @Test
-  public void testReadEntityWithNonExistingKey() throws Exception {
-    ContentResponse response = http.GET(baseURL + "/Airlines('OO')");
-    assertEquals(404, response.getStatus());
-  }
-
-  @Test
-  public void testRead$Count() throws Exception {
-    ContentResponse response = http.GET(baseURL + "/Airlines/$count");
-    assertEquals(200, response.getStatus());
-    assertEquals("15", response.getContentAsString());
-  }
-
-  @Test
-  public void testReadPrimitiveProperty() throws Exception {
-    ContentResponse response = http.GET(baseURL + "/Airlines('AA')/Name");
-    assertEquals(200, response.getStatus());
-    JsonNode node = getJSONNode(response);
-    assertEquals("$metadata#Airlines('AA')/Name", node.get("@odata.context").asText());
-    assertEquals("American Airlines", node.get("value").asText());
-  }
-
-  @Test
-  public void testReadNonExistentProperty() throws Exception {
-    ContentResponse response = http.GET(baseURL + "/Airlines('AA')/Unknown");
-    assertEquals(404, response.getStatus());
-  }
-
-  @Test
-  public void testReadPrimitiveArrayProperty() throws Exception {
-    ContentResponse response = http.GET(baseURL + "/People('russellwhyte')/Emails");
-    assertEquals(200, response.getStatus());
-    JsonNode node = getJSONNode(response);
-    assertEquals("$metadata#People('russellwhyte')/Emails", node.get("@odata.context").asText());
-    assertTrue(node.get("value").isArray());
-    assertEquals("Russell@example.com", ((ArrayNode)node.get("value")).get(0).asText());
-    assertEquals("Russell@contoso.com", ((ArrayNode)node.get("value")).get(1).asText());
-  }
-
-  @Test
-  public void testReadPrimitivePropertyValue() throws Exception {
-    ContentResponse response = http.GET(baseURL + "/Airlines('AA')/Name/$value");
-    assertEquals(200, response.getStatus());
-    assertEquals("American Airlines", response.getContentAsString());
-  }
-
-  @Test @Ignore
-  // TODO: Support geometry types to make this run
-  public void testReadComplexProperty() throws Exception {
-    ContentResponse response = http.GET(baseURL + "/Airports('KSFO')/Location");
-    fail("support geometry type");
-  }
-
-  @Test
-  public void testReadComplexArrayProperty() throws Exception {
-    ContentResponse response = http.GET(baseURL + "/People('russellwhyte')/AddressInfo");
-    assertEquals(200, response.getStatus());
-    JsonNode node = getJSONNode(response);
-    assertEquals("$metadata#People('russellwhyte')/AddressInfo", node.get("@odata.context").asText());
-    assertTrue(node.get("value").isArray());
-    assertEquals("187 Suffolk Ln.", ((ArrayNode)node.get("value")).get(0).get("Address").asText());
-  }
-
-  @Test
-  public void testReadMedia() throws Exception {
-    ContentResponse response = http.GET(baseURL + "/Photos(1)/$value");
-    assertEquals(200, response.getStatus());
-  }
-
-  @Test
-  public void testCreateMedia() throws Exception {
-    // treating update and create as same for now, as there is details about
-    // how entity payload and media payload can be sent at same time in request's body
-    String editUrl = baseURL + "/Photos(1)/$value";
-    ContentResponse response = http.newRequest(editUrl)
-        .content(content("bytecontents"), "image/jpeg")
-        .method(HttpMethod.PUT)
-        .send();
-    assertEquals(204, response.getStatus());
-  }
-
-  @Test
-  public void testDeleteMedia() throws Exception {
-    // treating update and create as same for now, as there is details about
-    // how entity payload and media payload can be sent at same time in request's body
-    String editUrl = baseURL + "/Photos(1)/$value";
-    ContentResponse response = http.newRequest(editUrl)
-        .content(content("bytecontents"), "image/jpeg")
-        .method(HttpMethod.DELETE)
-        .send();
-    assertEquals(204, response.getStatus());
-  }
-
-  @Test
-  public void testCreateStream() throws Exception {
-    // treating update and create as same for now, as there is details about
-    // how entity payload and media payload can be sent at same time in request's body
-    String editUrl = baseURL + "/Airlines('AA')/Picture";
-    ContentResponse response = http.newRequest(editUrl)
-        .content(content("bytecontents"), "image/jpeg")
-        .method(HttpMethod.POST)
-        .send();
-    // method not allowed
-    assertEquals(405, response.getStatus());
-  }
-
-  @Test
-  public void testCreateStream2() throws Exception {
-    // treating update and create as same for now, as there is details about
-    // how entity payload and media payload can be sent at same time in request's body
-    String editUrl = baseURL + "/Airlines('AA')/Picture";
-    ContentResponse response = http.newRequest(editUrl)
-        .content(content("bytecontents"), "image/jpeg")
-        .method(HttpMethod.PUT)
-        .send();
-    assertEquals(204, response.getStatus());
-  }
-
-  @Test
-  public void testDeleteStream() throws Exception {
-    // treating update and create as same for now, as there is details about
-    // how entity payload and media payload can be sent at same time in request's body
-    String editUrl = baseURL + "/Airlines('AA')/Picture";
-    ContentResponse response = http.newRequest(editUrl)
-        .method(HttpMethod.DELETE)
-        .send();
-    assertEquals(204, response.getStatus());
-  }
-
-  @Test
-  public void testReadStream() throws Exception {
-    // treating update and create as same for now, as there is details about
-    // how entity payload and media payload can be sent at same time in request's body
-    String editUrl = baseURL + "/Airlines('AA')/Picture";
-    ContentResponse response = http.newRequest(editUrl)
-        .method(HttpMethod.GET)
-        .send();
-    assertEquals(200, response.getStatus());
-  }
-
-  @Test
-  public void testLambdaAny() throws Exception {
-    // this is just testing to see the labba expresions are going through the
-    // framework, none of the system options are not implemented in example service
-    String query = "Friends/any(d:d/UserName eq 'foo')";
-    ContentResponse response = http.newRequest(baseURL + "/People?$filter="+Encoder.encode(query))
-        .method(HttpMethod.GET)
-        .send();
-    assertEquals(200, response.getStatus());
-  }
-
-  @Test
-  public void testSingleton() throws Exception {
-    ContentResponse response = http.GET(baseURL + "/Me");
-    assertEquals(200, response.getStatus());
-    JsonNode node = getJSONNode(response);
-    assertEquals("$metadata#Me", node.get("@odata.context").asText());
-    assertEquals("russellwhyte", node.get("UserName").asText());
-  }
-
-  @Test
-  public void testSelectOption() throws Exception {
-    ContentResponse response = http.GET(baseURL + "/People('russellwhyte')?$select=FirstName,LastName");
-    assertEquals(200, response.getStatus());
-    JsonNode node = getJSONNode(response);
-    assertEquals("$metadata#People(FirstName,LastName)/$entity", node.get("@odata.context").asText());
-    assertEquals("Russell", node.get("FirstName").asText());
-  }
-
-  @Test
-  public void testActionImportWithNoResponse() throws Exception {
-    ContentResponse response = http.POST(baseURL + "/ResetDataSource").send();
-    assertEquals(204, response.getStatus());
-  }
-
-  @Test
-  public void testFunctionImport() throws Exception {
-    //TODO: fails because of lack of geometery support
-    ContentResponse response = http.GET(baseURL + "/GetNearestAirport(lat=23.0,lon=34.0)");
-  }
-
-  @Test
-  public void testBadReferences() throws Exception {
-    ContentResponse response = http.GET(baseURL + "/People('russelwhyte')/$ref");
-    assertEquals(405, response.getStatus());
-  }
-
-  @Test
-  public void testReadReferences() throws Exception {
-    ContentResponse response = http.GET(baseURL + "/People('russellwhyte')/Friends/$ref");
-    assertEquals(200, response.getStatus());
-    JsonNode node = getJSONNode(response);
-    assertEquals("$metadata#Collection($ref)", node.get("@odata.context").asText());
-    assertTrue(node.get("value").isArray());
-    assertEquals("/People('scottketchum')", ((ArrayNode)node.get("value")).get(0).get("@odata.id").asText());
-  }
-
-  @Test
-  public void testAddCollectionReferences() throws Exception {
-    //GET
-    ContentResponse response = http.GET(baseURL + "/People('kristakemp')/Friends/$ref");
-    assertEquals(200, response.getStatus());
-    JsonNode node = getJSONNode(response);
-
-    assertTrue(node.get("value").isArray());
-    assertEquals("/People('genevievereeves')", ((ArrayNode)node.get("value")).get(0).get("@odata.id").asText());
-    assertNull(((ArrayNode)node.get("value")).get(1));
-
-    //ADD
-    String payload = "{\n" +
-        "  \"@odata.context\": \""+baseURL+"/$metadata#Collection($ref)\",\n" +
-        "  \"value\": [\n" +
-        "    { \"@odata.id\": \"People('russellwhyte')\" },\n" +
-        "    { \"@odata.id\": \"People('scottketchum')\" } \n" +
-        "  ]\n" +
-        "}";
-    response = http.POST(baseURL + "/People('kristakemp')/Friends/$ref")
-        .content(content(payload), "application/json")
-        .send();
-    assertEquals(204, response.getStatus());
-
-    //GET
-    response = http.GET(baseURL + "/People('kristakemp')/Friends/$ref");
-    assertEquals(200, response.getStatus());
-    node = getJSONNode(response);
-
-    assertTrue(node.get("value").isArray());
-    assertEquals("/People('genevievereeves')", ((ArrayNode)node.get("value")).get(0).get("@odata.id").asText());
-    assertEquals("/People('russellwhyte')", ((ArrayNode)node.get("value")).get(1).get("@odata.id").asText());
-    assertEquals("/People('scottketchum')", ((ArrayNode)node.get("value")).get(2).get("@odata.id").asText());
-  }
-
-
-  @Test
-  public void testEntityId() throws Exception {
-    ContentResponse response = http.GET(baseURL+"/$entity?$id="+baseURL + "/People('kristakemp')");
-    assertEquals(200, response.getStatus());
-    JsonNode node = getJSONNode(response);
-    assertEquals("$metadata#People/$entity", node.get("@odata.context").asText());
-    assertEquals("kristakemp", node.get("UserName").asText());
-
-    // using relative URL
-    response = http.GET(baseURL+"/$entity?$id="+"People('kristakemp')");
-    assertEquals(200, response.getStatus());
-    node = getJSONNode(response);
-    assertEquals("$metadata#People/$entity", node.get("@odata.context").asText());
-    assertEquals("kristakemp", node.get("UserName").asText());
-  }
-
-  @Test
-  public void testCreateReadDeleteEntity() throws Exception {
-    String payload = "{\n" +
-        "         \"UserName\":\"olingodude\",\n" +
-        "         \"FirstName\":\"Olingo\",\n" +
-        "         \"LastName\":\"Apache\",\n" +
-        "         \"Emails\":[\n" +
-        "            \"olingo@apache.org\"\n" +
-        "         ],\n" +
-        "         \"AddressInfo\":[\n" +
-        "            {\n" +
-        "               \"Address\":\"100 apache Ln.\",\n" +
-        "               \"City\":{\n" +
-        "                  \"CountryRegion\":\"United States\",\n" +
-        "                  \"Name\":\"Boise\",\n" +
-        "                  \"Region\":\"ID\"\n" +
-        "               }\n" +
-        "            }\n" +
-        "         ],\n" +
-        "         \"Gender\":\"0\",\n" +
-        "         \"Concurrency\":635585295719432047\n" +
-        "}";
-    ContentResponse response = http.POST(baseURL + "/People")
-        .content(content(payload), "application/json")
-        .header("Prefer", "return=minimal")
-        .send();
-    // the below woud be 204, if minimal was not supplied
-    assertEquals(204, response.getStatus());
-    assertEquals("/People('olingodude')", response.getHeaders().get("Location"));
-    assertEquals("return=minimal", response.getHeaders().get("Preference-Applied"));
-
-    String location = baseURL+response.getHeaders().get("Location");
-    response = http.GET(location);
-    assertEquals(200, response.getStatus());
-
-    response = http.newRequest(location).method(HttpMethod.DELETE).send();
-    assertEquals(204, response.getStatus());
-
-    response = http.GET(location);
-    assertEquals(404, response.getStatus());
-  }
-
-
-  @Test
-  public void testCreateEntityWithLinkToRelatedEntities() throws Exception {
-    String payload = "{\n" +
-        "         \"UserName\":\"olingo\",\n" +
-        "         \"FirstName\":\"Olingo\",\n" +
-        "         \"LastName\":\"Apache\",\n" +
-        "         \"Emails\":[\n" +
-        "            \"olingo@apache.org\"\n" +
-        "         ],\n" +
-        "         \"AddressInfo\":[\n" +
-        "            {\n" +
-        "               \"Address\":\"100 apache Ln.\",\n" +
-        "               \"City\":{\n" +
-        "                  \"CountryRegion\":\"United States\",\n" +
-        "                  \"Name\":\"Boise\",\n" +
-        "                  \"Region\":\"ID\"\n" +
-        "               }\n" +
-        "            }\n" +
-        "         ],\n" +
-        "         \"Gender\":\"0\",\n" +
-        "         \"Concurrency\":635585295719432047,\n" +
-        "\"Friends@odata.bind\":[\"" +
-         baseURL+"/People('russellwhyte')\",\""+
-         baseURL+"/People('scottketchum')\""+
-        "]"+
-        "}";
-    ContentResponse response = http.POST(baseURL + "/People")
-        .content(content(payload), "application/json")
-        .header("Prefer", "return=minimal")
-        .send();
-    // the below woud be 204, if minimal was not supplied
-    assertEquals(204, response.getStatus());
-
-    response = http.GET(baseURL+"/People('olingo')/Friends");
-    assertEquals(200, response.getStatus());
-
-    JsonNode node = getJSONNode(response);
-    assertEquals("$metadata#People", node.get("@odata.context").asText());
-    assertTrue(node.get("value").isArray());
-    assertEquals("scottketchum", ((ArrayNode)node.get("value")).get(1).get("UserName").asText());
-  }
-
-  @Test
-  public void testUpdatePrimitiveProperty() throws Exception {
-    String payload = "{"
-        + " \"value\":\"Pilar Ackerman\""
-        + "}";
-
-    String editUrl = baseURL + "/People('russellwhyte')/FirstName";
-    ContentResponse response = http.newRequest(editUrl)
-        .content(content(payload), "application/json")
-        .method(HttpMethod.PUT)
-        .send();
-    assertEquals(204, response.getStatus());
-
-    response = http.GET(editUrl);
-    assertEquals(200, response.getStatus());
-    JsonNode node = getJSONNode(response);
-    assertEquals("$metadata#People('russellwhyte')/FirstName", node.get("@odata.context").asText());
-    assertEquals("Pilar Ackerman", node.get("value").asText());
-  }
-
-  @Test
-  public void testUpdatePrimitiveArrayProperty() throws Exception {
-    String payload = "{"
-        + " \"value\": [\n" +
-        "       \"olingo@apache.com\"\n" +
-        "    ]"
-        + "}";
-
-    String editUrl = baseURL + "/People('russellwhyte')/Emails";
-    ContentResponse response = http.newRequest(editUrl)
-        .content(content(payload), "application/json")
-        .method(HttpMethod.PUT)
-        .send();
-    assertEquals(204, response.getStatus());
-
-    response = http.GET(editUrl);
-    assertEquals(200, response.getStatus());
-    JsonNode node = getJSONNode(response);
-    assertEquals("$metadata#People('russellwhyte')/Emails", node.get("@odata.context").asText());
-    assertTrue(node.get("value").isArray());
-    assertEquals("olingo@apache.com", ((ArrayNode)node.get("value")).get(0).asText());
-  }
-
-  @Test
-  public void testDeleteProperty() throws Exception {
-    String editUrl = baseURL + "/People('russellwhyte')/FirstName";
-    ContentResponse response = http.GET(editUrl);
-    assertEquals(200, response.getStatus());
-    JsonNode node = getJSONNode(response);
-    assertEquals("Russell", node.get("value").asText());
-
-    response = http.newRequest(editUrl)
-        .method(HttpMethod.DELETE)
-        .send();
-    assertEquals(204, response.getStatus());
-
-    response = http.GET(editUrl);
-    assertEquals(204, response.getStatus());
-  }
-
-  @Test
-  public void testReadNavigationPropertyEntityCollection() throws Exception {
-    String editUrl = baseURL + "/People('russellwhyte')/Friends";
-    ContentResponse response = http.GET(editUrl);
-    assertEquals(200, response.getStatus());
-
-    JsonNode node = getJSONNode(response);
-    assertEquals("$metadata#People", node.get("@odata.context").asText());
-
-    JsonNode person = ((ArrayNode)node.get("value")).get(0);
-    assertEquals("scottketchum", person.get("UserName").asText());
-  }
-
-  @Test
-  public void testReadNavigationPropertyEntityCollection2() throws Exception {
-    String editUrl = baseURL + "/People('russellwhyte')/Friends('scottketchum')/Trips";
-    ContentResponse response = http.GET(editUrl);
-    assertEquals(200, response.getStatus());
-
-    JsonNode node = getJSONNode(response);
-    assertEquals("$metadata#People('russellwhyte')/Friends('scottketchum')/Trips",
-        node.get("@odata.context").asText());
-    assertTrue(node.get("value").isArray());
-    assertEquals("1001", ((ArrayNode)node.get("value")).get(0).get("TripId").asText());
-  }
-
-  @Test
-  public void testReadNavigationPropertyEntity() throws Exception {
-    String editUrl = baseURL + "/People('russellwhyte')/Trips(1003)";
-    ContentResponse response = http.GET(editUrl);
-    assertEquals(200, response.getStatus());
-
-    JsonNode node = getJSONNode(response);
-    assertEquals("$metadata#People('russellwhyte')/Trips/$entity",
-        node.get("@odata.context").asText());
-    assertEquals("f94e9116-8bdd-4dac-ab61-08438d0d9a71", node.get("ShareId").asText());
-  }
-
-  @Test
-  public void testReadNavigationPropertyEntityNotExisting() throws Exception {
-    String editUrl = baseURL + "/People('russellwhyte')/Trips(9999)";
-    ContentResponse response = http.GET(editUrl);
-    assertEquals(204, response.getStatus());
-  }
-
-  @Test
-  public void testReadNavigationPropertyEntitySetNotExisting() throws Exception {
-    String editUrl = baseURL + "/People('jhondoe')/Trips";
-    ContentResponse response = http.GET(editUrl);
-    assertEquals(200, response.getStatus());
-    JsonNode node = getJSONNode(response);
-    assertEquals("$metadata#People('jhondoe')/Trips",
-        node.get("@odata.context").asText());
-    assertEquals(0, ((ArrayNode)node.get("value")).size());
-  }
-
-  @Test
-  public void testBadNavigationProperty() throws Exception {
-    String editUrl = baseURL + "/People('russellwhyte')/Unknown";
-    ContentResponse response = http.GET(editUrl);
-    assertEquals(404, response.getStatus());
-  }
-
-  @Test
-  public void testReadNavigationPropertyEntityProperty() throws Exception {
-    String editUrl = baseURL + "/People('russellwhyte')/Trips(1003)/PlanItems(5)/ConfirmationCode";
-    ContentResponse response = http.GET(editUrl);
-    assertEquals(200, response.getStatus());
-
-    JsonNode node = getJSONNode(response);
-    assertEquals("$metadata#People('russellwhyte')/Trips(1003)/PlanItems(5)/ConfirmationCode",
-        node.get("@odata.context").asText());
-
-    assertEquals("JH58494", node.get("value").asText());
-  }
-
-  @Test
-  public void testReadNavigationPropertyEntityMultipleDerivedTypes() throws Exception {
-    String editUrl = baseURL + "/People('russellwhyte')/Trips(1003)/PlanItems";
-    ContentResponse response = http.GET(editUrl);
-    assertEquals(200, response.getStatus());
-
-    JsonNode node = getJSONNode(response);
-    assertEquals("$metadata#People('russellwhyte')/Trips(1003)/PlanItems",
-        node.get("@odata.context").asText());
-
-    assertEquals("#Microsoft.OData.SampleService.Models.TripPin.Flight",
-        ((ArrayNode) node.get("value")).get(0).get("@odata.type").asText());
-  }
-
-  @Test
-  public void testReadNavigationPropertyEntityCoolectionDerivedFilter() throws Exception {
-    String editUrl = baseURL
-        + "/People('russellwhyte')/Trips(1003)/PlanItems/Microsoft.OData.SampleService.Models.TripPin.Event";
-    ContentResponse response = http.GET(editUrl);
-    assertEquals(200, response.getStatus());
-
-    JsonNode node = getJSONNode(response);
-    assertEquals("$metadata#People('russellwhyte')/Trips(1003)/PlanItems/"
-        + "Microsoft.OData.SampleService.Models.TripPin.Event",
-        node.get("@odata.context").asText());
-
-    assertEquals("#Microsoft.OData.SampleService.Models.TripPin.Event",
-        ((ArrayNode) node.get("value")).get(0).get("@odata.type").asText());
-  }
-
-  @Test
-  public void testReadNavigationPropertyEntityDerivedFilter() throws Exception {
-    String editUrl = baseURL+ "/People('russellwhyte')/Trips(1003)/PlanItems(56)/"
-        + "Microsoft.OData.SampleService.Models.TripPin.Event";
-    ContentResponse response = http.GET(editUrl);
-    assertEquals(200, response.getStatus());
-    JsonNode node = getJSONNode(response);
-    assertEquals("$metadata#People('russellwhyte')/Trips(1003)/PlanItems/"
-        + "Microsoft.OData.SampleService.Models.TripPin.Event/$entity",
-        node.get("@odata.context").asText());
-
-    assertEquals("#Microsoft.OData.SampleService.Models.TripPin.Event", node.get("@odata.type").asText());
-    assertEquals("56", node.get("PlanItemId").asText());
-  }
-
-  @Test
-  public void testUpdateReference() throws Exception {
-    ContentResponse response = http.GET(baseURL+"/People('ronaldmundy')/Photo/$ref");
-    assertEquals(200, response.getStatus());
-    JsonNode node = getJSONNode(response);
-    assertEquals("/Photos(12)", node.get("@odata.id").asText());
-
-    String msg = "{\n" +
-        "\"@odata.id\": \"/Photos(11)\"\n" +
-        "}";
-    String editUrl = baseURL + "/People('ronaldmundy')/Photo/$ref";
-    response = http.newRequest(editUrl)
-        .method(HttpMethod.PUT)
-        .content(content(msg))
-        .header("Content-Type", "application/json;odata.metadata=minimal")
-        .send();
-    assertEquals(204, response.getStatus());
-
-    response = http.GET(baseURL+"/People('ronaldmundy')/Photo/$ref");
-    assertEquals(200, response.getStatus());
-    node = getJSONNode(response);
-    assertEquals("/Photos(11)", node.get("@odata.id").asText());
-  }
-
-  @Test
-  public void testAddDelete2ReferenceCollection() throws Exception {
-    // add
-    String msg = "{\n" +
-        "\"@odata.id\": \"/People('russellwhyte')\"\n" +
-        "}";
-    String editUrl = baseURL + "/People('vincentcalabrese')/Friends/$ref";
-    ContentResponse response = http.newRequest(editUrl)
-        .method(HttpMethod.POST)
-        .content(content(msg))
-        .header("Content-Type", "application/json;odata.metadata=minimal")
-        .send();
-    assertEquals(204, response.getStatus());
-
-    // get
-    response = http.GET(editUrl);
-    assertEquals(200, response.getStatus());
-    JsonNode node = getJSONNode(response);
-    assertEquals("/People('russellwhyte')",
-        ((ArrayNode) node.get("value")).get(2).get("@odata.id").asText());
-
-    //delete
-    response = http.newRequest(editUrl+"?$id="+baseURL+"/People('russellwhyte')")
-        .method(HttpMethod.DELETE)
-        .content(content(msg))
-        .header("Content-Type", "application/json;odata.metadata=minimal")
-        .send();
-    assertEquals(204, response.getStatus());
-
-    // get
-    response = http.GET(editUrl);
-    assertEquals(200, response.getStatus());
-    node = getJSONNode(response);
-    assertNull("/People('russellwhyte')", ((ArrayNode) node.get("value")).get(2));
-  }
-
-  @Test
-  public void testDeleteReference() throws Exception {
-    String editUrl = baseURL + "/People('russellwhyte')/Photo/$ref";
-    ContentResponse response = http.GET(editUrl);
-    assertEquals(200, response.getStatus());
-
-    response = http.newRequest(editUrl)
-        .method(HttpMethod.DELETE)
-        .send();
-    assertEquals(204, response.getStatus());
-
-    response = http.GET(editUrl);
-    assertEquals(204, response.getStatus());
-  }
-
-  @Test
-  public void testCrossJoin() throws Exception {
-    String editUrl = baseURL + "/$crossjoin(People,Airlines)";
-    ContentResponse response = http.GET(editUrl);
-    assertEquals(200, response.getStatus());
-  }
-
-  public static ContentProvider content(final String msg) {
-    return new ContentProvider() {
-      boolean hasNext = true;
-
-      @Override
-      public Iterator<ByteBuffer> iterator() {
-        return new Iterator<ByteBuffer>() {
-          @Override
-          public boolean hasNext() {
-            return hasNext;
-          }
-          @Override
-          public ByteBuffer next() {
-            hasNext = false;
-            return ByteBuffer.wrap(msg.getBytes());
-          }
-          @Override
-          public void remove() {
-          }
-        };
-      }
-      @Override
-      public long getLength() {
-        return msg.length();
-      }
-    };
-  }
+//  private static Server server = new Server();
+//  private static String baseURL;
+//  private static HttpClient http = new HttpClient();
+//
+//  @BeforeClass
+//  public static void beforeTest() throws Exception {
+//    ServerConnector connector = new ServerConnector(server);
+//    server.setConnectors(new Connector[] { connector });
+//
+//    ServletContextHandler context = new ServletContextHandler();
+//    context.setContextPath("/trippin");
+//    context.addServlet(new ServletHolder(new TripPinServlet()), "/*");
+//    server.setHandler(context);
+//    server.start();
+//    int port = connector.getLocalPort();
+//    http.start();
+//    baseURL = "http://localhost:"+port+"/trippin";
+//  }
+//
+//  @AfterClass
+//  public static void afterTest() throws Exception {
+//    server.stop();
+//  }
+//
+//  @Test
+//  public void testEntitySet() throws Exception {
+//    ContentResponse response = http.newRequest(baseURL + "/People")
+//    .header("Content-Type", "application/json;odata.metadata=minimal")
+//    .method(HttpMethod.GET)
+//    .send();
+//    assertEquals(200, response.getStatus());
+//
+//    JsonNode node = getJSONNode(response);
+//
+//    assertEquals("$metadata#People", node.get("@odata.context").asText());
+//    assertEquals(baseURL+"/People?$skiptoken=8", node.get("@odata.nextLink").asText());
+//
+//    JsonNode person = ((ArrayNode)node.get("value")).get(0);
+//    assertEquals("russellwhyte", person.get("UserName").asText());
+//  }
+//
+//  private JsonNode getJSONNode(ContentResponse response) throws IOException,
+//      JsonProcessingException {
+//    ObjectMapper objectMapper = new ObjectMapper();
+//    JsonNode node = objectMapper.readTree(response.getContent());
+//    return node;
+//  }
+//
+//  @Test
+//  public void testReadEntitySetWithPaging() throws Exception {
+//    ContentResponse response = http.newRequest(baseURL + "/People")
+//        .header("Prefer", "odata.maxpagesize=10").send();
+//
+//    assertEquals(200, response.getStatus());
+//
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("$metadata#People", node.get("@odata.context").asText());
+//    assertEquals(baseURL+"/People?$skiptoken=10", node.get("@odata.nextLink").asText());
+//
+//    JsonNode person = ((ArrayNode)node.get("value")).get(0);
+//    assertEquals("russellwhyte", person.get("UserName").asText());
+//
+//    assertNotNull(response.getHeaders().get("Preference-Applied"));
+//  }
+//
+//  @Test
+//  public void testReadEntityWithKey() throws Exception {
+//    ContentResponse response = http.GET(baseURL + "/Airlines('AA')");
+//    assertEquals(200, response.getStatus());
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("$metadata#Airlines/$entity", node.get("@odata.context").asText());
+//    assertEquals("American Airlines", node.get("Name").asText());
+//  }
+//
+//  @Test
+//  public void testReadEntityWithNonExistingKey() throws Exception {
+//    ContentResponse response = http.GET(baseURL + "/Airlines('OO')");
+//    assertEquals(404, response.getStatus());
+//  }
+//
+//  @Test
+//  public void testRead$Count() throws Exception {
+//    ContentResponse response = http.GET(baseURL + "/Airlines/$count");
+//    assertEquals(200, response.getStatus());
+//    assertEquals("15", response.getContentAsString());
+//  }
+//
+//  @Test
+//  public void testReadPrimitiveProperty() throws Exception {
+//    ContentResponse response = http.GET(baseURL + "/Airlines('AA')/Name");
+//    assertEquals(200, response.getStatus());
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("$metadata#Airlines('AA')/Name", node.get("@odata.context").asText());
+//    assertEquals("American Airlines", node.get("value").asText());
+//  }
+//
+//  @Test
+//  public void testReadNonExistentProperty() throws Exception {
+//    ContentResponse response = http.GET(baseURL + "/Airlines('AA')/Unknown");
+//    assertEquals(404, response.getStatus());
+//  }
+//
+//  @Test
+//  public void testReadPrimitiveArrayProperty() throws Exception {
+//    ContentResponse response = http.GET(baseURL + "/People('russellwhyte')/Emails");
+//    assertEquals(200, response.getStatus());
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("$metadata#People('russellwhyte')/Emails", node.get("@odata.context").asText());
+//    assertTrue(node.get("value").isArray());
+//    assertEquals("Russell@example.com", ((ArrayNode)node.get("value")).get(0).asText());
+//    assertEquals("Russell@contoso.com", ((ArrayNode)node.get("value")).get(1).asText());
+//  }
+//
+//  @Test
+//  public void testReadPrimitivePropertyValue() throws Exception {
+//    ContentResponse response = http.GET(baseURL + "/Airlines('AA')/Name/$value");
+//    assertEquals(200, response.getStatus());
+//    assertEquals("American Airlines", response.getContentAsString());
+//  }
+//
+//  @Test @Ignore
+//  // TODO: Support geometry types to make this run
+//  public void testReadComplexProperty() throws Exception {
+//    ContentResponse response = http.GET(baseURL + "/Airports('KSFO')/Location");
+//    fail("support geometry type");
+//  }
+//
+//  @Test
+//  public void testReadComplexArrayProperty() throws Exception {
+//    ContentResponse response = http.GET(baseURL + "/People('russellwhyte')/AddressInfo");
+//    assertEquals(200, response.getStatus());
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("$metadata#People('russellwhyte')/AddressInfo", node.get("@odata.context").asText());
+//    assertTrue(node.get("value").isArray());
+//    assertEquals("187 Suffolk Ln.", ((ArrayNode)node.get("value")).get(0).get("Address").asText());
+//  }
+//
+//  @Test
+//  public void testReadMedia() throws Exception {
+//    ContentResponse response = http.GET(baseURL + "/Photos(1)/$value");
+//    assertEquals(200, response.getStatus());
+//  }
+//
+//  @Test
+//  public void testCreateMedia() throws Exception {
+//    // treating update and create as same for now, as there is details about
+//    // how entity payload and media payload can be sent at same time in request's body
+//    String editUrl = baseURL + "/Photos(1)/$value";
+//    ContentResponse response = http.newRequest(editUrl)
+//        .content(content("bytecontents"), "image/jpeg")
+//        .method(HttpMethod.PUT)
+//        .send();
+//    assertEquals(204, response.getStatus());
+//  }
+//
+//  @Test
+//  public void testDeleteMedia() throws Exception {
+//    // treating update and create as same for now, as there is details about
+//    // how entity payload and media payload can be sent at same time in request's body
+//    String editUrl = baseURL + "/Photos(1)/$value";
+//    ContentResponse response = http.newRequest(editUrl)
+//        .content(content("bytecontents"), "image/jpeg")
+//        .method(HttpMethod.DELETE)
+//        .send();
+//    assertEquals(204, response.getStatus());
+//  }
+//
+//  @Test
+//  public void testCreateStream() throws Exception {
+//    // treating update and create as same for now, as there is details about
+//    // how entity payload and media payload can be sent at same time in request's body
+//    String editUrl = baseURL + "/Airlines('AA')/Picture";
+//    ContentResponse response = http.newRequest(editUrl)
+//        .content(content("bytecontents"), "image/jpeg")
+//        .method(HttpMethod.POST)
+//        .send();
+//    // method not allowed
+//    assertEquals(405, response.getStatus());
+//  }
+//
+//  @Test
+//  public void testCreateStream2() throws Exception {
+//    // treating update and create as same for now, as there is details about
+//    // how entity payload and media payload can be sent at same time in request's body
+//    String editUrl = baseURL + "/Airlines('AA')/Picture";
+//    ContentResponse response = http.newRequest(editUrl)
+//        .content(content("bytecontents"), "image/jpeg")
+//        .method(HttpMethod.PUT)
+//        .send();
+//    assertEquals(204, response.getStatus());
+//  }
+//
+//  @Test
+//  public void testDeleteStream() throws Exception {
+//    // treating update and create as same for now, as there is details about
+//    // how entity payload and media payload can be sent at same time in request's body
+//    String editUrl = baseURL + "/Airlines('AA')/Picture";
+//    ContentResponse response = http.newRequest(editUrl)
+//        .method(HttpMethod.DELETE)
+//        .send();
+//    assertEquals(204, response.getStatus());
+//  }
+//
+//  @Test
+//  public void testReadStream() throws Exception {
+//    // treating update and create as same for now, as there is details about
+//    // how entity payload and media payload can be sent at same time in request's body
+//    String editUrl = baseURL + "/Airlines('AA')/Picture";
+//    ContentResponse response = http.newRequest(editUrl)
+//        .method(HttpMethod.GET)
+//        .send();
+//    assertEquals(200, response.getStatus());
+//  }
+//
+//  @Test
+//  public void testLambdaAny() throws Exception {
+//    // this is just testing to see the labba expresions are going through the
+//    // framework, none of the system options are not implemented in example service
+//    String query = "Friends/any(d:d/UserName eq 'foo')";
+//    ContentResponse response = http.newRequest(baseURL + "/People?$filter="+Encoder.encode(query))
+//        .method(HttpMethod.GET)
+//        .send();
+//    assertEquals(200, response.getStatus());
+//  }
+//
+//  @Test
+//  public void testSingleton() throws Exception {
+//    ContentResponse response = http.GET(baseURL + "/Me");
+//    assertEquals(200, response.getStatus());
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("$metadata#Me", node.get("@odata.context").asText());
+//    assertEquals("russellwhyte", node.get("UserName").asText());
+//  }
+//
+//  @Test
+//  public void testSelectOption() throws Exception {
+//    ContentResponse response = http.GET(baseURL + "/People('russellwhyte')?$select=FirstName,LastName");
+//    assertEquals(200, response.getStatus());
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("$metadata#People(FirstName,LastName)/$entity", node.get("@odata.context").asText());
+//    assertEquals("Russell", node.get("FirstName").asText());
+//  }
+//
+//  @Test
+//  public void testActionImportWithNoResponse() throws Exception {
+//    ContentResponse response = http.POST(baseURL + "/ResetDataSource").send();
+//    assertEquals(204, response.getStatus());
+//  }
+//
+//  @Test
+//  public void testFunctionImport() throws Exception {
+//    //TODO: fails because of lack of geometery support
+//    ContentResponse response = http.GET(baseURL + "/GetNearestAirport(lat=23.0,lon=34.0)");
+//  }
+//
+//  @Test
+//  public void testBadReferences() throws Exception {
+//    ContentResponse response = http.GET(baseURL + "/People('russelwhyte')/$ref");
+//    assertEquals(405, response.getStatus());
+//  }
+//
+//  @Test
+//  public void testReadReferences() throws Exception {
+//    ContentResponse response = http.GET(baseURL + "/People('russellwhyte')/Friends/$ref");
+//    assertEquals(200, response.getStatus());
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("$metadata#Collection($ref)", node.get("@odata.context").asText());
+//    assertTrue(node.get("value").isArray());
+//    assertEquals("/People('scottketchum')", ((ArrayNode)node.get("value")).get(0).get("@odata.id").asText());
+//  }
+//
+//  @Test
+//  public void testAddCollectionReferences() throws Exception {
+//    //GET
+//    ContentResponse response = http.GET(baseURL + "/People('kristakemp')/Friends/$ref");
+//    assertEquals(200, response.getStatus());
+//    JsonNode node = getJSONNode(response);
+//
+//    assertTrue(node.get("value").isArray());
+//    assertEquals("/People('genevievereeves')", ((ArrayNode)node.get("value")).get(0).get("@odata.id").asText());
+//    assertNull(((ArrayNode)node.get("value")).get(1));
+//
+//    //ADD
+//    String payload = "{\n" +
+//        "  \"@odata.context\": \""+baseURL+"/$metadata#Collection($ref)\",\n" +
+//        "  \"value\": [\n" +
+//        "    { \"@odata.id\": \"People('russellwhyte')\" },\n" +
+//        "    { \"@odata.id\": \"People('scottketchum')\" } \n" +
+//        "  ]\n" +
+//        "}";
+//    response = http.POST(baseURL + "/People('kristakemp')/Friends/$ref")
+//        .content(content(payload), "application/json")
+//        .send();
+//    assertEquals(204, response.getStatus());
+//
+//    //GET
+//    response = http.GET(baseURL + "/People('kristakemp')/Friends/$ref");
+//    assertEquals(200, response.getStatus());
+//    node = getJSONNode(response);
+//
+//    assertTrue(node.get("value").isArray());
+//    assertEquals("/People('genevievereeves')", ((ArrayNode)node.get("value")).get(0).get("@odata.id").asText());
+//    assertEquals("/People('russellwhyte')", ((ArrayNode)node.get("value")).get(1).get("@odata.id").asText());
+//    assertEquals("/People('scottketchum')", ((ArrayNode)node.get("value")).get(2).get("@odata.id").asText());
+//  }
+//
+//
+//  @Test
+//  public void testEntityId() throws Exception {
+//    ContentResponse response = http.GET(baseURL+"/$entity?$id="+baseURL + "/People('kristakemp')");
+//    assertEquals(200, response.getStatus());
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("$metadata#People/$entity", node.get("@odata.context").asText());
+//    assertEquals("kristakemp", node.get("UserName").asText());
+//
+//    // using relative URL
+//    response = http.GET(baseURL+"/$entity?$id="+"People('kristakemp')");
+//    assertEquals(200, response.getStatus());
+//    node = getJSONNode(response);
+//    assertEquals("$metadata#People/$entity", node.get("@odata.context").asText());
+//    assertEquals("kristakemp", node.get("UserName").asText());
+//  }
+//
+//  @Test
+//  public void testCreateReadDeleteEntity() throws Exception {
+//    String payload = "{\n" +
+//        "         \"UserName\":\"olingodude\",\n" +
+//        "         \"FirstName\":\"Olingo\",\n" +
+//        "         \"LastName\":\"Apache\",\n" +
+//        "         \"Emails\":[\n" +
+//        "            \"olingo@apache.org\"\n" +
+//        "         ],\n" +
+//        "         \"AddressInfo\":[\n" +
+//        "            {\n" +
+//        "               \"Address\":\"100 apache Ln.\",\n" +
+//        "               \"City\":{\n" +
+//        "                  \"CountryRegion\":\"United States\",\n" +
+//        "                  \"Name\":\"Boise\",\n" +
+//        "                  \"Region\":\"ID\"\n" +
+//        "               }\n" +
+//        "            }\n" +
+//        "         ],\n" +
+//        "         \"Gender\":\"0\",\n" +
+//        "         \"Concurrency\":635585295719432047\n" +
+//        "}";
+//    ContentResponse response = http.POST(baseURL + "/People")
+//        .content(content(payload), "application/json")
+//        .header("Prefer", "return=minimal")
+//        .send();
+//    // the below woud be 204, if minimal was not supplied
+//    assertEquals(204, response.getStatus());
+//    assertEquals("/People('olingodude')", response.getHeaders().get("Location"));
+//    assertEquals("return=minimal", response.getHeaders().get("Preference-Applied"));
+//
+//    String location = baseURL+response.getHeaders().get("Location");
+//    response = http.GET(location);
+//    assertEquals(200, response.getStatus());
+//
+//    response = http.newRequest(location).method(HttpMethod.DELETE).send();
+//    assertEquals(204, response.getStatus());
+//
+//    response = http.GET(location);
+//    assertEquals(404, response.getStatus());
+//  }
+//
+//
+//  @Test
+//  public void testCreateEntityWithLinkToRelatedEntities() throws Exception {
+//    String payload = "{\n" +
+//        "         \"UserName\":\"olingo\",\n" +
+//        "         \"FirstName\":\"Olingo\",\n" +
+//        "         \"LastName\":\"Apache\",\n" +
+//        "         \"Emails\":[\n" +
+//        "            \"olingo@apache.org\"\n" +
+//        "         ],\n" +
+//        "         \"AddressInfo\":[\n" +
+//        "            {\n" +
+//        "               \"Address\":\"100 apache Ln.\",\n" +
+//        "               \"City\":{\n" +
+//        "                  \"CountryRegion\":\"United States\",\n" +
+//        "                  \"Name\":\"Boise\",\n" +
+//        "                  \"Region\":\"ID\"\n" +
+//        "               }\n" +
+//        "            }\n" +
+//        "         ],\n" +
+//        "         \"Gender\":\"0\",\n" +
+//        "         \"Concurrency\":635585295719432047,\n" +
+//        "\"Friends@odata.bind\":[\"" +
+//         baseURL+"/People('russellwhyte')\",\""+
+//         baseURL+"/People('scottketchum')\""+
+//        "]"+
+//        "}";
+//    ContentResponse response = http.POST(baseURL + "/People")
+//        .content(content(payload), "application/json")
+//        .header("Prefer", "return=minimal")
+//        .send();
+//    // the below woud be 204, if minimal was not supplied
+//    assertEquals(204, response.getStatus());
+//
+//    response = http.GET(baseURL+"/People('olingo')/Friends");
+//    assertEquals(200, response.getStatus());
+//
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("$metadata#People", node.get("@odata.context").asText());
+//    assertTrue(node.get("value").isArray());
+//    assertEquals("scottketchum", ((ArrayNode)node.get("value")).get(1).get("UserName").asText());
+//  }
+//
+//  @Test
+//  public void testUpdatePrimitiveProperty() throws Exception {
+//    String payload = "{"
+//        + " \"value\":\"Pilar Ackerman\""
+//        + "}";
+//
+//    String editUrl = baseURL + "/People('russellwhyte')/FirstName";
+//    ContentResponse response = http.newRequest(editUrl)
+//        .content(content(payload), "application/json")
+//        .method(HttpMethod.PUT)
+//        .send();
+//    assertEquals(204, response.getStatus());
+//
+//    response = http.GET(editUrl);
+//    assertEquals(200, response.getStatus());
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("$metadata#People('russellwhyte')/FirstName", node.get("@odata.context").asText());
+//    assertEquals("Pilar Ackerman", node.get("value").asText());
+//  }
+//
+//  @Test
+//  public void testUpdatePrimitiveArrayProperty() throws Exception {
+//    String payload = "{"
+//        + " \"value\": [\n" +
+//        "       \"olingo@apache.com\"\n" +
+//        "    ]"
+//        + "}";
+//
+//    String editUrl = baseURL + "/People('russellwhyte')/Emails";
+//    ContentResponse response = http.newRequest(editUrl)
+//        .content(content(payload), "application/json")
+//        .method(HttpMethod.PUT)
+//        .send();
+//    assertEquals(204, response.getStatus());
+//
+//    response = http.GET(editUrl);
+//    assertEquals(200, response.getStatus());
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("$metadata#People('russellwhyte')/Emails", node.get("@odata.context").asText());
+//    assertTrue(node.get("value").isArray());
+//    assertEquals("olingo@apache.com", ((ArrayNode)node.get("value")).get(0).asText());
+//  }
+//
+//  @Test
+//  public void testDeleteProperty() throws Exception {
+//    String editUrl = baseURL + "/People('russellwhyte')/FirstName";
+//    ContentResponse response = http.GET(editUrl);
+//    assertEquals(200, response.getStatus());
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("Russell", node.get("value").asText());
+//
+//    response = http.newRequest(editUrl)
+//        .method(HttpMethod.DELETE)
+//        .send();
+//    assertEquals(204, response.getStatus());
+//
+//    response = http.GET(editUrl);
+//    assertEquals(204, response.getStatus());
+//  }
+//
+//  @Test
+//  public void testReadNavigationPropertyEntityCollection() throws Exception {
+//    String editUrl = baseURL + "/People('russellwhyte')/Friends";
+//    ContentResponse response = http.GET(editUrl);
+//    assertEquals(200, response.getStatus());
+//
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("$metadata#People", node.get("@odata.context").asText());
+//
+//    JsonNode person = ((ArrayNode)node.get("value")).get(0);
+//    assertEquals("scottketchum", person.get("UserName").asText());
+//  }
+//
+//  @Test
+//  public void testReadNavigationPropertyEntityCollection2() throws Exception {
+//    String editUrl = baseURL + "/People('russellwhyte')/Friends('scottketchum')/Trips";
+//    ContentResponse response = http.GET(editUrl);
+//    assertEquals(200, response.getStatus());
+//
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("$metadata#People('russellwhyte')/Friends('scottketchum')/Trips",
+//        node.get("@odata.context").asText());
+//    assertTrue(node.get("value").isArray());
+//    assertEquals("1001", ((ArrayNode)node.get("value")).get(0).get("TripId").asText());
+//  }
+//
+//  @Test
+//  public void testReadNavigationPropertyEntity() throws Exception {
+//    String editUrl = baseURL + "/People('russellwhyte')/Trips(1003)";
+//    ContentResponse response = http.GET(editUrl);
+//    assertEquals(200, response.getStatus());
+//
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("$metadata#People('russellwhyte')/Trips/$entity",
+//        node.get("@odata.context").asText());
+//    assertEquals("f94e9116-8bdd-4dac-ab61-08438d0d9a71", node.get("ShareId").asText());
+//  }
+//
+//  @Test
+//  public void testReadNavigationPropertyEntityNotExisting() throws Exception {
+//    String editUrl = baseURL + "/People('russellwhyte')/Trips(9999)";
+//    ContentResponse response = http.GET(editUrl);
+//    assertEquals(204, response.getStatus());
+//  }
+//
+//  @Test
+//  public void testReadNavigationPropertyEntitySetNotExisting() throws Exception {
+//    String editUrl = baseURL + "/People('jhondoe')/Trips";
+//    ContentResponse response = http.GET(editUrl);
+//    assertEquals(200, response.getStatus());
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("$metadata#People('jhondoe')/Trips",
+//        node.get("@odata.context").asText());
+//    assertEquals(0, ((ArrayNode)node.get("value")).size());
+//  }
+//
+//  @Test
+//  public void testBadNavigationProperty() throws Exception {
+//    String editUrl = baseURL + "/People('russellwhyte')/Unknown";
+//    ContentResponse response = http.GET(editUrl);
+//    assertEquals(404, response.getStatus());
+//  }
+//
+//  @Test
+//  public void testReadNavigationPropertyEntityProperty() throws Exception {
+//    String editUrl = baseURL + "/People('russellwhyte')/Trips(1003)/PlanItems(5)/ConfirmationCode";
+//    ContentResponse response = http.GET(editUrl);
+//    assertEquals(200, response.getStatus());
+//
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("$metadata#People('russellwhyte')/Trips(1003)/PlanItems(5)/ConfirmationCode",
+//        node.get("@odata.context").asText());
+//
+//    assertEquals("JH58494", node.get("value").asText());
+//  }
+//
+//  @Test
+//  public void testReadNavigationPropertyEntityMultipleDerivedTypes() throws Exception {
+//    String editUrl = baseURL + "/People('russellwhyte')/Trips(1003)/PlanItems";
+//    ContentResponse response = http.GET(editUrl);
+//    assertEquals(200, response.getStatus());
+//
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("$metadata#People('russellwhyte')/Trips(1003)/PlanItems",
+//        node.get("@odata.context").asText());
+//
+//    assertEquals("#Microsoft.OData.SampleService.Models.TripPin.Flight",
+//        ((ArrayNode) node.get("value")).get(0).get("@odata.type").asText());
+//  }
+//
+//  @Test
+//  public void testReadNavigationPropertyEntityCoolectionDerivedFilter() throws Exception {
+//    String editUrl = baseURL
+//        + "/People('russellwhyte')/Trips(1003)/PlanItems/Microsoft.OData.SampleService.Models.TripPin.Event";
+//    ContentResponse response = http.GET(editUrl);
+//    assertEquals(200, response.getStatus());
+//
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("$metadata#People('russellwhyte')/Trips(1003)/PlanItems/"
+//        + "Microsoft.OData.SampleService.Models.TripPin.Event",
+//        node.get("@odata.context").asText());
+//
+//    assertEquals("#Microsoft.OData.SampleService.Models.TripPin.Event",
+//        ((ArrayNode) node.get("value")).get(0).get("@odata.type").asText());
+//  }
+//
+//  @Test
+//  public void testReadNavigationPropertyEntityDerivedFilter() throws Exception {
+//    String editUrl = baseURL+ "/People('russellwhyte')/Trips(1003)/PlanItems(56)/"
+//        + "Microsoft.OData.SampleService.Models.TripPin.Event";
+//    ContentResponse response = http.GET(editUrl);
+//    assertEquals(200, response.getStatus());
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("$metadata#People('russellwhyte')/Trips(1003)/PlanItems/"
+//        + "Microsoft.OData.SampleService.Models.TripPin.Event/$entity",
+//        node.get("@odata.context").asText());
+//
+//    assertEquals("#Microsoft.OData.SampleService.Models.TripPin.Event", node.get("@odata.type").asText());
+//    assertEquals("56", node.get("PlanItemId").asText());
+//  }
+//
+//  @Test
+//  public void testUpdateReference() throws Exception {
+//    ContentResponse response = http.GET(baseURL+"/People('ronaldmundy')/Photo/$ref");
+//    assertEquals(200, response.getStatus());
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("/Photos(12)", node.get("@odata.id").asText());
+//
+//    String msg = "{\n" +
+//        "\"@odata.id\": \"/Photos(11)\"\n" +
+//        "}";
+//    String editUrl = baseURL + "/People('ronaldmundy')/Photo/$ref";
+//    response = http.newRequest(editUrl)
+//        .method(HttpMethod.PUT)
+//        .content(content(msg))
+//        .header("Content-Type", "application/json;odata.metadata=minimal")
+//        .send();
+//    assertEquals(204, response.getStatus());
+//
+//    response = http.GET(baseURL+"/People('ronaldmundy')/Photo/$ref");
+//    assertEquals(200, response.getStatus());
+//    node = getJSONNode(response);
+//    assertEquals("/Photos(11)", node.get("@odata.id").asText());
+//  }
+//
+//  @Test
+//  public void testAddDelete2ReferenceCollection() throws Exception {
+//    // add
+//    String msg = "{\n" +
+//        "\"@odata.id\": \"/People('russellwhyte')\"\n" +
+//        "}";
+//    String editUrl = baseURL + "/People('vincentcalabrese')/Friends/$ref";
+//    ContentResponse response = http.newRequest(editUrl)
+//        .method(HttpMethod.POST)
+//        .content(content(msg))
+//        .header("Content-Type", "application/json;odata.metadata=minimal")
+//        .send();
+//    assertEquals(204, response.getStatus());
+//
+//    // get
+//    response = http.GET(editUrl);
+//    assertEquals(200, response.getStatus());
+//    JsonNode node = getJSONNode(response);
+//    assertEquals("/People('russellwhyte')",
+//        ((ArrayNode) node.get("value")).get(2).get("@odata.id").asText());
+//
+//    //delete
+//    response = http.newRequest(editUrl+"?$id="+baseURL+"/People('russellwhyte')")
+//        .method(HttpMethod.DELETE)
+//        .content(content(msg))
+//        .header("Content-Type", "application/json;odata.metadata=minimal")
+//        .send();
+//    assertEquals(204, response.getStatus());
+//
+//    // get
+//    response = http.GET(editUrl);
+//    assertEquals(200, response.getStatus());
+//    node = getJSONNode(response);
+//    assertNull("/People('russellwhyte')", ((ArrayNode) node.get("value")).get(2));
+//  }
+//
+//  @Test
+//  public void testDeleteReference() throws Exception {
+//    String editUrl = baseURL + "/People('russellwhyte')/Photo/$ref";
+//    ContentResponse response = http.GET(editUrl);
+//    assertEquals(200, response.getStatus());
+//
+//    response = http.newRequest(editUrl)
+//        .method(HttpMethod.DELETE)
+//        .send();
+//    assertEquals(204, response.getStatus());
+//
+//    response = http.GET(editUrl);
+//    assertEquals(204, response.getStatus());
+//  }
+//
+//  @Test
+//  public void testCrossJoin() throws Exception {
+//    String editUrl = baseURL + "/$crossjoin(People,Airlines)";
+//    ContentResponse response = http.GET(editUrl);
+//    assertEquals(200, response.getStatus());
+//  }
+//
+//  public static ContentProvider content(final String msg) {
+//    return new ContentProvider() {
+//      boolean hasNext = true;
+//
+//      @Override
+//      public Iterator<ByteBuffer> iterator() {
+//        return new Iterator<ByteBuffer>() {
+//          @Override
+//          public boolean hasNext() {
+//            return hasNext;
+//          }
+//          @Override
+//          public ByteBuffer next() {
+//            hasNext = false;
+//            return ByteBuffer.wrap(msg.getBytes());
+//          }
+//          @Override
+//          public void remove() {
+//          }
+//        };
+//      }
+//      @Override
+//      public long getLength() {
+//        return msg.length();
+//      }
+//    };
+//  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b6da769a/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index b2e16f3..00ebf8a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -95,7 +95,9 @@
     <tomcat.servlet.port>9080</tomcat.servlet.port>
     <tomcat.version>7.0.55</tomcat.version>
 
+    <!-- Project build settings -->
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.build.source>1.6</project.build.source>
   </properties>
 
   <dependencyManagement>
@@ -291,7 +293,6 @@
   </dependencyManagement>
 
   <build>
-
     <finalName>${project.name}-${project.version}</finalName>
 
     <pluginManagement>
@@ -463,8 +464,8 @@
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
         <configuration>
-          <source>1.6</source>
-          <target>1.6</target>
+          <source>${project.build.source}</source>
+          <target>${project.build.source}</target>
           <showWarnings>true</showWarnings>
           <showDeprecation>true</showDeprecation>
           <compilerArgument>-Xlint:unchecked</compilerArgument>


[21/22] olingo-odata4 git commit: OLINGO-573: merging to master

Posted by ra...@apache.org.
OLINGO-573: merging to master


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/3ac433b0
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/3ac433b0
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/3ac433b0

Branch: refs/heads/OLINGO-573
Commit: 3ac433b0771fcfc3edf3c205f4a037c302e547d5
Parents: 547725d
Author: Ramesh Reddy <ra...@jboss.org>
Authored: Sun Apr 5 17:54:44 2015 -0500
Committer: Ramesh Reddy <ra...@jboss.org>
Committed: Mon Apr 20 08:59:28 2015 -0500

----------------------------------------------------------------------
 lib/server-core-ext/pom.xml                     |   1 -
 .../server/core/ReturnRepresentation.java       |   2 +-
 .../olingo/server/core/ServiceRequest.java      |  17 ++-
 .../server/core/requests/ActionRequest.java     |  29 ++++-
 .../server/core/requests/DataRequest.java       | 110 +++++++++++++++----
 .../server/core/requests/FunctionRequest.java   |  29 +++--
 .../server/core/responses/EntityResponse.java   |  62 +++++++++--
 .../core/responses/EntitySetResponse.java       |  13 ++-
 .../server/core/responses/MetadataResponse.java |   9 ++
 .../core/responses/PrimitiveValueResponse.java  |  10 ++
 .../server/core/responses/PropertyResponse.java |  15 +++
 .../server/core/responses/ResponseUtil.java     |  86 +++++++++++++++
 .../core/responses/ServiceDocumentResponse.java |   9 ++
 .../server/core/responses/ServiceResponse.java  |   9 ++
 .../server/core/ServiceDispatcherTest.java      |   4 -
 .../olingo/server/example/TripPinDataModel.java |  93 ++++++++--------
 .../olingo/server/example/TripPinHandler.java   |  40 ++-----
 .../server/example/TripPinServiceTest.java      |  22 +++-
 .../src/test/resources/airlines.json            |   6 +-
 .../serializer/json/ODataJsonSerializer.java    |   6 +
 20 files changed, 437 insertions(+), 135 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3ac433b0/lib/server-core-ext/pom.xml
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/pom.xml b/lib/server-core-ext/pom.xml
index 5249ed4..6070052 100644
--- a/lib/server-core-ext/pom.xml
+++ b/lib/server-core-ext/pom.xml
@@ -81,7 +81,6 @@
     <dependency>
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
-      <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.tomcat.embed</groupId>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3ac433b0/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ReturnRepresentation.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ReturnRepresentation.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ReturnRepresentation.java
index e9a213e..6779d76 100644
--- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ReturnRepresentation.java
+++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ReturnRepresentation.java
@@ -19,5 +19,5 @@
 package org.apache.olingo.server.core;
 
 public enum ReturnRepresentation {
-  REPRESENTATION, MINIMAL
+  REPRESENTATION, MINIMAL, NONE
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3ac433b0/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ServiceRequest.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ServiceRequest.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ServiceRequest.java
index e9a8cfe..0fda018 100644
--- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ServiceRequest.java
+++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ServiceRequest.java
@@ -41,6 +41,7 @@ import org.apache.olingo.server.api.serializer.CustomContentTypeSupport;
 import org.apache.olingo.server.api.serializer.EntityCollectionSerializerOptions;
 import org.apache.olingo.server.api.serializer.EntitySerializerOptions;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.serializer.PrimitiveSerializerOptions;
 import org.apache.olingo.server.api.serializer.SerializerException;
 import org.apache.olingo.server.api.uri.UriInfo;
 import org.apache.olingo.server.core.requests.DataRequest;
@@ -155,19 +156,23 @@ public abstract class ServiceRequest {
     } else if (serilizerOptions.isAssignableFrom(ComplexSerializerOptions.class)) {
       return (T) ComplexSerializerOptions.with().contextURL(contextUrl)
           .expand(this.uriInfo.getExpandOption()).select(this.uriInfo.getSelectOption()).build();
+    } else if (serilizerOptions.isAssignableFrom(PrimitiveSerializerOptions.class)) {
+      return (T) PrimitiveSerializerOptions.with().contextURL(contextUrl)
+          .build();
     }
     return null;
   }
 
   public ReturnRepresentation getReturnRepresentation() {
     String prefer = this.request.getHeader(HttpHeader.PREFER);
-    if (prefer == null) {
-      return ReturnRepresentation.REPRESENTATION;
-    }
-    if (prefer.contains("return=minimal")) { //$NON-NLS-1$
-      return ReturnRepresentation.MINIMAL;
+    if (prefer != null) {
+      if (prefer.contains("return=minimal")) { //$NON-NLS-1$
+        return ReturnRepresentation.MINIMAL;
+      } else if (prefer.contains("return=representation")) {    
+        return ReturnRepresentation.REPRESENTATION;
+      }
     }
-    return ReturnRepresentation.REPRESENTATION;
+    return ReturnRepresentation.NONE;
   }
 
   public String getHeader(String key) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3ac433b0/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/ActionRequest.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/ActionRequest.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/ActionRequest.java
index 133ee3e..d4502cc 100644
--- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/ActionRequest.java
+++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/ActionRequest.java
@@ -19,6 +19,9 @@
 
 package org.apache.olingo.server.core.requests;
 
+import java.io.InputStream;
+
+import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.edm.EdmAction;
 import org.apache.olingo.commons.api.edm.EdmReturnType;
 import org.apache.olingo.server.api.OData;
@@ -26,7 +29,9 @@ import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.ODataTranslatedException;
 import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.serializer.PrimitiveSerializerOptions;
 import org.apache.olingo.server.api.uri.UriResourceAction;
+import org.apache.olingo.server.core.ContentNegotiatorException;
 import org.apache.olingo.server.core.ServiceHandler;
 import org.apache.olingo.server.core.responses.EntityResponse;
 import org.apache.olingo.server.core.responses.EntitySetResponse;
@@ -59,10 +64,7 @@ public class ActionRequest extends OperationRequest {
     if (!hasReturnType()) {
       handler.invoke(this, getETag(), new NoContentResponse(getServiceMetaData(), response));
     } else {
-      if (isReturnTypePrimitive()) {
-        handler.invoke(this, getETag(),
-            PrimitiveValueResponse.getInstance(this, response, isCollection(), getReturnType()));
-      } else if (isReturnTypeComplex()) {
+      if (isReturnTypePrimitive() || isReturnTypeComplex()) {
         handler.invoke(this, getETag(), PropertyResponse.getInstance(this, response,
             getReturnType().getType(), getContextURL(this.odata), isCollection()));
       } else {
@@ -83,6 +85,21 @@ public class ActionRequest extends OperationRequest {
     // 11.5.4.1 Invoking an Action - only allows POST
     return (isPOST());
   }
+  
+  @Override
+  public <T> T getSerializerOptions(Class<T> serilizerOptions, ContextURL contextUrl, boolean references)
+      throws ContentNegotiatorException {
+    if (hasReturnType() && serilizerOptions.isAssignableFrom(PrimitiveSerializerOptions.class)) {
+      return (T) PrimitiveSerializerOptions.with().contextURL(contextUrl)
+          .nullable(getReturnType().isNullable())
+          .maxLength(getReturnType().getMaxLength())
+          .precision(getReturnType().getPrecision())
+          .scale(getReturnType().getScale())
+          .unicode(null)
+          .build();
+    }
+    return super.getSerializerOptions(serilizerOptions, contextUrl, references);
+  }  
 
   public UriResourceAction getUriResourceAction() {
     return uriResourceAction;
@@ -117,4 +134,8 @@ public class ActionRequest extends OperationRequest {
   public boolean hasReturnType() {
     return getAction().getReturnType() != null;
   }
+  
+  public InputStream getPayload() {
+    return getODataRequest().getBody();
+  }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3ac433b0/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/DataRequest.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/DataRequest.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/DataRequest.java
index cebaf64..8855486 100644
--- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/DataRequest.java
+++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/DataRequest.java
@@ -18,27 +18,31 @@
  */
 package org.apache.olingo.server.core.requests;
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.LinkedList;
 import java.util.List;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.data.ContextURL.Suffix;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ValueType;
 import org.apache.olingo.commons.api.edm.EdmBindingTarget;
 import org.apache.olingo.commons.api.edm.EdmComplexType;
 import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
+import org.apache.olingo.commons.api.edm.EdmNavigationPropertyBinding;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.http.HttpHeader;
-import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmStream;
 import org.apache.olingo.server.api.OData;
@@ -66,6 +70,7 @@ import org.apache.olingo.server.api.uri.UriResourceProperty;
 import org.apache.olingo.server.api.uri.UriResourceSingleton;
 import org.apache.olingo.server.core.ContentNegotiator;
 import org.apache.olingo.server.core.ContentNegotiatorException;
+import org.apache.olingo.server.core.ReturnRepresentation;
 import org.apache.olingo.server.core.ServiceHandler;
 import org.apache.olingo.server.core.ServiceRequest;
 import org.apache.olingo.server.core.responses.CountResponse;
@@ -261,6 +266,11 @@ public class DataRequest extends ServiceRequest {
       if (!getNavigations().isEmpty() && !isGET()) {
         return false;
       }
+      
+      if ((isGET() || isDELETE()) && getReturnRepresentation() != ReturnRepresentation.NONE) {
+        return false;
+      }
+      
       return true;
     }
 
@@ -290,7 +300,8 @@ public class DataRequest extends ServiceRequest {
         // an If-None-Match or an If-Modified-Since header fields is undefined
         // by this specification.
         boolean ifMatch = getHeader(HttpHeader.IF_MATCH) != null;
-        boolean ifNoneMatch = getHeader(HttpHeader.IF_NONE_MATCH).equals("*");
+        boolean ifNoneMatch = (getHeader(HttpHeader.IF_NONE_MATCH)!= null 
+            && getHeader(HttpHeader.IF_NONE_MATCH).equals("*"));
         if(ifMatch) {
           handler.updateEntity(DataRequest.this, getEntityFromClient(), isPATCH(), getETag(),
               entityResponse);
@@ -332,6 +343,10 @@ public class DataRequest extends ServiceRequest {
 
     @Override
     public boolean allowedMethod() {
+      if (getReturnRepresentation() != ReturnRepresentation.NONE) {
+        return false;
+      }
+
       return isGET();
     }
 
@@ -359,6 +374,10 @@ public class DataRequest extends ServiceRequest {
 
     @Override
     public boolean allowedMethod() {
+      if ((isGET() || isDELETE()) && getReturnRepresentation() != ReturnRepresentation.NONE) {
+        return false;
+      }
+      
       // references are only allowed on the navigation properties
       if (getNavigations().isEmpty()) {
         return false;
@@ -448,6 +467,10 @@ public class DataRequest extends ServiceRequest {
 
     @Override
     public boolean allowedMethod() {
+      if ((isGET() || isDELETE() || isPropertyStream()) && getReturnRepresentation() != ReturnRepresentation.NONE) {
+        return false;
+      }
+      
       // create of properties is not allowed,
       // only read, update, delete. Note that delete is
       // same as update with null
@@ -502,13 +525,11 @@ public class DataRequest extends ServiceRequest {
         }
       } else if (isDELETE()) {
         if (isPropertyStream()) {
-          handler.upsertStreamProperty(DataRequest.this, getETag(), request.getBody(),
+          handler.upsertStreamProperty(DataRequest.this, getETag(), null,
               new NoContentResponse(getServiceMetaData(), response));
         } else {
-          Property property = new PropertyImpl();
-          property.setName(edmProperty.getName());
-          property.setType(edmProperty.getType().getFullQualifiedName()
-              .getFullQualifiedNameAsString());
+          Property property = new Property(edmProperty.getType().getFullQualifiedName()
+              .getFullQualifiedNameAsString(), edmProperty.getName());
           handler.updateProperty(DataRequest.this, property, false, getETag(),
               buildResponse(response, edmProperty));
         }
@@ -527,8 +548,8 @@ public class DataRequest extends ServiceRequest {
       final UriHelper helper = odata.createUriHelper();
       EdmProperty edmProperty = getUriResourceProperty().getProperty();
 
-      ContextURL.Builder builder = ContextURL.with().entitySet(getEntitySet());
-      builder = ContextURL.with().entitySet(getEntitySet());
+      ContextURL.Builder builder =
+          ContextURL.with().entitySetOrSingletonOrType(getTargetEntitySet(getEntitySet(), getNavigations()));
       builder.keyPath(helper.buildContextURLKeyPredicate(getUriResourceEntitySet()
           .getKeyPredicates()));
       String navPath = buildNavPath(helper, getEntitySet().getEntityType(), getNavigations(), true);
@@ -551,11 +572,17 @@ public class DataRequest extends ServiceRequest {
 
     @Override
     public boolean allowedMethod() {
-      //part2-url-conventions # 4.2
+      //part2-url-conventions # 4.7
+      // Properties of type Edm.Stream already return the raw value of 
+      // the media stream and do not support appending the $value segment.
       if (isPropertyStream() && isGET()) {
         return false;
       }
 
+      if ((isGET() || isDELETE() || isPropertyStream()) && getReturnRepresentation() != ReturnRepresentation.NONE) {
+        return false;
+      }
+
       return isGET() || isDELETE() || isPUT();
     }
 
@@ -576,17 +603,20 @@ public class DataRequest extends ServiceRequest {
         handler.read(DataRequest.this, PrimitiveValueResponse.getInstance(DataRequest.this,
             response, isCollection(), getUriResourceProperty().getProperty()));
       } else if (isDELETE()) {
-        Property property = new PropertyImpl();
-        property.setName(edmProperty.getName());
-        property.setType(edmProperty.getType().getFullQualifiedName().getFullQualifiedNameAsString());
-
+        Property property = new Property(
+            edmProperty.getType().getFullQualifiedName().getFullQualifiedNameAsString(),
+            edmProperty.getName());
         PropertyResponse propertyResponse = PropertyResponse.getInstance(DataRequest.this, response,
             edmProperty.getType(), getContextURL(odata), edmProperty.isCollection());
         handler.updateProperty(DataRequest.this, property, false, getETag(), propertyResponse);
       } else if (isPUT()) {
         PropertyResponse propertyResponse = PropertyResponse.getInstance(DataRequest.this, response,
             edmProperty.getType(), getContextURL(odata), edmProperty.isCollection());
-        handler.updateProperty(DataRequest.this, getPropertyValueFromClient(edmProperty), false,
+        Property property = new Property(
+            edmProperty.getType().getFullQualifiedName().getFullQualifiedNameAsString(),
+            edmProperty.getName());
+        property.setValue(ValueType.PRIMITIVE, getRawValueFromClient(edmProperty));
+        handler.updateProperty(DataRequest.this, property, false,
             getETag(), propertyResponse);
       }
     }
@@ -659,20 +689,38 @@ public class DataRequest extends ServiceRequest {
 
   private org.apache.olingo.commons.api.data.Property getPropertyValueFromClient(
       EdmProperty edmProperty) throws DeserializerException {
-    // TODO:this is not right, we should be deserializing the property
-    // (primitive, complex, collection of)
-    // for now it is responsibility of the user
     ODataDeserializer deserializer = odata.createDeserializer(ODataFormat
         .fromContentType(getRequestContentType()));
     return deserializer.property(getODataRequest().getBody(), edmProperty).getProperty();
   }
+  
+  private Object getRawValueFromClient(
+      EdmProperty edmProperty) throws DeserializerException {
+    ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
+    byte[] buffer = new byte[1024];
+    int read = 0;
+    do {
+      try {
+        read = IOUtils.read(getODataRequest().getBody(), buffer, 0, 1024);
+        bos.write(buffer, 0, read);
+        if (read < 1024) {
+          break;
+        }
+      } catch (IOException e) {
+        new DeserializerException("Error reading raw value",
+            SerializerException.MessageKeys.IO_EXCEPTION);
+      }
+    } while (true);
+    return bos.toByteArray(); 
+  }  
 
   static ContextURL.Builder buildEntitySetContextURL(UriHelper helper,
       EdmBindingTarget edmEntitySet, List<UriParameter> keyPredicates, UriInfo uriInfo,
       LinkedList<UriResourceNavigation> navigations, boolean collectionReturn, boolean singleton)
       throws SerializerException {
 
-    ContextURL.Builder builder = ContextURL.with().entitySetOrSingletonOrType(edmEntitySet.getName());
+    ContextURL.Builder builder =
+        ContextURL.with().entitySetOrSingletonOrType(getTargetEntitySet(edmEntitySet, navigations));
     String select = helper.buildContextURLSelectList(edmEntitySet.getEntityType(),
         uriInfo.getExpandOption(), uriInfo.getSelectOption());
     if (!singleton) {
@@ -718,6 +766,30 @@ public class DataRequest extends ServiceRequest {
     return result.length() == 0?null:result.toString();
   }
 
+  static String getTargetEntitySet(EdmBindingTarget root, LinkedList<UriResourceNavigation> navigations) {
+    EdmEntityType type = root.getEntityType();
+    EdmBindingTarget targetEntitySet = root;
+    String targetEntitySetName = root.getName();
+    String name = null;
+    for (UriResourceNavigation nav:navigations) {
+      name = nav.getProperty().getName();
+      EdmNavigationProperty property = type.getNavigationProperty(name);
+      if (property.containsTarget()) {
+        return root.getName();
+      }
+      type = nav.getProperty().getType();
+      
+      for(EdmNavigationPropertyBinding enb:targetEntitySet.getNavigationPropertyBindings()) {
+        if (enb.getPath().equals(name)) {
+          targetEntitySetName = enb.getTarget();
+        } else if (enb.getPath().endsWith("/"+name)) {
+          targetEntitySetName = enb.getTarget();
+        }
+      }
+    }
+    return targetEntitySetName;
+  }
+  
   static String buildNavPath(UriHelper helper, EdmEntityType rootType,
       LinkedList<UriResourceNavigation> navigations, boolean includeLastPredicates)
       throws SerializerException {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3ac433b0/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/FunctionRequest.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/FunctionRequest.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/FunctionRequest.java
index a9f9341..b77fb2b 100644
--- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/FunctionRequest.java
+++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/FunctionRequest.java
@@ -21,6 +21,7 @@ package org.apache.olingo.server.core.requests;
 
 import java.util.List;
 
+import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.edm.EdmFunction;
 import org.apache.olingo.commons.api.edm.EdmReturnType;
 import org.apache.olingo.server.api.OData;
@@ -28,8 +29,10 @@ import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.ODataTranslatedException;
 import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.serializer.PrimitiveSerializerOptions;
 import org.apache.olingo.server.api.uri.UriParameter;
 import org.apache.olingo.server.api.uri.UriResourceFunction;
+import org.apache.olingo.server.core.ContentNegotiatorException;
 import org.apache.olingo.server.core.ServiceHandler;
 import org.apache.olingo.server.core.responses.EntityResponse;
 import org.apache.olingo.server.core.responses.EntitySetResponse;
@@ -52,14 +55,9 @@ public class FunctionRequest extends OperationRequest {
     }
 
     // Functions always have return per 11.5.3
-    if (isReturnTypePrimitive()) {
-      // functions can not return a typed property in the context of entity, so
-      // it must be treated
-      // as value based response
-      handler.invoke(this, getODataRequest().getMethod(),
-          PrimitiveValueResponse.getInstance(this, response, isCollection(), getReturnType()));
-    } else if (isReturnTypeComplex()) {
-      handler.invoke(this, getODataRequest().getMethod(), PropertyResponse.getInstance(this, response,
+    if (isReturnTypePrimitive() || isReturnTypeComplex()) {
+      // per odata-json-format/v4.0 = 11 Individual Property or Operation Response
+      handler.invoke(this, getODataRequest().getMethod(), PropertyResponse.getInstance(this, response, 
           getReturnType().getType(), getContextURL(this.odata), isCollection()));
     } else {
       // returnType.getType().getKind() == EdmTypeKind.ENTITY
@@ -83,6 +81,21 @@ public class FunctionRequest extends OperationRequest {
     return isGET();
   }
 
+  @Override
+  public <T> T getSerializerOptions(Class<T> serilizerOptions, ContextURL contextUrl, boolean references)
+      throws ContentNegotiatorException {
+    if (serilizerOptions.isAssignableFrom(PrimitiveSerializerOptions.class)) {
+      return (T) PrimitiveSerializerOptions.with().contextURL(contextUrl)
+          .nullable(getReturnType().isNullable())
+          .maxLength(getReturnType().getMaxLength())
+          .precision(getReturnType().getPrecision())
+          .scale(getReturnType().getScale())
+          .unicode(null)
+          .build();
+    }
+    return super.getSerializerOptions(serilizerOptions, contextUrl, references);
+  }  
+  
   public UriResourceFunction getUriResourceFunction() {
     return uriResourceFunction;
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3ac433b0/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/EntityResponse.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/EntityResponse.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/EntityResponse.java
index e90681d..eb79c07 100644
--- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/EntityResponse.java
+++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/EntityResponse.java
@@ -22,12 +22,14 @@ import java.util.Map;
 
 import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.ODataServerError;
 import org.apache.olingo.server.api.ODataTranslatedException;
 import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.serializer.EntitySerializerOptions;
@@ -42,15 +44,17 @@ public class EntityResponse extends ServiceResponse {
   private final ODataSerializer serializer;
   private final EntitySerializerOptions options;
   private final ContentType responseContentType;
+  private final String baseURL;
 
   private EntityResponse(ServiceMetadata metadata, ODataResponse response,
       ODataSerializer serializer, EntitySerializerOptions options, ContentType responseContentType,
-      Map<String, String> preferences, ReturnRepresentation returnRepresentation) {
+      Map<String, String> preferences, ReturnRepresentation returnRepresentation, String baseURL) {
     super(metadata, response, preferences);
     this.serializer = serializer;
     this.options = options;
     this.responseContentType = responseContentType;
     this.returnRepresentation = returnRepresentation;
+    this.baseURL = baseURL;
   }
 
   public static EntityResponse getInstance(ServiceRequest request, ContextURL contextURL,
@@ -59,7 +63,8 @@ public class EntityResponse extends ServiceResponse {
     EntitySerializerOptions options = request.getSerializerOptions(EntitySerializerOptions.class,
         contextURL, references);
     return new EntityResponse(request.getServiceMetaData(), response, request.getSerializer(),
-        options, request.getResponseContentType(), request.getPreferences(), returnRepresentation);
+        options, request.getResponseContentType(), request.getPreferences(), returnRepresentation, 
+        request.getODataRequest().getRawBaseUri());
   }
 
   public static EntityResponse getInstance(ServiceRequest request, ContextURL contextURL,
@@ -68,7 +73,8 @@ public class EntityResponse extends ServiceResponse {
     EntitySerializerOptions options = request.getSerializerOptions(EntitySerializerOptions.class,
         contextURL, references);
     return new EntityResponse(request.getServiceMetaData(), response, request.getSerializer(),
-        options, request.getResponseContentType(), request.getPreferences(), null);
+        options, request.getResponseContentType(), request.getPreferences(), null,
+        request.getODataRequest().getRawBaseUri());
   }
 
   // write single entity
@@ -87,19 +93,24 @@ public class EntityResponse extends ServiceResponse {
     close();
   }
 
-  public void writeCreatedEntity(EdmEntityType entityType, Entity entity, String locationHeader)
+  public void writeCreatedEntity(EdmEntitySet entitySet, Entity entity)
       throws SerializerException {
     // upsert/insert must created a entity, otherwise should have throw an
     // exception
     assert (entity != null);
+    
+    String locationHeader = buildLocation(this.baseURL, entity, entitySet.getName(), entitySet.getEntityType());
 
     // Note that if media written just like Stream, but on entity URL
 
     // 8.2.8.7
-    if (this.returnRepresentation == ReturnRepresentation.MINIMAL) {
+    if (this.returnRepresentation == ReturnRepresentation.MINIMAL || 
+        this.returnRepresentation == ReturnRepresentation.NONE) {
       writeNoContent(false);
       writeHeader(HttpHeader.LOCATION, locationHeader);
-      writeHeader("Preference-Applied", "return=minimal"); //$NON-NLS-1$ //$NON-NLS-2$
+      if (this.returnRepresentation == ReturnRepresentation.MINIMAL) {
+        writeHeader("Preference-Applied", "return=minimal"); //$NON-NLS-1$ //$NON-NLS-2$
+      }
       // 8.3.3
       writeHeader("OData-EntityId", entity.getId().toASCIIString()); //$NON-NLS-1$
       close();
@@ -107,7 +118,8 @@ public class EntityResponse extends ServiceResponse {
     }
 
     // return the content of the created entity
-    this.response.setContent(this.serializer.entity(this.metadata, entityType, entity, this.options).getContent());
+    this.response.setContent(this.serializer.entity(this.metadata, entitySet.getEntityType(), entity, this.options)
+        .getContent());
     writeCreated(false);
     writeHeader(HttpHeader.LOCATION, locationHeader);
     writeHeader("Preference-Applied", "return=representation"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -137,4 +149,40 @@ public class EntityResponse extends ServiceResponse {
       close();
     }
   }
+  
+  public void writeError(ODataServerError error) {
+    try {
+      writeContent(this.serializer.error(error).getContent(), error.getStatusCode(), true);
+    } catch (SerializerException e) {
+      writeServerError(true);
+    }
+  }
+  
+  public void writeNotModified() {
+    this.response.setStatusCode(HttpStatusCode.NOT_MODIFIED.getStatusCode());
+    close();
+  }  
+  
+  public static String buildLocation(String baseURL, Entity entity, String enitySetName, EdmEntityType type) {
+    String location = baseURL + "/" + enitySetName + "(";
+    int i = 0;
+    boolean usename = type.getKeyPredicateNames().size() > 1;
+
+    for (String key : type.getKeyPredicateNames()) {
+      if (i > 0) {
+        location += ",";
+      }
+      i++;
+      if (usename) {
+        location += (key + "=");
+      }
+      if (entity.getProperty(key).getType().equals("Edm.String")) {
+        location = location + "'" + entity.getProperty(key).getValue().toString() + "'";
+      } else {
+        location = location + entity.getProperty(key).getValue().toString();
+      }
+    }
+    location += ")";
+    return location;
+  }  
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3ac433b0/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/EntitySetResponse.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/EntitySetResponse.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/EntitySetResponse.java
index c70854b..27675c3 100644
--- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/EntitySetResponse.java
+++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/EntitySetResponse.java
@@ -21,11 +21,12 @@ package org.apache.olingo.server.core.responses;
 import java.util.Map;
 
 import org.apache.olingo.commons.api.data.ContextURL;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.ODataServerError;
 import org.apache.olingo.server.api.ODataTranslatedException;
 import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.serializer.EntityCollectionSerializerOptions;
@@ -58,7 +59,7 @@ public class EntitySetResponse extends ServiceResponse {
 
   // write collection of entities
   // TODO: server paging needs to be implemented.
-  public void writeReadEntitySet(EdmEntityType entityType, EntitySet entitySet)
+  public void writeReadEntitySet(EdmEntityType entityType, EntityCollection entitySet)
       throws SerializerException {
 
     assert (!isClosed());
@@ -80,4 +81,12 @@ public class EntitySetResponse extends ServiceResponse {
       ODataApplicationException {
     visitor.visit(this);
   }
+  
+  public void writeError(ODataServerError error) {
+    try {
+      writeContent(this.serializer.error(error).getContent(), error.getStatusCode(), true);
+    } catch (SerializerException e) {
+      writeServerError(true);
+    }
+  }  
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3ac433b0/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/MetadataResponse.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/MetadataResponse.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/MetadataResponse.java
index b325421..a644358 100644
--- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/MetadataResponse.java
+++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/MetadataResponse.java
@@ -23,6 +23,7 @@ import java.util.Map;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.ODataServerError;
 import org.apache.olingo.server.api.ODataTranslatedException;
 import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
@@ -59,4 +60,12 @@ public class MetadataResponse extends ServiceResponse {
       ODataApplicationException {
     visitor.visit(this);
   }
+  
+  public void writeError(ODataServerError error) {
+    try {
+      writeContent(this.serializer.error(error).getContent(), error.getStatusCode(), true);
+    } catch (SerializerException e) {
+      writeServerError(true);
+    }
+  }  
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3ac433b0/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/PrimitiveValueResponse.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/PrimitiveValueResponse.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/PrimitiveValueResponse.java
index 005bfca..d5fa32b 100644
--- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/PrimitiveValueResponse.java
+++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/PrimitiveValueResponse.java
@@ -18,6 +18,7 @@
  */
 package org.apache.olingo.server.core.responses;
 
+import java.io.ByteArrayInputStream;
 import java.util.Map;
 
 import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
@@ -92,6 +93,15 @@ public class PrimitiveValueResponse extends ServiceResponse {
 
     writeOK(HttpContentType.TEXT_PLAIN);
   }
+  
+  public void writeEdmBinary(byte[] value) throws SerializerException {
+    if (value == null) {
+      writeNoContent(true);
+      return;
+    }
+    this.response.setContent(new ByteArrayInputStream(value));
+    writeOK(HttpContentType.APPLICATION_OCTET_STREAM);
+  }  
 
   public boolean isReturnCollection() {
     return returnCollection;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3ac433b0/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/PropertyResponse.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/PropertyResponse.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/PropertyResponse.java
index 79ac90d..86ce46f 100644
--- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/PropertyResponse.java
+++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/PropertyResponse.java
@@ -27,8 +27,10 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
 import org.apache.olingo.commons.api.edm.EdmType;
 import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
 import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.ODataServerError;
 import org.apache.olingo.server.api.ODataTranslatedException;
 import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.serializer.ComplexSerializerOptions;
@@ -141,4 +143,17 @@ public class PropertyResponse extends ServiceResponse {
   public void writePropertyDeleted() {
     writeNoContent(true);
   }
+  
+  public void writeError(ODataServerError error) {
+    try {
+      writeContent(this.serializer.error(error).getContent(), error.getStatusCode(), true);
+    } catch (SerializerException e) {
+      writeServerError(true);
+    }
+  } 
+  
+  public void writeNotModified() {
+    this.response.setStatusCode(HttpStatusCode.NOT_MODIFIED.getStatusCode());
+    close();
+  }  
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3ac433b0/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/ResponseUtil.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/ResponseUtil.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/ResponseUtil.java
new file mode 100644
index 0000000..257f8c7
--- /dev/null
+++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/ResponseUtil.java
@@ -0,0 +1,86 @@
+/*
+ * 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 WARRANTIES OR 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.olingo.server.core.responses;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.olingo.commons.api.data.ComplexValue;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ValueType;
+import org.apache.olingo.commons.api.domain.ODataLinkType;
+
+public class ResponseUtil {
+  public static Property createPrimitive(final String name, final String type, final Object value) {
+    return new Property(type, name, ValueType.PRIMITIVE, value);
+  }
+
+  public static Property createPrimitiveCollection(final String name, final Object... values) {
+    return new Property(null, name, ValueType.COLLECTION_PRIMITIVE, Arrays.asList(values));
+  }
+
+  public static Property createComplex(final String name, final String type, final Property... properties) {
+    ComplexValue complexValue = new ComplexValue();
+    for (final Property property : properties) {
+      complexValue.getValue().add(property);
+    }
+    return new Property(type, name, ValueType.COMPLEX, complexValue);
+  }
+
+  public static Property createComplexCollection(final String name, final String type,
+      final List<Property>... propertiesList) {
+    List<ComplexValue> complexCollection = new ArrayList<ComplexValue>();
+    for (final List<Property> properties : propertiesList) {
+      ComplexValue complexValue = new ComplexValue();
+      complexValue.getValue().addAll(properties);
+      complexCollection.add(complexValue);
+    }
+    return new Property(type, name, ValueType.COLLECTION_COMPLEX, complexCollection);
+  }
+
+  public static void setLink(Entity entity, final String navigationPropertyName, final Entity target) {
+    Link link = entity.getNavigationLink(navigationPropertyName);
+    if (link == null) {
+      link = new Link();
+      link.setType(ODataLinkType.ENTITY_NAVIGATION.toString());
+      link.setTitle(navigationPropertyName);
+      entity.getNavigationLinks().add(link);
+    }
+    link.setInlineEntity(target);
+  }
+
+  public static void setLinks(Entity entity, final String navigationPropertyName, final Entity... targets) {
+    Link link = entity.getNavigationLink(navigationPropertyName);
+    if (link == null) {
+      link = new Link();
+      link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
+      link.setTitle(navigationPropertyName);
+      EntityCollection target = new EntityCollection();
+      target.getEntities().addAll(Arrays.asList(targets));
+      link.setInlineEntitySet(target);
+      entity.getNavigationLinks().add(link);
+    } else {
+      link.getInlineEntitySet().getEntities().addAll(Arrays.asList(targets));
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3ac433b0/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/ServiceDocumentResponse.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/ServiceDocumentResponse.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/ServiceDocumentResponse.java
index 8b77684..0f3733c 100644
--- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/ServiceDocumentResponse.java
+++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/ServiceDocumentResponse.java
@@ -23,6 +23,7 @@ import java.util.Map;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.ODataServerError;
 import org.apache.olingo.server.api.ODataTranslatedException;
 import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
@@ -60,4 +61,12 @@ public class ServiceDocumentResponse extends ServiceResponse {
       ODataApplicationException {
     visitor.visit(this);
   }
+  
+  public void writeError(ODataServerError error) {
+    try {
+      writeContent(this.serializer.error(error).getContent(), error.getStatusCode(), true);
+    } catch (SerializerException e) {
+      writeServerError(true);
+    }
+  }  
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3ac433b0/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/ServiceResponse.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/ServiceResponse.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/ServiceResponse.java
index a306551..bf000e0 100644
--- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/ServiceResponse.java
+++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/ServiceResponse.java
@@ -19,6 +19,7 @@
 
 package org.apache.olingo.server.core.responses;
 
+import java.io.InputStream;
 import java.util.Map;
 
 import org.apache.olingo.commons.api.http.HttpHeader;
@@ -105,6 +106,14 @@ public abstract class ServiceResponse {
       this.response.setHeader(key, value);
     }
   }
+  
+  public void writeContent(InputStream content, int statusCode, boolean closeResponse) {
+    this.response.setContent(content);
+    this.response.setStatusCode(statusCode);
+    if (closeResponse) {
+      close();
+    }    
+  }
 
   /**
    * When true; the "Preference-Applied" header is strictly checked.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3ac433b0/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/ServiceDispatcherTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/ServiceDispatcherTest.java b/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/ServiceDispatcherTest.java
index faabafc..a289738 100644
--- a/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/ServiceDispatcherTest.java
+++ b/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/ServiceDispatcherTest.java
@@ -36,7 +36,6 @@ import org.apache.catalina.startup.Tomcat;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpDelete;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
@@ -62,7 +61,6 @@ import org.apache.olingo.server.core.responses.NoContentResponse;
 import org.apache.olingo.server.core.responses.PrimitiveValueResponse;
 import org.apache.olingo.server.core.responses.PropertyResponse;
 import org.apache.olingo.server.core.responses.StreamResponse;
-import org.apache.olingo.server.example.TripPinServiceTest;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mockito;
@@ -70,7 +68,6 @@ import org.mockito.Mockito;
 public class ServiceDispatcherTest {
   private static final int TOMCAT_PORT = 9900;
   private Tomcat tomcat = new Tomcat();
-  private String baseURL;
   
   public class SampleODataServlet extends HttpServlet {
     private final ServiceHandler handler; // must be stateless
@@ -103,7 +100,6 @@ public class ServiceDispatcherTest {
     Context cxt = tomcat.addContext("/trippin", baseDir.getAbsolutePath());
     Tomcat.addServlet(cxt, "trippin", new SampleODataServlet(serviceHandler, edmProvider));
     cxt.addServletMapping("/*", "trippin");
-    baseURL = "http://" + tomcat.getHost().getName() + ":"+ TOMCAT_PORT;
     tomcat.setPort(TOMCAT_PORT);
     tomcat.start();
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3ac433b0/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinDataModel.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinDataModel.java b/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinDataModel.java
index 055f073..a960d67 100644
--- a/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinDataModel.java
+++ b/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinDataModel.java
@@ -33,7 +33,7 @@ import java.util.Map;
 import java.util.UUID;
 
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.edm.EdmEntityContainer;
@@ -45,21 +45,19 @@ import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.commons.api.edm.EdmType;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
-import org.apache.olingo.commons.core.data.EntityImpl;
-import org.apache.olingo.commons.core.data.EntitySetImpl;
-import org.apache.olingo.commons.core.data.LinkImpl;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.deserializer.DeserializerException;
 import org.apache.olingo.server.api.uri.UriParameter;
 import org.apache.olingo.server.api.uri.UriResourceNavigation;
 import org.apache.olingo.server.core.deserializer.json.ODataJsonDeserializer;
+import org.apache.olingo.server.core.responses.EntityResponse;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 
 public class TripPinDataModel {
   private final ServiceMetadata metadata;
-  private HashMap<String, EntitySet> entitySetMap;
+  private HashMap<String, EntityCollection> entitySetMap;
   private Map<Integer, Map> tripLinks;
   private Map<String, Map> peopleLinks;
   private Map<Integer, Map> flightLinks;
@@ -70,7 +68,7 @@ public class TripPinDataModel {
   }
 
   public void loadData() throws Exception {
-    this.entitySetMap = new HashMap<String, EntitySet>();
+    this.entitySetMap = new HashMap<String, EntityCollection>();
     this.tripLinks = new HashMap<Integer, Map>();
     this.peopleLinks = new HashMap<String, Map>();
     this.flightLinks = new HashMap<Integer, Map>();
@@ -78,7 +76,7 @@ public class TripPinDataModel {
     EdmEntityContainer ec = metadata.getEdm().getEntityContainer(null);
     for (EdmEntitySet edmEntitySet : ec.getEntitySets()) {
       String entitySetName = edmEntitySet.getName();
-      EntitySet set = loadEnities(entitySetName, edmEntitySet.getEntityType());
+      EntityCollection set = loadEnities(entitySetName, edmEntitySet.getEntityType());
       if (set != null) {
         this.entitySetMap.put(entitySetName, set);
       }
@@ -119,19 +117,19 @@ public class TripPinDataModel {
     }
   }
 
-  private EntitySet loadEnities(String entitySetName, EdmEntityType type) {
+  private EntityCollection loadEnities(String entitySetName, EdmEntityType type) {
     try {
       ODataJsonDeserializer deserializer = new ODataJsonDeserializer();
 
-      EntitySet set = deserializer.entityCollection(new FileInputStream(new File(
+      EntityCollection set = deserializer.entityCollection(new FileInputStream(new File(
           "src/test/resources/" + entitySetName.toLowerCase() + ".json")), type).getEntityCollection();
       // TODO: the count needs to be part of deserializer
       set.setCount(set.getEntities().size());
       for (Entity entity : set.getEntities()) {
-        ((EntityImpl) entity).setETag(UUID.randomUUID().toString());
-        ((EntityImpl) entity).setId(new URI(TripPinHandler.buildLocation(entity, entitySetName,
+        entity.setETag(UUID.randomUUID().toString());
+        entity.setId(new URI(EntityResponse.buildLocation("", entity, entitySetName,
             type)));
-        ((EntityImpl) entity).setType(type.getFullQualifiedName().getFullQualifiedNameAsString());
+        entity.setType(type.getFullQualifiedName().getFullQualifiedNameAsString());
       }
       return set;
     } catch (FileNotFoundException e) {
@@ -149,17 +147,17 @@ public class TripPinDataModel {
     return null;
   }
 
-  public EntitySet getEntitySet(String name) {
+  public EntityCollection getEntitySet(String name) {
     return getEntitySet(name, -1, -1);
   }
 
-  public EntitySet getEntitySet(String name, int skip, int pageSize) {
-    EntitySet set = this.entitySetMap.get(name);
+  public EntityCollection getEntitySet(String name, int skip, int pageSize) {
+    EntityCollection set = this.entitySetMap.get(name);
     if (set == null) {
       return null;
     }
 
-    EntitySetImpl modifiedES = new EntitySetImpl();
+    EntityCollection modifiedES = new EntityCollection();
     int i = 0;
     for (Entity e : set.getEntities()) {
       if (skip >= 0 && i >= skip && modifiedES.getEntities().size() < pageSize) {
@@ -232,11 +230,11 @@ public class TripPinDataModel {
   }
 
   public Entity getEntity(String name, List<UriParameter> keys) throws ODataApplicationException {
-    EntitySet es = getEntitySet(name);
+    EntityCollection es = getEntitySet(name);
     return getEntity(es, keys);
   }
 
-  public Entity getEntity(EntitySet es, List<UriParameter> keys) throws ODataApplicationException {
+  public Entity getEntity(EntityCollection es, List<UriParameter> keys) throws ODataApplicationException {
     List<Entity> search = es.getEntities();
     for (UriParameter param : keys) {
       search = getMatch(param, search);
@@ -247,15 +245,15 @@ public class TripPinDataModel {
     return search.get(0);
   }
 
-  private EntitySet getFriends(String userName) {
+  private EntityCollection getFriends(String userName) {
     Map<String, Object> map = this.peopleLinks.get(userName);
     if (map == null) {
       return null;
     }
     ArrayList<String> friends = (ArrayList<String>) map.get("Friends");
-    EntitySet set = getEntitySet("People");
+    EntityCollection set = getEntitySet("People");
 
-    EntitySetImpl result = new EntitySetImpl();
+    EntityCollection result = new EntityCollection();
     int i = 0;
     if (friends != null) {
       for (String friend : friends) {
@@ -272,16 +270,16 @@ public class TripPinDataModel {
     return result;
   }
 
-  private EntitySet getTrips(String userName) {
+  private EntityCollection getTrips(String userName) {
     Map<String, Object> map = this.peopleLinks.get(userName);
     if (map == null) {
       return null;
     }
 
     ArrayList<Integer> trips = (ArrayList<Integer>) map.get("Trips");
-    EntitySet set = getEntitySet("Trip");
+    EntityCollection set = getEntitySet("Trip");
 
-    EntitySetImpl result = new EntitySetImpl();
+    EntityCollection result = new EntityCollection();
     int i = 0;
     if (trips != null) {
       for (int trip : trips) {
@@ -305,7 +303,7 @@ public class TripPinDataModel {
     }
 
     Integer photoID = (Integer) map.get("Photo");
-    EntitySet set = getEntitySet("Photos");
+    EntityCollection set = getEntitySet("Photos");
     if (photoID != null) {
       for (Entity e : set.getEntities()) {
         if (e.getProperty("Id").getValue().equals(photoID.longValue())) {
@@ -316,20 +314,20 @@ public class TripPinDataModel {
     return null;
   }
 
-  private EntitySet getPlanItems(int tripId, EntitySetImpl result) {
+  private EntityCollection getPlanItems(int tripId, EntityCollection result) {
     getFlights(tripId, result);
     getEvents(tripId, result);
     return result;
   }
 
-  private EntitySet getEvents(int tripId, EntitySetImpl result) {
+  private EntityCollection getEvents(int tripId, EntityCollection result) {
     Map<Integer, Object> map = this.tripLinks.get(tripId);
     if (map == null) {
       return null;
     }
 
     ArrayList<Integer> events = (ArrayList<Integer>) map.get("Events");
-    EntitySet set = getEntitySet("Event");
+    EntityCollection set = getEntitySet("Event");
     int i = result.getEntities().size();
     if (events != null) {
       for (int event : events) {
@@ -346,14 +344,14 @@ public class TripPinDataModel {
     return result;
   }
 
-  private EntitySet getFlights(int tripId, EntitySetImpl result) {
+  private EntityCollection getFlights(int tripId, EntityCollection result) {
     Map<Integer, Object> map = this.tripLinks.get(tripId);
     if (map == null) {
       return null;
     }
 
     ArrayList<Integer> flights = (ArrayList<Integer>) map.get("Flights");
-    EntitySet set = getEntitySet("Flight");
+    EntityCollection set = getEntitySet("Flight");
     int i = result.getEntities().size();
     if (flights != null) {
       for (int flight : flights) {
@@ -370,7 +368,7 @@ public class TripPinDataModel {
     return result;
   }
 
-  private EntitySet getTripPhotos(int tripId) {
+  private EntityCollection getTripPhotos(int tripId) {
     Map<Integer, Object> map = this.tripLinks.get(tripId);
     if (map == null) {
       return null;
@@ -378,8 +376,8 @@ public class TripPinDataModel {
 
     ArrayList<Integer> photos = (ArrayList<Integer>) map.get("Photos");
 
-    EntitySet set = getEntitySet("Photos");
-    EntitySetImpl result = new EntitySetImpl();
+    EntityCollection set = getEntitySet("Photos");
+    EntityCollection result = new EntityCollection();
     int i = 0;
     if (photos != null) {
       for (int photo : photos) {
@@ -403,7 +401,7 @@ public class TripPinDataModel {
     }
 
     String from = (String) map.get("From");
-    EntitySet set = getEntitySet("Airports");
+    EntityCollection set = getEntitySet("Airports");
 
     if (from != null) {
       for (Entity e : set.getEntities()) {
@@ -422,7 +420,7 @@ public class TripPinDataModel {
     }
 
     String to = (String) map.get("To");
-    EntitySet set = getEntitySet("Airports");
+    EntityCollection set = getEntitySet("Airports");
 
     if (to != null) {
       for (Entity e : set.getEntities()) {
@@ -441,7 +439,7 @@ public class TripPinDataModel {
     }
 
     String airline = (String) map.get("Airline");
-    EntitySet set = getEntitySet("Airlines");
+    EntityCollection set = getEntitySet("Airlines");
 
     if (airline != null) {
       for (Entity e : set.getEntities()) {
@@ -560,7 +558,7 @@ public class TripPinDataModel {
 
   protected static void setLink(Entity entity, final String navigationPropertyName,
       final Entity target) {
-    Link link = new LinkImpl();
+    Link link = new Link();
     link.setTitle(navigationPropertyName);
     link.setInlineEntity(target);
     entity.getNavigationLinks().add(link);
@@ -607,18 +605,19 @@ public class TripPinDataModel {
     return updated;
   }
 
-  public Entity createEntity(String entitySetName, Entity entity, String location)
+  public Entity createEntity(EdmEntitySet edmEntitySet, Entity entity, String baseURL)
       throws ODataApplicationException {
 
-    EntitySet set = this.entitySetMap.get(entitySetName);
-    EntityImpl copy = new EntityImpl();
+    EntityCollection set = this.entitySetMap.get(edmEntitySet.getName());
+    Entity copy = new Entity();
     copy.setType(entity.getType());
     for (Property p : entity.getProperties()) {
       copy.addProperty(p);
     }
 
     try {
-      copy.setId(new URI(location));
+      copy.setId(new URI(EntityResponse.buildLocation(baseURL, entity, edmEntitySet.getName(), edmEntitySet
+          .getEntityType())));
       copy.setETag(UUID.randomUUID().toString());
     } catch (URISyntaxException e) {
       throw new ODataApplicationException("Failed to create ID for entity", 500,
@@ -630,7 +629,7 @@ public class TripPinDataModel {
   }
 
   public boolean deleteEntity(String entitySetName, String eTag, String key, Object keyValue) {
-    EntitySet set = getEntitySet(entitySetName);
+    EntityCollection set = getEntitySet(entitySetName);
     Iterator<Entity> it = set.getEntities().iterator();
     boolean removed = false;
     while (it.hasNext()) {
@@ -647,7 +646,7 @@ public class TripPinDataModel {
 
   public boolean updateProperty(String entitySetName, String eTag, String key, Object keyValue,
       Property property) {
-    EntitySet set = getEntitySet(entitySetName);
+    EntityCollection set = getEntitySet(entitySetName);
     Iterator<Entity> it = set.getEntities().iterator();
     boolean replaced = false;
     while (it.hasNext()) {
@@ -663,20 +662,20 @@ public class TripPinDataModel {
     return replaced;
   }
 
-  public EntitySet getNavigableEntitySet(Entity parentEntity, UriResourceNavigation navigation) {
+  public EntityCollection getNavigableEntitySet(Entity parentEntity, UriResourceNavigation navigation) {
     EdmEntityType type = this.metadata.getEdm().getEntityType(
         new FullQualifiedName(parentEntity.getType()));
 
     String key = type.getKeyPredicateNames().get(0);
     String linkName = navigation.getProperty().getName();
 
-    EntitySet results = null;
+    EntityCollection results = null;
     if (type.getName().equals("Person") && linkName.equals("Friends")) {
       results = getFriends((String) parentEntity.getProperty(key).getValue());
     } else if (type.getName().equals("Person") && linkName.equals("Trips")) {
       results = getTrips((String) parentEntity.getProperty(key).getValue());
     } else if (type.getName().equals("Trip") && linkName.equals("PlanItems")) {
-      EntitySetImpl planitems = new EntitySetImpl();
+      EntityCollection planitems = new EntityCollection();
       if (navigation.getTypeFilterOnCollection() == null) {
         results = getPlanItems((Integer) parentEntity.getProperty(key).getValue(), planitems);
       } else if (navigation.getTypeFilterOnCollection().getName().equals("Flight")) {
@@ -700,7 +699,7 @@ public class TripPinDataModel {
     String key = type.getKeyPredicateNames().get(0);
     String linkName = navigation.getProperty().getName();
 
-    EntitySet results = null;
+    EntityCollection results = null;
     if (navigation.getProperty().isCollection()) {
       results = getNavigableEntitySet(parentEntity, navigation);
       return this.getEntity(results, navigation.getKeyPredicates());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3ac433b0/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinHandler.java b/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinHandler.java
index 040a7da..7172818 100644
--- a/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinHandler.java
+++ b/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinHandler.java
@@ -27,7 +27,7 @@ import java.util.Locale;
 import java.util.Random;
 
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.edm.EdmAction;
@@ -36,9 +36,9 @@ import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.EdmFunction;
 import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.commons.api.edm.EdmSingleton;
+import org.apache.olingo.commons.api.edm.provider.EntitySet;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.http.HttpMethod;
-import org.apache.olingo.commons.core.data.EntitySetImpl;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.ODataRequest;
@@ -94,7 +94,7 @@ public class TripPinHandler implements ServiceHandler {
   }
 
   static class EntityDetails {
-    EntitySet entitySet = null;
+    EntityCollection entitySet = null;
     Entity entity = null;
     EdmEntityType entityType;
     String navigationProperty;
@@ -102,7 +102,7 @@ public class TripPinHandler implements ServiceHandler {
   }
 
   private EntityDetails process(final DataRequest request) throws ODataApplicationException {
-    EntitySet entitySet = null;
+    EntityCollection entitySet = null;
     Entity entity = null;
     EdmEntityType entityType;
     Entity parentEntity = null;
@@ -206,7 +206,7 @@ public class TripPinHandler implements ServiceHandler {
           response.writeHeader("Preference-Applied", "odata.maxpagesize="+request.getPreference("odata.maxpagesize"));
         }
         if (details.entity == null && !request.getNavigations().isEmpty()) {
-          response.writeReadEntitySet(details.entityType, new EntitySetImpl());
+          response.writeReadEntitySet(details.entityType, new EntityCollection());
         } else {
           response.writeReadEntitySet(details.entityType, details.entitySet);
         }
@@ -237,8 +237,7 @@ public class TripPinHandler implements ServiceHandler {
       throws ODataTranslatedException, ODataApplicationException {
     EdmEntitySet edmEntitySet = request.getEntitySet();
 
-    String location = buildLocation(entity, edmEntitySet.getName(), edmEntitySet.getEntityType());
-    Entity created = this.dataModel.createEntity(edmEntitySet.getName(), entity, location);
+    Entity created = this.dataModel.createEntity(edmEntitySet, entity, request.getODataRequest().getRawBaseUri());
 
     try {
       // create references, they come in "@odata.bind" value
@@ -271,30 +270,7 @@ public class TripPinHandler implements ServiceHandler {
       throw new ODataApplicationException(e.getMessage(), 500, Locale.getDefault());
     }
 
-    response.writeCreatedEntity(edmEntitySet.getEntityType(), created, location);
-  }
-
-  static String buildLocation(Entity entity, String name, EdmEntityType type) {
-    String location = "/" + name + "(";
-    int i = 0;
-    boolean usename = type.getKeyPredicateNames().size() > 1;
-
-    for (String key : type.getKeyPredicateNames()) {
-      if (i > 0) {
-        location += ",";
-      }
-      i++;
-      if (usename) {
-        location += (key + "=");
-      }
-      if (entity.getProperty(key).getType().equals("Edm.String")) {
-        location = location + "'" + entity.getProperty(key).getValue().toString() + "'";
-      } else {
-        location = location + entity.getProperty(key).getValue().toString();
-      }
-    }
-    location += ")";
-    return location;
+    response.writeCreatedEntity(edmEntitySet, created);
   }
 
   @Override
@@ -360,7 +336,7 @@ public class TripPinHandler implements ServiceHandler {
       final EdmEntityType type = serviceMetadata.getEdm().getEntityContainer(null)
           .getEntitySet("Airports").getEntityType();
 
-      EntitySet es = this.dataModel.getEntitySet("Airports");
+      EntityCollection es = this.dataModel.getEntitySet("Airports");
       int i = new Random().nextInt(es.getEntities().size());
       final Entity entity = es.getEntities().get(i);
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3ac433b0/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinServiceTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinServiceTest.java b/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinServiceTest.java
index 3547b50..1766f1a 100644
--- a/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinServiceTest.java
+++ b/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinServiceTest.java
@@ -147,6 +147,7 @@ public class TripPinServiceTest {
     JsonNode node = getJSONNode(response);
     assertEquals("$metadata#Airlines/$entity", node.get("@odata.context").asText());
     assertEquals("American Airlines", node.get("Name").asText());
+    //assertEquals("/Airlines('AA')/Picture", node.get("Picture@odata.mediaReadLink").asText());
   }
 
   @Test
@@ -278,7 +279,7 @@ public class TripPinServiceTest {
 
   @Test
   public void testLambdaAny() throws Exception {
-    // this is just testing to see the labba expresions are going through the
+    // this is just testing to see the lamda expressions are going through the
     // framework, none of the system options are not implemented in example service
     String query = "Friends/any(d:d/UserName eq 'foo')";
     HttpResponse response = httpGET(baseURL + "/People?$filter="+Encoder.encode(query), 200);
@@ -405,10 +406,10 @@ public class TripPinServiceTest {
 
     HttpResponse response = httpSend(postRequest, 204);
     // the below woud be 204, if minimal was not supplied
-    assertEquals("/People('olingodude')", getHeader(response, "Location"));
+    assertEquals("http://localhost:9900/trippin/People('olingodude')", getHeader(response, "Location"));
     assertEquals("return=minimal", getHeader(response, "Preference-Applied"));
 
-    String location = baseURL+getHeader(response, "Location");
+    String location = getHeader(response, "Location");
     response = httpGET(location, 200);
     EntityUtils.consumeQuietly(response.getEntity());
 
@@ -527,6 +528,21 @@ public class TripPinServiceTest {
   }
 
   @Test
+  public void testReadNavigationPropertyNoContainsTarget() throws Exception {
+    String editUrl = baseURL + "/People('scottketchum')/Photo";
+    HttpResponse response = httpGET(editUrl, 200);
+
+    JsonNode node = getJSONNode(response);
+    assertEquals("$metadata#Photos/$entity", node.get("@odata.context").asText());
+  }
+  
+  @Test
+  public void testReadNavigationPropertyNonExistingNavigation() throws Exception {
+    String editUrl = baseURL + "/People('russellwhyte')/Foobar";
+    httpGET(editUrl, 404);
+  }  
+  
+  @Test
   public void testReadNavigationPropertyEntityCollection2() throws Exception {
     String editUrl = baseURL + "/People('russellwhyte')/Friends('scottketchum')/Trips";
     HttpResponse response = httpGET(editUrl, 200);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3ac433b0/lib/server-core-ext/src/test/resources/airlines.json
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/test/resources/airlines.json b/lib/server-core-ext/src/test/resources/airlines.json
index 78eccdc..1d93aa7 100644
--- a/lib/server-core-ext/src/test/resources/airlines.json
+++ b/lib/server-core-ext/src/test/resources/airlines.json
@@ -2,7 +2,11 @@
    "value":[
       {
          "AirlineCode":"AA",
-         "Name":"American Airlines"
+         "Name":"American Airlines",
+         "Picture@odata.mediaReadLink": "/Airlines('AA')/Picture",
+         "Picture@odata.mediaEditLink": "/Airlines('AA')/Picture",
+         "Picture@odata.mediaContentType": "image/jpeg",
+         "Picture@odata.mediaEtag": "12345"         
       },
       {
          "AirlineCode":"FM",

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/3ac433b0/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
index ff7eff2..1de8562 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
@@ -229,6 +229,12 @@ public class ODataJsonSerializer implements ODataSerializer {
         if (entity.getMediaContentType() != null) {
           json.writeStringField(Constants.JSON_MEDIA_CONTENT_TYPE, entity.getMediaContentType());
         }
+        if (entity.getMediaContentSource() != null) {
+          json.writeStringField(Constants.JSON_MEDIA_READ_LINK, entity.getMediaContentSource().toString());
+        }
+        if (entity.getMediaEditLinks() != null && !entity.getMediaEditLinks().isEmpty()) {
+          json.writeStringField(Constants.JSON_MEDIA_EDIT_LINK, entity.getMediaEditLinks().get(0).getHref());
+        }
       }
     }
     if (onlyReference) {


[08/22] olingo-odata4 git commit: [OLINGO-603] Delete core dependecies in Tec Scenario

Posted by ra...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
index d47aa46..a203750 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
@@ -40,17 +40,12 @@ import org.apache.olingo.commons.api.edm.EdmFunction;
 import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.commons.api.edm.EdmStructuredType;
-import org.apache.olingo.commons.api.edm.EdmType;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.commons.core.data.ComplexValueImpl;
-import org.apache.olingo.commons.core.data.EntityImpl;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmInt16;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmInt32;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmInt64;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmString;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.deserializer.DeserializerException;
@@ -137,7 +132,7 @@ public class DataProvider {
     final EntitySet entitySet = readAll(edmEntitySet);
     final List<Entity> entities = entitySet.getEntities();
     final Map<String, Object> newKey = findFreeComposedKey(entities, edmEntitySet.getEntityType());
-    final Entity newEntity = new EntityImpl();
+    final Entity newEntity = new Entity();
     newEntity.setType(edmEntityType.getFullQualifiedName().getFullQualifiedNameAsString());
     for (final String keyName : edmEntityType.getKeyPredicateNames()) {
       newEntity.addProperty(DataCreator.createPrimitive(keyName, newKey.get(keyName)));
@@ -154,17 +149,19 @@ public class DataProvider {
     // Weak key construction
     final HashMap<String, Object> keys = new HashMap<String, Object>();
     for (final String keyName : entityType.getKeyPredicateNames()) {
-      final EdmType type = entityType.getProperty(keyName).getType();
+      final FullQualifiedName typeName = entityType.getProperty(keyName).getType().getFullQualifiedName();
       Object newValue = null;
 
-      if (type instanceof EdmInt16 || type instanceof EdmInt32 || type instanceof EdmInt64) {
+      if (EdmPrimitiveTypeKind.Int16.getFullQualifiedName().equals(typeName)
+          || EdmPrimitiveTypeKind.Int32.getFullQualifiedName().equals(typeName)
+          || EdmPrimitiveTypeKind.Int64.getFullQualifiedName().equals(typeName)) {
         // Integer keys
         newValue = Integer.valueOf(1);
 
         while (!isFree(newValue, keyName, entities)) {
           newValue = ((Integer) newValue) + 1;
         }
-      } else if (type instanceof EdmString) {
+      } else if (EdmPrimitiveTypeKind.String.getFullQualifiedName().equals(typeName)) {
         // String keys
         newValue = String.valueOf(1);
         int i = 0;
@@ -431,7 +428,7 @@ public class DataProvider {
 
   private ComplexValue createComplexValue(final EdmProperty edmProperty, final ComplexValue complexValue,
       final boolean patch) throws DataProviderException {
-    final ComplexValueImpl result = new ComplexValueImpl();
+    final ComplexValue result = new ComplexValue();
     final EdmComplexType edmType = (EdmComplexType) edmProperty.getType();
     final List<Property> givenProperties = complexValue.getValue();
 
@@ -446,7 +443,7 @@ public class DataProvider {
         updateProperty(innerEdmProperty, newProperty, currentProperty, patch);
       } else {
         if (innerEdmProperty.isNullable()) {
-          // Check complex properties ... maybe null is not allowed
+          // Check complex properties ... may be null is not allowed
           if (edmProperty.getType().getKind() == EdmTypeKind.COMPLEX) {
             updateProperty(innerEdmProperty, newProperty, null, patch);
           }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
index 5451d5d..1028cd8 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
@@ -6,9 +6,9 @@
  * 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 WARRANTIES OR CONDITIONS OF ANY
@@ -27,8 +27,7 @@ import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.core.data.EntitySetImpl;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
+import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.uri.UriParameter;
 import org.apache.olingo.server.tecsvc.data.DataProvider.DataProviderException;
 
@@ -38,7 +37,7 @@ public class FunctionData {
       final Map<String, EntitySet> data) throws DataProviderException {
     if (name.equals("UFCRTCollETTwoKeyNavParam")) {
       final List<Entity> esTwoKeyNav = data.get("ESTwoKeyNav").getEntities();
-      EntitySet result = new EntitySetImpl();
+      EntitySet result = new EntitySet();
       final int endIndex = parameters.isEmpty() ? 0 : Short.valueOf(parameters.get(0).getText());
       result.getEntities().addAll(
           esTwoKeyNav.subList(0,
@@ -85,15 +84,16 @@ public class FunctionData {
           DataCreator.createPrimitive("PropertyString", "UFCRTCTTwoPrim string value"));
     } else if (name.equals("UFCRTCTTwoPrimParam")) {
       try {
+
+        OData oData = OData.newInstance();
         return DataCreator.createComplex(name,
-            DataCreator.createPrimitive("PropertyInt16",
-                EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int16).valueOfString(
-                    getParameterText("ParameterInt16", parameters),
+            DataCreator.createPrimitive("PropertyInt16", oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Int16)
+                .valueOfString(getParameterText("ParameterInt16", parameters),
                     null, null, null, null, null, Short.class)),
-            DataCreator.createPrimitive("PropertyString",
-                EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.String).valueOfString(
-                    EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.String).fromUriLiteral(
-                        getParameterText("ParameterString", parameters)),
+            DataCreator.createPrimitive("PropertyString", oData
+                .createPrimitiveTypeInstance(EdmPrimitiveTypeKind.String)
+                .valueOfString(oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.String)
+                    .fromUriLiteral(getParameterText("ParameterString", parameters)),
                     null, null, null, null, null, String.class)));
       } catch (final EdmPrimitiveTypeException e) {
         throw new DataProviderException("Error in function " + name + ".", e);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
index a2774e3..858963d 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
@@ -34,7 +34,6 @@ import org.apache.olingo.commons.api.http.HttpContentType;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpMethod;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.commons.core.data.EntitySetImpl;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
@@ -77,11 +76,8 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
     EntityProcessor, ActionEntityProcessor, MediaEntityProcessor,
     ActionVoidProcessor {
 
-  private final ServiceMetadata serviceMetadata;
-
   public TechnicalEntityProcessor(final DataProvider dataProvider, ServiceMetadata serviceMetadata) {
-    super(dataProvider);
-    this.serviceMetadata = serviceMetadata;
+    super(dataProvider, serviceMetadata);
   }
 
   @Override
@@ -101,7 +97,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
     } else {
       // Modifying the original entitySet means modifying the "database", so we have to make a shallow
       // copy of the entity set (new EntitySet, but exactly the same data)
-      EntitySet entitySet = new EntitySetImpl();
+      EntitySet entitySet = new EntitySet();
       entitySet.getEntities().addAll(entitySetInitial.getEntities());
 
       // Apply system query options

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
index 8a9968f..303800f 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
@@ -6,9 +6,9 @@
  * 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 WARRANTIES OR CONDITIONS OF ANY
@@ -40,7 +40,6 @@ import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
@@ -82,12 +81,9 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor
     ComplexProcessor, ActionComplexProcessor,
     ComplexCollectionProcessor, ActionComplexCollectionProcessor {
 
-  private final ServiceMetadata serviceMetadata;
-
   public TechnicalPrimitiveComplexProcessor(final DataProvider dataProvider,
       ServiceMetadata serviceMetadata) {
-    super(dataProvider);
-    this.serviceMetadata = serviceMetadata;
+    super(dataProvider, serviceMetadata);
   }
 
   @Override
@@ -251,7 +247,7 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor
                   .build()).getContent());
           break;
         case COMPLEX:
-          response.setContent(serializer.complex(this.serviceMetadata,(EdmComplexType) type, property,
+          response.setContent(serializer.complex(this.serviceMetadata, (EdmComplexType) type, property,
               ComplexSerializerOptions.with().contextURL(contextURL)
                   .expand(expand).select(select)
                   .build()).getContent());
@@ -388,7 +384,7 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor
       final EdmReturnType returnType = resourceParts.get(0) instanceof UriResourceFunction ?
           ((UriResourceFunction) resourceParts.get(0)).getFunction().getReturnType() : null;
       final FixedFormatSerializer serializer = odata.createFixedFormatSerializer();
-      response.setContent(type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Binary) ?
+      response.setContent(type == odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Binary) ?
           serializer.binary((byte[]) property.getValue()) :
           serializer.primitiveValue(type, property.getValue(),
               PrimitiveValueSerializerOptions.with()

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
index 4fb2e5e..33cd98f 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
@@ -54,6 +54,11 @@ public abstract class TechnicalProcessor implements Processor {
   protected TechnicalProcessor(final DataProvider dataProvider) {
     this.dataProvider = dataProvider;
   }
+  
+  protected TechnicalProcessor(final DataProvider dataProvider, ServiceMetadata serviceMetadata) {
+    this.dataProvider = dataProvider;
+    this.serviceMetadata = serviceMetadata;
+  }
 
   @Override
   public void init(final OData odata, final ServiceMetadata serviceMetadata) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java
index ce1b774..e6b9849 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java
@@ -31,9 +31,6 @@ import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.commons.core.data.EntityImpl;
-import org.apache.olingo.commons.core.data.EntitySetImpl;
-import org.apache.olingo.commons.core.data.LinkImpl;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.uri.UriResource;
 import org.apache.olingo.server.api.uri.UriResourceNavigation;
@@ -132,9 +129,7 @@ public class ExpandSystemQueryOptionHandler {
   
   public Entity transformEntityGraphToTree(final Entity entity, EdmBindingTarget edmEntitySet, 
       final ExpandOption expand) throws ODataApplicationException {
-
     final Entity newEntity = newEntity(entity);
-
     if (hasExpandItems(expand)) {
       final boolean expandAll = expandAll(expand);
       final Set<String> expanded = expandAll ? null : getExpandedPropertyNames(expand.getExpandItems());
@@ -167,7 +162,7 @@ public class ExpandSystemQueryOptionHandler {
   }
   
   public EntitySet newEntitySet(final EntitySet entitySet) {
-    final EntitySet newEntitySet = new EntitySetImpl();
+    final EntitySet newEntitySet = new EntitySet();
     newEntitySet.setCount(entitySet.getCount());
     newEntitySet.setDeltaLink(entitySet.getDeltaLink());
     newEntitySet.setNext(entitySet.getNext());
@@ -176,7 +171,7 @@ public class ExpandSystemQueryOptionHandler {
   }
   
   private Entity newEntity(final Entity entity) {
-    final Entity newEntity = new EntityImpl();
+    final Entity newEntity = new Entity();
     
     newEntity.getProperties().addAll(entity.getProperties());
     newEntity.getAnnotations().addAll(entity.getAnnotations());
@@ -195,7 +190,7 @@ public class ExpandSystemQueryOptionHandler {
   }
   
   private Link newLink(Link link) {
-    final Link newLink = new LinkImpl();
+    final Link newLink = new Link();
     newLink.setMediaETag(link.getMediaETag());
     newLink.setTitle(link.getTitle());
     newLink.setType(link.getType());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operand/TypedOperand.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operand/TypedOperand.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operand/TypedOperand.java
index d45e8a9..6391390 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operand/TypedOperand.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operand/TypedOperand.java
@@ -26,14 +26,6 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.commons.api.edm.EdmType;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmByte;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDecimal;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmInt16;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmInt32;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmInt64;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmSByte;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmSingle;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.primitive.EdmNull;
 
@@ -73,13 +65,11 @@ public class TypedOperand extends VisitorOperand {
     Object newValue = null;
     for (EdmPrimitiveType asType : asTypes) {
       // Use BigDecimal for unlimited precision
-      if (asType.equals(EdmDouble.getInstance())
-          || asType.equals(EdmSingle.getInstance())
-          || asType.equals(EdmDecimal.getInstance())) {
-        
+      if (asType.equals(primDouble) || asType.equals(primSingle) || asType.equals(primDecimal)) {
+
         try {
           newValue = new BigDecimal(value.toString());
-        } catch(NumberFormatException e) {
+        } catch (NumberFormatException e) {
           // Nothing to do
         }
       } else {
@@ -117,18 +107,18 @@ public class TypedOperand extends VisitorOperand {
       return this;
     }
 
-    if (type.equals(EdmDouble.getInstance()) || oType.equals(EdmDouble.getInstance())) {
-      return asTypedOperand(EdmDouble.getInstance());
-    } else if (type.equals(EdmSingle.getInstance()) || oType.equals(EdmSingle.getInstance())) {
-      return asTypedOperand(EdmSingle.getInstance());
-    } else if (type.equals(EdmDecimal.getInstance()) || oType.equals(EdmDecimal.getInstance())) {
-      return asTypedOperand(EdmDecimal.getInstance());
-    } else if (type.equals(EdmInt64.getInstance()) || oType.equals(EdmInt64.getInstance())) {
-      return asTypedOperand(EdmInt64.getInstance());
-    } else if (type.equals(EdmInt32.getInstance()) || oType.equals(EdmInt32.getInstance())) {
-      return asTypedOperand(EdmInt32.getInstance());
-    } else if (type.equals(EdmInt16.getInstance()) || oType.equals(EdmInt16.getInstance())) {
-      return asTypedOperand(EdmInt16.getInstance());
+    if (type.equals(primDouble) || oType.equals(primDouble)) {
+      return asTypedOperand(primDouble);
+    } else if (type.equals(primSingle) || oType.equals(primSingle)) {
+      return asTypedOperand(primSingle);
+    } else if (type.equals(primDecimal) || oType.equals(primDecimal)) {
+      return asTypedOperand(primDecimal);
+    } else if (type.equals(primInt64) || oType.equals(primInt64)) {
+      return asTypedOperand(primInt64);
+    } else if (type.equals(primInt32) || oType.equals(primInt32)) {
+      return asTypedOperand(primInt32);
+    } else if (type.equals(primInt16) || oType.equals(primInt16)) {
+      return asTypedOperand(primInt16);
     } else {
       return asTypedOperand((EdmPrimitiveType) type);
     }
@@ -151,17 +141,19 @@ public class TypedOperand extends VisitorOperand {
   }
 
   public boolean isIntegerType() {
-    return is(EdmByte.getInstance(),
-        EdmSByte.getInstance(),
-        EdmInt16.getInstance(),
-        EdmInt32.getInstance(),
-        EdmInt64.getInstance());
+    return is(
+        primByte,
+        primSByte,
+        primInt16,
+        primInt32,
+        primInt64);
   }
 
   public boolean isDecimalType() {
-    return is(EdmSingle.getInstance(),
-        EdmDouble.getInstance(),
-        EdmDecimal.getInstance());
+    return is(
+        primSingle,
+        primDouble,
+        primDecimal);
   }
 
   public boolean is(EdmPrimitiveType... types) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operand/UntypedOperand.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operand/UntypedOperand.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operand/UntypedOperand.java
index ddb33af..f9652da 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operand/UntypedOperand.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operand/UntypedOperand.java
@@ -23,20 +23,6 @@ import java.util.Locale;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
 import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmBoolean;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmByte;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDate;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDateTimeOffset;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDecimal;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDuration;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmInt16;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmInt32;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmInt64;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmSByte;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmSingle;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmString;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmTimeOfDay;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.primitive.EdmNull;
 
@@ -84,65 +70,65 @@ public class UntypedOperand extends VisitorOperand {
     }
 
     // String
-    if ((newValue = tryCast(literal, EdmString.getInstance())) != null) {
-      return new TypedOperand(newValue, EdmString.getInstance());
+    if ((newValue = tryCast(literal, primString)) != null) {
+      return new TypedOperand(newValue, primString);
     }
 
     // Boolean
-    if ((newValue = tryCast(literal, EdmBoolean.getInstance())) != null) {
-      return new TypedOperand(newValue, EdmBoolean.getInstance());
+    if ((newValue = tryCast(literal, primBoolean)) != null) {
+      return new TypedOperand(newValue, primBoolean);
     }
 
     // Date
-    if ((newValue = tryCast(literal, EdmDateTimeOffset.getInstance())) != null) {
-      return new TypedOperand(newValue, EdmDateTimeOffset.getInstance());
+    if ((newValue = tryCast(literal, primDateTimeOffset)) != null) {
+      return new TypedOperand(newValue, primDateTimeOffset);
     }
 
-    if ((newValue = tryCast(literal, EdmDate.getInstance())) != null) {
-      return new TypedOperand(newValue, EdmDate.getInstance());
+    if ((newValue = tryCast(literal, primDate)) != null) {
+      return new TypedOperand(newValue, primDate);
     }
 
-    if ((newValue = tryCast(literal, EdmTimeOfDay.getInstance())) != null) {
-      return new TypedOperand(newValue, EdmTimeOfDay.getInstance());
+    if ((newValue = tryCast(literal, primTimeOfDay)) != null) {
+      return new TypedOperand(newValue, primTimeOfDay);
     }
 
-    if ((newValue = tryCast(literal, EdmDuration.getInstance())) != null) {
-      return new TypedOperand(newValue, EdmDuration.getInstance());
+    if ((newValue = tryCast(literal, primDuration)) != null) {
+      return new TypedOperand(newValue, primDuration);
     }
 
     // Integer
-    if ((newValue = tryCast(literal, EdmSByte.getInstance())) != null) {
-      return new TypedOperand(newValue, EdmSByte.getInstance());
+    if ((newValue = tryCast(literal, primSByte)) != null) {
+      return new TypedOperand(newValue, primSByte);
     }
 
-    if ((newValue = tryCast(literal, EdmByte.getInstance())) != null) {
-      return new TypedOperand(newValue, EdmByte.getInstance());
+    if ((newValue = tryCast(literal, primByte)) != null) {
+      return new TypedOperand(newValue, primByte);
     }
 
-    if ((newValue = tryCast(literal, EdmInt16.getInstance())) != null) {
-      return new TypedOperand(newValue, EdmInt16.getInstance());
+    if ((newValue = tryCast(literal, primInt16)) != null) {
+      return new TypedOperand(newValue, primInt16);
     }
 
-    if ((newValue = tryCast(literal, EdmInt32.getInstance())) != null) {
-      return new TypedOperand(newValue, EdmInt32.getInstance());
+    if ((newValue = tryCast(literal, primInt32)) != null) {
+      return new TypedOperand(newValue, primInt32);
     }
 
-    if ((newValue = tryCast(literal, EdmInt64.getInstance())) != null) {
-      return new TypedOperand(newValue, EdmInt64.getInstance());
+    if ((newValue = tryCast(literal, primInt64)) != null) {
+      return new TypedOperand(newValue, primInt64);
     }
 
     // Decimal
-    if ((newValue = tryCast(literal, EdmDecimal.getInstance())) != null) {
-      return new TypedOperand(newValue, EdmDecimal.getInstance());
+    if ((newValue = tryCast(literal, primDecimal)) != null) {
+      return new TypedOperand(newValue, primDecimal);
     }
 
     // Float
-    if ((newValue = tryCast(literal, EdmSingle.getInstance())) != null) {
-      return new TypedOperand(newValue, EdmSingle.getInstance());
+    if ((newValue = tryCast(literal, primSingle)) != null) {
+      return new TypedOperand(newValue, primSingle);
     }
 
-    if ((newValue = tryCast(literal, EdmDouble.getInstance())) != null) {
-      return new TypedOperand(newValue, EdmDouble.getInstance());
+    if ((newValue = tryCast(literal, primDouble)) != null) {
+      return new TypedOperand(newValue, primDouble);
     }
 
     throw new ODataApplicationException("Could not determine type for literal " + literal,

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operand/VisitorOperand.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operand/VisitorOperand.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operand/VisitorOperand.java
index ed9f60e..5c0e65a 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operand/VisitorOperand.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operand/VisitorOperand.java
@@ -24,32 +24,57 @@ import java.util.HashMap;
 
 import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.commons.api.edm.EdmType;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmByte;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDecimal;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmInt16;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmInt32;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmInt64;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmSByte;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmSingle;
+import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataApplicationException;
 
 public abstract class VisitorOperand {
   final static private HashMap<EdmType, Class<?>> defaultTypeMapping = new HashMap<EdmType, Class<?>>();
   protected Object value;
+  protected static final OData oData;
+  protected static final EdmPrimitiveType primString;
+  protected static final EdmPrimitiveType primBoolean;
+  protected static final EdmPrimitiveType primDateTimeOffset;
+  protected static final EdmPrimitiveType primDate;
+  protected static final EdmPrimitiveType primTimeOfDay;
+  protected static final EdmPrimitiveType primDuration;
+  protected static final EdmPrimitiveType primSByte;
+  protected static final EdmPrimitiveType primByte;
+  protected static final EdmPrimitiveType primInt16;
+  protected static final EdmPrimitiveType primInt32;
+  protected static final EdmPrimitiveType primInt64;
+  protected static final EdmPrimitiveType primDecimal;
+  protected static final EdmPrimitiveType primSingle;
+  protected static final EdmPrimitiveType primDouble;
 
   static {
-    defaultTypeMapping.put(EdmByte.getInstance(), BigInteger.class);
-    defaultTypeMapping.put(EdmSByte.getInstance(), BigInteger.class);
-    defaultTypeMapping.put(EdmInt16.getInstance(), BigInteger.class);
-    defaultTypeMapping.put(EdmInt32.getInstance(), BigInteger.class);
-    defaultTypeMapping.put(EdmInt64.getInstance(), BigInteger.class);
+    oData = OData.newInstance();
+    primString = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.String);
+    primBoolean = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Boolean);
+    primDateTimeOffset = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.DateTimeOffset);
+    primDate = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Date);
+    primTimeOfDay = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.TimeOfDay);
+    primDuration = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Duration);
+    primSByte = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.SByte);
+    primByte = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Byte);
+    primInt16 = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Int16);
+    primInt32 = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Int32);
+    primInt64 = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Int64);
+    primDecimal = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Decimal);
+    primSingle = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Single);
+    primDouble = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Double);
+    
+    defaultTypeMapping.put(primByte, BigInteger.class);
+    defaultTypeMapping.put(primSByte, BigInteger.class);
+    defaultTypeMapping.put(primInt16, BigInteger.class);
+    defaultTypeMapping.put(primInt32, BigInteger.class);
+    defaultTypeMapping.put(primInt64, BigInteger.class);
 
-    defaultTypeMapping.put(EdmSingle.getInstance(), BigDecimal.class);
-    defaultTypeMapping.put(EdmDouble.getInstance(), BigDecimal.class);
-    defaultTypeMapping.put(EdmDecimal.getInstance(), BigDecimal.class);
+    defaultTypeMapping.put(primSingle, BigDecimal.class);
+    defaultTypeMapping.put(primDouble, BigDecimal.class);
+    defaultTypeMapping.put(primDecimal, BigDecimal.class);
   }
 
   public VisitorOperand(Object value) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operation/BinaryOperator.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operation/BinaryOperator.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operation/BinaryOperator.java
index 9d9e23f..6d49243 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operation/BinaryOperator.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operation/BinaryOperator.java
@@ -24,19 +24,11 @@ import java.sql.Timestamp;
 import java.util.Calendar;
 import java.util.Locale;
 
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.EdmType;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmBoolean;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmByte;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDate;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDateTimeOffset;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDuration;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmInt16;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmInt32;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmInt64;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmSByte;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmSingle;
+import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;
 import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.operand.TypedOperand;
@@ -62,6 +54,40 @@ public class BinaryOperator {
   private static final int EQUALS = 0;
   private static final int LESS_THAN = -1;
   private static final int GREATER_THAN = 1;
+  
+  protected static final OData oData;
+  protected static final EdmPrimitiveType primString;
+  protected static final EdmPrimitiveType primBoolean;
+  protected static final EdmPrimitiveType primDateTimeOffset;
+  protected static final EdmPrimitiveType primDate;
+  protected static final EdmPrimitiveType primTimeOfDay;
+  protected static final EdmPrimitiveType primDuration;
+  protected static final EdmPrimitiveType primSByte;
+  protected static final EdmPrimitiveType primByte;
+  protected static final EdmPrimitiveType primInt16;
+  protected static final EdmPrimitiveType primInt32;
+  protected static final EdmPrimitiveType primInt64;
+  protected static final EdmPrimitiveType primDecimal;
+  protected static final EdmPrimitiveType primSingle;
+  protected static final EdmPrimitiveType primDouble;
+
+  static {
+    oData = OData.newInstance();
+    primString = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.String);
+    primBoolean = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Boolean);
+    primDateTimeOffset = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.DateTimeOffset);
+    primDate = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Date);
+    primTimeOfDay = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.TimeOfDay);
+    primDuration = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Duration);
+    primSByte = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.SByte);
+    primByte = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Byte);
+    primInt16 = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Int16);
+    primInt32 = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Int32);
+    primInt64 = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Int64);
+    primDecimal = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Decimal);
+    primSingle = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Single);
+    primDouble = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Double);
+  }
 
   private TypedOperand right;
   private TypedOperand left;
@@ -77,14 +103,14 @@ public class BinaryOperator {
 
   public VisitorOperand andOperator() throws ODataApplicationException {
     Boolean result = null;
-    if (left.is(EdmBoolean.getInstance()) && right.is(EdmBoolean.getInstance())) {
+    if (left.is(primBoolean) && right.is(primBoolean)) {
       if (Boolean.TRUE.equals(left.getValue()) && Boolean.TRUE.equals(right.getValue())) {
         result = true;
       } else if (Boolean.FALSE.equals(left.getValue()) || Boolean.FALSE.equals(right.getValue())) {
         result = false;
       }
 
-      return new TypedOperand(result, EdmBoolean.getInstance());
+      return new TypedOperand(result, primBoolean);
     } else {
       throw new ODataApplicationException("Add operator needs two binary operands",
           HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ROOT);
@@ -93,14 +119,14 @@ public class BinaryOperator {
 
   public VisitorOperand orOperator() throws ODataApplicationException {
     Boolean result = null;
-    if (left.is(EdmBoolean.getInstance()) && right.is(EdmBoolean.getInstance())) {
+    if (left.is(primBoolean) && right.is(primBoolean)) {
       if (Boolean.TRUE.equals(left.getValue()) || Boolean.TRUE.equals(right.getValue())) {
         result = true;
       } else if (Boolean.FALSE.equals(left.getValue()) && Boolean.FALSE.equals(right.getValue())) {
         result = false;
       }
 
-      return new TypedOperand(result, EdmBoolean.getInstance());
+      return new TypedOperand(result, primBoolean);
     } else {
       throw new ODataApplicationException("Or operator needs two binary operands",
           HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ROOT);
@@ -109,12 +135,12 @@ public class BinaryOperator {
 
   public VisitorOperand equalsOperator() {
     final boolean result = isBinaryComparisonNecessary() && binaryComparison(EQUALS);
-    return new TypedOperand(result, EdmBoolean.getInstance());
+    return new TypedOperand(result, primBoolean);
   }
 
   public VisitorOperand notEqualsOperator() {
     final VisitorOperand equalsOperator = equalsOperator();
-    return new TypedOperand(!(Boolean) equalsOperator.getValue(), EdmBoolean.getInstance());
+    return new TypedOperand(!(Boolean) equalsOperator.getValue(), primBoolean);
   }
 
   private boolean isBinaryComparisonNecessary() {
@@ -124,22 +150,22 @@ public class BinaryOperator {
 
   public VisitorOperand greaterEqualsOperator() {
     final boolean result = isBinaryComparisonNecessary() && binaryComparison(GREATER_THAN, EQUALS);
-    return new TypedOperand(result, EdmBoolean.getInstance());
+    return new TypedOperand(result, primBoolean);
   }
 
   public VisitorOperand greaterThanOperator() {
     final boolean result = isBinaryComparisonNecessary() && binaryComparison(GREATER_THAN);
-    return new TypedOperand(result, EdmBoolean.getInstance());
+    return new TypedOperand(result, primBoolean);
   }
 
   public VisitorOperand lessEqualsOperator() {
     final boolean result = isBinaryComparisonNecessary() && binaryComparison(LESS_THAN, EQUALS);
-    return new TypedOperand(result, EdmBoolean.getInstance());
+    return new TypedOperand(result, primBoolean);
   }
 
   public VisitorOperand lessThanOperator() {
     final boolean result = isBinaryComparisonNecessary() && binaryComparison(LESS_THAN);
-    return new TypedOperand(result, EdmBoolean.getInstance());
+    return new TypedOperand(result, primBoolean);
   }
 
   private boolean binaryComparison(int... expect) {
@@ -176,7 +202,7 @@ public class BinaryOperator {
       } else if (left.isDecimalType()) {
         final BigDecimal result = decimalArithmeticOperation(operator);
         return new TypedOperand(result, determineResultType(result, left));
-      } else if (left.is(EdmDate.getInstance(), EdmDuration.getInstance(), EdmDateTimeOffset.getInstance())) {
+      } else if (left.is(primDate, primDuration, primDateTimeOffset)) {
         return dateArithmeticOperation(operator);
       } else {
         throw new ODataApplicationException("Invalid type", HttpStatusCode.BAD_REQUEST.getStatusCode(),
@@ -190,81 +216,81 @@ public class BinaryOperator {
     if (leftOperand.isDecimalType()) {
       final BigDecimal value = (BigDecimal) arithmeticResult;
       if (value.compareTo(EDM_SINGLE_MIN) >= 0 && value.compareTo(EDM_SINGLE_MAX) <= 0) {
-        return EdmSingle.getInstance();
+        return primSingle;
       } else {
-        return EdmDouble.getInstance();
+        return primDouble;
       }
     } else {
       final BigInteger value = (BigInteger) arithmeticResult;
 
       if (value.compareTo(EDN_SBYTE_MAX) <= 0 && value.compareTo(EDM_SBYTE_MIN) >= 0) {
-        return EdmSByte.getInstance();
+        return primSByte;
       }
       if (value.compareTo(EDM_BYTE_MAX) <= 0 && value.compareTo(EDM_BYTE_MIN) >= 0) {
-        return EdmByte.getInstance();
+        return primByte;
       }
       if (value.compareTo(EDM_INT16_MAX) <= 0 && value.compareTo(EDM_INT16_MIN) >= 0) {
-        return EdmInt16.getInstance();
+        return primInt16;
       }
       if (value.compareTo(EDM_INT32_MAX) <= 0 && value.compareTo(EDM_INT32_MIN) >= 0) {
-        return EdmInt32.getInstance();
+        return primInt32;
       }
       if (value.compareTo(EDM_INT64_MAX) <= 0 && value.compareTo(EDM_INT64_MIN) >= 0) {
-        return EdmInt64.getInstance();
+        return primInt64;
       }
       // Choose double instead single because precision is higher (52 bits instead of 23)
-      return EdmDouble.getInstance();
+      return primDouble;
     }
   }
 
   private VisitorOperand dateArithmeticOperation(BinaryOperatorKind operator) throws ODataApplicationException {
     VisitorOperand result = null;
 
-    if (left.is(EdmDate.getInstance())) {
-      if (right.is(EdmDate.getInstance()) && operator == BinaryOperatorKind.SUB) {
+    if (left.is(primDate)) {
+      if (right.is(primDate) && operator == BinaryOperatorKind.SUB) {
         long millis = left.getTypedValue(Calendar.class).getTimeInMillis()
             - left.getTypedValue(Calendar.class).getTimeInMillis();
 
-        result = new TypedOperand(new BigDecimal(millis).divide(FACTOR_SECOND), EdmDuration.getInstance());
-      } else if (right.is(EdmDuration.getInstance()) && operator == BinaryOperatorKind.ADD) {
+        result = new TypedOperand(new BigDecimal(millis).divide(FACTOR_SECOND), primDuration);
+      } else if (right.is(primDuration) && operator == BinaryOperatorKind.ADD) {
         long millis = left.getTypedValue(Calendar.class).getTimeInMillis()
             + (right.getTypedValue(BigDecimal.class).longValue() * FACTOR_SECOND_INT);
 
-        result = new TypedOperand(new Timestamp(millis), EdmDateTimeOffset.getInstance());
-      } else if (right.is(EdmDuration.getInstance()) && operator == BinaryOperatorKind.SUB) {
+        result = new TypedOperand(new Timestamp(millis), primDateTimeOffset);
+      } else if (right.is(primDuration) && operator == BinaryOperatorKind.SUB) {
         long millis = left.getTypedValue(Calendar.class).getTimeInMillis()
             - (right.getTypedValue(BigDecimal.class).longValue() * FACTOR_SECOND_INT);
 
-        result = new TypedOperand(new Timestamp(millis), EdmDateTimeOffset.getInstance());
+        result = new TypedOperand(new Timestamp(millis), primDateTimeOffset);
       }
-    } else if (left.is(EdmDuration.getInstance())) {
-      if (right.is(EdmDuration.getInstance()) && operator == BinaryOperatorKind.ADD) {
+    } else if (left.is(primDuration)) {
+      if (right.is(primDuration) && operator == BinaryOperatorKind.ADD) {
         long seconds = left.getTypedValue(BigDecimal.class).longValue()
             + right.getTypedValue(BigDecimal.class).longValue();
 
-        result = new TypedOperand(new BigDecimal(seconds), EdmDuration.getInstance());
-      } else if (right.is(EdmDuration.getInstance()) && operator == BinaryOperatorKind.SUB) {
+        result = new TypedOperand(new BigDecimal(seconds), primDuration);
+      } else if (right.is(primDuration) && operator == BinaryOperatorKind.SUB) {
         long seconds = left.getTypedValue(BigDecimal.class).longValue()
             - right.getTypedValue(BigDecimal.class).longValue();
 
-        result = new TypedOperand(new BigDecimal(seconds), EdmDuration.getInstance());
+        result = new TypedOperand(new BigDecimal(seconds), primDuration);
       }
-    } else if (left.is(EdmDateTimeOffset.getInstance())) {
-      if (right.is(EdmDuration.getInstance()) && operator == BinaryOperatorKind.ADD) {
+    } else if (left.is(primDateTimeOffset)) {
+      if (right.is(primDuration) && operator == BinaryOperatorKind.ADD) {
         long millis = left.getTypedValue(Timestamp.class).getTime()
             + (right.getTypedValue(BigDecimal.class).longValue() * FACTOR_SECOND_INT);
 
-        result = new TypedOperand(new Timestamp(millis), EdmDateTimeOffset.getInstance());
-      } else if (right.is(EdmDuration.getInstance()) && operator == BinaryOperatorKind.SUB) {
+        result = new TypedOperand(new Timestamp(millis), primDateTimeOffset);
+      } else if (right.is(primDuration) && operator == BinaryOperatorKind.SUB) {
         long millis = left.getTypedValue(Timestamp.class).getTime()
             - (right.getTypedValue(BigDecimal.class).longValue() * FACTOR_SECOND_INT);
 
-        result = new TypedOperand(new Timestamp(millis), EdmDateTimeOffset.getInstance());
-      } else if (right.is(EdmDateTimeOffset.getInstance()) && operator == BinaryOperatorKind.SUB) {
+        result = new TypedOperand(new Timestamp(millis), primDateTimeOffset);
+      } else if (right.is(primDateTimeOffset) && operator == BinaryOperatorKind.SUB) {
         long millis = left.getTypedValue(Timestamp.class).getTime()
             - right.getTypedValue(Timestamp.class).getTime();
 
-        result = new TypedOperand(new BigDecimal(millis).divide(FACTOR_SECOND), EdmDuration.getInstance());
+        result = new TypedOperand(new BigDecimal(millis).divide(FACTOR_SECOND), primDuration);
       }
     }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operation/MethodCallOperator.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operation/MethodCallOperator.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operation/MethodCallOperator.java
index 62fbb6d..5f8575b 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operation/MethodCallOperator.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operation/MethodCallOperator.java
@@ -30,21 +30,50 @@ import java.util.Locale;
 import java.util.TimeZone;
 
 import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.EdmType;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmBoolean;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDate;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDateTimeOffset;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDecimal;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmInt32;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmString;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmTimeOfDay;
+import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.operand.TypedOperand;
 import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.operand.VisitorOperand;
 
 public class MethodCallOperator {
 
+  protected static final OData oData;
+  protected static final EdmPrimitiveType primString;
+  protected static final EdmPrimitiveType primBoolean;
+  protected static final EdmPrimitiveType primDateTimeOffset;
+  protected static final EdmPrimitiveType primDate;
+  protected static final EdmPrimitiveType primTimeOfDay;
+  protected static final EdmPrimitiveType primDuration;
+  protected static final EdmPrimitiveType primSByte;
+  protected static final EdmPrimitiveType primByte;
+  protected static final EdmPrimitiveType primInt16;
+  protected static final EdmPrimitiveType primInt32;
+  protected static final EdmPrimitiveType primInt64;
+  protected static final EdmPrimitiveType primDecimal;
+  protected static final EdmPrimitiveType primSingle;
+  protected static final EdmPrimitiveType primDouble;
+
+  static {
+    oData = OData.newInstance();
+    primString = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.String);
+    primBoolean = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Boolean);
+    primDateTimeOffset = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.DateTimeOffset);
+    primDate = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Date);
+    primTimeOfDay = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.TimeOfDay);
+    primDuration = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Duration);
+    primSByte = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.SByte);
+    primByte = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Byte);
+    primInt16 = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Int16);
+    primInt32 = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Int32);
+    primInt64 = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Int64);
+    primDecimal = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Decimal);
+    primSingle = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Single);
+    primDouble = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Double);
+  }
+  
   final private List<VisitorOperand> parameters;
 
   public MethodCallOperator(List<VisitorOperand> parameters) {
@@ -57,7 +86,7 @@ public class MethodCallOperator {
       public Object perform(List<String> params) {
         return params.get(0).endsWith(params.get(1));
       }
-    }, EdmBoolean.getInstance());
+    }, primBoolean);
   }
 
   public VisitorOperand indexOf() throws ODataApplicationException {
@@ -67,7 +96,7 @@ public class MethodCallOperator {
         // If the first string do not contain the second string, return -1. See OASIS JIRA ODATA-780
         return params.get(0).indexOf(params.get(1));
       }
-    }, EdmInt32.getInstance());
+    }, primInt32);
   }
 
   public VisitorOperand startsWith() throws ODataApplicationException {
@@ -76,7 +105,7 @@ public class MethodCallOperator {
       public Object perform(List<String> params) {
         return params.get(0).startsWith(params.get(1));
       }
-    }, EdmBoolean.getInstance());
+    }, primBoolean);
   }
 
   public VisitorOperand toLower() throws ODataApplicationException {
@@ -85,7 +114,7 @@ public class MethodCallOperator {
       public Object perform(List<String> params) {
         return params.get(0).toLowerCase();
       }
-    }, EdmString.getInstance());
+    }, primString);
   }
 
   public VisitorOperand toUpper() throws ODataApplicationException {
@@ -94,7 +123,7 @@ public class MethodCallOperator {
       public Object perform(List<String> params) {
         return params.get(0).toUpperCase();
       }
-    }, EdmString.getInstance());
+    }, primString);
   }
 
   public VisitorOperand trim() throws ODataApplicationException {
@@ -103,7 +132,7 @@ public class MethodCallOperator {
       public Object perform(List<String> params) {
         return params.get(0).trim();
       }
-    }, EdmString.getInstance());
+    }, primString);
   }
 
   public VisitorOperand substring() throws ODataApplicationException {
@@ -113,8 +142,8 @@ public class MethodCallOperator {
     final TypedOperand startOperand = parameters.get(1).asTypedOperand();
 
     if (valueOperand.isNull() || startOperand.isNull()) {
-      return new TypedOperand(null, EdmString.getInstance());
-    } else if (valueOperand.is(EdmString.getInstance()) && startOperand.isIntegerType()) {
+      return new TypedOperand(null, primString);
+    } else if (valueOperand.is(primString) && startOperand.isIntegerType()) {
       final String value = valueOperand.getTypedValue(String.class);
       int start = Math.min(startOperand.getTypedValue(BigInteger.class).intValue(), value.length());
       start = start < 0 ? 0 : start;
@@ -125,7 +154,7 @@ public class MethodCallOperator {
         final TypedOperand lengthOperand = parameters.get(2).asTypedOperand();
 
         if (lengthOperand.isNull()) {
-          return new TypedOperand(null, EdmString.getInstance());
+          return new TypedOperand(null, primString);
         } else if (lengthOperand.isIntegerType()) {
           end = Math.min(start + lengthOperand.getTypedValue(BigInteger.class).intValue(), value.length());
           end = end < 0 ? 0 : end;
@@ -136,7 +165,7 @@ public class MethodCallOperator {
       }
 
       return new TypedOperand(value.substring(start, end),
-          EdmString.getInstance());
+          primString);
     } else {
       throw new ODataApplicationException("Substring has invalid parameters. First parameter should be Edm.String,"
           + " second parameter should be Edm.Int32", HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ROOT);
@@ -149,7 +178,7 @@ public class MethodCallOperator {
       public Object perform(List<String> params) {
         return params.get(0).contains(params.get(1));
       }
-    }, EdmBoolean.getInstance());
+    }, primBoolean);
   }
 
   public VisitorOperand concat() throws ODataApplicationException {
@@ -158,7 +187,7 @@ public class MethodCallOperator {
       public Object perform(List<String> params) {
         return params.get(0) + params.get(1);
       }
-    }, EdmString.getInstance());
+    }, primString);
   }
 
   public VisitorOperand length() throws ODataApplicationException {
@@ -167,7 +196,7 @@ public class MethodCallOperator {
       public Object perform(List<String> params) {
         return params.get(0).length();
       }
-    }, EdmInt32.getInstance());
+    }, primInt32);
   }
 
   public VisitorOperand year() throws ODataApplicationException {
@@ -176,7 +205,7 @@ public class MethodCallOperator {
       public Object perform(Calendar calendar, TypedOperand operand) {
         return calendar.get(Calendar.YEAR);
       }
-    }, EdmInt32.getInstance(), EdmDateTimeOffset.getInstance(), EdmDate.getInstance());
+    }, primInt32, primDateTimeOffset, primDate);
   }
 
   public VisitorOperand month() throws ODataApplicationException {
@@ -186,7 +215,7 @@ public class MethodCallOperator {
         // Month is 0-based!
         return calendar.get(Calendar.MONTH) + 1;
       }
-    }, EdmInt32.getInstance(), EdmDateTimeOffset.getInstance(), EdmDate.getInstance());
+    }, primInt32, primDateTimeOffset, primDate);
   }
 
   public VisitorOperand day() throws ODataApplicationException {
@@ -195,7 +224,7 @@ public class MethodCallOperator {
       public Object perform(Calendar calendar, TypedOperand operand) {
         return calendar.get(Calendar.DAY_OF_MONTH);
       }
-    }, EdmInt32.getInstance(), EdmDateTimeOffset.getInstance(), EdmDate.getInstance());
+    }, primInt32, primDateTimeOffset, primDate);
   }
 
   public VisitorOperand hour() throws ODataApplicationException {
@@ -204,7 +233,7 @@ public class MethodCallOperator {
       public Object perform(Calendar calendar, TypedOperand operand) {
         return calendar.get(Calendar.HOUR_OF_DAY);
       }
-    }, EdmInt32.getInstance(), EdmDateTimeOffset.getInstance(), EdmTimeOfDay.getInstance());
+    }, primInt32, primDateTimeOffset, primTimeOfDay);
   }
 
   public VisitorOperand minute() throws ODataApplicationException {
@@ -213,7 +242,7 @@ public class MethodCallOperator {
       public Object perform(Calendar calendar, TypedOperand operand) {
         return calendar.get(Calendar.MINUTE);
       }
-    }, EdmInt32.getInstance(), EdmDateTimeOffset.getInstance(), EdmTimeOfDay.getInstance());
+    }, primInt32, primDateTimeOffset, primTimeOfDay);
   }
 
   public VisitorOperand second() throws ODataApplicationException {
@@ -222,7 +251,7 @@ public class MethodCallOperator {
       public Object perform(Calendar calendar, TypedOperand operand) {
         return calendar.get(Calendar.SECOND);
       }
-    }, EdmInt32.getInstance(), EdmDateTimeOffset.getInstance(), EdmTimeOfDay.getInstance());
+    }, primInt32, primDateTimeOffset, primTimeOfDay);
   }
 
   public VisitorOperand fractionalseconds() throws ODataApplicationException {
@@ -236,7 +265,7 @@ public class MethodCallOperator {
           return new BigDecimal(calendar.get(Calendar.MILLISECOND)).divide(BigDecimal.valueOf(1000));
         }
       }
-    }, EdmDecimal.getInstance(), EdmDateTimeOffset.getInstance(), EdmTimeOfDay.getInstance());
+    }, primDecimal, primDateTimeOffset, primTimeOfDay);
   }
 
   public VisitorOperand round() throws ODataApplicationException {
@@ -290,13 +319,13 @@ public class MethodCallOperator {
     if (operand.is(expectedTypes)) {
       if (!operand.isNull()) {
         Calendar calendar = null;
-        if (operand.is(EdmDate.getInstance())) {
+        if (operand.is(primDate)) {
           calendar = operand.getTypedValue(Calendar.class);
-        } else if (operand.is(EdmDateTimeOffset.getInstance())) {
+        } else if (operand.is(primDateTimeOffset)) {
           final Timestamp timestamp = operand.getTypedValue(Timestamp.class);
           calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
           calendar.setTimeInMillis(timestamp.getTime());
-        } else if (operand.is(EdmTimeOfDay.getInstance())) {
+        } else if (operand.is(primTimeOfDay)) {
           calendar = operand.getTypedValue(Calendar.class);
         } else {
           throw new ODataApplicationException("Invalid type", HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ROOT);
@@ -327,7 +356,7 @@ public class MethodCallOperator {
       TypedOperand operand = param.asTypedOperand();
       if (operand.isNull()) {
         result.add(null);
-      } else if (operand.is(EdmString.getInstance())) {
+      } else if (operand.is(primString)) {
         result.add(operand.getTypedValue(String.class));
       } else {
         throw new ODataApplicationException("Invalid parameter. Expected Edm.String", HttpStatusCode.BAD_REQUEST

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operation/UnaryOperator.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operation/UnaryOperator.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operation/UnaryOperator.java
index 7f5ba21..5e0c2bc 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operation/UnaryOperator.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/operation/UnaryOperator.java
@@ -23,14 +23,26 @@ import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.util.Locale;
 
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmBoolean;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmDuration;
+import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.operand.TypedOperand;
 import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.operand.VisitorOperand;
 
 public class UnaryOperator {
+  
+  protected static final OData oData;
+  protected static final EdmPrimitiveType primBoolean;
+  protected static final EdmPrimitiveType primDuration;
+
+  static {
+    oData = OData.newInstance();
+    primBoolean = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Boolean);
+    primDuration = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Duration);
+  }
+  
   final private TypedOperand operand;
 
   public UnaryOperator(VisitorOperand operand) throws ODataApplicationException {
@@ -42,7 +54,7 @@ public class UnaryOperator {
       return operand;
     } else if (operand.isIntegerType()) {
       return new TypedOperand(operand.getTypedValue(BigInteger.class).negate(), operand.getType());
-    } else if (operand.isDecimalType() || operand.is(EdmDuration.getInstance())) {
+    } else if (operand.isDecimalType() || operand.is(primDuration)) {
       return new TypedOperand(operand.getTypedValue(BigDecimal.class).negate(), operand.getType());
     } else {
       throw new ODataApplicationException("Unsupported type", HttpStatusCode.BAD_REQUEST.getStatusCode(),
@@ -53,7 +65,7 @@ public class UnaryOperator {
   public VisitorOperand notOperation() throws ODataApplicationException {
     if (operand.isNull()) {
       return operand;
-    } else if (operand.is(EdmBoolean.getInstance())) {
+    } else if (operand.is(primBoolean)) {
       return new TypedOperand(!operand.getTypedValue(Boolean.class), operand.getType());
     } else {
       throw new ODataApplicationException("Unsupported type", HttpStatusCode.BAD_REQUEST.getStatusCode(),

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/primitive/EdmNull.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/primitive/EdmNull.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/primitive/EdmNull.java
index b46aa28..156e2cb 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/primitive/EdmNull.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/primitive/EdmNull.java
@@ -18,11 +18,13 @@
  */
 package org.apache.olingo.server.tecsvc.processor.queryoptions.expression.primitive;
 
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.core.edm.primitivetype.SingletonPrimitiveType;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
 
 
-public final class EdmNull extends SingletonPrimitiveType {
+public final class EdmNull implements EdmPrimitiveType {
   
   private static final EdmNull instance = new EdmNull();
   
@@ -34,8 +36,88 @@ public final class EdmNull extends SingletonPrimitiveType {
   public Class<?> getDefaultType() {
     return Object.class;
   }
+  
+  protected String uriPrefix = "";
+
+  protected String uriSuffix = "";
+
+  @Override
+  public FullQualifiedName getFullQualifiedName() {
+    return new FullQualifiedName(getNamespace(), getName());
+  }
+
+  @Override
+  public boolean isCompatible(final EdmPrimitiveType primitiveType) {
+    return equals(primitiveType);
+  }
+
+  @Override
+  public boolean validate(final String value,
+      final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale,
+      final Boolean isUnicode) {
+
+    try {
+      valueOfString(value, isNullable, maxLength, precision, scale, isUnicode, getDefaultType());
+      return true;
+    } catch (final EdmPrimitiveTypeException e) {
+      return false;
+    }
+  }
+
+  @Override
+  public final <T> T valueOfString(final String value,
+      final Boolean isNullable, final Integer maxLength, final Integer precision,
+      final Integer scale, final Boolean isUnicode, final Class<T> returnType)
+      throws EdmPrimitiveTypeException {
+
+    if (value == null) {
+      if (isNullable != null && !isNullable) {
+        throw new EdmPrimitiveTypeException("The literal 'null' is not allowed.");
+      }
+      return null;
+    }
+    return internalValueOfString(value, isNullable, maxLength, precision, scale, isUnicode, returnType);
+  }
+
+  @Override
+  public final String valueToString(final Object value,
+      final Boolean isNullable, final Integer maxLength, final Integer precision,
+      final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+    if (value == null) {
+      if (isNullable != null && !isNullable) {
+        throw new EdmPrimitiveTypeException("The value NULL is not allowed.");
+      }
+      return null;
+    }
+    return internalValueToString(value, isNullable, maxLength, precision, scale, isUnicode);
+  }
+
+  @Override
+  public String toUriLiteral(final String literal) {
+    return literal == null ? null :
+        uriPrefix.isEmpty() && uriSuffix.isEmpty() ? literal : uriPrefix + literal + uriSuffix;
+  }
 
   @Override
+  public String fromUriLiteral(final String literal) throws EdmPrimitiveTypeException {
+    if (literal == null) {
+      return null;
+    } else if (uriPrefix.isEmpty() && uriSuffix.isEmpty()) {
+      return literal;
+    } else if (literal.length() >= uriPrefix.length() + uriSuffix.length()
+        && literal.startsWith(uriPrefix) && literal.endsWith(uriSuffix)) {
+
+      return literal.substring(uriPrefix.length(), literal.length() - uriSuffix.length());
+    } else {
+      throw new EdmPrimitiveTypeException("The literal '" + literal + "' has illegal content.");
+    }
+  }
+
+  @Override
+  public String toString() {
+    return new FullQualifiedName(getNamespace(), getName()).getFullQualifiedNameAsString();
+  }
+
   protected <T> T internalValueOfString(String value, Boolean isNullable, Integer maxLength, Integer precision,
       Integer scale, Boolean isUnicode, Class<T> returnType) throws EdmPrimitiveTypeException {
     if (!value.equals("null")) {
@@ -49,10 +131,34 @@ public final class EdmNull extends SingletonPrimitiveType {
     }
   }
 
-  @Override
   protected <T> String internalValueToString(T value, Boolean isNullable, Integer maxLength, Integer precision,
       Integer scale, Boolean isUnicode) throws EdmPrimitiveTypeException {
     return "null";
   }
 
+  @Override
+  public boolean equals(final Object obj) {
+    return this == obj || obj != null && getClass() == obj.getClass();
+  }
+
+  @Override
+  public int hashCode() {
+    return getClass().hashCode();
+  }
+
+  @Override
+  public String getNamespace() {
+    return EDM_NAMESPACE;
+  }
+
+  @Override
+  public String getName() {
+    return getClass().getSimpleName().substring(3);
+  }
+
+  @Override
+  public EdmTypeKind getKind() {
+    return EdmTypeKind.PRIMITIVE;
+  }
+  
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/FilterHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/FilterHandler.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/FilterHandler.java
index d4068a1..69fa2e4 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/FilterHandler.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/FilterHandler.java
@@ -24,34 +24,26 @@ import java.util.Locale;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.edm.EdmBindingTarget;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmBoolean;
+import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.uri.queryoption.FilterOption;
 import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException;
 import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.ExpressionVisitorImpl;
-/*
- * 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 WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
 import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.operand.TypedOperand;
 import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.operand.VisitorOperand;
 
 public class FilterHandler {
+  
+  protected static final OData oData;
+  protected static final EdmPrimitiveType primBoolean;
+  
+  static {
+    oData = OData.newInstance();
+    primBoolean = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Boolean);
+  }
 
   public static void applyFilterSystemQuery(FilterOption filterOption, EntitySet entitySet, 
       EdmBindingTarget edmEntitySet) throws ODataApplicationException {
@@ -68,7 +60,7 @@ public class FilterHandler {
             .accept(new ExpressionVisitorImpl(iter.next(), edmEntitySet));
         final TypedOperand typedOperand = operand.asTypedOperand();
 
-        if (!(typedOperand.is(EdmBoolean.getInstance())
+        if (!(typedOperand.is(primBoolean)
         && Boolean.TRUE.equals(typedOperand.getTypedValue(Boolean.class)))) {
           iter.remove();
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/ServerSidePagingHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/ServerSidePagingHandler.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/ServerSidePagingHandler.java
index b5aedac..a945edb 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/ServerSidePagingHandler.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/ServerSidePagingHandler.java
@@ -25,10 +25,10 @@ import java.util.Locale;
 import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.commons.core.Encoder;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.uri.queryoption.SkipTokenOption;
 import org.apache.olingo.server.api.uri.queryoption.SystemQueryOptionKind;
+import org.apache.olingo.server.tecsvc.Encoder;
 
 public class ServerSidePagingHandler {
   private static final int MAX_PAGE_SIZE = 10;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
index f8b1dab..801377e 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
@@ -39,7 +39,6 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
 import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.edmx.EdmxReference;
@@ -615,7 +614,7 @@ public class ODataJsonSerializerTest {
   public void primitivePropertyNull() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
     final EdmProperty edmProperty = (EdmProperty) edmEntitySet.getEntityType().getProperty("PropertyString");
-    final Property property = new PropertyImpl("Edm.String", edmProperty.getName(), ValueType.PRIMITIVE, null);
+    final Property property = new Property("Edm.String", edmProperty.getName(), ValueType.PRIMITIVE, null);
     serializer.primitive((EdmPrimitiveType) edmProperty.getType(), property,
         PrimitiveSerializerOptions.with()
             .contextURL(ContextURL.with()

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/samples/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java
----------------------------------------------------------------------
diff --git a/samples/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java b/samples/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java
index 2e44e35..b8789bd 100644
--- a/samples/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java
+++ b/samples/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java
@@ -33,9 +33,6 @@ import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.EdmProperty;
-import org.apache.olingo.commons.core.data.EntityImpl;
-import org.apache.olingo.commons.core.data.EntitySetImpl;
-import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.server.api.uri.UriParameter;
 import org.apache.olingo.server.sample.edmprovider.CarsEdmProvider;
 
@@ -97,37 +94,37 @@ public class DataProvider {
   }
 
   private EntitySet createCars() {
-    EntitySet entitySet = new EntitySetImpl();
+    EntitySet entitySet = new EntitySet();
 
-    entitySet.getEntities().add(new EntityImpl()
+    entitySet.getEntities().add(new Entity()
         .addProperty(createPrimitive("Id", 1))
         .addProperty(createPrimitive("Model", "F1 W03"))
         .addProperty(createPrimitive("ModelYear", "2012"))
         .addProperty(createPrimitive("Price", 189189.43))
         .addProperty(createPrimitive("Currency", "EUR")));
 
-    entitySet.getEntities().add(new EntityImpl()
+    entitySet.getEntities().add(new Entity()
         .addProperty(createPrimitive("Id", 2))
         .addProperty(createPrimitive("Model", "F1 W04"))
         .addProperty(createPrimitive("ModelYear", "2013"))
         .addProperty(createPrimitive("Price", 199999.99))
         .addProperty(createPrimitive("Currency", "EUR")));
 
-    entitySet.getEntities().add(new EntityImpl()
+    entitySet.getEntities().add(new Entity()
         .addProperty(createPrimitive("Id", 3))
         .addProperty(createPrimitive("Model", "F2012"))
         .addProperty(createPrimitive("ModelYear", "2012"))
         .addProperty(createPrimitive("Price", 137285.33))
         .addProperty(createPrimitive("Currency", "EUR")));
 
-    entitySet.getEntities().add(new EntityImpl()
+    entitySet.getEntities().add(new Entity()
         .addProperty(createPrimitive("Id", 4))
         .addProperty(createPrimitive("Model", "F2013"))
         .addProperty(createPrimitive("ModelYear", "2013"))
         .addProperty(createPrimitive("Price", 145285.00))
         .addProperty(createPrimitive("Currency", "EUR")));
 
-    entitySet.getEntities().add(new EntityImpl()
+    entitySet.getEntities().add(new Entity()
         .addProperty(createPrimitive("Id", 5))
         .addProperty(createPrimitive("Model", "F1 W02"))
         .addProperty(createPrimitive("ModelYear", "2011"))
@@ -141,14 +138,14 @@ public class DataProvider {
   }
 
   private EntitySet createManufacturers() {
-    EntitySet entitySet = new EntitySetImpl();
+    EntitySet entitySet = new EntitySet();
 
-    entitySet.getEntities().add(new EntityImpl()
+    entitySet.getEntities().add(new Entity()
         .addProperty(createPrimitive("Id", 1))
         .addProperty(createPrimitive("Name", "Star Powered Racing"))
         .addProperty(createAddress("Star Street 137", "Stuttgart", "70173", "Germany")));
 
-    entitySet.getEntities().add(new EntityImpl()
+    entitySet.getEntities().add(new Entity()
         .addProperty(createPrimitive("Id", 2))
         .addProperty(createPrimitive("Name", "Horse Powered Racing"))
         .addProperty(createAddress("Horse Street 1", "Maranello", "41053", "Italy")));
@@ -165,10 +162,10 @@ public class DataProvider {
     addressProperties.add(createPrimitive("City", city));
     addressProperties.add(createPrimitive("ZipCode", zipCode));
     addressProperties.add(createPrimitive("Country", country));
-    return new PropertyImpl(null, "Address", ValueType.COMPLEX, addressProperties);
+    return new Property(null, "Address", ValueType.COMPLEX, addressProperties);
   }
 
   private Property createPrimitive(final String name, final Object value) {
-    return new PropertyImpl(null, name, ValueType.PRIMITIVE, value);
+    return new Property(null, name, ValueType.PRIMITIVE, value);
   }
 }


[04/22] olingo-odata4 git commit: [OLINGO-616] Fix: BatchReferenceRewriter

Posted by ra...@apache.org.
[OLINGO-616] Fix: BatchReferenceRewriter


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/97a01784
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/97a01784
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/97a01784

Branch: refs/heads/OLINGO-573
Commit: 97a017843249093d4c71838ea59d5a1d472140c5
Parents: 189de7b
Author: Christian Holzer <c....@sap.com>
Authored: Thu Apr 2 13:41:07 2015 +0200
Committer: Christian Holzer <ch...@t-online.de>
Committed: Fri Apr 3 12:42:03 2015 +0200

----------------------------------------------------------------------
 .../fit/tecsvc/client/BatchClientITCase.java    | 74 ++++++++++++++++++--
 .../BatchReferenceRewriter.java                 |  3 +-
 2 files changed, 69 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/97a01784/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
index ed249fd..a46644c 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
@@ -20,8 +20,8 @@ package org.apache.olingo.fit.tecsvc.client;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.net.URI;
@@ -30,6 +30,7 @@ import java.util.HashMap;
 import java.util.Iterator;
 
 import org.apache.olingo.client.api.ODataBatchConstants;
+import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.communication.request.batch.BatchManager;
 import org.apache.olingo.client.api.communication.request.batch.ODataBatchRequest;
 import org.apache.olingo.client.api.communication.request.batch.ODataBatchResponseItem;
@@ -48,6 +49,7 @@ import org.apache.olingo.client.core.communication.request.batch.ODataChangesetR
 import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.commons.api.domain.ODataEntity;
 import org.apache.olingo.commons.api.domain.ODataEntitySet;
+import org.apache.olingo.commons.api.domain.ODataObjectFactory;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.format.ContentType;
@@ -62,6 +64,11 @@ import org.junit.Test;
 public class BatchClientITCase extends AbstractTestITCase {
   private final static String ACCEPT = ContentType.APPLICATION_OCTET_STREAM.toContentTypeString();
   private static final String SERVICE_URI = TecSvcConst.BASE_URI;
+  private static final String SERVICE_NAMESPACE = "olingo.odata.test1";
+  private static final String ES_NOT_AVAILABLE_NAME = "ESNotAvailable";
+  private static final FullQualifiedName ES_NOT_AVAILABLE = new FullQualifiedName(SERVICE_NAMESPACE, 
+                                                                                  ES_NOT_AVAILABLE_NAME);
+  private static final String PROPERTY_STRING = "PropertyString";
 
   @Before
   public void setup() {
@@ -69,6 +76,59 @@ public class BatchClientITCase extends AbstractTestITCase {
   }
 
   @Test
+  public void testBadRequestInChangeSet() {
+    /*
+     * A bad request (status code >= 400) without "continue on error prefer header" in a changeset
+     * should return a single response with Content-Type: application/http
+     * 
+     * See:
+     * OData Version 4.0 Part 1: Protocol Plus Errata 01
+     * 11.7.4 Responding to a Batch Request
+     * 
+     * When a request within a change set fails, the change set response is not represented using
+     * the multipart/mixed media type. Instead, a single response, using the application/http media type
+     * and a Content-Transfer-Encoding header with a value of binary, is returned that applies to all requests
+     * in the change set and MUST be formatted according to the Error Handling defined
+     * for the particular response format.
+     */
+
+    final ODataClient client = getClient();
+    final ODataObjectFactory of = client.getObjectFactory();
+
+    // Try to create entity, with invalid type
+    final ODataEntity entity = of.newEntity(ES_NOT_AVAILABLE);
+    entity.getProperties().add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder()
+        .buildString("1")));
+    final ODataBatchRequest batchRequest = client.getBatchRequestFactory().getBatchRequest(SERVICE_URI);
+    batchRequest.setAccept(ACCEPT);
+    final BatchManager payloadManager = batchRequest.payloadManager();
+    final ODataChangeset changeset = payloadManager.addChangeset();
+    final URI targetURI = client.newURIBuilder(SERVICE_URI)
+        .appendEntitySetSegment(ES_NOT_AVAILABLE_NAME)
+        .build();
+    final ODataEntityCreateRequest<ODataEntity> createRequest = client.getCUDRequestFactory()
+                                                                      .getEntityCreateRequest(targetURI, entity);
+    changeset.addRequest(createRequest);
+
+    final ODataBatchResponse response = payloadManager.getResponse();
+    assertEquals(HttpStatusCode.ACCEPTED.getStatusCode(), response.getStatusCode());
+
+    // Check response items
+    final Iterator<ODataBatchResponseItem> responseBodyIter = response.getBody();
+    assertTrue(responseBodyIter.hasNext());
+
+    final ODataBatchResponseItem changeSetResponse = responseBodyIter.next();
+    assertTrue(changeSetResponse.isChangeset());
+    assertTrue(changeSetResponse.hasNext());
+
+    final ODataResponse updateResponse = changeSetResponse.next();
+    assertTrue(changeSetResponse.isBreaking());
+
+    assertEquals(HttpStatusCode.NOT_FOUND.getStatusCode(), updateResponse.getStatusCode());
+    assertEquals(ODataFormat.JSON.toString(), updateResponse.getContentType());
+  }
+
+  @Test
   public void emptyBatchRequest() {
     // create your request
     final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(SERVICE_URI);
@@ -191,7 +251,7 @@ public class BatchClientITCase extends AbstractTestITCase {
     // Check if third request is available
     assertFalse(iter.hasNext());
   }
-  
+
   @Test
   public void testInvalidAbsoluteUri() throws URISyntaxException {
     final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(SERVICE_URI);
@@ -209,14 +269,14 @@ public class BatchClientITCase extends AbstractTestITCase {
 
     final Iterator<ODataBatchResponseItem> bodyIterator = response.getBody();
     assertTrue(bodyIterator.hasNext());
-    
+
     ODataBatchResponseItem item = bodyIterator.next();
     assertFalse(item.isChangeset());
-    
+
     final ODataResponse oDataResponse = item.next();
     assertEquals(400, oDataResponse.getStatusCode());
   }
-  
+
   @Test
   @Ignore
   public void testInvalidHost() throws URISyntaxException {
@@ -233,7 +293,7 @@ public class BatchClientITCase extends AbstractTestITCase {
     final ODataBatchResponse response = payload.getResponse();
     assertEquals(400, response.getStatusCode());
   }
-  
+
   @Test
   @Ignore
   public void testInvalidAbsoluteRequest() throws URISyntaxException {
@@ -250,7 +310,7 @@ public class BatchClientITCase extends AbstractTestITCase {
     final ODataBatchResponse response = payload.getResponse();
     assertEquals(400, response.getStatusCode());
   }
-  
+
   @Test
   public void testErrorWithContinueOnErrorPreferHeader() throws URISyntaxException {
     client.getConfiguration().setContinueOnError(true);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/97a01784/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/referenceRewriting/BatchReferenceRewriter.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/referenceRewriting/BatchReferenceRewriter.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/referenceRewriting/BatchReferenceRewriter.java
index 772fd9d..9f0429a 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/referenceRewriting/BatchReferenceRewriter.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/batchhandler/referenceRewriting/BatchReferenceRewriter.java
@@ -78,7 +78,8 @@ public class BatchReferenceRewriter {
     if (request.getMethod() == HttpMethod.POST) {
       // Create entity
       // The URI of the new resource will be generated by the server and published in the location header
-      resourceUri = parseODataPath(response.getHeaders().get(HttpHeader.LOCATION), request.getRawBaseUri());
+      final String locationHeader = response.getHeaders().get(HttpHeader.LOCATION);
+      resourceUri = locationHeader == null ? null : parseODataPath(locationHeader, request.getRawBaseUri());
     } else {
       // Update, Upsert (PUT, PATCH, Delete)
       // These methods still addresses a given resource, so we use the URI given by the request


[15/22] olingo-odata4 git commit: stricter cardinality check in expression parser

Posted by ra...@apache.org.
stricter cardinality check in expression parser

Change-Id: Ie48e84e73a9da37134f4062aee7bbbe50d605443

Signed-off-by: Christian Amend <ch...@apache.org>


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

Branch: refs/heads/OLINGO-573
Commit: b76ebe95d13cc528d80bda5ef5064cd2d925ab33
Parents: 9e232a2
Author: Klaus Straubinger <kl...@sap.com>
Authored: Fri Apr 10 15:25:12 2015 +0200
Committer: Christian Amend <ch...@apache.org>
Committed: Tue Apr 14 15:01:13 2015 +0200

----------------------------------------------------------------------
 .../core/uri/parser/UriParseTreeVisitor.java    | 25 ++++++++-------
 .../expression/ExpressionVisitorImpl.java       | 24 ++++++---------
 .../core/uri/antlr/TestFullResourcePath.java    | 22 +++++++++-----
 .../core/uri/testutil/FilterValidator.java      | 32 +++++---------------
 4 files changed, 45 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b76ebe95/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
index 5373fda..a94efbe 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
@@ -366,14 +366,14 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
     UriResource lastResourcePart = context.contextUriInfo.getLastResourcePart();
 
     if (lastResourcePart == null) {
-      if (context.contextTypes.size() == 0) {
-        if(checkFirst && ctx.vNS == null){
+      if (context.contextTypes.empty()) {
+        if (checkFirst && ctx.vNS == null) {
           throw wrap(new UriParserSemanticException(
               "Cannot find EntitySet, Singleton, ActionImport or FunctionImport with name '" + odi + "'.",
               UriParserSemanticException.MessageKeys.RESOURCE_NOT_FOUND, odi));
         }
-        throw wrap(new UriParserSemanticException("Resource part '" + odi + "' can only applied on typed "
-            + "resource parts",
+        throw wrap(new UriParserSemanticException(
+            "Resource part '" + odi + "' can only applied on typed resource parts",
             UriParserSemanticException.MessageKeys.RESOURCE_PART_ONLY_FOR_TYPED_PARTS, odi));
       }
       source = context.contextTypes.peek();
@@ -381,8 +381,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
       source = getTypeInformation(lastResourcePart);
 
       if (source.type == null) {
-        throw wrap(new UriParserSemanticException("Resource part '" + odi + "' can only be applied on typed "
-            + "resource parts.", UriParserSemanticException.MessageKeys.RESOURCE_PART_ONLY_FOR_TYPED_PARTS, odi));
+        throw wrap(new UriParserSemanticException(
+            "Resource part '" + odi + "' can only be applied on typed resource parts.",
+            UriParserSemanticException.MessageKeys.RESOURCE_PART_ONLY_FOR_TYPED_PARTS, odi));
       }
     }
 
@@ -400,12 +401,14 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
       }
 
       if (!(source.type instanceof EdmStructuredType)) {
-        throw wrap(new UriParserSemanticException("Cannot parse '" + odi
-            + "'; previous path segment is not a structural type.",
+        throw wrap(new UriParserSemanticException(
+            "Cannot parse '" + odi + "'; previous path segment is not a structural type.",
             UriParserSemanticException.MessageKeys.RESOURCE_PART_MUST_BE_PRECEDED_BY_STRUCTURAL_TYPE, odi));
       }
 
-      if (ctx.depth() <= 2  // path evaluation for the resource path
+      if ((ctx.depth() <= 2  // path evaluation for the resource path
+          || lastResourcePart instanceof UriResourceTypedImpl
+          || lastResourcePart instanceof UriResourceNavigationPropertyImpl)
           && source.isCollection) {
         throw wrap(new UriParserSemanticException("Property '" + odi + "' is not allowed after collection.",
             UriParserSemanticException.MessageKeys.PROPERTY_AFTER_COLLECTION, odi));
@@ -416,11 +419,11 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
       EdmElement property = structType.getProperty(odi);
       if (property == null) {
         throw wrap(new UriParserSemanticException("Property '" + odi + "' not found in type '"
-            + structType.getNamespace() + "." + structType.getName() + "'",
+            + structType.getFullQualifiedName().getFullQualifiedNameAsString() + "'",
             ctx.depth() > 2 ?  // path evaluation inside an expression or for the resource path?
                 UriParserSemanticException.MessageKeys.EXPRESSION_PROPERTY_NOT_IN_TYPE :
                 UriParserSemanticException.MessageKeys.PROPERTY_NOT_IN_TYPE,
-            structType.getFullQualifiedName().toString(), odi));
+            structType.getFullQualifiedName().getFullQualifiedNameAsString(), odi));
       }
 
       if (property instanceof EdmProperty) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b76ebe95/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
index ab0eca3..9c035a8 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
@@ -24,7 +24,6 @@ import java.util.Locale;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.edm.EdmBindingTarget;
-import org.apache.olingo.commons.api.edm.EdmComplexType;
 import org.apache.olingo.commons.api.edm.EdmEnumType;
 import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.commons.api.edm.EdmType;
@@ -32,7 +31,7 @@ import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.uri.UriInfoResource;
 import org.apache.olingo.server.api.uri.UriResource;
-import org.apache.olingo.server.api.uri.UriResourcePartTyped;
+import org.apache.olingo.server.api.uri.UriResourceProperty;
 import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;
 import org.apache.olingo.server.api.uri.queryoption.expression.Expression;
 import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException;
@@ -102,7 +101,7 @@ public class ExpressionVisitorImpl implements ExpressionVisitor<VisitorOperand>
     case NOT:
       return unaryOperator.notOperation();
     default:
-      // Can`t happen
+      // Can't happen.
       return throwNotImplemented();
     }
   }
@@ -180,22 +179,19 @@ public class ExpressionVisitorImpl implements ExpressionVisitor<VisitorOperand>
     final List<UriResource> uriResourceParts = member.getUriResourceParts();
 
     // UriResourceParts contains at least one UriResource
-    Property currentProperty = entity.getProperty(uriResourceParts.get(0).toString());
-    EdmType currentType = ((UriResourcePartTyped) uriResourceParts.get(0)).getType();
+    if (!(uriResourceParts.get(0) instanceof UriResourceProperty)) {
+      return throwNotImplemented();
+    }
 
-    EdmProperty currentEdmProperty = bindingTarget.getEntityType()
-        .getStructuralProperty(uriResourceParts.get(0).toString());
+    EdmProperty currentEdmProperty = ((UriResourceProperty) uriResourceParts.get(0)).getProperty();
+    Property currentProperty = entity.getProperty(currentEdmProperty.getName());
 
     for (int i = 1; i < uriResourceParts.size(); i++) {
-      currentType = ((UriResourcePartTyped) uriResourceParts.get(i)).getType();
-
       if (currentProperty.isComplex()) {
+        currentEdmProperty = ((UriResourceProperty) uriResourceParts.get(i)).getProperty();
         final List<Property> complex = currentProperty.asComplex().getValue();
-
         for (final Property innerProperty : complex) {
-          if (innerProperty.getName().equals(uriResourceParts.get(i).toString())) {
-            EdmComplexType edmComplexType = (EdmComplexType) currentEdmProperty.getType();
-            currentEdmProperty = edmComplexType.getStructuralProperty(uriResourceParts.get(i).toString());
+          if (innerProperty.getName().equals(currentEdmProperty.getName())) {
             currentProperty = innerProperty;
             break;
           }
@@ -203,7 +199,7 @@ public class ExpressionVisitorImpl implements ExpressionVisitor<VisitorOperand>
       }
     }
 
-    return new TypedOperand(currentProperty.getValue(), currentType, currentEdmProperty);
+    return new TypedOperand(currentProperty.getValue(), currentEdmProperty.getType(), currentEdmProperty);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b76ebe95/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
index 416346c..88cd44e 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
@@ -2950,21 +2950,27 @@ public class TestFullResourcePath {
 
     testFilter.runOnETTwoKeyNavEx("invalid")
         .isExSemantic(UriParserSemanticException.MessageKeys.EXPRESSION_PROPERTY_NOT_IN_TYPE);
-    testFilter.runOnETTwoKeyNavEx("PropertyComp")
-        .isExSemantic(UriParserSemanticException.MessageKeys.EXPRESSION_PROPERTY_NOT_IN_TYPE);
+    // TODO: This should throw an exception because the top node of the filter tree must be boolean.
+    //testFilter.runOnETTwoKeyNavEx("PropertyComp")
+    //    .isExSemantic(UriParserSemanticException.MessageKeys.XYZ);
     testFilter.runOnETTwoKeyNavEx("PropertyComp/invalid")
         .isExSemantic(UriParserSemanticException.MessageKeys.EXPRESSION_PROPERTY_NOT_IN_TYPE);
     testFilter.runOnETTwoKeyNavEx("concat('a','b')/invalid").isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
     testFilter.runOnETTwoKeyNavEx("PropertyComp/concat('a','b')")
         .isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
-    testFilter.runOnETTwoKeyNavEx("PropertyComp/PropertyInt16 eq '1'")
-        .isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
-    testFilter.runOnETTwoKeyNavEx("PropertyComp/PropertyComp/PropertyDate eq 1")
-        .isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
-    testFilter.runOnETTwoKeyNavEx("PropertyComp/PropertyComp/PropertyString eq 1")
-        .isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
+    // TODO: These should throw exceptions because the types are incompatible.
+    //testFilter.runOnETTwoKeyNavEx("PropertyComp/PropertyInt16 eq '1'")
+    //    .isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
+    //testFilter.runOnETTwoKeyNavEx("PropertyComp/PropertyComp/PropertyDate eq 1")
+    //    .isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
+    //testFilter.runOnETTwoKeyNavEx("PropertyComp/PropertyComp/PropertyString eq 1")
+    //    .isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
     testFilter.runOnETTwoKeyNavEx("PropertyComp/PropertyInt64 eq 1")
         .isExSemantic(UriParserSemanticException.MessageKeys.EXPRESSION_PROPERTY_NOT_IN_TYPE);
+    testFilter.runOnETTwoKeyNavEx("NavPropertyETKeyNavMany/PropertyInt16 gt 42")
+        .isExSemantic(UriParserSemanticException.MessageKeys.PROPERTY_AFTER_COLLECTION);
+    testFilter.runOnETTwoKeyNavEx("NavPropertyETKeyNavMany/NavPropertyETTwoKeyNavOne eq null")
+        .isExSemantic(UriParserSemanticException.MessageKeys.PROPERTY_AFTER_COLLECTION);
 
     testFilter.runOnETAllPrim("PropertySByte eq PropertySByte")
         .is("<<PropertySByte> eq <PropertySByte>>")

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b76ebe95/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java
index 4d67fcd..daf8ed0 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java
@@ -193,22 +193,13 @@ public class FilterValidator implements TestValidator {
   }
 
   public FilterValidator runUriEx(final String path, final String query) {
-    Parser parser = new Parser();
-    UriInfo uriInfo = null;
-
+    exception = null;
     try {
-      uriInfo = parser.parseUri(path, query, null, edm);
-    } catch (UriParserException e) {
+      new Parser().parseUri(path, query, null, edm);
+      fail("Expected exception not thrown.");
+    } catch (final UriParserException e) {
       exception = e;
-      return this;
-    }
-
-    if (uriInfo.getKind() != UriInfoKind.resource) {
-      fail("Filtervalidator can only be used on resourcePaths");
     }
-
-    setFilter((FilterOptionImpl) uriInfo.getFilterOption());
-    curExpression = filter.getExpression();
     return this;
   }
 
@@ -227,22 +218,13 @@ public class FilterValidator implements TestValidator {
   }
 
   public FilterValidator runUriOrderByEx(final String path, final String query) {
-    Parser parser = new Parser();
-    UriInfo uriInfo = null;
-
+    exception = null;
     try {
-      uriInfo = parser.parseUri(path, query, null, edm);
+      new Parser().parseUri(path, query, null, edm);
       fail("Expected exception not thrown.");
-    } catch (UriParserException e) {
+    } catch (final UriParserException e) {
       exception = e;
-      return this;
-    }
-
-    if (uriInfo.getKind() != UriInfoKind.resource) {
-      fail("Filtervalidator can only be used on resourcePaths");
     }
-
-    setOrderBy((OrderByOptionImpl) uriInfo.getOrderByOption());
     return this;
   }
 


[19/22] olingo-odata4 git commit: OLINGO-573: making tests work with tomcat and making it 1.6 compatible

Posted by ra...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/547725d7/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinServiceTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinServiceTest.java b/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinServiceTest.java
index 6af2b29..3547b50 100644
--- a/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinServiceTest.java
+++ b/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinServiceTest.java
@@ -19,19 +19,31 @@
 package org.apache.olingo.server.example;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 import java.io.File;
 import java.io.IOException;
 
 import org.apache.catalina.Context;
 import org.apache.catalina.startup.Tomcat;
+import org.apache.commons.io.IOUtils;
+import org.apache.http.Header;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpDelete;
 import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.ByteArrayEntity;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.util.EntityUtils;
+import org.apache.olingo.commons.core.Encoder;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.Ignore;
 import org.junit.Test;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
@@ -55,10 +67,10 @@ public class TripPinServiceTest {
   public static void beforeTest() throws Exception {
     tomcat.setPort(TOMCAT_PORT);
     File baseDir = new File(System.getProperty("java.io.tmpdir"));
-    Context cxt = tomcat.addContext("/", baseDir.getAbsolutePath());
+    Context cxt = tomcat.addContext("/trippin", baseDir.getAbsolutePath());
     Tomcat.addServlet(cxt, "trippin", new TripPinServlet());
     cxt.addServletMapping("/*", "trippin");
-    baseURL = "http://" + tomcat.getHost().getName() + ":"+ TOMCAT_PORT;
+    baseURL = "http://" + tomcat.getHost().getName() + ":"+ TOMCAT_PORT+"/trippin";
     tomcat.start();
   }
 
@@ -70,15 +82,41 @@ public class TripPinServiceTest {
   private HttpHost getLocalhost() {
     return new HttpHost(tomcat.getHost().getName(), 9900);
   }
+  
+  private HttpResponse httpGET(String url, int expectedStatus) throws Exception{
+    HttpRequest request = new HttpGet(url);
+	  return httpSend(request, expectedStatus);
+  }
+  
+  private HttpResponse httpSend(HttpRequest request, int expectedStatus) throws Exception{
+    HttpResponse response = http.execute(getLocalhost(), request);
+    assertEquals(expectedStatus, response.getStatusLine().getStatusCode());
+    return response;
+  }
+
+  private JsonNode getJSONNode(HttpResponse response) throws IOException,
+      JsonProcessingException {
+    ObjectMapper objectMapper = new ObjectMapper();
+    JsonNode node = objectMapper.readTree(response.getEntity().getContent());
+    return node;
+  }
+  
+  private String getHeader(HttpResponse response, String header) {
+    Header[] headers = response.getAllHeaders();
+    for (int i = 0; i < headers.length; i++) {
+      if (headers[i].getName().equalsIgnoreCase(header)) {
+        return headers[i].getValue();
+      }
+    }
+    return null;
+  }
 
   @Test
   public void testEntitySet() throws Exception {
-    HttpRequest req = new HttpGet("/People");
+    HttpRequest req = new HttpGet(baseURL+"/People");
     req.setHeader("Content-Type", "application/json;odata.metadata=minimal");
 
-    HttpResponse response = http.execute(getLocalhost(), req);
-    assertEquals(200, response.getStatusLine().getStatusCode());
-
+    HttpResponse response = httpSend(req, 200);
     JsonNode node = getJSONNode(response);
 
     assertEquals("$metadata#People", node.get("@odata.context").asText());
@@ -88,710 +126,570 @@ public class TripPinServiceTest {
     assertEquals("russellwhyte", person.get("UserName").asText());
   }
 
+  @Test
+  public void testReadEntitySetWithPaging() throws Exception {
+    String url = baseURL+"/People";
+    HttpRequest request = new HttpGet(url);
+    request.setHeader("Prefer", "odata.maxpagesize=10");
+    HttpResponse response = httpSend(request, 200);
+    JsonNode node = getJSONNode(response);
+    assertEquals("$metadata#People", node.get("@odata.context").asText());
+    assertEquals(baseURL+"/People?$skiptoken=10", node.get("@odata.nextLink").asText());
 
-  private JsonNode getJSONNode(HttpResponse response) throws IOException,
-      JsonProcessingException {
-    ObjectMapper objectMapper = new ObjectMapper();
-    JsonNode node = objectMapper.readTree(response.getEntity().getContent());
-    return node;
+    JsonNode person = ((ArrayNode)node.get("value")).get(0);
+    assertEquals("russellwhyte", person.get("UserName").asText());
+    assertEquals("odata.maxpagesize=10", getHeader(response, "Preference-Applied"));
+  }
+
+  @Test
+  public void testReadEntityWithKey() throws Exception {
+    HttpResponse response = httpGET(baseURL + "/Airlines('AA')", 200);
+    JsonNode node = getJSONNode(response);
+    assertEquals("$metadata#Airlines/$entity", node.get("@odata.context").asText());
+    assertEquals("American Airlines", node.get("Name").asText());
+  }
+
+  @Test
+  public void testReadEntityWithNonExistingKey() throws Exception {
+    HttpResponse response = httpGET(baseURL + "/Airlines('OO')", 404);
+    EntityUtils.consumeQuietly(response.getEntity());
+  }
+
+  @Test
+  public void testRead$Count() throws Exception {
+    HttpResponse response = httpGET(baseURL + "/Airlines/$count", 200);
+    assertEquals("15", IOUtils.toString(response.getEntity().getContent()));
+  }
+
+  @Test
+  public void testReadPrimitiveProperty() throws Exception {
+    HttpResponse response = httpGET(baseURL + "/Airlines('AA')/Name", 200);
+    JsonNode node = getJSONNode(response);
+    assertEquals("$metadata#Airlines('AA')/Name", node.get("@odata.context").asText());
+    assertEquals("American Airlines", node.get("value").asText());
+  }
+
+  @Test
+  public void testReadNonExistentProperty() throws Exception {
+    HttpResponse response = httpGET(baseURL + "/Airlines('AA')/Unknown", 404);
+    EntityUtils.consumeQuietly(response.getEntity());
+  }
+
+  @Test
+  public void testReadPrimitiveArrayProperty() throws Exception {
+    HttpResponse response = httpGET(baseURL + "/People('russellwhyte')/Emails", 200);
+    JsonNode node = getJSONNode(response);
+    assertEquals("$metadata#People('russellwhyte')/Emails", node.get("@odata.context").asText());
+    assertTrue(node.get("value").isArray());
+    assertEquals("Russell@example.com", ((ArrayNode)node.get("value")).get(0).asText());
+    assertEquals("Russell@contoso.com", ((ArrayNode)node.get("value")).get(1).asText());
+  }
+
+  @Test
+  public void testReadPrimitivePropertyValue() throws Exception {
+    HttpResponse response = httpGET(baseURL + "/Airlines('AA')/Name/$value", 200);
+    assertEquals("American Airlines", IOUtils.toString(response.getEntity().getContent()));
+  }
+
+  @Test @Ignore
+  // TODO: Support geometry types to make this run
+  public void testReadComplexProperty() throws Exception {
+    //HttpResponse response = httpGET(baseURL + "/Airports('KSFO')/Location");
+    //fail("support geometry type");
+  }
+
+  @Test
+  public void testReadComplexArrayProperty() throws Exception {
+    HttpResponse response = httpGET(baseURL + "/People('russellwhyte')/AddressInfo", 200);
+    JsonNode node = getJSONNode(response);
+    assertEquals("$metadata#People('russellwhyte')/AddressInfo", node.get("@odata.context").asText());
+    assertTrue(node.get("value").isArray());
+    assertEquals("187 Suffolk Ln.", ((ArrayNode)node.get("value")).get(0).get("Address").asText());
+  }
+
+  @Test
+  public void testReadMedia() throws Exception {
+    HttpResponse response = httpGET(baseURL + "/Photos(1)/$value", 200);
+    EntityUtils.consumeQuietly(response.getEntity());
+  }
+
+  @Test
+  public void testCreateMedia() throws Exception {
+    // treating update and create as same for now, as there is details about
+    // how entity payload and media payload can be sent at same time in request's body
+    String editUrl = baseURL + "/Photos(1)/$value";
+    HttpPut request = new HttpPut(editUrl);
+    request.setEntity(new ByteArrayEntity("bytecontents".getBytes(), ContentType.APPLICATION_OCTET_STREAM));
+    HttpResponse response = httpSend(request, 204);
+    EntityUtils.consumeQuietly(response.getEntity());
+  }
+
+  @Test
+  public void testDeleteMedia() throws Exception {
+    // treating update and create as same for now, as there is details about
+    // how entity payload and media payload can be sent at same time in request's body
+    String editUrl = baseURL + "/Photos(1)/$value";
+    HttpDelete request = new HttpDelete(editUrl);
+    HttpResponse response = httpSend(request, 204);
+    EntityUtils.consumeQuietly(response.getEntity());
+  }
+
+  @Test
+  public void testCreateStream() throws Exception {
+    // treating update and create as same for now, as there is details about
+    // how entity payload and media payload can be sent at same time in request's body
+    String editUrl = baseURL + "/Airlines('AA')/Picture";
+    HttpPost request = new HttpPost(editUrl);
+    request.setEntity(new ByteArrayEntity("bytecontents".getBytes(), ContentType.APPLICATION_OCTET_STREAM));
+    // method not allowed
+    HttpResponse response = httpSend(request, 405);
+    EntityUtils.consumeQuietly(response.getEntity());
+  }
+
+  @Test
+  public void testCreateStream2() throws Exception {
+    // treating update and create as same for now, as there is details about
+    // how entity payload and media payload can be sent at same time in request's body
+    String editUrl = baseURL + "/Airlines('AA')/Picture";
+    HttpPut request = new HttpPut(editUrl);
+    request.setEntity(new ByteArrayEntity("bytecontents".getBytes(), ContentType.APPLICATION_OCTET_STREAM));
+    HttpResponse response = httpSend(request, 204);
+    EntityUtils.consumeQuietly(response.getEntity());
+  }
+
+  @Test
+  public void testDeleteStream() throws Exception {
+    // treating update and create as same for now, as there is details about
+    // how entity payload and media payload can be sent at same time in request's body
+    String editUrl = baseURL + "/Airlines('AA')/Picture";
+    HttpDelete request = new HttpDelete(editUrl);
+    HttpResponse response = httpSend(request, 204);
+    EntityUtils.consumeQuietly(response.getEntity());
+  }
+
+  @Test
+  public void testReadStream() throws Exception {
+    // treating update and create as same for now, as there is details about
+    // how entity payload and media payload can be sent at same time in request's body
+    String editUrl = baseURL + "/Airlines('AA')/Picture";
+    HttpResponse response = httpGET(editUrl, 200);
+    EntityUtils.consumeQuietly(response.getEntity());
+  }
+
+  @Test
+  public void testLambdaAny() throws Exception {
+    // this is just testing to see the labba expresions are going through the
+    // framework, none of the system options are not implemented in example service
+    String query = "Friends/any(d:d/UserName eq 'foo')";
+    HttpResponse response = httpGET(baseURL + "/People?$filter="+Encoder.encode(query), 200);
+    EntityUtils.consumeQuietly(response.getEntity());
+  }
+
+  @Test
+  public void testSingleton() throws Exception {
+    HttpResponse response = httpGET(baseURL + "/Me", 200);
+    JsonNode node = getJSONNode(response);
+    assertEquals("$metadata#Me", node.get("@odata.context").asText());
+    assertEquals("russellwhyte", node.get("UserName").asText());
+  }
+
+  @Test
+  public void testSelectOption() throws Exception {
+    HttpResponse response = httpGET(baseURL + "/People('russellwhyte')?$select=FirstName,LastName", 200);
+    JsonNode node = getJSONNode(response);
+    assertEquals("$metadata#People(FirstName,LastName)/$entity", node.get("@odata.context").asText());
+    assertEquals("Russell", node.get("FirstName").asText());
+  }
+
+  @Test
+  public void testActionImportWithNoResponse() throws Exception {
+    HttpPost request = new HttpPost(baseURL + "/ResetDataSource");
+    HttpResponse response = httpSend(request, 204);
+    EntityUtils.consumeQuietly(response.getEntity());
+  }
+
+  @Test @Ignore
+  public void testFunctionImport() throws Exception {
+    //TODO: fails because of lack of geometery support
+    HttpResponse response = httpGET(baseURL + "/GetNearestAirport(lat=23.0,lon=34.0)", 200);
+    EntityUtils.consumeQuietly(response.getEntity());
+  }
+
+  @Test
+  public void testBadReferences() throws Exception {
+    HttpResponse response = httpGET(baseURL + "/People('russelwhyte')/$ref", 405);
+    EntityUtils.consumeQuietly(response.getEntity());
+  }
+
+  @Test
+  public void testReadReferences() throws Exception {
+    HttpResponse response = httpGET(baseURL + "/People('russellwhyte')/Friends/$ref", 200);
+    JsonNode node = getJSONNode(response);
+    assertEquals("$metadata#Collection($ref)", node.get("@odata.context").asText());
+    assertTrue(node.get("value").isArray());
+    assertEquals("/People('scottketchum')", ((ArrayNode)node.get("value")).get(0).get("@odata.id").asText());
+  }
+
+  @Test
+  public void testAddCollectionReferences() throws Exception {
+    //GET
+    HttpResponse response = httpGET(baseURL + "/People('kristakemp')/Friends/$ref", 200);
+    JsonNode node = getJSONNode(response);
+
+    assertTrue(node.get("value").isArray());
+    assertEquals("/People('genevievereeves')", ((ArrayNode)node.get("value")).get(0).get("@odata.id").asText());
+    assertNull(((ArrayNode)node.get("value")).get(1));
+
+    //ADD
+    String payload = "{\n" +
+        "  \"@odata.context\": \""+baseURL+"/$metadata#Collection($ref)\",\n" +
+        "  \"value\": [\n" +
+        "    { \"@odata.id\": \"People('russellwhyte')\" },\n" +
+        "    { \"@odata.id\": \"People('scottketchum')\" } \n" +
+        "  ]\n" +
+        "}";
+    HttpPost postRequest = new HttpPost(baseURL + "/People('kristakemp')/Friends/$ref");
+    postRequest.setEntity(new StringEntity(payload, ContentType.APPLICATION_JSON));
+    response = httpSend(postRequest, 204);
+    
+    //GET
+    response = httpGET(baseURL + "/People('kristakemp')/Friends/$ref", 200);
+    node = getJSONNode(response);
+
+    assertTrue(node.get("value").isArray());
+    assertEquals("/People('genevievereeves')", ((ArrayNode)node.get("value")).get(0).get("@odata.id").asText());
+    assertEquals("/People('russellwhyte')", ((ArrayNode)node.get("value")).get(1).get("@odata.id").asText());
+    assertEquals("/People('scottketchum')", ((ArrayNode)node.get("value")).get(2).get("@odata.id").asText());
+  }
+
+
+  @Test
+  public void testEntityId() throws Exception {
+    HttpResponse response = httpGET(baseURL+"/$entity?$id="+baseURL + "/People('kristakemp')", 200);
+    JsonNode node = getJSONNode(response);
+    assertEquals("$metadata#People/$entity", node.get("@odata.context").asText());
+    assertEquals("kristakemp", node.get("UserName").asText());
+
+    // using relative URL
+    response = httpGET(baseURL+"/$entity?$id="+"People('kristakemp')", 200);
+    node = getJSONNode(response);
+    assertEquals("$metadata#People/$entity", node.get("@odata.context").asText());
+    assertEquals("kristakemp", node.get("UserName").asText());
+  }
+
+  @Test
+  public void testCreateReadDeleteEntity() throws Exception {
+    String payload = "{\n" +
+        "         \"UserName\":\"olingodude\",\n" +
+        "         \"FirstName\":\"Olingo\",\n" +
+        "         \"LastName\":\"Apache\",\n" +
+        "         \"Emails\":[\n" +
+        "            \"olingo@apache.org\"\n" +
+        "         ],\n" +
+        "         \"AddressInfo\":[\n" +
+        "            {\n" +
+        "               \"Address\":\"100 apache Ln.\",\n" +
+        "               \"City\":{\n" +
+        "                  \"CountryRegion\":\"United States\",\n" +
+        "                  \"Name\":\"Boise\",\n" +
+        "                  \"Region\":\"ID\"\n" +
+        "               }\n" +
+        "            }\n" +
+        "         ],\n" +
+        "         \"Gender\":\"0\",\n" +
+        "         \"Concurrency\":635585295719432047\n" +
+        "}";
+    HttpPost postRequest = new HttpPost(baseURL + "/People");
+    postRequest.setEntity(new StringEntity(payload, ContentType.APPLICATION_JSON));
+    postRequest.addHeader("Prefer", "return=minimal");
+
+    HttpResponse response = httpSend(postRequest, 204);
+    // the below woud be 204, if minimal was not supplied
+    assertEquals("/People('olingodude')", getHeader(response, "Location"));
+    assertEquals("return=minimal", getHeader(response, "Preference-Applied"));
+
+    String location = baseURL+getHeader(response, "Location");
+    response = httpGET(location, 200);
+    EntityUtils.consumeQuietly(response.getEntity());
+
+    HttpDelete deleteRequest = new HttpDelete(location);
+    response = httpSend(deleteRequest, 204);
+    EntityUtils.consumeQuietly(response.getEntity());
+
+    response = httpGET(location, 404);
+    EntityUtils.consumeQuietly(response.getEntity());
+  }
+
+
+  @Test
+  public void testCreateEntityWithLinkToRelatedEntities() throws Exception {
+    String payload = "{\n" +
+        "         \"UserName\":\"olingo\",\n" +
+        "         \"FirstName\":\"Olingo\",\n" +
+        "         \"LastName\":\"Apache\",\n" +
+        "         \"Emails\":[\n" +
+        "            \"olingo@apache.org\"\n" +
+        "         ],\n" +
+        "         \"AddressInfo\":[\n" +
+        "            {\n" +
+        "               \"Address\":\"100 apache Ln.\",\n" +
+        "               \"City\":{\n" +
+        "                  \"CountryRegion\":\"United States\",\n" +
+        "                  \"Name\":\"Boise\",\n" +
+        "                  \"Region\":\"ID\"\n" +
+        "               }\n" +
+        "            }\n" +
+        "         ],\n" +
+        "         \"Gender\":\"0\",\n" +
+        "         \"Concurrency\":635585295719432047,\n" +
+        "\"Friends@odata.bind\":[\"" +
+         baseURL+"/People('russellwhyte')\",\""+
+         baseURL+"/People('scottketchum')\""+
+        "]"+
+        "}";
+    HttpPost postRequest = new HttpPost(baseURL + "/People");
+    postRequest.setEntity(new StringEntity(payload, ContentType.APPLICATION_JSON));
+    postRequest.setHeader("Prefer", "return=minimal");
+    HttpResponse response = httpSend(postRequest, 204);
+    EntityUtils.consumeQuietly(response.getEntity());
+    
+    response = httpGET(baseURL+"/People('olingo')/Friends", 200);
+    JsonNode node = getJSONNode(response);
+    assertEquals("$metadata#People", node.get("@odata.context").asText());
+    assertTrue(node.get("value").isArray());
+    assertEquals("scottketchum", ((ArrayNode)node.get("value")).get(1).get("UserName").asText());
+  }
+
+  @Test
+  public void testUpdatePrimitiveProperty() throws Exception {
+    String payload = "{"
+        + " \"value\":\"Pilar Ackerman\""
+        + "}";
+
+    String editUrl = baseURL + "/People('russellwhyte')/FirstName";
+    HttpPut postRequest = new HttpPut(editUrl);
+    postRequest.setEntity(new StringEntity(payload, ContentType.APPLICATION_JSON));
+    HttpResponse response = httpSend(postRequest, 204);
+    EntityUtils.consumeQuietly(response.getEntity());
+    
+    response = httpGET(editUrl, 200);
+    JsonNode node = getJSONNode(response);
+    assertEquals("$metadata#People('russellwhyte')/FirstName", node.get("@odata.context").asText());
+    assertEquals("Pilar Ackerman", node.get("value").asText());
+  }
+
+  @Test
+  public void testUpdatePrimitiveArrayProperty() throws Exception {
+    String payload = "{"
+        + " \"value\": [\n" +
+        "       \"olingo@apache.com\"\n" +
+        "    ]"
+        + "}";
+
+    String editUrl = baseURL + "/People('russellwhyte')/Emails";
+    HttpPut postRequest = new HttpPut(editUrl);
+    postRequest.setEntity(new StringEntity(payload, ContentType.APPLICATION_JSON));
+    HttpResponse response = httpSend(postRequest, 204);
+    EntityUtils.consumeQuietly(response.getEntity());
+
+    response = httpGET(editUrl, 200);
+    JsonNode node = getJSONNode(response);
+    assertEquals("$metadata#People('russellwhyte')/Emails", node.get("@odata.context").asText());
+    assertTrue(node.get("value").isArray());
+    assertEquals("olingo@apache.com", ((ArrayNode)node.get("value")).get(0).asText());
+  }
+
+  @Test
+  public void testDeleteProperty() throws Exception {
+    String editUrl = baseURL + "/People('russellwhyte')/FirstName";
+    HttpResponse response = httpGET(editUrl, 200);
+    JsonNode node = getJSONNode(response);
+    assertEquals("Russell", node.get("value").asText());
+
+    HttpDelete deleteRequest = new HttpDelete(editUrl);
+    response = httpSend(deleteRequest, 204);
+    EntityUtils.consumeQuietly(response.getEntity());
+    
+    response = httpGET(editUrl, 204);
+    EntityUtils.consumeQuietly(response.getEntity());
+  }
+
+  @Test
+  public void testReadNavigationPropertyEntityCollection() throws Exception {
+    String editUrl = baseURL + "/People('russellwhyte')/Friends";
+    HttpResponse response = httpGET(editUrl, 200);
+
+    JsonNode node = getJSONNode(response);
+    assertEquals("$metadata#People", node.get("@odata.context").asText());
+
+    JsonNode person = ((ArrayNode)node.get("value")).get(0);
+    assertEquals("scottketchum", person.get("UserName").asText());
+  }
+
+  @Test
+  public void testReadNavigationPropertyEntityCollection2() throws Exception {
+    String editUrl = baseURL + "/People('russellwhyte')/Friends('scottketchum')/Trips";
+    HttpResponse response = httpGET(editUrl, 200);
+    JsonNode node = getJSONNode(response);
+    assertEquals("$metadata#People('russellwhyte')/Friends('scottketchum')/Trips",
+        node.get("@odata.context").asText());
+    assertTrue(node.get("value").isArray());
+    assertEquals("1001", ((ArrayNode)node.get("value")).get(0).get("TripId").asText());
   }
 
-//  private static Server server = new Server();
-//  private static String baseURL;
-//  private static HttpClient http = new HttpClient();
-//
-//  @BeforeClass
-//  public static void beforeTest() throws Exception {
-//    ServerConnector connector = new ServerConnector(server);
-//    server.setConnectors(new Connector[] { connector });
-//
-//    ServletContextHandler context = new ServletContextHandler();
-//    context.setContextPath("/trippin");
-//    context.addServlet(new ServletHolder(new TripPinServlet()), "/*");
-//    server.setHandler(context);
-//    server.start();
-//    int port = connector.getLocalPort();
-//    http.start();
-//    baseURL = "http://localhost:"+port+"/trippin";
-//  }
-//
-//  @AfterClass
-//  public static void afterTest() throws Exception {
-//    server.stop();
-//  }
-//
-//  @Test
-//  public void testEntitySet() throws Exception {
-//    ContentResponse response = http.newRequest(baseURL + "/People")
-//    .header("Content-Type", "application/json;odata.metadata=minimal")
-//    .method(HttpMethod.GET)
-//    .send();
-//    assertEquals(200, response.getStatus());
-//
-//    JsonNode node = getJSONNode(response);
-//
-//    assertEquals("$metadata#People", node.get("@odata.context").asText());
-//    assertEquals(baseURL+"/People?$skiptoken=8", node.get("@odata.nextLink").asText());
-//
-//    JsonNode person = ((ArrayNode)node.get("value")).get(0);
-//    assertEquals("russellwhyte", person.get("UserName").asText());
-//  }
-//
-//  private JsonNode getJSONNode(ContentResponse response) throws IOException,
-//      JsonProcessingException {
-//    ObjectMapper objectMapper = new ObjectMapper();
-//    JsonNode node = objectMapper.readTree(response.getContent());
-//    return node;
-//  }
-//
-//  @Test
-//  public void testReadEntitySetWithPaging() throws Exception {
-//    ContentResponse response = http.newRequest(baseURL + "/People")
-//        .header("Prefer", "odata.maxpagesize=10").send();
-//
-//    assertEquals(200, response.getStatus());
-//
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("$metadata#People", node.get("@odata.context").asText());
-//    assertEquals(baseURL+"/People?$skiptoken=10", node.get("@odata.nextLink").asText());
-//
-//    JsonNode person = ((ArrayNode)node.get("value")).get(0);
-//    assertEquals("russellwhyte", person.get("UserName").asText());
-//
-//    assertNotNull(response.getHeaders().get("Preference-Applied"));
-//  }
-//
-//  @Test
-//  public void testReadEntityWithKey() throws Exception {
-//    ContentResponse response = http.GET(baseURL + "/Airlines('AA')");
-//    assertEquals(200, response.getStatus());
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("$metadata#Airlines/$entity", node.get("@odata.context").asText());
-//    assertEquals("American Airlines", node.get("Name").asText());
-//  }
-//
-//  @Test
-//  public void testReadEntityWithNonExistingKey() throws Exception {
-//    ContentResponse response = http.GET(baseURL + "/Airlines('OO')");
-//    assertEquals(404, response.getStatus());
-//  }
-//
-//  @Test
-//  public void testRead$Count() throws Exception {
-//    ContentResponse response = http.GET(baseURL + "/Airlines/$count");
-//    assertEquals(200, response.getStatus());
-//    assertEquals("15", response.getContentAsString());
-//  }
-//
-//  @Test
-//  public void testReadPrimitiveProperty() throws Exception {
-//    ContentResponse response = http.GET(baseURL + "/Airlines('AA')/Name");
-//    assertEquals(200, response.getStatus());
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("$metadata#Airlines('AA')/Name", node.get("@odata.context").asText());
-//    assertEquals("American Airlines", node.get("value").asText());
-//  }
-//
-//  @Test
-//  public void testReadNonExistentProperty() throws Exception {
-//    ContentResponse response = http.GET(baseURL + "/Airlines('AA')/Unknown");
-//    assertEquals(404, response.getStatus());
-//  }
-//
-//  @Test
-//  public void testReadPrimitiveArrayProperty() throws Exception {
-//    ContentResponse response = http.GET(baseURL + "/People('russellwhyte')/Emails");
-//    assertEquals(200, response.getStatus());
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("$metadata#People('russellwhyte')/Emails", node.get("@odata.context").asText());
-//    assertTrue(node.get("value").isArray());
-//    assertEquals("Russell@example.com", ((ArrayNode)node.get("value")).get(0).asText());
-//    assertEquals("Russell@contoso.com", ((ArrayNode)node.get("value")).get(1).asText());
-//  }
-//
-//  @Test
-//  public void testReadPrimitivePropertyValue() throws Exception {
-//    ContentResponse response = http.GET(baseURL + "/Airlines('AA')/Name/$value");
-//    assertEquals(200, response.getStatus());
-//    assertEquals("American Airlines", response.getContentAsString());
-//  }
-//
-//  @Test @Ignore
-//  // TODO: Support geometry types to make this run
-//  public void testReadComplexProperty() throws Exception {
-//    ContentResponse response = http.GET(baseURL + "/Airports('KSFO')/Location");
-//    fail("support geometry type");
-//  }
-//
-//  @Test
-//  public void testReadComplexArrayProperty() throws Exception {
-//    ContentResponse response = http.GET(baseURL + "/People('russellwhyte')/AddressInfo");
-//    assertEquals(200, response.getStatus());
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("$metadata#People('russellwhyte')/AddressInfo", node.get("@odata.context").asText());
-//    assertTrue(node.get("value").isArray());
-//    assertEquals("187 Suffolk Ln.", ((ArrayNode)node.get("value")).get(0).get("Address").asText());
-//  }
-//
-//  @Test
-//  public void testReadMedia() throws Exception {
-//    ContentResponse response = http.GET(baseURL + "/Photos(1)/$value");
-//    assertEquals(200, response.getStatus());
-//  }
-//
-//  @Test
-//  public void testCreateMedia() throws Exception {
-//    // treating update and create as same for now, as there is details about
-//    // how entity payload and media payload can be sent at same time in request's body
-//    String editUrl = baseURL + "/Photos(1)/$value";
-//    ContentResponse response = http.newRequest(editUrl)
-//        .content(content("bytecontents"), "image/jpeg")
-//        .method(HttpMethod.PUT)
-//        .send();
-//    assertEquals(204, response.getStatus());
-//  }
-//
-//  @Test
-//  public void testDeleteMedia() throws Exception {
-//    // treating update and create as same for now, as there is details about
-//    // how entity payload and media payload can be sent at same time in request's body
-//    String editUrl = baseURL + "/Photos(1)/$value";
-//    ContentResponse response = http.newRequest(editUrl)
-//        .content(content("bytecontents"), "image/jpeg")
-//        .method(HttpMethod.DELETE)
-//        .send();
-//    assertEquals(204, response.getStatus());
-//  }
-//
-//  @Test
-//  public void testCreateStream() throws Exception {
-//    // treating update and create as same for now, as there is details about
-//    // how entity payload and media payload can be sent at same time in request's body
-//    String editUrl = baseURL + "/Airlines('AA')/Picture";
-//    ContentResponse response = http.newRequest(editUrl)
-//        .content(content("bytecontents"), "image/jpeg")
-//        .method(HttpMethod.POST)
-//        .send();
-//    // method not allowed
-//    assertEquals(405, response.getStatus());
-//  }
-//
-//  @Test
-//  public void testCreateStream2() throws Exception {
-//    // treating update and create as same for now, as there is details about
-//    // how entity payload and media payload can be sent at same time in request's body
-//    String editUrl = baseURL + "/Airlines('AA')/Picture";
-//    ContentResponse response = http.newRequest(editUrl)
-//        .content(content("bytecontents"), "image/jpeg")
-//        .method(HttpMethod.PUT)
-//        .send();
-//    assertEquals(204, response.getStatus());
-//  }
-//
-//  @Test
-//  public void testDeleteStream() throws Exception {
-//    // treating update and create as same for now, as there is details about
-//    // how entity payload and media payload can be sent at same time in request's body
-//    String editUrl = baseURL + "/Airlines('AA')/Picture";
-//    ContentResponse response = http.newRequest(editUrl)
-//        .method(HttpMethod.DELETE)
-//        .send();
-//    assertEquals(204, response.getStatus());
-//  }
-//
-//  @Test
-//  public void testReadStream() throws Exception {
-//    // treating update and create as same for now, as there is details about
-//    // how entity payload and media payload can be sent at same time in request's body
-//    String editUrl = baseURL + "/Airlines('AA')/Picture";
-//    ContentResponse response = http.newRequest(editUrl)
-//        .method(HttpMethod.GET)
-//        .send();
-//    assertEquals(200, response.getStatus());
-//  }
-//
-//  @Test
-//  public void testLambdaAny() throws Exception {
-//    // this is just testing to see the labba expresions are going through the
-//    // framework, none of the system options are not implemented in example service
-//    String query = "Friends/any(d:d/UserName eq 'foo')";
-//    ContentResponse response = http.newRequest(baseURL + "/People?$filter="+Encoder.encode(query))
-//        .method(HttpMethod.GET)
-//        .send();
-//    assertEquals(200, response.getStatus());
-//  }
-//
-//  @Test
-//  public void testSingleton() throws Exception {
-//    ContentResponse response = http.GET(baseURL + "/Me");
-//    assertEquals(200, response.getStatus());
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("$metadata#Me", node.get("@odata.context").asText());
-//    assertEquals("russellwhyte", node.get("UserName").asText());
-//  }
-//
-//  @Test
-//  public void testSelectOption() throws Exception {
-//    ContentResponse response = http.GET(baseURL + "/People('russellwhyte')?$select=FirstName,LastName");
-//    assertEquals(200, response.getStatus());
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("$metadata#People(FirstName,LastName)/$entity", node.get("@odata.context").asText());
-//    assertEquals("Russell", node.get("FirstName").asText());
-//  }
-//
-//  @Test
-//  public void testActionImportWithNoResponse() throws Exception {
-//    ContentResponse response = http.POST(baseURL + "/ResetDataSource").send();
-//    assertEquals(204, response.getStatus());
-//  }
-//
-//  @Test
-//  public void testFunctionImport() throws Exception {
-//    //TODO: fails because of lack of geometery support
-//    ContentResponse response = http.GET(baseURL + "/GetNearestAirport(lat=23.0,lon=34.0)");
-//  }
-//
-//  @Test
-//  public void testBadReferences() throws Exception {
-//    ContentResponse response = http.GET(baseURL + "/People('russelwhyte')/$ref");
-//    assertEquals(405, response.getStatus());
-//  }
-//
-//  @Test
-//  public void testReadReferences() throws Exception {
-//    ContentResponse response = http.GET(baseURL + "/People('russellwhyte')/Friends/$ref");
-//    assertEquals(200, response.getStatus());
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("$metadata#Collection($ref)", node.get("@odata.context").asText());
-//    assertTrue(node.get("value").isArray());
-//    assertEquals("/People('scottketchum')", ((ArrayNode)node.get("value")).get(0).get("@odata.id").asText());
-//  }
-//
-//  @Test
-//  public void testAddCollectionReferences() throws Exception {
-//    //GET
-//    ContentResponse response = http.GET(baseURL + "/People('kristakemp')/Friends/$ref");
-//    assertEquals(200, response.getStatus());
-//    JsonNode node = getJSONNode(response);
-//
-//    assertTrue(node.get("value").isArray());
-//    assertEquals("/People('genevievereeves')", ((ArrayNode)node.get("value")).get(0).get("@odata.id").asText());
-//    assertNull(((ArrayNode)node.get("value")).get(1));
-//
-//    //ADD
-//    String payload = "{\n" +
-//        "  \"@odata.context\": \""+baseURL+"/$metadata#Collection($ref)\",\n" +
-//        "  \"value\": [\n" +
-//        "    { \"@odata.id\": \"People('russellwhyte')\" },\n" +
-//        "    { \"@odata.id\": \"People('scottketchum')\" } \n" +
-//        "  ]\n" +
-//        "}";
-//    response = http.POST(baseURL + "/People('kristakemp')/Friends/$ref")
-//        .content(content(payload), "application/json")
-//        .send();
-//    assertEquals(204, response.getStatus());
-//
-//    //GET
-//    response = http.GET(baseURL + "/People('kristakemp')/Friends/$ref");
-//    assertEquals(200, response.getStatus());
-//    node = getJSONNode(response);
-//
-//    assertTrue(node.get("value").isArray());
-//    assertEquals("/People('genevievereeves')", ((ArrayNode)node.get("value")).get(0).get("@odata.id").asText());
-//    assertEquals("/People('russellwhyte')", ((ArrayNode)node.get("value")).get(1).get("@odata.id").asText());
-//    assertEquals("/People('scottketchum')", ((ArrayNode)node.get("value")).get(2).get("@odata.id").asText());
-//  }
-//
-//
-//  @Test
-//  public void testEntityId() throws Exception {
-//    ContentResponse response = http.GET(baseURL+"/$entity?$id="+baseURL + "/People('kristakemp')");
-//    assertEquals(200, response.getStatus());
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("$metadata#People/$entity", node.get("@odata.context").asText());
-//    assertEquals("kristakemp", node.get("UserName").asText());
-//
-//    // using relative URL
-//    response = http.GET(baseURL+"/$entity?$id="+"People('kristakemp')");
-//    assertEquals(200, response.getStatus());
-//    node = getJSONNode(response);
-//    assertEquals("$metadata#People/$entity", node.get("@odata.context").asText());
-//    assertEquals("kristakemp", node.get("UserName").asText());
-//  }
-//
-//  @Test
-//  public void testCreateReadDeleteEntity() throws Exception {
-//    String payload = "{\n" +
-//        "         \"UserName\":\"olingodude\",\n" +
-//        "         \"FirstName\":\"Olingo\",\n" +
-//        "         \"LastName\":\"Apache\",\n" +
-//        "         \"Emails\":[\n" +
-//        "            \"olingo@apache.org\"\n" +
-//        "         ],\n" +
-//        "         \"AddressInfo\":[\n" +
-//        "            {\n" +
-//        "               \"Address\":\"100 apache Ln.\",\n" +
-//        "               \"City\":{\n" +
-//        "                  \"CountryRegion\":\"United States\",\n" +
-//        "                  \"Name\":\"Boise\",\n" +
-//        "                  \"Region\":\"ID\"\n" +
-//        "               }\n" +
-//        "            }\n" +
-//        "         ],\n" +
-//        "         \"Gender\":\"0\",\n" +
-//        "         \"Concurrency\":635585295719432047\n" +
-//        "}";
-//    ContentResponse response = http.POST(baseURL + "/People")
-//        .content(content(payload), "application/json")
-//        .header("Prefer", "return=minimal")
-//        .send();
-//    // the below woud be 204, if minimal was not supplied
-//    assertEquals(204, response.getStatus());
-//    assertEquals("/People('olingodude')", response.getHeaders().get("Location"));
-//    assertEquals("return=minimal", response.getHeaders().get("Preference-Applied"));
-//
-//    String location = baseURL+response.getHeaders().get("Location");
-//    response = http.GET(location);
-//    assertEquals(200, response.getStatus());
-//
-//    response = http.newRequest(location).method(HttpMethod.DELETE).send();
-//    assertEquals(204, response.getStatus());
-//
-//    response = http.GET(location);
-//    assertEquals(404, response.getStatus());
-//  }
-//
-//
-//  @Test
-//  public void testCreateEntityWithLinkToRelatedEntities() throws Exception {
-//    String payload = "{\n" +
-//        "         \"UserName\":\"olingo\",\n" +
-//        "         \"FirstName\":\"Olingo\",\n" +
-//        "         \"LastName\":\"Apache\",\n" +
-//        "         \"Emails\":[\n" +
-//        "            \"olingo@apache.org\"\n" +
-//        "         ],\n" +
-//        "         \"AddressInfo\":[\n" +
-//        "            {\n" +
-//        "               \"Address\":\"100 apache Ln.\",\n" +
-//        "               \"City\":{\n" +
-//        "                  \"CountryRegion\":\"United States\",\n" +
-//        "                  \"Name\":\"Boise\",\n" +
-//        "                  \"Region\":\"ID\"\n" +
-//        "               }\n" +
-//        "            }\n" +
-//        "         ],\n" +
-//        "         \"Gender\":\"0\",\n" +
-//        "         \"Concurrency\":635585295719432047,\n" +
-//        "\"Friends@odata.bind\":[\"" +
-//         baseURL+"/People('russellwhyte')\",\""+
-//         baseURL+"/People('scottketchum')\""+
-//        "]"+
-//        "}";
-//    ContentResponse response = http.POST(baseURL + "/People")
-//        .content(content(payload), "application/json")
-//        .header("Prefer", "return=minimal")
-//        .send();
-//    // the below woud be 204, if minimal was not supplied
-//    assertEquals(204, response.getStatus());
-//
-//    response = http.GET(baseURL+"/People('olingo')/Friends");
-//    assertEquals(200, response.getStatus());
-//
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("$metadata#People", node.get("@odata.context").asText());
-//    assertTrue(node.get("value").isArray());
-//    assertEquals("scottketchum", ((ArrayNode)node.get("value")).get(1).get("UserName").asText());
-//  }
-//
-//  @Test
-//  public void testUpdatePrimitiveProperty() throws Exception {
-//    String payload = "{"
-//        + " \"value\":\"Pilar Ackerman\""
-//        + "}";
-//
-//    String editUrl = baseURL + "/People('russellwhyte')/FirstName";
-//    ContentResponse response = http.newRequest(editUrl)
-//        .content(content(payload), "application/json")
-//        .method(HttpMethod.PUT)
-//        .send();
-//    assertEquals(204, response.getStatus());
-//
-//    response = http.GET(editUrl);
-//    assertEquals(200, response.getStatus());
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("$metadata#People('russellwhyte')/FirstName", node.get("@odata.context").asText());
-//    assertEquals("Pilar Ackerman", node.get("value").asText());
-//  }
-//
-//  @Test
-//  public void testUpdatePrimitiveArrayProperty() throws Exception {
-//    String payload = "{"
-//        + " \"value\": [\n" +
-//        "       \"olingo@apache.com\"\n" +
-//        "    ]"
-//        + "}";
-//
-//    String editUrl = baseURL + "/People('russellwhyte')/Emails";
-//    ContentResponse response = http.newRequest(editUrl)
-//        .content(content(payload), "application/json")
-//        .method(HttpMethod.PUT)
-//        .send();
-//    assertEquals(204, response.getStatus());
-//
-//    response = http.GET(editUrl);
-//    assertEquals(200, response.getStatus());
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("$metadata#People('russellwhyte')/Emails", node.get("@odata.context").asText());
-//    assertTrue(node.get("value").isArray());
-//    assertEquals("olingo@apache.com", ((ArrayNode)node.get("value")).get(0).asText());
-//  }
-//
-//  @Test
-//  public void testDeleteProperty() throws Exception {
-//    String editUrl = baseURL + "/People('russellwhyte')/FirstName";
-//    ContentResponse response = http.GET(editUrl);
-//    assertEquals(200, response.getStatus());
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("Russell", node.get("value").asText());
-//
-//    response = http.newRequest(editUrl)
-//        .method(HttpMethod.DELETE)
-//        .send();
-//    assertEquals(204, response.getStatus());
-//
-//    response = http.GET(editUrl);
-//    assertEquals(204, response.getStatus());
-//  }
-//
-//  @Test
-//  public void testReadNavigationPropertyEntityCollection() throws Exception {
-//    String editUrl = baseURL + "/People('russellwhyte')/Friends";
-//    ContentResponse response = http.GET(editUrl);
-//    assertEquals(200, response.getStatus());
-//
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("$metadata#People", node.get("@odata.context").asText());
-//
-//    JsonNode person = ((ArrayNode)node.get("value")).get(0);
-//    assertEquals("scottketchum", person.get("UserName").asText());
-//  }
-//
-//  @Test
-//  public void testReadNavigationPropertyEntityCollection2() throws Exception {
-//    String editUrl = baseURL + "/People('russellwhyte')/Friends('scottketchum')/Trips";
-//    ContentResponse response = http.GET(editUrl);
-//    assertEquals(200, response.getStatus());
-//
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("$metadata#People('russellwhyte')/Friends('scottketchum')/Trips",
-//        node.get("@odata.context").asText());
-//    assertTrue(node.get("value").isArray());
-//    assertEquals("1001", ((ArrayNode)node.get("value")).get(0).get("TripId").asText());
-//  }
-//
-//  @Test
-//  public void testReadNavigationPropertyEntity() throws Exception {
-//    String editUrl = baseURL + "/People('russellwhyte')/Trips(1003)";
-//    ContentResponse response = http.GET(editUrl);
-//    assertEquals(200, response.getStatus());
-//
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("$metadata#People('russellwhyte')/Trips/$entity",
-//        node.get("@odata.context").asText());
-//    assertEquals("f94e9116-8bdd-4dac-ab61-08438d0d9a71", node.get("ShareId").asText());
-//  }
-//
-//  @Test
-//  public void testReadNavigationPropertyEntityNotExisting() throws Exception {
-//    String editUrl = baseURL + "/People('russellwhyte')/Trips(9999)";
-//    ContentResponse response = http.GET(editUrl);
-//    assertEquals(204, response.getStatus());
-//  }
-//
-//  @Test
-//  public void testReadNavigationPropertyEntitySetNotExisting() throws Exception {
-//    String editUrl = baseURL + "/People('jhondoe')/Trips";
-//    ContentResponse response = http.GET(editUrl);
-//    assertEquals(200, response.getStatus());
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("$metadata#People('jhondoe')/Trips",
-//        node.get("@odata.context").asText());
-//    assertEquals(0, ((ArrayNode)node.get("value")).size());
-//  }
-//
-//  @Test
-//  public void testBadNavigationProperty() throws Exception {
-//    String editUrl = baseURL + "/People('russellwhyte')/Unknown";
-//    ContentResponse response = http.GET(editUrl);
-//    assertEquals(404, response.getStatus());
-//  }
-//
-//  @Test
-//  public void testReadNavigationPropertyEntityProperty() throws Exception {
-//    String editUrl = baseURL + "/People('russellwhyte')/Trips(1003)/PlanItems(5)/ConfirmationCode";
-//    ContentResponse response = http.GET(editUrl);
-//    assertEquals(200, response.getStatus());
-//
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("$metadata#People('russellwhyte')/Trips(1003)/PlanItems(5)/ConfirmationCode",
-//        node.get("@odata.context").asText());
-//
-//    assertEquals("JH58494", node.get("value").asText());
-//  }
-//
-//  @Test
-//  public void testReadNavigationPropertyEntityMultipleDerivedTypes() throws Exception {
-//    String editUrl = baseURL + "/People('russellwhyte')/Trips(1003)/PlanItems";
-//    ContentResponse response = http.GET(editUrl);
-//    assertEquals(200, response.getStatus());
-//
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("$metadata#People('russellwhyte')/Trips(1003)/PlanItems",
-//        node.get("@odata.context").asText());
-//
-//    assertEquals("#Microsoft.OData.SampleService.Models.TripPin.Flight",
-//        ((ArrayNode) node.get("value")).get(0).get("@odata.type").asText());
-//  }
-//
-//  @Test
-//  public void testReadNavigationPropertyEntityCoolectionDerivedFilter() throws Exception {
-//    String editUrl = baseURL
-//        + "/People('russellwhyte')/Trips(1003)/PlanItems/Microsoft.OData.SampleService.Models.TripPin.Event";
-//    ContentResponse response = http.GET(editUrl);
-//    assertEquals(200, response.getStatus());
-//
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("$metadata#People('russellwhyte')/Trips(1003)/PlanItems/"
-//        + "Microsoft.OData.SampleService.Models.TripPin.Event",
-//        node.get("@odata.context").asText());
-//
-//    assertEquals("#Microsoft.OData.SampleService.Models.TripPin.Event",
-//        ((ArrayNode) node.get("value")).get(0).get("@odata.type").asText());
-//  }
-//
-//  @Test
-//  public void testReadNavigationPropertyEntityDerivedFilter() throws Exception {
-//    String editUrl = baseURL+ "/People('russellwhyte')/Trips(1003)/PlanItems(56)/"
-//        + "Microsoft.OData.SampleService.Models.TripPin.Event";
-//    ContentResponse response = http.GET(editUrl);
-//    assertEquals(200, response.getStatus());
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("$metadata#People('russellwhyte')/Trips(1003)/PlanItems/"
-//        + "Microsoft.OData.SampleService.Models.TripPin.Event/$entity",
-//        node.get("@odata.context").asText());
-//
-//    assertEquals("#Microsoft.OData.SampleService.Models.TripPin.Event", node.get("@odata.type").asText());
-//    assertEquals("56", node.get("PlanItemId").asText());
-//  }
-//
-//  @Test
-//  public void testUpdateReference() throws Exception {
-//    ContentResponse response = http.GET(baseURL+"/People('ronaldmundy')/Photo/$ref");
-//    assertEquals(200, response.getStatus());
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("/Photos(12)", node.get("@odata.id").asText());
-//
-//    String msg = "{\n" +
-//        "\"@odata.id\": \"/Photos(11)\"\n" +
-//        "}";
-//    String editUrl = baseURL + "/People('ronaldmundy')/Photo/$ref";
-//    response = http.newRequest(editUrl)
-//        .method(HttpMethod.PUT)
-//        .content(content(msg))
-//        .header("Content-Type", "application/json;odata.metadata=minimal")
-//        .send();
-//    assertEquals(204, response.getStatus());
-//
-//    response = http.GET(baseURL+"/People('ronaldmundy')/Photo/$ref");
-//    assertEquals(200, response.getStatus());
-//    node = getJSONNode(response);
-//    assertEquals("/Photos(11)", node.get("@odata.id").asText());
-//  }
-//
-//  @Test
-//  public void testAddDelete2ReferenceCollection() throws Exception {
-//    // add
-//    String msg = "{\n" +
-//        "\"@odata.id\": \"/People('russellwhyte')\"\n" +
-//        "}";
-//    String editUrl = baseURL + "/People('vincentcalabrese')/Friends/$ref";
-//    ContentResponse response = http.newRequest(editUrl)
-//        .method(HttpMethod.POST)
-//        .content(content(msg))
-//        .header("Content-Type", "application/json;odata.metadata=minimal")
-//        .send();
-//    assertEquals(204, response.getStatus());
-//
-//    // get
-//    response = http.GET(editUrl);
-//    assertEquals(200, response.getStatus());
-//    JsonNode node = getJSONNode(response);
-//    assertEquals("/People('russellwhyte')",
-//        ((ArrayNode) node.get("value")).get(2).get("@odata.id").asText());
-//
-//    //delete
-//    response = http.newRequest(editUrl+"?$id="+baseURL+"/People('russellwhyte')")
-//        .method(HttpMethod.DELETE)
-//        .content(content(msg))
-//        .header("Content-Type", "application/json;odata.metadata=minimal")
-//        .send();
-//    assertEquals(204, response.getStatus());
-//
-//    // get
-//    response = http.GET(editUrl);
-//    assertEquals(200, response.getStatus());
-//    node = getJSONNode(response);
-//    assertNull("/People('russellwhyte')", ((ArrayNode) node.get("value")).get(2));
-//  }
-//
-//  @Test
-//  public void testDeleteReference() throws Exception {
-//    String editUrl = baseURL + "/People('russellwhyte')/Photo/$ref";
-//    ContentResponse response = http.GET(editUrl);
-//    assertEquals(200, response.getStatus());
-//
-//    response = http.newRequest(editUrl)
-//        .method(HttpMethod.DELETE)
-//        .send();
-//    assertEquals(204, response.getStatus());
-//
-//    response = http.GET(editUrl);
-//    assertEquals(204, response.getStatus());
-//  }
-//
-//  @Test
-//  public void testCrossJoin() throws Exception {
-//    String editUrl = baseURL + "/$crossjoin(People,Airlines)";
-//    ContentResponse response = http.GET(editUrl);
-//    assertEquals(200, response.getStatus());
-//  }
-//
-//  public static ContentProvider content(final String msg) {
-//    return new ContentProvider() {
-//      boolean hasNext = true;
-//
-//      @Override
-//      public Iterator<ByteBuffer> iterator() {
-//        return new Iterator<ByteBuffer>() {
-//          @Override
-//          public boolean hasNext() {
-//            return hasNext;
-//          }
-//          @Override
-//          public ByteBuffer next() {
-//            hasNext = false;
-//            return ByteBuffer.wrap(msg.getBytes());
-//          }
-//          @Override
-//          public void remove() {
-//          }
-//        };
-//      }
-//      @Override
-//      public long getLength() {
-//        return msg.length();
-//      }
-//    };
-//  }
+  @Test
+  public void testReadNavigationPropertyEntity() throws Exception {
+    String editUrl = baseURL + "/People('russellwhyte')/Trips(1003)";
+    HttpResponse response = httpGET(editUrl, 200);
+    JsonNode node = getJSONNode(response);
+    assertEquals("$metadata#People('russellwhyte')/Trips/$entity",
+        node.get("@odata.context").asText());
+    assertEquals("f94e9116-8bdd-4dac-ab61-08438d0d9a71", node.get("ShareId").asText());
+  }
+
+  @Test
+  public void testReadNavigationPropertyEntityNotExisting() throws Exception {
+    String editUrl = baseURL + "/People('russellwhyte')/Trips(9999)";
+    HttpResponse response = httpGET(editUrl, 204);
+    EntityUtils.consumeQuietly(response.getEntity());
+  }
+
+  @Test
+  public void testReadNavigationPropertyEntitySetNotExisting() throws Exception {
+    String editUrl = baseURL + "/People('jhondoe')/Trips";
+    HttpResponse response = httpGET(editUrl, 200);
+    JsonNode node = getJSONNode(response);
+    assertEquals("$metadata#People('jhondoe')/Trips",
+        node.get("@odata.context").asText());
+    assertEquals(0, ((ArrayNode)node.get("value")).size());
+  }
+
+  @Test
+  public void testBadNavigationProperty() throws Exception {
+    String editUrl = baseURL + "/People('russellwhyte')/Unknown";
+    HttpResponse response = httpGET(editUrl, 404);
+    EntityUtils.consumeQuietly(response.getEntity());
+  }
+
+  @Test
+  public void testReadNavigationPropertyEntityProperty() throws Exception {
+    String editUrl = baseURL + "/People('russellwhyte')/Trips(1003)/PlanItems(5)/ConfirmationCode";
+    HttpResponse response = httpGET(editUrl, 200);
+    JsonNode node = getJSONNode(response);
+    assertEquals("$metadata#People('russellwhyte')/Trips(1003)/PlanItems(5)/ConfirmationCode",
+        node.get("@odata.context").asText());
+    assertEquals("JH58494", node.get("value").asText());
+  }
+
+  @Test
+  public void testReadNavigationPropertyEntityMultipleDerivedTypes() throws Exception {
+    String editUrl = baseURL + "/People('russellwhyte')/Trips(1003)/PlanItems";
+    HttpResponse response = httpGET(editUrl, 200);
+    JsonNode node = getJSONNode(response);
+    assertEquals("$metadata#People('russellwhyte')/Trips(1003)/PlanItems",
+        node.get("@odata.context").asText());
+    assertEquals("#Microsoft.OData.SampleService.Models.TripPin.Flight",
+        ((ArrayNode) node.get("value")).get(0).get("@odata.type").asText());
+  }
+
+  @Test
+  public void testReadNavigationPropertyEntityCoolectionDerivedFilter() throws Exception {
+    String editUrl = baseURL
+        + "/People('russellwhyte')/Trips(1003)/PlanItems/Microsoft.OData.SampleService.Models.TripPin.Event";
+    HttpResponse response = httpGET(editUrl, 200);
+
+    JsonNode node = getJSONNode(response);
+    assertEquals("$metadata#People('russellwhyte')/Trips(1003)/PlanItems/"
+        + "Microsoft.OData.SampleService.Models.TripPin.Event",
+        node.get("@odata.context").asText());
+
+    assertEquals("#Microsoft.OData.SampleService.Models.TripPin.Event",
+        ((ArrayNode) node.get("value")).get(0).get("@odata.type").asText());
+  }
+
+  @Test
+  public void testReadNavigationPropertyEntityDerivedFilter() throws Exception {
+    String editUrl = baseURL+ "/People('russellwhyte')/Trips(1003)/PlanItems(56)/"
+        + "Microsoft.OData.SampleService.Models.TripPin.Event";
+    HttpResponse response = httpGET(editUrl, 200);
+    JsonNode node = getJSONNode(response);
+    assertEquals("$metadata#People('russellwhyte')/Trips(1003)/PlanItems/"
+        + "Microsoft.OData.SampleService.Models.TripPin.Event/$entity",
+        node.get("@odata.context").asText());
+    assertEquals("#Microsoft.OData.SampleService.Models.TripPin.Event", node.get("@odata.type").asText());
+    assertEquals("56", node.get("PlanItemId").asText());
+  }
+
+  @Test
+  public void testUpdateReference() throws Exception {
+    HttpResponse response = httpGET(baseURL+"/People('ronaldmundy')/Photo/$ref", 200);
+    JsonNode node = getJSONNode(response);
+    assertEquals("/Photos(12)", node.get("@odata.id").asText());
+
+    String msg = "{\n" +
+        "\"@odata.id\": \"/Photos(11)\"\n" +
+        "}";
+    String editUrl = baseURL + "/People('ronaldmundy')/Photo/$ref";
+    HttpPut putRequest = new HttpPut(editUrl);
+    putRequest.setEntity(new StringEntity(msg, ContentType.APPLICATION_JSON));
+    putRequest.setHeader("Content-Type", "application/json;odata.metadata=minimal");
+    response = httpSend(putRequest, 204);
+    EntityUtils.consumeQuietly(response.getEntity());
+
+    response = httpGET(baseURL+"/People('ronaldmundy')/Photo/$ref", 200);
+    node = getJSONNode(response);
+    assertEquals("/Photos(11)", node.get("@odata.id").asText());
+  }
+
+  @Test
+  public void testAddDelete2ReferenceCollection() throws Exception {
+    // add
+    String msg = "{\n" +
+        "\"@odata.id\": \"/People('russellwhyte')\"\n" +
+        "}";
+    String editUrl = baseURL + "/People('vincentcalabrese')/Friends/$ref";
+    HttpPost postRequest = new HttpPost(editUrl);
+    postRequest.setEntity(new StringEntity(msg, ContentType.APPLICATION_JSON));
+    postRequest.addHeader("Content-Type", "application/json;odata.metadata=minimal");
+    HttpResponse response = httpSend(postRequest, 204);
+    EntityUtils.consumeQuietly(response.getEntity());
+    
+    // get
+    response = httpGET(editUrl, 200);
+    JsonNode node = getJSONNode(response);
+    assertEquals("/People('russellwhyte')",
+        ((ArrayNode) node.get("value")).get(2).get("@odata.id").asText());
+
+    //delete
+    HttpDelete deleteRequest = new HttpDelete(editUrl+"?$id="+baseURL+"/People('russellwhyte')");
+    deleteRequest.addHeader("Content-Type", "application/json;odata.metadata=minimal");
+    response = httpSend(deleteRequest, 204);
+    EntityUtils.consumeQuietly(response.getEntity());
+
+    // get
+    response = httpGET(editUrl, 200);
+    node = getJSONNode(response);
+    assertNull("/People('russellwhyte')", ((ArrayNode) node.get("value")).get(2));
+  }
+
+  @Test
+  public void testDeleteReference() throws Exception {
+    String editUrl = baseURL + "/People('russellwhyte')/Photo/$ref";
+    HttpResponse response = httpGET(editUrl, 200);
+    EntityUtils.consumeQuietly(response.getEntity());
+    
+    HttpDelete deleteRequest = new HttpDelete(editUrl);
+    response = httpSend(deleteRequest, 204);
+    EntityUtils.consumeQuietly(response.getEntity());
+    
+    response = httpGET(editUrl, 204);
+    EntityUtils.consumeQuietly(response.getEntity());
+  }
+
+  @Test
+  public void testCrossJoin() throws Exception {
+    String editUrl = baseURL + "/$crossjoin(People,Airlines)";
+    HttpResponse response = httpGET(editUrl, 200);
+    EntityUtils.consumeQuietly(response.getEntity());
+  }
 }


[18/22] olingo-odata4 git commit: [OLINGO-573] Start replacement of Jetty with Tomcat

Posted by ra...@apache.org.
[OLINGO-573] Start replacement of Jetty with Tomcat


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

Branch: refs/heads/OLINGO-573
Commit: b6da769ac8f25ddd3a0bb3f8d7b6e6092b0279e3
Parents: 29e2833
Author: Michael Bolz <mi...@sap.com>
Authored: Thu Apr 2 15:09:02 2015 +0200
Committer: Ramesh Reddy <ra...@jboss.org>
Committed: Thu Apr 16 09:13:14 2015 -0500

----------------------------------------------------------------------
 lib/pom.xml                                     |    2 -
 lib/server-core-ext/pom.xml                     |   57 +-
 .../server/core/ServiceDispatcherTest.java      |  749 +++++----
 .../server/example/TripPinServiceTest.java      | 1417 +++++++++---------
 pom.xml                                         |    7 +-
 5 files changed, 1114 insertions(+), 1118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b6da769a/lib/pom.xml
----------------------------------------------------------------------
diff --git a/lib/pom.xml b/lib/pom.xml
index 44d6d7c..d1e8864 100644
--- a/lib/pom.xml
+++ b/lib/pom.xml
@@ -42,9 +42,7 @@
     <module>client-core</module>
     <module>server-api</module>
     <module>server-core</module>
-    <!-- Temporary disable build of core-ext module
     <module>server-core-ext</module>
-    -->
     <module>server-tecsvc</module>
     <module>server-test</module>
   </modules>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b6da769a/lib/server-core-ext/pom.xml
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/pom.xml b/lib/server-core-ext/pom.xml
index a5730c0..5249ed4 100644
--- a/lib/server-core-ext/pom.xml
+++ b/lib/server-core-ext/pom.xml
@@ -59,6 +59,7 @@
     <dependency>
       <groupId>javax.servlet</groupId>
       <artifactId>javax.servlet-api</artifactId>
+      <version>3.0.1</version>
       <scope>provided</scope>
     </dependency>
     <dependency>
@@ -82,36 +83,32 @@
       <artifactId>commons-io</artifactId>
       <scope>test</scope>
     </dependency>
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-server</artifactId>
-            <scope>test</scope>
-            <version>${jetty-version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-servlet</artifactId>
-            <version>${jetty-version}</version>
-            <scope>test</scope>
-            <exclusions>
-              <exclusion>
-                <groupId>javax.servlet</groupId>
-                <artifactId>javax.servlet-api</artifactId>
-              </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-http</artifactId>
-            <version>${jetty-version}</version>
-            <scope>test</scope>
-        </dependency>    
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-client</artifactId>
-            <scope>test</scope>
-            <version>${jetty-version}</version>
-        </dependency>        
+    <dependency>
+      <groupId>org.apache.tomcat.embed</groupId>
+      <artifactId>tomcat-embed-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomcat.embed</groupId>
+      <artifactId>tomcat-embed-logging-log4j</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomcat</groupId>
+      <artifactId>tomcat-jasper</artifactId>
+      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>javax.servlet</groupId>
+          <artifactId>javax.servlet-api</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
 </project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b6da769a/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/ServiceDispatcherTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/ServiceDispatcherTest.java b/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/ServiceDispatcherTest.java
index 16caa1a..c918134 100644
--- a/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/ServiceDispatcherTest.java
+++ b/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/ServiceDispatcherTest.java
@@ -18,400 +18,359 @@
  */
 package org.apache.olingo.server.core;
 
-import static org.junit.Assert.assertEquals;
-
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.URI;
-import java.util.Collections;
-import java.util.List;
-
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.olingo.commons.api.edm.provider.EdmProvider;
-import org.apache.olingo.commons.api.http.HttpMethod;
-import org.apache.olingo.server.api.OData;
-import org.apache.olingo.server.api.ODataHttpHandler;
-import org.apache.olingo.server.api.ServiceMetadata;
-import org.apache.olingo.server.core.requests.ActionRequest;
-import org.apache.olingo.server.core.requests.DataRequest;
-import org.apache.olingo.server.core.requests.FunctionRequest;
-import org.apache.olingo.server.core.requests.MediaRequest;
-import org.apache.olingo.server.core.requests.MetadataRequest;
-import org.apache.olingo.server.core.responses.CountResponse;
-import org.apache.olingo.server.core.responses.EntityResponse;
-import org.apache.olingo.server.core.responses.EntitySetResponse;
-import org.apache.olingo.server.core.responses.MetadataResponse;
-import org.apache.olingo.server.core.responses.NoContentResponse;
-import org.apache.olingo.server.core.responses.PrimitiveValueResponse;
-import org.apache.olingo.server.core.responses.PropertyResponse;
-import org.apache.olingo.server.core.responses.StreamResponse;
-import org.apache.olingo.server.example.TripPinServiceTest;
-import org.eclipse.jetty.client.HttpClient;
-import org.eclipse.jetty.server.Connector;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.ServerConnector;
-import org.eclipse.jetty.servlet.ServletContextHandler;
-import org.eclipse.jetty.servlet.ServletHolder;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mockito;
-
 public class ServiceDispatcherTest {
-  private Server server;
-
-  public class SampleODataServlet extends HttpServlet {
-    private final ServiceHandler handler; // must be stateless
-    private final EdmProvider provider; // must be stateless
-
-    public SampleODataServlet(ServiceHandler handler, EdmProvider provider) {
-      this.handler = handler;
-      this.provider = provider;
-    }
-
-    @Override
-    public void service(HttpServletRequest request, HttpServletResponse response)
-        throws IOException {
-      OData odata = OData4Impl.newInstance();
-      ServiceMetadata metadata = odata.createServiceMetadata(this.provider, Collections.EMPTY_LIST);
-
-      ODataHttpHandler handler = odata.createHandler(metadata);
-
-      handler.register(this.handler);
-      handler.process(request, response);
-    }
-  }
-
-  public int beforeTest(ServiceHandler serviceHandler) throws Exception {
-    MetadataParser parser = new MetadataParser();
-    EdmProvider edmProvider = parser.buildEdmProvider(new FileReader(
-        "src/test/resources/trippin.xml"));
-
-    this.server = new Server();
-
-    ServerConnector connector = new ServerConnector(this.server);
-    this.server.setConnectors(new Connector[] { connector });
-
-    ServletContextHandler context = new ServletContextHandler();
-    context.setContextPath("/trippin");
-    context
-        .addServlet(new ServletHolder(new SampleODataServlet(serviceHandler, edmProvider)), "/*");
-    this.server.setHandler(context);
-    this.server.start();
-
-    return connector.getLocalPort();
-  }
-
-  public void afterTest() throws Exception {
-    this.server.stop();
-  }
-
-  interface TestResult {
-    void validate() throws Exception;
-  }
-
-  private void helpGETTest(ServiceHandler handler, String path, TestResult validator)
-      throws Exception {
-    int port = beforeTest(handler);
-    HttpClient http = new HttpClient();
-    http.start();
-    http.GET("http://localhost:" + port + "/" + path);
-    validator.validate();
-    afterTest();
-  }
-
-  private void helpTest(ServiceHandler handler, String path, String method, String payload,
-      TestResult validator) throws Exception {
-    int port = beforeTest(handler);
-    HttpClient http = new HttpClient();
-    http.start();
-    String editUrl = "http://localhost:" + port + "/" + path;
-    http.newRequest(editUrl).method(method)
-        .header("Content-Type", "application/json;odata.metadata=minimal")
-        .content(TripPinServiceTest.content(payload)).send();
-    validator.validate();
-    afterTest();
-  }
-
-  @Test
-  public void testMetadata() throws Exception {
-    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-    helpGETTest(handler, "trippin/$metadata", new TestResult() {
-      @Override
-      public void validate() throws Exception {
-        ArgumentCaptor<MetadataRequest> arg1 = ArgumentCaptor.forClass(MetadataRequest.class);
-        ArgumentCaptor<MetadataResponse> arg2 = ArgumentCaptor.forClass(MetadataResponse.class);
-        Mockito.verify(handler).readMetadata(arg1.capture(), arg2.capture());
-      }
-    });
-  }
-
-  @Test
-  public void testEntitySet() throws Exception {
-    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-    helpGETTest(handler, "trippin/Airports", new TestResult() {
-      @Override
-      public void validate() throws Exception {
-        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
-        ArgumentCaptor<EntityResponse> arg2 = ArgumentCaptor.forClass(EntityResponse.class);
-        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
-
-        DataRequest request = arg1.getValue();
-        // Need toString on ContextURL class
-        // assertEquals("",
-        // request.getContextURL(request.getOdata()).toString());
-        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
-            .toContentTypeString());
-      }
-    });
-  }
-
-  @Test
-  public void testEntitySetCount() throws Exception {
-    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-    helpGETTest(handler, "trippin/Airports/$count", new TestResult() {
-      @Override
-      public void validate() throws Exception {
-        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
-        ArgumentCaptor<CountResponse> arg2 = ArgumentCaptor.forClass(CountResponse.class);
-        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
-
-        DataRequest request = arg1.getValue();
-        // Need toString on ContextURL class
-        // assertEquals("",
-        // request.getContextURL(request.getOdata()).toString());
-        assertEquals("text/plain", request.getResponseContentType().toContentTypeString());
-      }
-    });
-  }
-
-  @Test
-  public void testEntity() throws Exception {
-    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-    helpGETTest(handler, "trippin/Airports('0')", new TestResult() {
-      @Override
-      public void validate() throws Exception {
-        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
-        ArgumentCaptor<EntityResponse> arg2 = ArgumentCaptor.forClass(EntityResponse.class);
-        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
-
-        DataRequest request = arg1.getValue();
-        assertEquals(1, request.getUriResourceEntitySet().getKeyPredicates().size());
-        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
-            .toContentTypeString());
-      }
-    });
-  }
-
-  @Test
-  public void testReadProperty() throws Exception {
-    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-    helpGETTest(handler, "trippin/Airports('0')/IataCode", new TestResult() {
-      @Override
-      public void validate() throws Exception {
-        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
-        ArgumentCaptor<PropertyResponse> arg2 = ArgumentCaptor.forClass(PropertyResponse.class);
-        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
-
-        DataRequest request = arg1.getValue();
-        assertEquals(true, request.isPropertyRequest());
-        assertEquals(false, request.isPropertyComplex());
-        assertEquals(1, request.getUriResourceEntitySet().getKeyPredicates().size());
-        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
-            .toContentTypeString());
-      }
-    });
-  }
-
-  @Test
-  public void testReadComplexProperty() throws Exception {
-    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-    helpGETTest(handler, "trippin/Airports('0')/Location", new TestResult() {
-      @Override
-      public void validate() throws Exception {
-        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
-        ArgumentCaptor<PropertyResponse> arg2 = ArgumentCaptor.forClass(PropertyResponse.class);
-        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
-
-        DataRequest request = arg1.getValue();
-        assertEquals(true, request.isPropertyRequest());
-        assertEquals(true, request.isPropertyComplex());
-        assertEquals(1, request.getUriResourceEntitySet().getKeyPredicates().size());
-        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
-            .toContentTypeString());
-      }
-    });
-  }
-
-  @Test
-  public void testReadProperty$Value() throws Exception {
-    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-    helpGETTest(handler, "trippin/Airports('0')/IataCode/$value", new TestResult() {
-      @Override
-      public void validate() throws Exception {
-        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
-        ArgumentCaptor<PrimitiveValueResponse> arg2 = ArgumentCaptor
-            .forClass(PrimitiveValueResponse.class);
-        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
-
-        DataRequest request = arg1.getValue();
-        assertEquals(true, request.isPropertyRequest());
-        assertEquals(false, request.isPropertyComplex());
-        assertEquals(1, request.getUriResourceEntitySet().getKeyPredicates().size());
-        assertEquals("text/plain", request.getResponseContentType().toContentTypeString());
-      }
-    });
-  }
-
-  @Test
-  public void testReadPropertyRef() throws Exception {
-    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-    helpGETTest(handler, "trippin/Airports('0')/IataCode/$value", new TestResult() {
-      @Override
-      public void validate() throws Exception {
-        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
-        ArgumentCaptor<PrimitiveValueResponse> arg2 = ArgumentCaptor
-            .forClass(PrimitiveValueResponse.class);
-        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
-
-        DataRequest request = arg1.getValue();
-        assertEquals(true, request.isPropertyRequest());
-        assertEquals(false, request.isPropertyComplex());
-        assertEquals(1, request.getUriResourceEntitySet().getKeyPredicates().size());
-        assertEquals("text/plain", request.getResponseContentType().toContentTypeString());
-      }
-    });
-  }
-
-  @Test
-  public void testFunctionImport() throws Exception {
-    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-    helpGETTest(handler, "trippin/GetNearestAirport(lat=12.11,lon=34.23)", new TestResult() {
-      @Override
-      public void validate() throws Exception {
-        ArgumentCaptor<FunctionRequest> arg1 = ArgumentCaptor.forClass(FunctionRequest.class);
-        ArgumentCaptor<PropertyResponse> arg3 = ArgumentCaptor.forClass(PropertyResponse.class);
-        ArgumentCaptor<HttpMethod> arg2 = ArgumentCaptor.forClass(HttpMethod.class);
-        Mockito.verify(handler).invoke(arg1.capture(), arg2.capture(), arg3.capture());
-
-        FunctionRequest request = arg1.getValue();
-      }
-    });
-  }
-
-  @Test
-  public void testActionImport() throws Exception {
-    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-    helpTest(handler, "trippin/ResetDataSource", "POST", "", new TestResult() {
-      @Override
-      public void validate() throws Exception {
-        ArgumentCaptor<ActionRequest> arg1 = ArgumentCaptor.forClass(ActionRequest.class);
-        ArgumentCaptor<NoContentResponse> arg2 = ArgumentCaptor.forClass(NoContentResponse.class);
-        Mockito.verify(handler).invoke(arg1.capture(), Mockito.anyString(), arg2.capture());
-
-        ActionRequest request = arg1.getValue();
-      }
-    });
-  }
-
-  @Test
-  public void testReadMedia() throws Exception {
-    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-    helpGETTest(handler, "trippin/Photos(1)/$value", new TestResult() {
-      @Override
-      public void validate() throws Exception {
-        ArgumentCaptor<MediaRequest> arg1 = ArgumentCaptor.forClass(MediaRequest.class);
-        ArgumentCaptor<StreamResponse> arg2 = ArgumentCaptor.forClass(StreamResponse.class);
-        Mockito.verify(handler).readMediaStream(arg1.capture(), arg2.capture());
-
-        MediaRequest request = arg1.getValue();
-        assertEquals("application/octet-stream", request.getResponseContentType()
-            .toContentTypeString());
-      }
-    });
-  }
-
-  @Test
-  public void testReadNavigation() throws Exception {
-    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-    helpGETTest(handler, "trippin/People('russelwhyte')/Friends", new TestResult() {
-      @Override
-      public void validate() throws Exception {
-        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
-        ArgumentCaptor<EntitySetResponse> arg2 = ArgumentCaptor.forClass(EntitySetResponse.class);
-        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
-
-        DataRequest request = arg1.getValue();
-        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
-            .toContentTypeString());
-      }
-    });
-  }
-
-  @Test
-  public void testReadReference() throws Exception {
-    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-    helpGETTest(handler, "trippin/People('russelwhyte')/Friends/$ref", new TestResult() {
-      @Override
-      public void validate() throws Exception {
-        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
-        ArgumentCaptor<EntitySetResponse> arg2 = ArgumentCaptor.forClass(EntitySetResponse.class);
-        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
-
-        DataRequest request = arg1.getValue();
-        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
-            .toContentTypeString());
-      }
-    });
-  }
-
-  @Test
-  public void testWriteReferenceCollection() throws Exception {
-    String payload = "{\n" + "\"@odata.id\": \"/Photos(11)\"\n" + "}";
-
-    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-    helpTest(handler, "trippin/People('russelwhyte')/Friends/$ref", "POST", payload,
-        new TestResult() {
-          @Override
-          public void validate() throws Exception {
-            ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
-            ArgumentCaptor<String> arg2 = ArgumentCaptor.forClass(String.class);
-            ArgumentCaptor<List> arg3 = ArgumentCaptor.forClass(List.class);
-            ArgumentCaptor<NoContentResponse> arg4 = ArgumentCaptor
-                .forClass(NoContentResponse.class);
-            Mockito.verify(handler).addReference(arg1.capture(), arg2.capture(), arg3.capture(),
-                arg4.capture());
-
-            DataRequest request = arg1.getValue();
-            assertEquals("application/json;odata.metadata=minimal", request
-                .getResponseContentType().toContentTypeString());
-          }
-        });
-  }
-
-  @Test
-  public void testWriteReference() throws Exception {
-    String payload = "{\n" + "\"@odata.id\": \"/Photos(11)\"\n" + "}";
-
-    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
-    helpTest(handler, "trippin/People('russelwhyte')/Friends('someone')/Photo/$ref", "PUT", payload,
-        new TestResult() {
-          @Override
-          public void validate() throws Exception {
-            ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
-            ArgumentCaptor<String> arg2 = ArgumentCaptor.forClass(String.class);
-            ArgumentCaptor<URI> arg3 = ArgumentCaptor.forClass(URI.class);
-            ArgumentCaptor<NoContentResponse> arg4 = ArgumentCaptor
-                .forClass(NoContentResponse.class);
-            Mockito.verify(handler).updateReference(arg1.capture(), arg2.capture(), arg3.capture(),
-                arg4.capture());
-
-            DataRequest request = arg1.getValue();
-            assertEquals("application/json;odata.metadata=minimal", request
-                .getResponseContentType().toContentTypeString());
-          }
-        });
-  }
+//  private Server server;
+//
+//  public class SampleODataServlet extends HttpServlet {
+//    private final ServiceHandler handler; // must be stateless
+//    private final EdmProvider provider; // must be stateless
+//
+//    public SampleODataServlet(ServiceHandler handler, EdmProvider provider) {
+//      this.handler = handler;
+//      this.provider = provider;
+//    }
+//
+//    @Override
+//    public void service(HttpServletRequest request, HttpServletResponse response)
+//        throws IOException {
+//      OData odata = OData4Impl.newInstance();
+//      ServiceMetadata metadata = odata.createServiceMetadata(this.provider, Collections.EMPTY_LIST);
+//
+//      ODataHttpHandler handler = odata.createHandler(metadata);
+//
+//      handler.register(this.handler);
+//      handler.process(request, response);
+//    }
+//  }
+//
+//  public int beforeTest(ServiceHandler serviceHandler) throws Exception {
+//    MetadataParser parser = new MetadataParser();
+//    EdmProvider edmProvider = parser.buildEdmProvider(new FileReader(
+//        "src/test/resources/trippin.xml"));
+//
+//    this.server = new Server();
+//
+//    ServerConnector connector = new ServerConnector(this.server);
+//    this.server.setConnectors(new Connector[] { connector });
+//
+//    ServletContextHandler context = new ServletContextHandler();
+//    context.setContextPath("/trippin");
+//    context
+//        .addServlet(new ServletHolder(new SampleODataServlet(serviceHandler, edmProvider)), "/*");
+//    this.server.setHandler(context);
+//    this.server.start();
+//
+//    return connector.getLocalPort();
+//  }
+//
+//  public void afterTest() throws Exception {
+//    this.server.stop();
+//  }
+//
+//  interface TestResult {
+//    void validate() throws Exception;
+//  }
+//
+//  private void helpGETTest(ServiceHandler handler, String path, TestResult validator)
+//      throws Exception {
+//    int port = beforeTest(handler);
+//    HttpClient http = new HttpClient();
+//    http.start();
+//    http.GET("http://localhost:" + port + "/" + path);
+//    validator.validate();
+//    afterTest();
+//  }
+//
+//  private void helpTest(ServiceHandler handler, String path, String method, String payload,
+//      TestResult validator) throws Exception {
+//    int port = beforeTest(handler);
+//    HttpClient http = new HttpClient();
+//    http.start();
+//    String editUrl = "http://localhost:" + port + "/" + path;
+//    http.newRequest(editUrl).method(method)
+//        .header("Content-Type", "application/json;odata.metadata=minimal")
+//        .content(TripPinServiceTest.content(payload)).send();
+//    validator.validate();
+//    afterTest();
+//  }
+//
+//  @Test
+//  public void testMetadata() throws Exception {
+//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+//    helpGETTest(handler, "trippin/$metadata", new TestResult() {
+//      @Override
+//      public void validate() throws Exception {
+//        ArgumentCaptor<MetadataRequest> arg1 = ArgumentCaptor.forClass(MetadataRequest.class);
+//        ArgumentCaptor<MetadataResponse> arg2 = ArgumentCaptor.forClass(MetadataResponse.class);
+//        Mockito.verify(handler).readMetadata(arg1.capture(), arg2.capture());
+//      }
+//    });
+//  }
+//
+//  @Test
+//  public void testEntitySet() throws Exception {
+//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+//    helpGETTest(handler, "trippin/Airports", new TestResult() {
+//      @Override
+//      public void validate() throws Exception {
+//        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
+//        ArgumentCaptor<EntityResponse> arg2 = ArgumentCaptor.forClass(EntityResponse.class);
+//        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
+//
+//        DataRequest request = arg1.getValue();
+//        // Need toString on ContextURL class
+//        // assertEquals("",
+//        // request.getContextURL(request.getOdata()).toString());
+//        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
+//            .toContentTypeString());
+//      }
+//    });
+//  }
+//
+//  @Test
+//  public void testEntitySetCount() throws Exception {
+//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+//    helpGETTest(handler, "trippin/Airports/$count", new TestResult() {
+//      @Override
+//      public void validate() throws Exception {
+//        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
+//        ArgumentCaptor<CountResponse> arg2 = ArgumentCaptor.forClass(CountResponse.class);
+//        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
+//
+//        DataRequest request = arg1.getValue();
+//        // Need toString on ContextURL class
+//        // assertEquals("",
+//        // request.getContextURL(request.getOdata()).toString());
+//        assertEquals("text/plain", request.getResponseContentType().toContentTypeString());
+//      }
+//    });
+//  }
+//
+//  @Test
+//  public void testEntity() throws Exception {
+//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+//    helpGETTest(handler, "trippin/Airports('0')", new TestResult() {
+//      @Override
+//      public void validate() throws Exception {
+//        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
+//        ArgumentCaptor<EntityResponse> arg2 = ArgumentCaptor.forClass(EntityResponse.class);
+//        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
+//
+//        DataRequest request = arg1.getValue();
+//        assertEquals(1, request.getUriResourceEntitySet().getKeyPredicates().size());
+//        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
+//            .toContentTypeString());
+//      }
+//    });
+//  }
+//
+//  @Test
+//  public void testReadProperty() throws Exception {
+//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+//    helpGETTest(handler, "trippin/Airports('0')/IataCode", new TestResult() {
+//      @Override
+//      public void validate() throws Exception {
+//        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
+//        ArgumentCaptor<PropertyResponse> arg2 = ArgumentCaptor.forClass(PropertyResponse.class);
+//        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
+//
+//        DataRequest request = arg1.getValue();
+//        assertEquals(true, request.isPropertyRequest());
+//        assertEquals(false, request.isPropertyComplex());
+//        assertEquals(1, request.getUriResourceEntitySet().getKeyPredicates().size());
+//        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
+//            .toContentTypeString());
+//      }
+//    });
+//  }
+//
+//  @Test
+//  public void testReadComplexProperty() throws Exception {
+//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+//    helpGETTest(handler, "trippin/Airports('0')/Location", new TestResult() {
+//      @Override
+//      public void validate() throws Exception {
+//        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
+//        ArgumentCaptor<PropertyResponse> arg2 = ArgumentCaptor.forClass(PropertyResponse.class);
+//        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
+//
+//        DataRequest request = arg1.getValue();
+//        assertEquals(true, request.isPropertyRequest());
+//        assertEquals(true, request.isPropertyComplex());
+//        assertEquals(1, request.getUriResourceEntitySet().getKeyPredicates().size());
+//        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
+//            .toContentTypeString());
+//      }
+//    });
+//  }
+//
+//  @Test
+//  public void testReadProperty$Value() throws Exception {
+//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+//    helpGETTest(handler, "trippin/Airports('0')/IataCode/$value", new TestResult() {
+//      @Override
+//      public void validate() throws Exception {
+//        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
+//        ArgumentCaptor<PrimitiveValueResponse> arg2 = ArgumentCaptor
+//            .forClass(PrimitiveValueResponse.class);
+//        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
+//
+//        DataRequest request = arg1.getValue();
+//        assertEquals(true, request.isPropertyRequest());
+//        assertEquals(false, request.isPropertyComplex());
+//        assertEquals(1, request.getUriResourceEntitySet().getKeyPredicates().size());
+//        assertEquals("text/plain", request.getResponseContentType().toContentTypeString());
+//      }
+//    });
+//  }
+//
+//  @Test
+//  public void testReadPropertyRef() throws Exception {
+//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+//    helpGETTest(handler, "trippin/Airports('0')/IataCode/$value", new TestResult() {
+//      @Override
+//      public void validate() throws Exception {
+//        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
+//        ArgumentCaptor<PrimitiveValueResponse> arg2 = ArgumentCaptor
+//            .forClass(PrimitiveValueResponse.class);
+//        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
+//
+//        DataRequest request = arg1.getValue();
+//        assertEquals(true, request.isPropertyRequest());
+//        assertEquals(false, request.isPropertyComplex());
+//        assertEquals(1, request.getUriResourceEntitySet().getKeyPredicates().size());
+//        assertEquals("text/plain", request.getResponseContentType().toContentTypeString());
+//      }
+//    });
+//  }
+//
+//  @Test
+//  public void testFunctionImport() throws Exception {
+//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+//    helpGETTest(handler, "trippin/GetNearestAirport(lat=12.11,lon=34.23)", new TestResult() {
+//      @Override
+//      public void validate() throws Exception {
+//        ArgumentCaptor<FunctionRequest> arg1 = ArgumentCaptor.forClass(FunctionRequest.class);
+//        ArgumentCaptor<PropertyResponse> arg3 = ArgumentCaptor.forClass(PropertyResponse.class);
+//        ArgumentCaptor<HttpMethod> arg2 = ArgumentCaptor.forClass(HttpMethod.class);
+//        Mockito.verify(handler).invoke(arg1.capture(), arg2.capture(), arg3.capture());
+//
+//        FunctionRequest request = arg1.getValue();
+//      }
+//    });
+//  }
+//
+//  @Test
+//  public void testActionImport() throws Exception {
+//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+//    helpTest(handler, "trippin/ResetDataSource", "POST", "", new TestResult() {
+//      @Override
+//      public void validate() throws Exception {
+//        ArgumentCaptor<ActionRequest> arg1 = ArgumentCaptor.forClass(ActionRequest.class);
+//        ArgumentCaptor<NoContentResponse> arg2 = ArgumentCaptor.forClass(NoContentResponse.class);
+//        Mockito.verify(handler).invoke(arg1.capture(), Mockito.anyString(), arg2.capture());
+//
+//        ActionRequest request = arg1.getValue();
+//      }
+//    });
+//  }
+//
+//  @Test
+//  public void testReadMedia() throws Exception {
+//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+//    helpGETTest(handler, "trippin/Photos(1)/$value", new TestResult() {
+//      @Override
+//      public void validate() throws Exception {
+//        ArgumentCaptor<MediaRequest> arg1 = ArgumentCaptor.forClass(MediaRequest.class);
+//        ArgumentCaptor<StreamResponse> arg2 = ArgumentCaptor.forClass(StreamResponse.class);
+//        Mockito.verify(handler).readMediaStream(arg1.capture(), arg2.capture());
+//
+//        MediaRequest request = arg1.getValue();
+//        assertEquals("application/octet-stream", request.getResponseContentType()
+//            .toContentTypeString());
+//      }
+//    });
+//  }
+//
+//  @Test
+//  public void testReadNavigation() throws Exception {
+//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+//    helpGETTest(handler, "trippin/People('russelwhyte')/Friends", new TestResult() {
+//      @Override
+//      public void validate() throws Exception {
+//        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
+//        ArgumentCaptor<EntitySetResponse> arg2 = ArgumentCaptor.forClass(EntitySetResponse.class);
+//        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
+//
+//        DataRequest request = arg1.getValue();
+//        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
+//            .toContentTypeString());
+//      }
+//    });
+//  }
+//
+//  @Test
+//  public void testReadReference() throws Exception {
+//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+//    helpGETTest(handler, "trippin/People('russelwhyte')/Friends/$ref", new TestResult() {
+//      @Override
+//      public void validate() throws Exception {
+//        ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
+//        ArgumentCaptor<EntitySetResponse> arg2 = ArgumentCaptor.forClass(EntitySetResponse.class);
+//        Mockito.verify(handler).read(arg1.capture(), arg2.capture());
+//
+//        DataRequest request = arg1.getValue();
+//        assertEquals("application/json;odata.metadata=minimal", request.getResponseContentType()
+//            .toContentTypeString());
+//      }
+//    });
+//  }
+//
+//  @Test
+//  public void testWriteReferenceCollection() throws Exception {
+//    String payload = "{\n" + "\"@odata.id\": \"/Photos(11)\"\n" + "}";
+//
+//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+//    helpTest(handler, "trippin/People('russelwhyte')/Friends/$ref", "POST", payload,
+//        new TestResult() {
+//          @Override
+//          public void validate() throws Exception {
+//            ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
+//            ArgumentCaptor<String> arg2 = ArgumentCaptor.forClass(String.class);
+//            ArgumentCaptor<List> arg3 = ArgumentCaptor.forClass(List.class);
+//            ArgumentCaptor<NoContentResponse> arg4 = ArgumentCaptor
+//                .forClass(NoContentResponse.class);
+//            Mockito.verify(handler).addReference(arg1.capture(), arg2.capture(), arg3.capture(),
+//                arg4.capture());
+//
+//            DataRequest request = arg1.getValue();
+//            assertEquals("application/json;odata.metadata=minimal", request
+//                .getResponseContentType().toContentTypeString());
+//          }
+//        });
+//  }
+//
+//  @Test
+//  public void testWriteReference() throws Exception {
+//    String payload = "{\n" + "\"@odata.id\": \"/Photos(11)\"\n" + "}";
+//
+//    final ServiceHandler handler = Mockito.mock(ServiceHandler.class);
+//    helpTest(handler, "trippin/People('russelwhyte')/Friends('someone')/Photo/$ref", "PUT", payload,
+//        new TestResult() {
+//          @Override
+//          public void validate() throws Exception {
+//            ArgumentCaptor<DataRequest> arg1 = ArgumentCaptor.forClass(DataRequest.class);
+//            ArgumentCaptor<String> arg2 = ArgumentCaptor.forClass(String.class);
+//            ArgumentCaptor<URI> arg3 = ArgumentCaptor.forClass(URI.class);
+//            ArgumentCaptor<NoContentResponse> arg4 = ArgumentCaptor
+//                .forClass(NoContentResponse.class);
+//            Mockito.verify(handler).updateReference(arg1.capture(), arg2.capture(), arg3.capture(),
+//                arg4.capture());
+//
+//            DataRequest request = arg1.getValue();
+//            assertEquals("application/json;odata.metadata=minimal", request
+//                .getResponseContentType().toContentTypeString());
+//          }
+//        });
+//  }
 }


[22/22] olingo-odata4 git commit: OLINGO-573: merging with master

Posted by ra...@apache.org.
OLINGO-573: merging with master


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

Branch: refs/heads/OLINGO-573
Commit: f262563fa60175b947212213c289b4a791dcdaec
Parents: 3ac433b 26ec32a
Author: Ramesh Reddy <ra...@jboss.org>
Authored: Mon Apr 20 09:04:45 2015 -0500
Committer: Ramesh Reddy <ra...@jboss.org>
Committed: Mon Apr 20 09:27:17 2015 -0500

----------------------------------------------------------------------
 lib/server-core-ext/pom.xml                     | 26 ++++++++++++++++++++
 .../server/core/ServiceDispatcherTest.java      |  2 ++
 .../server/example/TripPinServiceTest.java      |  4 +--
 3 files changed, 30 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f262563f/lib/server-core-ext/pom.xml
----------------------------------------------------------------------
diff --cc lib/server-core-ext/pom.xml
index 6070052,5249ed4..2c411fb
--- a/lib/server-core-ext/pom.xml
+++ b/lib/server-core-ext/pom.xml
@@@ -81,33 -81,34 +81,59 @@@
      <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
 +    </dependency>
 +    <dependency>
 +      <groupId>org.apache.tomcat.embed</groupId>
 +      <artifactId>tomcat-embed-core</artifactId>
 +      <scope>test</scope>
 +    </dependency>
 +    <dependency>
 +      <groupId>org.apache.tomcat.embed</groupId>
 +      <artifactId>tomcat-embed-logging-log4j</artifactId>
 +      <scope>test</scope>
 +    </dependency>
 +    <dependency>
 +      <groupId>org.apache.tomcat</groupId>
 +      <artifactId>tomcat-jasper</artifactId>
 +      <scope>test</scope>
 +      <exclusions>
 +        <exclusion>
 +          <groupId>javax.servlet</groupId>
 +          <artifactId>javax.servlet-api</artifactId>
 +        </exclusion>
 +      </exclusions>
 +    </dependency>
 +    <dependency>
 +      <groupId>org.apache.httpcomponents</groupId>
 +      <artifactId>httpclient</artifactId>
        <scope>test</scope>
      </dependency>
+     <dependency>
+       <groupId>org.apache.tomcat.embed</groupId>
+       <artifactId>tomcat-embed-core</artifactId>
+       <scope>test</scope>
+     </dependency>
+     <dependency>
+       <groupId>org.apache.tomcat.embed</groupId>
+       <artifactId>tomcat-embed-logging-log4j</artifactId>
+       <scope>test</scope>
+     </dependency>
+     <dependency>
+       <groupId>org.apache.tomcat</groupId>
+       <artifactId>tomcat-jasper</artifactId>
+       <scope>test</scope>
+       <exclusions>
+         <exclusion>
+           <groupId>javax.servlet</groupId>
+           <artifactId>javax.servlet-api</artifactId>
+         </exclusion>
+       </exclusions>
+     </dependency>
+     <dependency>
+       <groupId>org.apache.httpcomponents</groupId>
+       <artifactId>httpclient</artifactId>
+       <scope>test</scope>
+     </dependency>
    </dependencies>
  
  </project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f262563f/lib/server-core-ext/src/test/java/org/apache/olingo/server/core/ServiceDispatcherTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f262563f/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinServiceTest.java
----------------------------------------------------------------------
diff --cc lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinServiceTest.java
index 1766f1a,3547b50..7eb73ef
--- a/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinServiceTest.java
+++ b/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinServiceTest.java
@@@ -405,11 -404,11 +405,11 @@@ public class TripPinServiceTest 
      postRequest.addHeader("Prefer", "return=minimal");
  
      HttpResponse response = httpSend(postRequest, 204);
--    // the below woud be 204, if minimal was not supplied
-     assertEquals("http://localhost:9900/trippin/People('olingodude')", getHeader(response, "Location"));
 -    assertEquals("/People('olingodude')", getHeader(response, "Location"));
++    // the below would be 204, if minimal was not supplied
++    assertEquals(baseURL +"/People('olingodude')", getHeader(response, "Location"));
      assertEquals("return=minimal", getHeader(response, "Preference-Applied"));
  
 -    String location = baseURL+getHeader(response, "Location");
 +    String location = getHeader(response, "Location");
      response = httpGET(location, 200);
      EntityUtils.consumeQuietly(response.getEntity());
  


[12/22] olingo-odata4 git commit: [OLINGO-603] Rename entity set to entity collection

Posted by ra...@apache.org.
[OLINGO-603] Rename entity set to entity collection


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

Branch: refs/heads/OLINGO-573
Commit: d692d129bddbdd63adfbd58aacabc0e5a3bf4db1
Parents: 05935a0
Author: Christian Amend <ch...@apache.org>
Authored: Tue Apr 7 15:20:39 2015 +0200
Committer: Christian Amend <ch...@apache.org>
Committed: Tue Apr 7 15:20:39 2015 +0200

----------------------------------------------------------------------
 .../org/apache/olingo/fit/AbstractServices.java |  10 +-
 .../java/org/apache/olingo/fit/V4Services.java  |  18 ++--
 .../olingo/fit/utils/AbstractUtilities.java     |   6 +-
 .../olingo/fit/AbstractBaseTestITCase.java      |   4 +-
 .../fit/v4/JSONFormatConformanceTestITCase.java |   4 +-
 .../client/api/serialization/ODataBinder.java   |   8 +-
 .../retrieve/ODataEntitySetRequestImpl.java     |  23 +++--
 .../ClientODataDeserializerImpl.java            |   4 +-
 .../core/serialization/ODataBinderImpl.java     |  16 +--
 .../core/serialization/ODataReaderImpl.java     |   4 +-
 .../olingo/client/core/v4/EntitySetTest.java    |  26 ++---
 .../apache/olingo/commons/api/data/Delta.java   |   2 +-
 .../commons/api/data/EntityCollection.java      |  97 +++++++++++++++++
 .../olingo/commons/api/data/EntitySet.java      |  97 -----------------
 .../apache/olingo/commons/api/data/Link.java    |   6 +-
 .../api/serialization/ODataDeserializer.java    |   6 +-
 .../core/serialization/AtomDeserializer.java    |  10 +-
 .../core/serialization/AtomSerializer.java      |  20 ++--
 .../core/serialization/JsonDeserializer.java    |   6 +-
 .../JsonEntitySetDeserializer.java              |   8 +-
 .../serialization/JsonEntitySetSerializer.java  |  10 +-
 .../core/serialization/JsonSerializer.java      |  10 +-
 .../serialization/AtomDeserializerTest.java     |   6 +-
 .../api/deserializer/DeserializerResult.java    |   6 +-
 .../api/deserializer/ODataDeserializer.java     |   4 +-
 .../server/api/serializer/ODataSerializer.java  |   4 +-
 .../deserializer/DeserializerResultImpl.java    |  10 +-
 .../json/ODataJsonDeserializer.java             |   8 +-
 .../serializer/json/ODataJsonSerializer.java    |   6 +-
 .../serializer/xml/ODataXmlSerializerImpl.java  |   4 +-
 .../olingo/server/tecsvc/data/DataCreator.java  | 100 +++++++++---------
 .../olingo/server/tecsvc/data/DataProvider.java |  16 +--
 .../olingo/server/tecsvc/data/FunctionData.java |  12 +--
 .../server/tecsvc/data/RequestValidator.java    |   4 +-
 .../processor/TechnicalEntityProcessor.java     |  12 +--
 .../tecsvc/processor/TechnicalProcessor.java    |   4 +-
 .../ExpandSystemQueryOptionHandler.java         | 103 ++++++++++---------
 .../queryoptions/options/CountHandler.java      |   4 +-
 .../queryoptions/options/FilterHandler.java     |   4 +-
 .../queryoptions/options/OrderByHandler.java    |   6 +-
 .../options/ServerSidePagingHandler.java        |   4 +-
 .../queryoptions/options/SkipHandler.java       |   6 +-
 .../queryoptions/options/TopHandler.java        |   6 +-
 .../server/tecsvc/data/DataProviderTest.java    |  12 +--
 .../ODataDeserializerEntityCollectionTest.java  |   8 +-
 .../json/ODataJsonSerializerTest.java           |  12 +--
 .../olingo/server/sample/data/DataProvider.java |  18 ++--
 .../server/sample/processor/CarsProcessor.java  |   4 +-
 48 files changed, 391 insertions(+), 387 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
index a57f11b..01f0d92 100644
--- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
+++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
@@ -70,7 +70,7 @@ import org.apache.cxf.jaxrs.ext.multipart.Multipart;
 import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;
 import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ResWrap;
@@ -997,7 +997,7 @@ public abstract class AbstractServices {
 
         final InputStream feed = FSManager.instance(version).readFile(builder.toString(), Accept.ATOM);
 
-        final ResWrap<EntitySet> container = atomDeserializer.toEntitySet(feed);
+        final ResWrap<EntityCollection> container = atomDeserializer.toEntitySet(feed);
 
         setInlineCount(container.getPayload(), count);
 
@@ -1040,7 +1040,7 @@ public abstract class AbstractServices {
     }
   }
 
-  protected abstract void setInlineCount(final EntitySet feed, final String count);
+  protected abstract void setInlineCount(final EntityCollection feed, final String count);
 
   @GET
   @Path("/Person({entityId})")
@@ -1256,7 +1256,7 @@ public abstract class AbstractServices {
               rep.setInlineEntity(inline);
             } else if (link.getType().equals(Constants.get(ConstantKey.ATOM_LINK_FEED))) {
               // inline feed
-              final EntitySet inline = atomDeserializer.toEntitySet(
+              final EntityCollection inline = atomDeserializer.toEntitySet(
                   xml.expandEntity(entitySetName, entityId, link.getTitle())).getPayload();
               rep.setInlineEntitySet(inline);
             }
@@ -1911,7 +1911,7 @@ public abstract class AbstractServices {
         alink.setRel(Constants.get(ConstantKey.ATOM_LINK_REL) + property.getName());
 
         if (property.isCollection()) {
-          EntitySet inline = new EntitySet();
+          EntityCollection inline = new EntityCollection();
           for (Object value : property.asCollection()) {
             Entity inlineEntity = new Entity();
             inlineEntity.setType(navProperties.get(property.getName()).getType());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/fit/src/main/java/org/apache/olingo/fit/V4Services.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/V4Services.java b/fit/src/main/java/org/apache/olingo/fit/V4Services.java
index 6c1038d..4a41002 100644
--- a/fit/src/main/java/org/apache/olingo/fit/V4Services.java
+++ b/fit/src/main/java/org/apache/olingo/fit/V4Services.java
@@ -64,7 +64,7 @@ import org.apache.cxf.jaxrs.ext.multipart.Attachment;
 import org.apache.cxf.jaxrs.ext.multipart.Multipart;
 import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ResWrap;
@@ -283,7 +283,7 @@ public class V4Services extends AbstractServices {
   }
 
   @Override
-  protected void setInlineCount(final EntitySet entitySet, final String count) {
+  protected void setInlineCount(final EntityCollection entitySet, final String count) {
     if ("true".equals(count)) {
       entitySet.setCount(entitySet.getEntities().size());
     }
@@ -456,14 +456,14 @@ public class V4Services extends AbstractServices {
       if (StringUtils.isBlank(deltatoken)) {
         final InputStream input = (InputStream) getEntitySet(
             uriInfo, accept, "Customers", null, null, format, null, null, null, null).getEntity();
-        final EntitySet entitySet = xml.readEntitySet(acceptType, input);
+        final EntityCollection entitySet = xml.readEntitySet(acceptType, input);
 
         boolean trackChanges = prefer.contains("odata.track-changes");
         if (trackChanges) {
           entitySet.setDeltaLink(URI.create("Customers?$deltatoken=8015"));
         }
 
-        output = xml.writeEntitySet(acceptType, new ResWrap<EntitySet>(
+        output = xml.writeEntitySet(acceptType, new ResWrap<EntityCollection>(
             URI.create(Constants.get(ConstantKey.ODATA_METADATA_PREFIX) + "Customers"),
             null,
             entitySet));
@@ -580,10 +580,10 @@ public class V4Services extends AbstractServices {
               + "ProductDetails(ProductID=6,ProductDetailID=1)").toASCIIString());
       entry.setEditLink(link);
 
-      final EntitySet feed = new EntitySet();
+      final EntityCollection feed = new EntityCollection();
       feed.getEntities().add(entry);
 
-      final ResWrap<EntitySet> container = new ResWrap<EntitySet>(
+      final ResWrap<EntityCollection> container = new ResWrap<EntityCollection>(
           URI.create(Constants.get(ConstantKey.ODATA_METADATA_PREFIX) + "ProductDetail"), null,
           feed);
 
@@ -934,7 +934,7 @@ public class V4Services extends AbstractServices {
       // 3. Update the contained entity set
       final String atomFeedRelativePath = containedPath(entityId, containedEntitySetName).toString();
       final InputStream feedIS = FSManager.instance(version).readFile(atomFeedRelativePath, Accept.ATOM);
-      final ResWrap<EntitySet> feedContainer = atomDeserializer.toEntitySet(feedIS);
+      final ResWrap<EntityCollection> feedContainer = atomDeserializer.toEntitySet(feedIS);
       feedContainer.getPayload().getEntities().add(entry);
 
       final ByteArrayOutputStream content = new ByteArrayOutputStream();
@@ -1050,7 +1050,7 @@ public class V4Services extends AbstractServices {
       // 3. Update the contained entity set
       final String atomFeedRelativePath = containedPath(entityId, containedEntitySetName).toString();
       final InputStream feedIS = FSManager.instance(version).readFile(atomFeedRelativePath, Accept.ATOM);
-      final ResWrap<EntitySet> feedContainer = atomDeserializer.toEntitySet(feedIS);
+      final ResWrap<EntityCollection> feedContainer = atomDeserializer.toEntitySet(feedIS);
       feedContainer.getPayload().getEntities().remove(container.getPayload());
 
       final ByteArrayOutputStream content = new ByteArrayOutputStream();
@@ -1103,7 +1103,7 @@ public class V4Services extends AbstractServices {
       final InputStream feed = FSManager.instance(version).
           readFile(containedPath(entityId, tempContainedESName).toString(), Accept.ATOM);
 
-      final ResWrap<EntitySet> container = atomDeserializer.toEntitySet(feed);
+      final ResWrap<EntityCollection> container = atomDeserializer.toEntitySet(feed);
 
       if (derivedType != null) {
         final List<Entity> nonMatching = new ArrayList<Entity>();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java b/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
index 126a0b6..6639f7f 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java
@@ -43,7 +43,7 @@ import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.vfs2.FileObject;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ResWrap;
@@ -507,14 +507,14 @@ public abstract class AbstractUtilities {
     return builder.build();
   }
 
-  public EntitySet readEntitySet(final Accept accept, final InputStream entitySet)
+  public EntityCollection readEntitySet(final Accept accept, final InputStream entitySet)
       throws ODataDeserializerException {
     return (accept == Accept.ATOM || accept == Accept.XML ? atomDeserializer.toEntitySet(entitySet) : jsonDeserializer.
         toEntitySet(entitySet))
         .getPayload();
   }
 
-  public InputStream writeEntitySet(final Accept accept, final ResWrap<EntitySet> container)
+  public InputStream writeEntitySet(final Accept accept, final ResWrap<EntityCollection> container)
       throws ODataSerializerException, IOException {
 
     final StringWriter writer = new StringWriter();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
index baadf20..e915f3f 100644
--- a/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
@@ -31,7 +31,7 @@ import org.apache.catalina.LifecycleException;
 import org.apache.commons.io.IOUtils;
 import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.domain.ODataEntity;
 import org.apache.olingo.commons.api.domain.ODataProperty;
 import org.apache.olingo.commons.api.domain.ODataValue;
@@ -81,7 +81,7 @@ public abstract class AbstractBaseTestITCase {
     }
   }
 
-  protected void debugEntitySet(final EntitySet entitySet, final String message) {
+  protected void debugEntitySet(final EntityCollection entitySet, final String message) {
     if (LOG.isDebugEnabled()) {
       final StringWriter writer = new StringWriter();
       try {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/fit/src/test/java/org/apache/olingo/fit/v4/JSONFormatConformanceTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/JSONFormatConformanceTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/JSONFormatConformanceTestITCase.java
index b7a65e8..1af92d6 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/JSONFormatConformanceTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/JSONFormatConformanceTestITCase.java
@@ -27,7 +27,7 @@ import org.apache.commons.io.IOUtils;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.ODataAnnotation;
 import org.apache.olingo.commons.api.domain.ODataEntity;
@@ -240,7 +240,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
             + "  \"@odata.deltaLink\": \"Customers?$expand=Orders&$deltatoken=8015\""
             + "}";
 
-    final ResWrap<EntitySet> entitySet =
+    final ResWrap<EntityCollection> entitySet =
             client.getDeserializer(ODataFormat.JSON).toEntitySet(IOUtils.toInputStream(fromSection45_2));
 
     assertEquals(5, entitySet.getPayload().getCount(), 0);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataBinder.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataBinder.java
index 289c0cb..6dc57dd 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataBinder.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataBinder.java
@@ -21,7 +21,7 @@ package org.apache.olingo.client.api.serialization;
 import org.apache.olingo.client.api.data.ServiceDocument;
 import org.apache.olingo.commons.api.data.Delta;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ResWrap;
@@ -38,9 +38,9 @@ public interface ODataBinder {
    * Gets a <tt>EntitySet</tt> from the given OData entity set.
    *
    * @param entitySet OData entity set.
-   * @return {@link EntitySet} object.
+   * @return {@link EntityCollection} object.
    */
-  EntitySet getEntitySet(ODataEntitySet entitySet);
+  EntityCollection getEntitySet(ODataEntitySet entitySet);
 
   /**
    * Gets an <tt>Entity</tt> from the given OData entity.
@@ -89,7 +89,7 @@ public interface ODataBinder {
    * @param resource entity set resource.
    * @return {@link org.apache.olingo.commons.api.domain.ODataEntitySet} object.
    */
-  ODataEntitySet getODataEntitySet(ResWrap<EntitySet> resource);
+  ODataEntitySet getODataEntitySet(ResWrap<EntityCollection> resource);
 
   /**
    * Gets <tt>ODataEntity</tt> from the given entity resource.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
index d552e75..20d75b7 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataEntitySetRequestImpl.java
@@ -1,18 +1,18 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * 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
- *
+ * 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 WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -25,7 +25,7 @@ import org.apache.http.client.HttpClient;
 import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.ODataEntitySet;
 import org.apache.olingo.commons.api.format.ODataFormat;
@@ -37,7 +37,7 @@ import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
  * @param <ES> concrete ODataEntitySet implementation
  */
 public class ODataEntitySetRequestImpl<ES extends ODataEntitySet>
-        extends AbstractODataRetrieveRequest<ES> implements ODataEntitySetRequest<ES> {
+    extends AbstractODataRetrieveRequest<ES> implements ODataEntitySetRequest<ES> {
 
   private ES entitySet = null;
 
@@ -68,7 +68,7 @@ public class ODataEntitySetRequestImpl<ES extends ODataEntitySet>
   protected class ODataEntitySetResponseImpl extends AbstractODataRetrieveResponse {
 
     private ODataEntitySetResponseImpl(final ODataClient odataClient, final HttpClient httpClient,
-            final HttpResponse res) {
+        final HttpResponse res) {
 
       super(odataClient, httpClient, res);
     }
@@ -78,7 +78,8 @@ public class ODataEntitySetRequestImpl<ES extends ODataEntitySet>
     public ES getBody() {
       if (entitySet == null) {
         try {
-          final ResWrap<EntitySet> resource = odataClient.getDeserializer(ODataFormat.fromString(getContentType())).
+          final ResWrap<EntityCollection> resource =
+              odataClient.getDeserializer(ODataFormat.fromString(getContentType())).
                   toEntitySet(getRawResponse());
 
           entitySet = (ES) odataClient.getBinder().getODataEntitySet(resource);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
index cd5003d..32cd726 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
@@ -32,7 +32,7 @@ import org.apache.olingo.client.core.edm.xml.EdmxImpl;
 import org.apache.olingo.client.core.edm.xml.XMLMetadataImpl;
 import org.apache.olingo.commons.api.data.Delta;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.ODataError;
@@ -71,7 +71,7 @@ public class ClientODataDeserializerImpl implements ClientODataDeserializer {
   }
 
   @Override
-  public ResWrap<EntitySet> toEntitySet(final InputStream input) throws ODataDeserializerException {
+  public ResWrap<EntityCollection> toEntitySet(final InputStream input) throws ODataDeserializerException {
     return deserializer.toEntitySet(input);
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
index 54823e0..fc295a0 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
@@ -41,7 +41,7 @@ import org.apache.olingo.commons.api.data.DeletedEntity;
 import org.apache.olingo.commons.api.data.Delta;
 import org.apache.olingo.commons.api.data.DeltaLink;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Linked;
 import org.apache.olingo.commons.api.data.Property;
@@ -192,8 +192,8 @@ public class ODataBinderImpl implements ODataBinder {
   }
 
   @Override
-  public EntitySet getEntitySet(final ODataEntitySet odataEntitySet) {
-    final EntitySet entitySet = new EntitySet();
+  public EntityCollection getEntitySet(final ODataEntitySet odataEntitySet) {
+    final EntityCollection entitySet = new EntityCollection();
 
     entitySet.setCount(odataEntitySet.getCount());
 
@@ -387,7 +387,7 @@ public class ODataBinderImpl implements ODataBinder {
   }
 
   @Override
-  public ODataEntitySet getODataEntitySet(final ResWrap<EntitySet> resource) {
+  public ODataEntitySet getODataEntitySet(final ResWrap<EntityCollection> resource) {
     if (LOG.isDebugEnabled()) {
       final StringWriter writer = new StringWriter();
       try {
@@ -432,7 +432,7 @@ public class ODataBinderImpl implements ODataBinder {
       final String href = link.getHref();
       final String title = link.getTitle();
       final Entity inlineEntity = link.getInlineEntity();
-      final EntitySet inlineEntitySet = link.getInlineEntitySet();
+      final EntityCollection inlineEntitySet = link.getInlineEntitySet();
       if (inlineEntity == null && inlineEntitySet == null) {
         ODataLinkType linkType = null;
         if (edmType instanceof EdmStructuredType) {
@@ -476,10 +476,10 @@ public class ODataBinderImpl implements ODataBinder {
             inlineEntity)));
   }
 
-  private ODataInlineEntitySet createODataInlineEntitySet(final EntitySet inlineEntitySet,
+  private ODataInlineEntitySet createODataInlineEntitySet(final EntityCollection inlineEntitySet,
       final URI uri, final String title, final String metadataETag) {
     return new ODataInlineEntitySet(uri, ODataLinkType.ENTITY_SET_NAVIGATION, title,
-        getODataEntitySet(new ResWrap<EntitySet>(
+        getODataEntitySet(new ResWrap<EntityCollection>(
             inlineEntitySet.getBaseURI() == null ? null : inlineEntitySet.getBaseURI(), metadataETag,
             inlineEntitySet)));
   }
@@ -567,7 +567,7 @@ public class ODataBinderImpl implements ODataBinder {
 
   private ODataLink createLinkFromNavigationProperty(final Property property, final String propertyTypeName) {
     if (property.isCollection()) {
-      EntitySet inlineEntitySet = new EntitySet();
+      EntityCollection inlineEntitySet = new EntityCollection();
       for (final Object inlined : property.asCollection()) {
         Entity inlineEntity = new Entity();
         inlineEntity.setType(propertyTypeName);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
index 253df78..39b1177 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
@@ -30,7 +30,7 @@ import org.apache.olingo.client.api.edm.xml.XMLMetadata;
 import org.apache.olingo.client.api.serialization.ODataReader;
 import org.apache.olingo.client.core.edm.ClientEdmProvider;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.ODataEntity;
@@ -98,7 +98,7 @@ public class ODataReaderImpl implements ODataReader {
             reference.cast(new ODataEntitySetIterator<ODataEntitySet, ODataEntity>(
                 client, src, ODataFormat.fromString(format))));
       } else if (ODataEntitySet.class.isAssignableFrom(reference)) {
-        final ResWrap<EntitySet> resource = client.getDeserializer(ODataFormat.fromString(format))
+        final ResWrap<EntityCollection> resource = client.getDeserializer(ODataFormat.fromString(format))
             .toEntitySet(src);
         res = new ResWrap<T>(
             resource.getContextURL(),

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java
index b8282e2..5d5671a 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntitySetTest.java
@@ -1,18 +1,18 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * 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
- *
+ * 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 WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -20,7 +20,7 @@ package org.apache.olingo.client.core.v4;
 
 import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.core.AbstractTest;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.ODataEntity;
 import org.apache.olingo.commons.api.domain.ODataEntitySet;
@@ -46,13 +46,14 @@ public class EntitySetTest extends AbstractTest {
   private void read(final ODataFormat format) throws IOException, ODataDeserializerException {
     final InputStream input = getClass().getResourceAsStream("Customers." + getSuffix(format));
     final ODataEntitySet entitySet = getClient().getBinder().getODataEntitySet(
-            getClient().getDeserializer(format).toEntitySet(input));
+        getClient().getDeserializer(format).toEntitySet(input));
     assertNotNull(entitySet);
 
     assertEquals(2, entitySet.getEntities().size());
     assertNull(entitySet.getNext());
 
-    final ODataEntitySet written = getClient().getBinder().getODataEntitySet(new ResWrap<EntitySet>((URI) null, null,
+    final ODataEntitySet written =
+        getClient().getBinder().getODataEntitySet(new ResWrap<EntityCollection>((URI) null, null,
             getClient().getBinder().getEntitySet(entitySet)));
     assertEquals(entitySet, written);
   }
@@ -70,7 +71,7 @@ public class EntitySetTest extends AbstractTest {
   private void ref(final ODataFormat format) throws ODataDeserializerException {
     final InputStream input = getClass().getResourceAsStream("collectionOfEntityReferences." + getSuffix(format));
     final ODataEntitySet entitySet = getClient().getBinder().getODataEntitySet(
-            getClient().getDeserializer(format).toEntitySet(input));
+        getClient().getDeserializer(format).toEntitySet(input));
     assertNotNull(entitySet);
 
     for (ODataEntity entity : entitySet.getEntities()) {
@@ -78,7 +79,8 @@ public class EntitySetTest extends AbstractTest {
     }
     entitySet.setCount(entitySet.getEntities().size());
 
-    final ODataEntitySet written = getClient().getBinder().getODataEntitySet(new ResWrap<EntitySet>((URI) null, null,
+    final ODataEntitySet written =
+        getClient().getBinder().getODataEntitySet(new ResWrap<EntityCollection>((URI) null, null,
             getClient().getBinder().getEntitySet(entitySet)));
     assertEquals(entitySet, written);
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java
index 5fe36f7..b87c05f 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Delta.java
@@ -21,7 +21,7 @@ package org.apache.olingo.commons.api.data;
 import java.util.ArrayList;
 import java.util.List;
 
-public class Delta extends EntitySet {
+public class Delta extends EntityCollection {
 
   private final List<DeletedEntity> deletedEntities = new ArrayList<DeletedEntity>();
   private final List<DeltaLink> addedLinks = new ArrayList<DeltaLink>();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntityCollection.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntityCollection.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntityCollection.java
new file mode 100644
index 0000000..0946bea
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntityCollection.java
@@ -0,0 +1,97 @@
+/*
+ * 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 WARRANTIES OR 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.olingo.commons.api.data;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+public class EntityCollection extends AbstractODataObject {
+
+  private Integer count;
+
+  private final List<Entity> entities = new ArrayList<Entity>();
+
+  private URI next;
+
+  private URI deltaLink;
+
+  /**
+   * Sets number of entries.
+   * 
+   * @param count number of entries
+   */
+  public void setCount(final Integer count) {
+    this.count = count;
+  }
+
+  /**
+   * Gets number of entries - if it was required.
+   * 
+   * @return number of entries into the entity set.
+   */
+  public Integer getCount() {
+    return count;
+  }
+
+  /**
+   * Gets entities.
+   * 
+   * @return entries.
+   */
+  public List<Entity> getEntities() {
+    return entities;
+  }
+
+  /**
+   * Sets next link.
+   * 
+   * @param next next link.
+   */
+  public void setNext(final URI next) {
+    this.next = next;
+  }
+
+  /**
+   * Gets next link if exists.
+   * 
+   * @return next link if exists; null otherwise.
+   */
+  public URI getNext() {
+    return next;
+  }
+
+  /**
+   * Gets delta link if exists.
+   * 
+   * @return delta link if exists; null otherwise.
+   */
+  public URI getDeltaLink() {
+    return deltaLink;
+  }
+
+  /**
+   * Sets delta link.
+   * 
+   * @param deltaLink delta link.
+   */
+  public void setDeltaLink(final URI deltaLink) {
+    this.deltaLink = deltaLink;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.java
deleted file mode 100644
index 8f2cfb7..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/EntitySet.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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 WARRANTIES OR 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.olingo.commons.api.data;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-public class EntitySet extends AbstractODataObject {
-
-  private Integer count;
-
-  private final List<Entity> entities = new ArrayList<Entity>();
-
-  private URI next;
-
-  private URI deltaLink;
-
-  /**
-   * Sets number of entries.
-   * 
-   * @param count number of entries
-   */
-  public void setCount(final Integer count) {
-    this.count = count;
-  }
-
-  /**
-   * Gets number of entries - if it was required.
-   * 
-   * @return number of entries into the entity set.
-   */
-  public Integer getCount() {
-    return count;
-  }
-
-  /**
-   * Gets entities.
-   * 
-   * @return entries.
-   */
-  public List<Entity> getEntities() {
-    return entities;
-  }
-
-  /**
-   * Sets next link.
-   * 
-   * @param next next link.
-   */
-  public void setNext(final URI next) {
-    this.next = next;
-  }
-
-  /**
-   * Gets next link if exists.
-   * 
-   * @return next link if exists; null otherwise.
-   */
-  public URI getNext() {
-    return next;
-  }
-
-  /**
-   * Gets delta link if exists.
-   * 
-   * @return delta link if exists; null otherwise.
-   */
-  public URI getDeltaLink() {
-    return deltaLink;
-  }
-
-  /**
-   * Sets delta link.
-   * 
-   * @param deltaLink delta link.
-   */
-  public void setDeltaLink(final URI deltaLink) {
-    this.deltaLink = deltaLink;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Link.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Link.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Link.java
index dff1069..8278633 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Link.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/data/Link.java
@@ -29,7 +29,7 @@ public class Link extends Annotatable {
   private String type;
   private String mediaETag;
   private Entity entity;
-  private EntitySet entitySet;
+  private EntityCollection entitySet;
   private String bindingLink;
   private List<String> bindingLinks = new ArrayList<String>();
 
@@ -147,7 +147,7 @@ public class Link extends Annotatable {
    * 
    * @return in-line entity set.
    */
-  public EntitySet getInlineEntitySet() {
+  public EntityCollection getInlineEntitySet() {
     return entitySet;
   }
 
@@ -156,7 +156,7 @@ public class Link extends Annotatable {
    * 
    * @param entitySet entity set.
    */
-  public void setInlineEntitySet(final EntitySet entitySet) {
+  public void setInlineEntitySet(final EntityCollection entitySet) {
     this.entitySet = entitySet;
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java
index e3b3759..8e313b1 100755
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java
@@ -19,7 +19,7 @@
 package org.apache.olingo.commons.api.serialization;
 
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.ODataError;
@@ -35,9 +35,9 @@ public interface ODataDeserializer {
    * Gets an entity set object from the given InputStream.
    * 
    * @param input stream to be de-serialized.
-   * @return {@link EntitySet} instance.
+   * @return {@link EntityCollection} instance.
    */
-  ResWrap<EntitySet> toEntitySet(InputStream input) throws ODataDeserializerException;
+  ResWrap<EntityCollection> toEntitySet(InputStream input) throws ODataDeserializerException;
 
   /**
    * Gets an entity object from the given InputStream.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
index cd5210a..84795bf 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
@@ -44,7 +44,7 @@ import org.apache.olingo.commons.api.data.DeletedEntity.Reason;
 import org.apache.olingo.commons.api.data.Delta;
 import org.apache.olingo.commons.api.data.DeltaLink;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ResWrap;
@@ -712,7 +712,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
     }
   }
 
-  private void count(final XMLEventReader reader, final StartElement start, final EntitySet entitySet)
+  private void count(final XMLEventReader reader, final StartElement start, final EntityCollection entitySet)
       throws XMLStreamException {
 
     boolean foundEndElement = false;
@@ -729,12 +729,12 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
     }
   }
 
-  private EntitySet entitySet(final XMLEventReader reader, final StartElement start)
+  private EntityCollection entitySet(final XMLEventReader reader, final StartElement start)
       throws XMLStreamException, EdmPrimitiveTypeException {
     if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
       return null;
     }
-    final EntitySet entitySet = new EntitySet();
+    final EntityCollection entitySet = new EntityCollection();
     final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
     if (xmlBase != null) {
       entitySet.setBaseURI(xmlBase.getValue());
@@ -788,7 +788,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
   }
 
   @Override
-  public ResWrap<EntitySet> toEntitySet(final InputStream input) throws ODataDeserializerException {
+  public ResWrap<EntityCollection> toEntitySet(final InputStream input) throws ODataDeserializerException {
     try {
       final XMLEventReader reader = getReader(input);
       final StartElement start = skipBeforeFirstStartElement(reader);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
index 196a46e..fb187fe 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
@@ -36,7 +36,7 @@ import org.apache.olingo.commons.api.data.Annotation;
 import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ResWrap;
@@ -393,7 +393,7 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
     writer.flush();
   }
 
-  private void entitySet(final XMLStreamWriter writer, final EntitySet entitySet)
+  private void entitySet(final XMLStreamWriter writer, final EntityCollection entitySet)
       throws XMLStreamException, EdmPrimitiveTypeException {
     if (entitySet.getBaseURI() != null) {
       writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, entitySet.getBaseURI().toASCIIString());
@@ -442,7 +442,7 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
     }
   }
 
-  private void entitySet(final Writer outWriter, final EntitySet entitySet)
+  private void entitySet(final Writer outWriter, final EntityCollection entitySet)
       throws XMLStreamException, EdmPrimitiveTypeException {
     final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
 
@@ -455,7 +455,7 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
     writer.flush();
   }
 
-  private void entitySet(final Writer outWriter, final ResWrap<EntitySet> entitySet)
+  private void entitySet(final Writer outWriter, final ResWrap<EntityCollection> entitySet)
       throws XMLStreamException, EdmPrimitiveTypeException {
     final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter);
 
@@ -491,8 +491,8 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
   @Override
   public <T> void write(final Writer writer, final T obj) throws ODataSerializerException {
     try {
-      if (obj instanceof EntitySet) {
-        entitySet(writer, (EntitySet) obj);
+      if (obj instanceof EntityCollection) {
+        entitySet(writer, (EntityCollection) obj);
       } else if (obj instanceof Entity) {
         entity(writer, (Entity) obj);
       } else if (obj instanceof Property) {
@@ -527,8 +527,8 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
     final T obj = container == null ? null : container.getPayload();
 
     try {
-      if (obj instanceof EntitySet) {
-        this.entitySet(writer, (ResWrap<EntitySet>) container);
+      if (obj instanceof EntityCollection) {
+        this.entitySet(writer, (ResWrap<EntityCollection>) container);
       } else if (obj instanceof Entity) {
         entity(writer, (ResWrap<Entity>) container);
       } else if (obj instanceof Property) {
@@ -551,8 +551,8 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
     if (container.getContextURL() != null) {
       final ContextURL contextURL = ContextURLParser.parse(container.getContextURL());
       String base = contextURL.getServiceRoot().toASCIIString();
-      if (container.getPayload() instanceof EntitySet) {
-        ((EntitySet) container.getPayload()).setBaseURI(base);
+      if (container.getPayload() instanceof EntityCollection) {
+        ((EntityCollection) container.getPayload()).setBaseURI(base);
       }
       if (container.getPayload() instanceof Entity) {
         ((Entity) container.getPayload()).setBaseURI(base);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
index 1db725b..34394bb 100755
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
@@ -36,7 +36,7 @@ import org.apache.olingo.commons.api.data.Annotatable;
 import org.apache.olingo.commons.api.data.Annotation;
 import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Linked;
 import org.apache.olingo.commons.api.data.Property;
@@ -106,7 +106,7 @@ public class JsonDeserializer implements ODataDeserializer {
       } else if (inline instanceof ArrayNode) {
         link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
 
-        final EntitySet entitySet = new EntitySet();
+        final EntityCollection entitySet = new EntityCollection();
         for (final Iterator<JsonNode> entries = inline.elements(); entries.hasNext();) {
           entitySet.getEntities().add(entityDeserializer.doDeserialize(entries.next().traverse(codec)).getPayload());
         }
@@ -381,7 +381,7 @@ public class JsonDeserializer implements ODataDeserializer {
   }
 
   @Override
-  public ResWrap<EntitySet> toEntitySet(final InputStream input) throws ODataDeserializerException {
+  public ResWrap<EntityCollection> toEntitySet(final InputStream input) throws ODataDeserializerException {
     try {
       parser = new JsonFactory(new ObjectMapper()).createParser(input);
       return new JsonEntitySetDeserializer(serverMode).doDeserialize(parser);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java
index f260369..abf131b 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java
@@ -26,7 +26,7 @@ import java.util.Map;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 
@@ -45,7 +45,7 @@ public class JsonEntitySetDeserializer extends JsonDeserializer {
     super(serverMode);
   }
 
-  protected ResWrap<EntitySet> doDeserialize(final JsonParser parser) throws IOException {
+  protected ResWrap<EntityCollection> doDeserialize(final JsonParser parser) throws IOException {
 
     final ObjectNode tree = (ObjectNode) parser.getCodec().readTree(parser);
 
@@ -53,7 +53,7 @@ public class JsonEntitySetDeserializer extends JsonDeserializer {
       return null;
     }
 
-    final EntitySet entitySet = new EntitySet();
+    final EntityCollection entitySet = new EntityCollection();
 
     URI contextURL;
     if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
@@ -115,6 +115,6 @@ public class JsonEntitySetDeserializer extends JsonDeserializer {
       }
     }
 
-    return new ResWrap<EntitySet>(contextURL, metadataETag, entitySet);
+    return new ResWrap<EntityCollection>(contextURL, metadataETag, entitySet);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetSerializer.java
index 3c67055..02af3cf 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetSerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetSerializer.java
@@ -24,7 +24,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.Annotation;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 
@@ -36,15 +36,15 @@ public class JsonEntitySetSerializer extends JsonSerializer {
     super(serverMode);
   }
 
-  protected void doSerialize(final EntitySet entitySet, final JsonGenerator jgen)
+  protected void doSerialize(final EntityCollection entitySet, final JsonGenerator jgen)
       throws IOException, EdmPrimitiveTypeException {
-    doContainerSerialize(new ResWrap<EntitySet>(null, null, entitySet), jgen);
+    doContainerSerialize(new ResWrap<EntityCollection>(null, null, entitySet), jgen);
   }
 
-  protected void doContainerSerialize(final ResWrap<EntitySet> container, final JsonGenerator jgen)
+  protected void doContainerSerialize(final ResWrap<EntityCollection> container, final JsonGenerator jgen)
       throws IOException, EdmPrimitiveTypeException {
 
-    final EntitySet entitySet = container.getPayload();
+    final EntityCollection entitySet = container.getPayload();
 
     jgen.writeStartObject();
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java
index e749736..0dd8dd4 100755
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java
@@ -33,7 +33,7 @@ import org.apache.olingo.commons.api.data.Annotatable;
 import org.apache.olingo.commons.api.data.Annotation;
 import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Linked;
 import org.apache.olingo.commons.api.data.Property;
@@ -81,8 +81,8 @@ public class JsonSerializer implements ODataSerializer {
   public <T> void write(final Writer writer, final T obj) throws ODataSerializerException {
     try {
       final JsonGenerator json = new JsonFactory().createGenerator(writer);
-      if (obj instanceof EntitySet) {
-        new JsonEntitySetSerializer(serverMode).doSerialize((EntitySet) obj, json);
+      if (obj instanceof EntityCollection) {
+        new JsonEntitySetSerializer(serverMode).doSerialize((EntityCollection) obj, json);
       } else if (obj instanceof Entity) {
         new JsonEntitySerializer(serverMode, format).doSerialize((Entity) obj, json);
       } else if (obj instanceof Property) {
@@ -113,8 +113,8 @@ public class JsonSerializer implements ODataSerializer {
     final T obj = container == null ? null : container.getPayload();
     try {
       final JsonGenerator json = new JsonFactory().createGenerator(writer);
-      if (obj instanceof EntitySet) {
-        new JsonEntitySetSerializer(serverMode).doContainerSerialize((ResWrap<EntitySet>) container, json);
+      if (obj instanceof EntityCollection) {
+        new JsonEntitySetSerializer(serverMode).doContainerSerialize((ResWrap<EntityCollection>) container, json);
       } else if (obj instanceof Entity) {
         new JsonEntitySerializer(serverMode).doContainerSerialize((ResWrap<Entity>) container, json);
       } else if (obj instanceof Property) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/commons-core/src/test/java/org/apache/olingo/commons/core/serialization/AtomDeserializerTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/serialization/AtomDeserializerTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/serialization/AtomDeserializerTest.java
index 062f46b..2c5087b 100644
--- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/serialization/AtomDeserializerTest.java
+++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/serialization/AtomDeserializerTest.java
@@ -26,7 +26,7 @@ import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.junit.Test;
 
@@ -230,7 +230,7 @@ public class AtomDeserializerTest {
     final ResWrap<Entity> entity = deserializer.toEntity(in);
     
     assertNotNull(entity);
-    final EntitySet inlineEntitySet = entity.getPayload().getNavigationLink("Supplier").getInlineEntitySet();
+    final EntityCollection inlineEntitySet = entity.getPayload().getNavigationLink("Supplier").getInlineEntitySet();
     assertNotNull(inlineEntitySet);
     assertEquals(0, inlineEntitySet.getEntities().size());
   }
@@ -321,7 +321,7 @@ public class AtomDeserializerTest {
     final ResWrap<Entity> entity = deserializer.toEntity(in);
     
     assertNotNull(entity);
-    final EntitySet inlineEntitySet = entity.getPayload().getNavigationLink("Supplier").getInlineEntitySet();
+    final EntityCollection inlineEntitySet = entity.getPayload().getNavigationLink("Supplier").getInlineEntitySet();
     assertNotNull(inlineEntitySet);
     assertEquals(1, inlineEntitySet.getEntities().size());
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerResult.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerResult.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerResult.java
index 3f36939..9fcc3fc 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerResult.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerResult.java
@@ -22,7 +22,7 @@ import java.net.URI;
 import java.util.List;
 
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Parameter;
 import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
 import org.apache.olingo.commons.api.data.Property;
@@ -39,9 +39,9 @@ public interface DeserializerResult {
 
   /**
    * Returns a entity set
-   * @return an {@link EntitySet} or null
+   * @return an {@link EntityCollection} or null
    */
-  EntitySet getEntityCollection();
+  EntityCollection getEntityCollection();
 
   /**
    * Returns the ExpandOptions for serialized entities

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/ODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/ODataDeserializer.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/ODataDeserializer.java
index f014ad6..5a927ed 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/ODataDeserializer.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/ODataDeserializer.java
@@ -21,7 +21,7 @@ package org.apache.olingo.server.api.deserializer;
 import java.io.InputStream;
 
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.edm.EdmAction;
 import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.EdmProperty;
@@ -43,7 +43,7 @@ public interface ODataDeserializer {
   DeserializerResult entity(InputStream stream, EdmEntityType edmEntityType) throws DeserializerException;
 
   /**
-   * Deserializes an entity collection stream into an {@link EntitySet} object.
+   * Deserializes an entity collection stream into an {@link EntityCollection} object.
    * @param stream
    * @param edmEntityType
    * @return {@link DeserializerResult#getEntityCollection()}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java
index 01db1a4..3a2fbe0 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java
@@ -21,7 +21,7 @@ package org.apache.olingo.server.api.serializer;
 import java.io.InputStream;
 
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmComplexType;
@@ -64,7 +64,7 @@ public interface ODataSerializer {
    * @param options    options for the serializer
    */
   SerializerResult entityCollection(ServiceMetadata metadata, EdmEntityType entityType,
-      EntitySet entitySet, EntityCollectionSerializerOptions options) throws SerializerException;
+      EntityCollection entitySet, EntityCollectionSerializerOptions options) throws SerializerException;
 
   /**
    * Writes entity data into an InputStream.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/DeserializerResultImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/DeserializerResultImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/DeserializerResultImpl.java
index 84d64ea..1c85f3e 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/DeserializerResultImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/DeserializerResultImpl.java
@@ -23,7 +23,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Parameter;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.server.api.deserializer.DeserializerResult;
@@ -31,7 +31,7 @@ import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
 
 public class DeserializerResultImpl implements DeserializerResult {
   private Entity entity;
-  private EntitySet entitySet;
+  private EntityCollection entitySet;
   private ExpandOption expandOption;
   private Property property;
   private List<Parameter> actionParametes;
@@ -45,7 +45,7 @@ public class DeserializerResultImpl implements DeserializerResult {
   }
 
   @Override
-  public EntitySet getEntityCollection() {
+  public EntityCollection getEntityCollection() {
     return entitySet;
   }
 
@@ -75,7 +75,7 @@ public class DeserializerResultImpl implements DeserializerResult {
   
   public static class DeserializerResultBuilder {
     private Entity entity;
-    private EntitySet entitySet;
+    private EntityCollection entitySet;
     private ExpandOption expandOption;
     private Property property;
     private List<Parameter> actionParametes;
@@ -98,7 +98,7 @@ public class DeserializerResultImpl implements DeserializerResult {
       return this;
     }
 
-    public DeserializerResultBuilder entityCollection(final EntitySet entitySet) {
+    public DeserializerResultBuilder entityCollection(final EntityCollection entitySet) {
       this.entitySet = entitySet;
       return this;
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
index fa2f6a5..d92ac0c 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
@@ -31,7 +31,7 @@ import java.util.Map.Entry;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Parameter;
 import org.apache.olingo.commons.api.data.Property;
@@ -92,9 +92,9 @@ public class ODataJsonDeserializer implements ODataDeserializer {
     }
   }
 
-  private EntitySet consumeEntitySetNode(EdmEntityType edmEntityType, final ObjectNode tree,
+  private EntityCollection consumeEntitySetNode(EdmEntityType edmEntityType, final ObjectNode tree,
       final ExpandTreeBuilder expandBuilder) throws DeserializerException {
-    EntitySet entitySet = new EntitySet();
+    EntityCollection entitySet = new EntityCollection();
 
     // Consume entities
     JsonNode jsonNode = tree.get(Constants.VALUE);
@@ -339,7 +339,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
             expandBuilder.expand(edmNavigationProperty) : null;
         if (jsonNode.isArray() && edmNavigationProperty.isCollection()) {
           link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
-          EntitySet inlineEntitySet = new EntitySet();
+          EntityCollection inlineEntitySet = new EntityCollection();
           inlineEntitySet.getEntities().addAll(consumeEntitySetArray(edmNavigationProperty.getType(), jsonNode,
               childExpandBuilder));
           link.setInlineEntitySet(inlineEntitySet);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
index c9944c7..ff7eff2 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
@@ -27,7 +27,7 @@ import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Linked;
 import org.apache.olingo.commons.api.data.Property;
@@ -130,7 +130,7 @@ public class ODataJsonSerializer implements ODataSerializer {
 
   @Override
   public SerializerResult entityCollection(final ServiceMetadata metadata,
-      final EdmEntityType entityType, final EntitySet entitySet,
+      final EdmEntityType entityType, final EntityCollection entitySet,
       final EntityCollectionSerializerOptions options) throws SerializerException {
     CircleStreamBuffer buffer = new CircleStreamBuffer();
     try {
@@ -194,7 +194,7 @@ public class ODataJsonSerializer implements ODataSerializer {
   }
 
   protected void writeEntitySet(final ServiceMetadata metadata, final EdmEntityType entityType,
-      final EntitySet entitySet, final ExpandOption expand, final SelectOption select,
+      final EntityCollection entitySet, final ExpandOption expand, final SelectOption select,
       final boolean onlyReference, final JsonGenerator json) throws IOException,
       SerializerException {
     json.writeStartArray();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializerImpl.java
index 6143727..2213c5a 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializerImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializerImpl.java
@@ -23,7 +23,7 @@ import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmComplexType;
@@ -95,7 +95,7 @@ public class ODataXmlSerializerImpl implements ODataSerializer {
 
   @Override
   public SerializerResult entityCollection(final ServiceMetadata metadata,
-      final EdmEntityType entityType, final EntitySet entitySet,
+      final EdmEntityType entityType, final EntityCollection entitySet,
       final EntityCollectionSerializerOptions options) throws SerializerException {
     throw new SerializerException("Entityset serialization not implemented for XML format",
         SerializerException.MessageKeys.NOT_IMPLEMENTED);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
index 06da176..b48d051 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
@@ -31,7 +31,7 @@ import java.util.UUID;
 
 import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ValueType;
@@ -41,10 +41,10 @@ public class DataCreator {
 
   private static final UUID GUID = UUID.fromString("01234567-89ab-cdef-0123-456789abcdef");
 
-  private final Map<String, EntitySet> data;
+  private final Map<String, EntityCollection> data;
 
   public DataCreator() {
-    data = new HashMap<String, EntitySet>();
+    data = new HashMap<String, EntityCollection>();
     data.put("ESTwoPrim", createESTwoPrim());
     data.put("ESAllPrim", createESAllPrim());
     data.put("ESCompAllPrim", createESCompAllPrim());
@@ -59,19 +59,19 @@ public class DataCreator {
     data.put("ESServerSidePaging", createESServerSidePaging());
 
     // No data available but to allow an insert operation create empty EntitySets
-    data.put("ESAllNullable", new EntitySet());
-    data.put("ESMixEnumDefCollComp", new EntitySet());
-    data.put("ESTwoBase", new EntitySet());
-    data.put("ESBaseTwoKeyNav", new EntitySet());
-    data.put("ESBaseTwoKeyTwoPrim", new EntitySet());
-    data.put("ESTwoKeyTwoPrim", new EntitySet());
-    data.put("ESCompCollAllPrim", new EntitySet());
-    data.put("ESKeyTwoKeyComp", new EntitySet());
-    data.put("ESFourKeyAlias", new EntitySet());
-    data.put("ESBase", new EntitySet());
-    data.put("ESTwoBaseTwoKeyTwoPrim", new EntitySet());
-    data.put("ESInvisible", new EntitySet());
-    data.put("ESCompMixPrimCollComp", new EntitySet());
+    data.put("ESAllNullable", new EntityCollection());
+    data.put("ESMixEnumDefCollComp", new EntityCollection());
+    data.put("ESTwoBase", new EntityCollection());
+    data.put("ESBaseTwoKeyNav", new EntityCollection());
+    data.put("ESBaseTwoKeyTwoPrim", new EntityCollection());
+    data.put("ESTwoKeyTwoPrim", new EntityCollection());
+    data.put("ESCompCollAllPrim", new EntityCollection());
+    data.put("ESKeyTwoKeyComp", new EntityCollection());
+    data.put("ESFourKeyAlias", new EntityCollection());
+    data.put("ESBase", new EntityCollection());
+    data.put("ESTwoBaseTwoKeyTwoPrim", new EntityCollection());
+    data.put("ESInvisible", new EntityCollection());
+    data.put("ESCompMixPrimCollComp", new EntityCollection());
 
     linkESTwoPrim(data);
     linkESAllPrim(data);
@@ -79,12 +79,12 @@ public class DataCreator {
     linkESTwoKeyNav(data);
   }
 
-  protected Map<String, EntitySet> getData() {
+  protected Map<String, EntityCollection> getData() {
     return data;
   }
 
-  private EntitySet createESServerSidePaging() {
-    EntitySet entitySet = new EntitySet();
+  private EntityCollection createESServerSidePaging() {
+    EntityCollection entitySet = new EntityCollection();
 
     for (int i = 1; i <= 503; i++) {
       entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", i))
@@ -94,8 +94,8 @@ public class DataCreator {
     return entitySet;
   }
 
-  private EntitySet createESKeyNav() {
-    final EntitySet entitySet = new EntitySet();
+  private EntityCollection createESKeyNav() {
+    final EntityCollection entitySet = new EntityCollection();
 
     entitySet.getEntities().add(createETKeyNavEntity(1, "I am String Property 1"));
     entitySet.getEntities().add(createETKeyNavEntity(2, "I am String Property 2"));
@@ -123,8 +123,8 @@ public class DataCreator {
             createComplex("PropertyCompNav", createPrimitive("PropertyInt16", 1))));
   }
 
-  private EntitySet createESTwoKeyNav() {
-    final EntitySet entitySet = new EntitySet();
+  private EntityCollection createESTwoKeyNav() {
+    final EntityCollection entitySet = new EntityCollection();
 
     entitySet.getEntities().add(createESTwoKeyNavEntity(1, "1"));
     entitySet.getEntities().add(createESTwoKeyNavEntity(1, "2"));
@@ -174,8 +174,8 @@ public class DataCreator {
   }
 
   @SuppressWarnings("unchecked")
-  private EntitySet createESCompCollComp() {
-    final EntitySet entitySet = new EntitySet();
+  private EntityCollection createESCompCollComp() {
+    final EntityCollection entitySet = new EntityCollection();
 
     entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
         .addProperty(createComplex("PropertyComp", createComplexCollection("CollPropertyComp", Arrays
@@ -198,8 +198,8 @@ public class DataCreator {
     return entitySet;
   }
 
-  private EntitySet createESTwoPrim() {
-    EntitySet entitySet = new EntitySet();
+  private EntityCollection createESTwoPrim() {
+    EntityCollection entitySet = new EntityCollection();
 
     entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", 32766))
         .addProperty(createPrimitive("PropertyString", "Test String1")));
@@ -216,8 +216,8 @@ public class DataCreator {
     return entitySet;
   }
 
-  private EntitySet createESAllPrim() {
-    EntitySet entitySet = new EntitySet();
+  private EntityCollection createESAllPrim() {
+    EntityCollection entitySet = new EntityCollection();
 
     entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
         .addProperty(createPrimitive("PropertyString", "First Resource - positive values"))
@@ -266,8 +266,8 @@ public class DataCreator {
     return entitySet;
   }
 
-  private EntitySet createESCompAllPrim() {
-    EntitySet entitySet = new EntitySet();
+  private EntityCollection createESCompAllPrim() {
+    EntityCollection entitySet = new EntityCollection();
 
     Entity entity = new Entity();
     entity.addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE));
@@ -318,8 +318,8 @@ public class DataCreator {
     return entitySet;
   }
 
-  private EntitySet createESCollAllPrim() {
-    EntitySet entitySet = new EntitySet();
+  private EntityCollection createESCollAllPrim() {
+    EntityCollection entitySet = new EntityCollection();
 
     entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", 1)).addProperty(
         createPrimitiveCollection("CollPropertyString", "Employee1@company.example", "Employee2@company.example",
@@ -361,13 +361,13 @@ public class DataCreator {
     return entitySet;
   }
 
-  private EntitySet createESMixPrimCollComp() {
+  private EntityCollection createESMixPrimCollComp() {
     @SuppressWarnings("unchecked") final Property complexCollection = createComplexCollection("CollPropertyComp",
         Arrays.asList(createPrimitive("PropertyInt16", 123), createPrimitive("PropertyString", "TEST 1")),
         Arrays.asList(createPrimitive("PropertyInt16", 456), createPrimitive("PropertyString", "TEST 2")),
         Arrays.asList(createPrimitive("PropertyInt16", 789), createPrimitive("PropertyString", "TEST 3")));
 
-    EntitySet entitySet = new EntitySet();
+    EntityCollection entitySet = new EntityCollection();
 
     entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
         .addProperty(
@@ -391,8 +391,8 @@ public class DataCreator {
     return entitySet;
   }
 
-  private EntitySet createESAllKey() {
-    EntitySet entitySet = new EntitySet();
+  private EntityCollection createESAllKey() {
+    EntityCollection entitySet = new EntityCollection();
 
     entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyString", "First"))
         .addProperty(createPrimitive("PropertyBoolean", true)).addProperty(createPrimitive("PropertyByte", 255))
@@ -420,8 +420,8 @@ public class DataCreator {
     return entitySet;
   }
 
-  private EntitySet createESCompComp() {
-    EntitySet entitySet = new EntitySet();
+  private EntityCollection createESCompComp() {
+    EntityCollection entitySet = new EntityCollection();
 
     Entity entity = new Entity();
     entity.addProperty(createPrimitive("PropertyInt16", 1));
@@ -440,8 +440,8 @@ public class DataCreator {
     return entitySet;
   }
 
-  private EntitySet createESMedia() {
-    EntitySet entitySet = new EntitySet();
+  private EntityCollection createESMedia() {
+    EntityCollection entitySet = new EntityCollection();
 
     Entity entity = new Entity().addProperty(createPrimitive("PropertyInt16", 1))
         .addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("darkturquoise")));
@@ -473,8 +473,8 @@ public class DataCreator {
         + "    <circle cx=\"50\" cy=\"50\" r=\"42\"/>\n" + "  </g>\n" + "</svg>\n").getBytes(Charset.forName("UTF-8"));
   }
 
-  private void linkESTwoPrim(Map<String, EntitySet> data) {
-    final EntitySet entitySet = data.get("ESTwoPrim");
+  private void linkESTwoPrim(Map<String, EntityCollection> data) {
+    final EntityCollection entitySet = data.get("ESTwoPrim");
     final List<Entity> targetEntities = data.get("ESAllPrim").getEntities();
 
     setLinks(entitySet.getEntities().get(1), "NavPropertyETAllPrimMany", targetEntities.get(1), targetEntities.get(2));
@@ -482,8 +482,8 @@ public class DataCreator {
     setLink(entitySet.getEntities().get(3), "NavPropertyETAllPrimOne", targetEntities.get(0));
   }
 
-  private void linkESAllPrim(Map<String, EntitySet> data) {
-    final EntitySet entitySet = data.get("ESAllPrim");
+  private void linkESAllPrim(Map<String, EntityCollection> data) {
+    final EntityCollection entitySet = data.get("ESAllPrim");
     final List<Entity> targetEntities = data.get("ESTwoPrim").getEntities();
 
     setLinks(entitySet.getEntities().get(0), "NavPropertyETTwoPrimMany", targetEntities.get(1));
@@ -493,8 +493,8 @@ public class DataCreator {
         targetEntities.get(3));
   }
 
-  private void linkESKeyNav(Map<String, EntitySet> data) {
-    final EntitySet entitySet = data.get("ESKeyNav");
+  private void linkESKeyNav(Map<String, EntityCollection> data) {
+    final EntityCollection entitySet = data.get("ESKeyNav");
     final List<Entity> esKeyNavTargets = data.get("ESKeyNav").getEntities();
     final List<Entity> esTwoKeyNavTargets = data.get("ESTwoKeyNav").getEntities();
     final List<Entity> esMediaTargets = data.get("ESMedia").getEntities();
@@ -524,8 +524,8 @@ public class DataCreator {
     setLink(entitySet.getEntities().get(2), "NavPropertyETMediaOne", esMediaTargets.get(2));
   }
 
-  private void linkESTwoKeyNav(Map<String, EntitySet> data) {
-    final EntitySet entitySet = data.get("ESTwoKeyNav");
+  private void linkESTwoKeyNav(Map<String, EntityCollection> data) {
+    final EntityCollection entitySet = data.get("ESTwoKeyNav");
     final List<Entity> esKeyNavTargets = data.get("ESKeyNav").getEntities();
     final List<Entity> esTwoKeyNavTargets = data.get("ESTwoKeyNav").getEntities();
 
@@ -619,7 +619,7 @@ public class DataCreator {
       link = new Link();
       link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
       link.setTitle(navigationPropertyName);
-      EntitySet target = new EntitySet();
+      EntityCollection target = new EntityCollection();
       target.getEntities().addAll(Arrays.asList(targets));
       link.setInlineEntitySet(target);
       entity.getNavigationLinks().add(link);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
index a203750..6bf79fa 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
@@ -29,7 +29,7 @@ import java.util.Map;
 
 import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.edm.Edm;
@@ -55,7 +55,7 @@ public class DataProvider {
 
   protected static final String MEDIA_PROPERTY_NAME = "$value";
 
-  final private Map<String, EntitySet> data;
+  final private Map<String, EntityCollection> data;
   private Edm edm;
   private OData odata;
 
@@ -63,16 +63,16 @@ public class DataProvider {
     data = new DataCreator().getData();
   }
 
-  public EntitySet readAll(final EdmEntitySet edmEntitySet) throws DataProviderException {
+  public EntityCollection readAll(final EdmEntitySet edmEntitySet) throws DataProviderException {
     return data.get(edmEntitySet.getName());
   }
 
   public Entity read(final EdmEntitySet edmEntitySet, final List<UriParameter> keys) throws DataProviderException {
-    final EntitySet entitySet = readAll(edmEntitySet);
+    final EntityCollection entitySet = readAll(edmEntitySet);
     return entitySet == null ? null : read(edmEntitySet.getEntityType(), entitySet, keys);
   }
 
-  public Entity read(final EdmEntityType edmEntityType, final EntitySet entitySet, final List<UriParameter> keys)
+  public Entity read(final EdmEntityType edmEntityType, final EntityCollection entitySet, final List<UriParameter> keys)
       throws DataProviderException {
     try {
       for (final Entity entity : entitySet.getEntities()) {
@@ -129,7 +129,7 @@ public class DataProvider {
 
   public Entity create(final EdmEntitySet edmEntitySet) throws DataProviderException {
     final EdmEntityType edmEntityType = edmEntitySet.getEntityType();
-    final EntitySet entitySet = readAll(edmEntitySet);
+    final EntityCollection entitySet = readAll(edmEntitySet);
     final List<Entity> entities = entitySet.getEntities();
     final Map<String, Object> newKey = findFreeComposedKey(entities, edmEntitySet.getEntityType());
     final Entity newEntity = new Entity();
@@ -349,7 +349,7 @@ public class DataProvider {
   }
 
   private List<Entity> createInlineEntities(final String rawBaseUri, final EdmEntitySet targetEntitySet,
-      final EntitySet changedEntitySet) throws DataProviderException {
+      final EntityCollection changedEntitySet) throws DataProviderException {
     List<Entity> entities = new ArrayList<Entity>();
 
     for (final Entity newEntity : changedEntitySet.getEntities()) {
@@ -473,7 +473,7 @@ public class DataProvider {
     entity.setMediaContentType(type);
   }
 
-  public EntitySet readFunctionEntitySet(final EdmFunction function, final List<UriParameter> parameters)
+  public EntityCollection readFunctionEntitySet(final EdmFunction function, final List<UriParameter> parameters)
       throws DataProviderException {
     return FunctionData.entityCollectionFunction(function.getName(), parameters, data);
   }


[11/22] olingo-odata4 git commit: [OLINGO-603] Rename entity set to entity collection

Posted by ra...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
index 1028cd8..7e126a0 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
@@ -23,7 +23,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
@@ -33,11 +33,11 @@ import org.apache.olingo.server.tecsvc.data.DataProvider.DataProviderException;
 
 public class FunctionData {
 
-  protected static EntitySet entityCollectionFunction(final String name, final List<UriParameter> parameters,
-      final Map<String, EntitySet> data) throws DataProviderException {
+  protected static EntityCollection entityCollectionFunction(final String name, final List<UriParameter> parameters,
+      final Map<String, EntityCollection> data) throws DataProviderException {
     if (name.equals("UFCRTCollETTwoKeyNavParam")) {
       final List<Entity> esTwoKeyNav = data.get("ESTwoKeyNav").getEntities();
-      EntitySet result = new EntitySet();
+      EntityCollection result = new EntityCollection();
       final int endIndex = parameters.isEmpty() ? 0 : Short.valueOf(parameters.get(0).getText());
       result.getEntities().addAll(
           esTwoKeyNav.subList(0,
@@ -53,7 +53,7 @@ public class FunctionData {
   }
 
   protected static Entity entityFunction(final String name, final List<UriParameter> parameters,
-      final Map<String, EntitySet> data) throws DataProviderException {
+      final Map<String, EntityCollection> data) throws DataProviderException {
     final List<Entity> esTwoKeyNav = data.get("ESTwoKeyNav").getEntities();
     if (name.equals("UFCRTETTwoKeyNav")) {
       return esTwoKeyNav.get(0);
@@ -71,7 +71,7 @@ public class FunctionData {
 
   @SuppressWarnings("unchecked")
   protected static Property primitiveComplexFunction(final String name, final List<UriParameter> parameters,
-      final Map<String, EntitySet> data) throws DataProviderException {
+      final Map<String, EntityCollection> data) throws DataProviderException {
     if (name.equals("UFNRTInt16")) {
       return DataCreator.createPrimitive(name, 12345);
     } else if (name.equals("UFCRTString")) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/RequestValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/RequestValidator.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/RequestValidator.java
index 113b252..c2e9da4 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/RequestValidator.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/RequestValidator.java
@@ -23,7 +23,7 @@ import java.util.List;
 
 import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Linked;
 import org.apache.olingo.commons.api.data.Property;
@@ -140,7 +140,7 @@ public class RequestValidator {
     }
     
     if(edmProperty.isCollection()) {
-      final EntitySet inlineEntitySet = navigationLink.getInlineEntitySet();
+      final EntityCollection inlineEntitySet = navigationLink.getInlineEntitySet();
       if(!isInsert && inlineEntitySet.getEntities().size() > 0) {
         throw new DataProvider.DataProviderException("Deep update is not allowed", HttpStatusCode.BAD_REQUEST);
       } else {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
index 858963d..01f2c90 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
@@ -24,7 +24,7 @@ import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.data.ContextURL.Builder;
 import org.apache.olingo.commons.api.data.ContextURL.Suffix;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.edm.EdmAction;
 import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.edm.EdmEntityType;
@@ -91,13 +91,13 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
             .get(uriInfo.getUriResourceParts().size() - 1)).getType() :
         edmEntitySet.getEntityType();
 
-    final EntitySet entitySetInitial = readEntityCollection(uriInfo);
+    final EntityCollection entitySetInitial = readEntityCollection(uriInfo);
     if (entitySetInitial == null) {
       throw new ODataApplicationException("Nothing found.", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ROOT);
     } else {
       // Modifying the original entitySet means modifying the "database", so we have to make a shallow
       // copy of the entity set (new EntitySet, but exactly the same data)
-      EntitySet entitySet = new EntitySet();
+      EntityCollection entitySet = new EntityCollection();
       entitySet.getEntities().addAll(entitySetInitial.getEntities());
 
       // Apply system query options
@@ -121,7 +121,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
       // Create a shallow copy of each entity. So the expanded navigation properties can be modified for serialization,
       // without affecting the data stored in the database.
       final ExpandSystemQueryOptionHandler expandHandler = new ExpandSystemQueryOptionHandler();
-      final EntitySet entitySetSerialization = expandHandler.transformEntitySetGraphToTree(entitySet, 
+      final EntityCollection entitySetSerialization = expandHandler.transformEntitySetGraphToTree(entitySet, 
                                                                                            edmEntitySet, 
                                                                                            expand);
       expandHandler.applyExpandQueryOptions(entitySetSerialization, edmEntitySet, expand);
@@ -155,7 +155,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
       throws ODataApplicationException, SerializerException {
     validateOptions(uriInfo.asUriInfoResource());
     getEdmEntitySet(uriInfo); // including checks
-    EntitySet entitySet = readEntityCollection(uriInfo);
+    EntityCollection entitySet = readEntityCollection(uriInfo);
     if (entitySet == null) {
       throw new ODataApplicationException("Nothing found.", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ROOT);
     } else {
@@ -330,7 +330,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
     response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
   }
 
-  private void setCount(EntitySet entitySet) {
+  private void setCount(EntityCollection entitySet) {
     if (entitySet.getCount() == null) {
       entitySet.setCount(entitySet.getEntities().size());
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
index 33cd98f..d826b19 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
@@ -22,7 +22,7 @@ import java.util.List;
 import java.util.Locale;
 
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.edm.EdmBindingTarget;
 import org.apache.olingo.commons.api.edm.EdmEntitySet;
@@ -163,7 +163,7 @@ public abstract class TechnicalProcessor implements Processor {
     return entity;
   }
 
-  protected EntitySet readEntityCollection(final UriInfoResource uriInfo) throws ODataApplicationException {
+  protected EntityCollection readEntityCollection(final UriInfoResource uriInfo) throws ODataApplicationException {
     final List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
     if (resourcePaths.size() > 1 && resourcePaths.get(1) instanceof UriResourceNavigation) {
       final Entity entity = readEntity(uriInfo);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java
index e6b9849..f68af3b 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java
@@ -24,7 +24,7 @@ import java.util.Locale;
 import java.util.Set;
 
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.edm.EdmBindingTarget;
 import org.apache.olingo.commons.api.edm.EdmEntitySet;
@@ -48,7 +48,7 @@ import org.apache.olingo.server.tecsvc.processor.queryoptions.options.TopHandler
 
 public class ExpandSystemQueryOptionHandler {
 
-  public void applyExpandQueryOptions(final EntitySet entitySet, final EdmEntitySet edmEntitySet,
+  public void applyExpandQueryOptions(final EntityCollection entitySet, final EdmEntitySet edmEntitySet,
       final ExpandOption expandOption) throws ODataApplicationException {
     if (expandOption == null) {
       return;
@@ -80,14 +80,14 @@ public class ExpandSystemQueryOptionHandler {
 
         final Link link = entity.getNavigationLink(navPropertyName);
         if (link != null && entityType.getNavigationProperty(navPropertyName).isCollection()) {
-          applyOptionsToEntityCollection(link.getInlineEntitySet(), 
-                                         targetEdmEntitySet, 
-                                         item.getFilterOption(),
-                                         item.getOrderByOption(), 
-                                         item.getCountOption(), 
-                                         item.getSkipOption(), 
-                                         item.getTopOption(), 
-                                         item.getExpandOption());
+          applyOptionsToEntityCollection(link.getInlineEntitySet(),
+              targetEdmEntitySet,
+              item.getFilterOption(),
+              item.getOrderByOption(),
+              item.getCountOption(),
+              item.getSkipOption(),
+              item.getTopOption(),
+              item.getExpandOption());
         }
       } else {
         throw new ODataApplicationException("Not supported resource part in expand system query option",
@@ -96,83 +96,84 @@ public class ExpandSystemQueryOptionHandler {
     }
   }
 
-  private void applyOptionsToEntityCollection(final EntitySet entitySet, final EdmBindingTarget edmBindingTarget,
+  private void applyOptionsToEntityCollection(final EntityCollection entitySet,
+      final EdmBindingTarget edmBindingTarget,
       final FilterOption filterOption, final OrderByOption orderByOption, final CountOption countOption,
-      final SkipOption skipOption, final TopOption topOption, final ExpandOption expandOption) 
-          throws ODataApplicationException {
+      final SkipOption skipOption, final TopOption topOption, final ExpandOption expandOption)
+      throws ODataApplicationException {
 
     FilterHandler.applyFilterSystemQuery(filterOption, entitySet, edmBindingTarget);
     OrderByHandler.applyOrderByOption(orderByOption, entitySet, edmBindingTarget);
     // TODO Add CountHandler
     SkipHandler.applySkipSystemQueryHandler(skipOption, entitySet);
     TopHandler.applyTopSystemQueryOption(topOption, entitySet);
-    
+
     // Apply nested expand system query options to remaining entities
-    if(expandOption != null) {
-      for(final Entity entity : entitySet.getEntities()) {
+    if (expandOption != null) {
+      for (final Entity entity : entitySet.getEntities()) {
         applyExpandOptionToEntity(entity, edmBindingTarget, expandOption);
       }
     }
   }
 
-  public EntitySet transformEntitySetGraphToTree(final EntitySet entitySet, final EdmBindingTarget edmBindingTarget, 
-      final ExpandOption expand) throws ODataApplicationException {
-    
-    final EntitySet newEntitySet = newEntitySet(entitySet);
-    
-    for(final Entity entity : entitySet.getEntities()) {
+  public EntityCollection transformEntitySetGraphToTree(final EntityCollection entitySet,
+      final EdmBindingTarget edmBindingTarget, final ExpandOption expand) throws ODataApplicationException {
+
+    final EntityCollection newEntitySet = newEntitySet(entitySet);
+
+    for (final Entity entity : entitySet.getEntities()) {
       newEntitySet.getEntities().add(transformEntityGraphToTree(entity, edmBindingTarget, expand));
     }
-    
+
     return newEntitySet;
   }
-  
-  public Entity transformEntityGraphToTree(final Entity entity, EdmBindingTarget edmEntitySet, 
+
+  public Entity transformEntityGraphToTree(final Entity entity, EdmBindingTarget edmEntitySet,
       final ExpandOption expand) throws ODataApplicationException {
     final Entity newEntity = newEntity(entity);
     if (hasExpandItems(expand)) {
       final boolean expandAll = expandAll(expand);
       final Set<String> expanded = expandAll ? null : getExpandedPropertyNames(expand.getExpandItems());
       final EdmEntityType edmType = edmEntitySet.getEntityType();
-      
+
       for (final Link link : entity.getNavigationLinks()) {
         final String propertyName = link.getTitle();
-        
+
         if (expandAll || expanded.contains(propertyName)) {
           final EdmNavigationProperty edmNavigationProperty = edmType.getNavigationProperty(propertyName);
           final EdmBindingTarget edmBindingTarget = edmEntitySet.getRelatedBindingTarget(propertyName);
           final Link newLink = newLink(link);
           newEntity.getNavigationLinks().add(newLink);
           final ExpandOption innerExpandOption = getInnerExpandOption(expand, propertyName);
-          
-          if(edmNavigationProperty.isCollection()) {
-            newLink.setInlineEntitySet(transformEntitySetGraphToTree(link.getInlineEntitySet(), 
-                                                                     edmBindingTarget, 
-                                                                     innerExpandOption));
+
+          if (edmNavigationProperty.isCollection()) {
+            newLink.setInlineEntitySet(transformEntitySetGraphToTree(link.getInlineEntitySet(),
+                edmBindingTarget,
+                innerExpandOption));
           } else {
-            newLink.setInlineEntity(transformEntityGraphToTree(link.getInlineEntity(), 
-                                                               edmBindingTarget, 
-                                                               innerExpandOption));  
+            newLink.setInlineEntity(transformEntityGraphToTree(link.getInlineEntity(),
+                edmBindingTarget,
+                innerExpandOption));
           }
         }
       }
-      
+
     }
     return newEntity;
   }
-  
-  public EntitySet newEntitySet(final EntitySet entitySet) {
-    final EntitySet newEntitySet = new EntitySet();
+
+  public EntityCollection newEntitySet(final EntityCollection entitySet) {
+    final EntityCollection newEntitySet = new EntityCollection();
     newEntitySet.setCount(entitySet.getCount());
     newEntitySet.setDeltaLink(entitySet.getDeltaLink());
     newEntitySet.setNext(entitySet.getNext());
-    
+
     return newEntitySet;
   }
-  
+
   private Entity newEntity(final Entity entity) {
     final Entity newEntity = new Entity();
-    
+
     newEntity.getProperties().addAll(entity.getProperties());
     newEntity.getAnnotations().addAll(entity.getAnnotations());
     newEntity.getAssociationLinks().addAll(entity.getAssociationLinks());
@@ -185,24 +186,24 @@ public class ExpandSystemQueryOptionHandler {
     newEntity.setSelfLink(entity.getSelfLink());
     newEntity.setType(entity.getType());
     newEntity.getNavigationBindings().addAll(entity.getNavigationBindings());
-    
+
     return newEntity;
   }
-  
+
   private Link newLink(Link link) {
     final Link newLink = new Link();
     newLink.setMediaETag(link.getMediaETag());
     newLink.setTitle(link.getTitle());
     newLink.setType(link.getType());
     newLink.setRel(link.getRel());
-    
+
     return newLink;
   }
-  
+
   private boolean hasExpandItems(ExpandOption expand) {
     return expand != null && expand.getExpandItems() != null && !expand.getExpandItems().isEmpty();
   }
-  
+
   private boolean expandAll(ExpandOption expand) {
     for (final ExpandItem item : expand.getExpandItems()) {
       if (item.isStar()) {
@@ -211,7 +212,7 @@ public class ExpandSystemQueryOptionHandler {
     }
     return false;
   }
-  
+
   private Set<String> getExpandedPropertyNames(List<ExpandItem> expandItems) throws ODataApplicationException {
     Set<String> expanded = new HashSet<String>();
     for (final ExpandItem item : expandItems) {
@@ -230,14 +231,14 @@ public class ExpandSystemQueryOptionHandler {
   }
 
   private ExpandOption getInnerExpandOption(final ExpandOption expand, final String propertyName) {
-    for(final ExpandItem item : expand.getExpandItems()) {
+    for (final ExpandItem item : expand.getExpandItems()) {
       final UriResource resource = item.getResourcePath().getUriResourceParts().get(0);
-      if(resource instanceof UriResourceNavigation 
+      if (resource instanceof UriResourceNavigation
           && propertyName.equals(((UriResourceNavigation) resource).getProperty().getName())) {
         return item.getExpandOption();
       }
     }
-    
+
     return null;
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/CountHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/CountHandler.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/CountHandler.java
index 59f6a4e..cfe79ec 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/CountHandler.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/CountHandler.java
@@ -18,11 +18,11 @@
  */
 package org.apache.olingo.server.tecsvc.processor.queryoptions.options;
 
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.server.api.uri.queryoption.CountOption;
 
 public class CountHandler {
-  public static void applyCountSystemQueryOption(final CountOption countOption, final EntitySet entitySet) {
+  public static void applyCountSystemQueryOption(final CountOption countOption, final EntityCollection entitySet) {
     if(countOption != null && countOption.getValue()) {
       entitySet.setCount(entitySet.getEntities().size());
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/FilterHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/FilterHandler.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/FilterHandler.java
index 69fa2e4..3db6b98 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/FilterHandler.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/FilterHandler.java
@@ -22,7 +22,7 @@ import java.util.Iterator;
 import java.util.Locale;
 
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.edm.EdmBindingTarget;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
@@ -45,7 +45,7 @@ public class FilterHandler {
     primBoolean = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Boolean);
   }
 
-  public static void applyFilterSystemQuery(FilterOption filterOption, EntitySet entitySet, 
+  public static void applyFilterSystemQuery(FilterOption filterOption, EntityCollection entitySet, 
       EdmBindingTarget edmEntitySet) throws ODataApplicationException {
 
     if (filterOption == null) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/OrderByHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/OrderByHandler.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/OrderByHandler.java
index d166c4e..ce472ba 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/OrderByHandler.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/OrderByHandler.java
@@ -23,7 +23,7 @@ import java.util.Comparator;
 import java.util.Locale;
 
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.edm.EdmBindingTarget;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.server.api.ODataApplicationException;
@@ -34,7 +34,7 @@ import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.Express
 import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.operand.TypedOperand;
 
 public class OrderByHandler {
-  public static void applyOrderByOption(final OrderByOption orderByOption, final EntitySet entitySet,
+  public static void applyOrderByOption(final OrderByOption orderByOption, final EntityCollection entitySet,
       final EdmBindingTarget edmBindingTarget) throws ODataApplicationException {
 
     if (orderByOption == null) {
@@ -54,7 +54,7 @@ public class OrderByHandler {
     }
   }
 
-  private static void applyOrderByOptionInternal(final OrderByOption orderByOption, final EntitySet entitySet,
+  private static void applyOrderByOptionInternal(final OrderByOption orderByOption, final EntityCollection entitySet,
       final EdmBindingTarget edmBindingTarget) throws ODataApplicationException {
     Collections.sort(entitySet.getEntities(), new Comparator<Entity>() {
       @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/ServerSidePagingHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/ServerSidePagingHandler.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/ServerSidePagingHandler.java
index a945edb..0871a33 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/ServerSidePagingHandler.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/ServerSidePagingHandler.java
@@ -22,7 +22,7 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Locale;
 
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.server.api.ODataApplicationException;
@@ -34,7 +34,7 @@ public class ServerSidePagingHandler {
   private static final int MAX_PAGE_SIZE = 10;
   private static final String ES_SERVER_SIDE_PAGING = "ESServerSidePaging";
 
-  public static void applyServerSidePaging(final SkipTokenOption skipTokenOption, final EntitySet entitySet,
+  public static void applyServerSidePaging(final SkipTokenOption skipTokenOption, final EntityCollection entitySet,
       final EdmEntitySet edmEntitySet, final String rawRequestUri) throws ODataApplicationException {
 
     if (edmEntitySet != null && shouldApplyServerSidePaging(edmEntitySet)) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/SkipHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/SkipHandler.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/SkipHandler.java
index 48414ea..835657b 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/SkipHandler.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/SkipHandler.java
@@ -22,13 +22,13 @@ import java.util.Iterator;
 import java.util.Locale;
 
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.uri.queryoption.SkipOption;
 
 public class SkipHandler {
-  public static void applySkipSystemQueryHandler(final SkipOption skipOption, final EntitySet entitySet)
+  public static void applySkipSystemQueryHandler(final SkipOption skipOption, final EntityCollection entitySet)
       throws ODataApplicationException {
     
     if (skipOption != null) {
@@ -41,7 +41,7 @@ public class SkipHandler {
     }
   }
 
-  static void popAtMost(final EntitySet entitySet, final int n) {
+  static void popAtMost(final EntityCollection entitySet, final int n) {
     final Iterator<Entity> iter = entitySet.getEntities().iterator();
     int i = 0;
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/TopHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/TopHandler.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/TopHandler.java
index 7edc105..3177f44 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/TopHandler.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/options/TopHandler.java
@@ -20,13 +20,13 @@ package org.apache.olingo.server.tecsvc.processor.queryoptions.options;
 
 import java.util.Locale;
 
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.uri.queryoption.TopOption;
 
 public class TopHandler {
-  public static void applyTopSystemQueryOption(final TopOption topOption, final EntitySet entitySet)
+  public static void applyTopSystemQueryOption(final TopOption topOption, final EntityCollection entitySet)
       throws ODataApplicationException {
 
     if (topOption != null) {
@@ -39,7 +39,7 @@ public class TopHandler {
     }
   }
 
-  static void reduceToSize(final EntitySet entitySet, final int n) {
+  static void reduceToSize(final EntityCollection entitySet, final int n) {
     while (entitySet.getEntities().size() > n) {
       entitySet.getEntities().remove(entitySet.getEntities().size() - 1);
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
index 4549a03..c9a8e65 100644
--- a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
+++ b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
@@ -24,7 +24,7 @@ import java.util.List;
 
 import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmEntityContainer;
@@ -88,14 +88,14 @@ public class DataProviderTest {
   @Test
   public void esAllPrim() throws Exception {
     final DataProvider data = new DataProvider();
-    EntitySet outSet = data.readAll(esAllPrim);
+    EntityCollection outSet = data.readAll(esAllPrim);
 
     Assert.assertEquals(3, outSet.getEntities().size());
 
     Entity first = outSet.getEntities().get(0);
     Assert.assertEquals(16, first.getProperties().size());
     Assert.assertEquals(2, first.getNavigationLinks().size());
-    final EntitySet target = first.getNavigationLink("NavPropertyETTwoPrimMany").getInlineEntitySet();
+    final EntityCollection target = first.getNavigationLink("NavPropertyETTwoPrimMany").getInlineEntitySet();
     Assert.assertNotNull(target);
     Assert.assertEquals(1, target.getEntities().size());
     Assert.assertEquals(data.readAll(entityContainer.getEntitySet("ESTwoPrim")).getEntities().get(1),
@@ -107,7 +107,7 @@ public class DataProviderTest {
 
   @Test
   public void esCollAllPrim() throws Exception {
-    EntitySet outSet = new DataProvider().readAll(esCollAllPrim);
+    EntityCollection outSet = new DataProvider().readAll(esCollAllPrim);
 
     Assert.assertEquals(3, outSet.getEntities().size());
     Assert.assertEquals(17, outSet.getEntities().get(0).getProperties().size());
@@ -120,7 +120,7 @@ public class DataProviderTest {
 
   @Test
   public void esCompAllPrim() throws Exception {
-    EntitySet outSet = new DataProvider().readAll(esCompAllPrim);
+    EntityCollection outSet = new DataProvider().readAll(esCompAllPrim);
 
     Assert.assertEquals(3, outSet.getEntities().size());
     Assert.assertEquals(2, outSet.getEntities().get(0).getProperties().size());
@@ -133,7 +133,7 @@ public class DataProviderTest {
 
   @Test
   public void esMixPrimCollComp() throws Exception {
-    EntitySet outSet = new DataProvider().readAll(esMixPrimCollComp);
+    EntityCollection outSet = new DataProvider().readAll(esMixPrimCollComp);
 
     Assert.assertEquals(3, outSet.getEntities().size());
     Assert.assertEquals(4, outSet.getEntities().get(0).getProperties().size());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerEntityCollectionTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerEntityCollectionTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerEntityCollectionTest.java
index 4864d24..0a593dc 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerEntityCollectionTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerEntityCollectionTest.java
@@ -28,7 +28,7 @@ import java.math.BigDecimal;
 import java.util.List;
 
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
@@ -43,7 +43,7 @@ public class ODataDeserializerEntityCollectionTest extends AbstractODataDeserial
   public void esAllPrim() throws Exception {
     EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
     InputStream stream = getFileAsStream("ESAllPrim.json");
-    EntitySet entitySet =
+    EntityCollection entitySet =
         OData.newInstance().createDeserializer(ODataFormat.JSON).entityCollection(stream, edmEntityType)
                            .getEntityCollection();
 
@@ -78,7 +78,7 @@ public class ODataDeserializerEntityCollectionTest extends AbstractODataDeserial
   public void eSCompCollComp() throws Exception {
     EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETCompCollComp"));
     InputStream stream = getFileAsStream("ESCompCollComp.json");
-    EntitySet entitySet =
+    EntityCollection entitySet =
         OData.newInstance().createDeserializer(ODataFormat.JSON).entityCollection(stream, edmEntityType)
                                                                 .getEntityCollection();
 
@@ -100,7 +100,7 @@ public class ODataDeserializerEntityCollectionTest extends AbstractODataDeserial
     String entityCollectionString = "{\"value\" : []}";
     InputStream stream = new ByteArrayInputStream(entityCollectionString.getBytes());
     EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETAllPrim"));
-    EntitySet entityCollection =
+    EntityCollection entityCollection =
         OData.newInstance().createDeserializer(ODataFormat.JSON).entityCollection(stream, edmEntityType)
                                                                 .getEntityCollection();
     assertNotNull(entityCollection.getEntities());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
index 801377e..8d44be3 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
@@ -27,7 +27,7 @@ import org.apache.commons.io.IOUtils;
 import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.data.ContextURL.Suffix;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ValueType;
 import org.apache.olingo.commons.api.edm.Edm;
@@ -159,7 +159,7 @@ public class ODataJsonSerializerTest {
   @Test
   public void entitySetAllPrim() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
-    EntitySet entitySet = data.readAll(edmEntitySet);
+    EntityCollection entitySet = data.readAll(edmEntitySet);
     entitySet.setCount(entitySet.getEntities().size());
     entitySet.setNext(URI.create("/next"));
     CountOption countOption = Mockito.mock(CountOption.class);
@@ -305,7 +305,7 @@ public class ODataJsonSerializerTest {
   @Test
   public void entitySetTwoPrimNoMetadata() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim");
-    final EntitySet entitySet = data.readAll(edmEntitySet);
+    final EntityCollection entitySet = data.readAll(edmEntitySet);
     InputStream result = new ODataJsonSerializer(ODataFormat.JSON_NO_METADATA)
         .entityCollection(metadata, edmEntitySet.getEntityType(), entitySet,
             EntityCollectionSerializerOptions.with()
@@ -338,7 +338,7 @@ public class ODataJsonSerializerTest {
   @Test
   public void entitySetMedia() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMedia");
-    final EntitySet entitySet = data.readAll(edmEntitySet);
+    final EntityCollection entitySet = data.readAll(edmEntitySet);
     final String resultString = IOUtils.toString(serializer.entityCollection(metadata,
         edmEntitySet.getEntityType(), entitySet,
         EntityCollectionSerializerOptions.with()
@@ -398,7 +398,7 @@ public class ODataJsonSerializerTest {
   public void selectComplex() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCompComp");
     final EdmEntityType entityType = edmEntitySet.getEntityType();
-    final EntitySet entitySet = data.readAll(edmEntitySet);
+    final EntityCollection entitySet = data.readAll(edmEntitySet);
     final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
         ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyComp", "PropertyComp", "PropertyString")));
     InputStream result = serializer
@@ -422,7 +422,7 @@ public class ODataJsonSerializerTest {
   public void selectComplexTwice() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCompComp");
     final EdmEntityType entityType = edmEntitySet.getEntityType();
-    final EntitySet entitySet = data.readAll(edmEntitySet);
+    final EntityCollection entitySet = data.readAll(edmEntitySet);
     final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
         ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyComp", "PropertyComp", "PropertyString"),
         ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyComp", "PropertyComp")));

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/samples/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java
----------------------------------------------------------------------
diff --git a/samples/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java b/samples/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java
index b8789bd..c2a1b1c 100644
--- a/samples/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java
+++ b/samples/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java
@@ -25,7 +25,7 @@ import java.util.Map;
 
 import org.apache.olingo.commons.api.ODataException;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ValueType;
 import org.apache.olingo.commons.api.edm.EdmEntitySet;
@@ -38,21 +38,21 @@ import org.apache.olingo.server.sample.edmprovider.CarsEdmProvider;
 
 public class DataProvider {
 
-  private final Map<String, EntitySet> data;
+  private final Map<String, EntityCollection> data;
 
   public DataProvider() {
-    data = new HashMap<String, EntitySet>();
+    data = new HashMap<String, EntityCollection>();
     data.put("Cars", createCars());
     data.put("Manufacturers", createManufacturers());
   }
 
-  public EntitySet readAll(EdmEntitySet edmEntitySet) {
+  public EntityCollection readAll(EdmEntitySet edmEntitySet) {
     return data.get(edmEntitySet.getName());
   }
 
   public Entity read(final EdmEntitySet edmEntitySet, final List<UriParameter> keys) throws DataProviderException {
     final EdmEntityType entityType = edmEntitySet.getEntityType();
-    final EntitySet entitySet = data.get(edmEntitySet.getName());
+    final EntityCollection entitySet = data.get(edmEntitySet.getName());
     if (entitySet == null) {
       return null;
     } else {
@@ -93,8 +93,8 @@ public class DataProvider {
     }
   }
 
-  private EntitySet createCars() {
-    EntitySet entitySet = new EntitySet();
+  private EntityCollection createCars() {
+    EntityCollection entitySet = new EntityCollection();
 
     entitySet.getEntities().add(new Entity()
         .addProperty(createPrimitive("Id", 1))
@@ -137,8 +137,8 @@ public class DataProvider {
     return entitySet;
   }
 
-  private EntitySet createManufacturers() {
-    EntitySet entitySet = new EntitySet();
+  private EntityCollection createManufacturers() {
+    EntityCollection entitySet = new EntityCollection();
 
     entitySet.getEntities().add(new Entity()
         .addProperty(createPrimitive("Id", 1))

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d692d129/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
----------------------------------------------------------------------
diff --git a/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java b/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
index 90df224..4305415 100644
--- a/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
+++ b/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
@@ -27,7 +27,7 @@ import java.util.Locale;
 import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.data.ContextURL.Suffix;
 import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.edm.EdmComplexType;
 import org.apache.olingo.commons.api.edm.EdmEntitySet;
@@ -97,7 +97,7 @@ public class CarsProcessor implements EntityCollectionProcessor, EntityProcessor
 
     // Second we fetch the data for this specific entity set from the mock database and transform it into an EntitySet
     // object which is understood by our serialization
-    EntitySet entitySet = dataProvider.readAll(edmEntitySet);
+    EntityCollection entitySet = dataProvider.readAll(edmEntitySet);
 
     // Next we create a serializer based on the requested format. This could also be a custom format but we do not
     // support them in this example


[03/22] olingo-odata4 git commit: [OLINGO-545] Fix: Bind operations are applyed before creating deep insert entities

Posted by ra...@apache.org.
[OLINGO-545] Fix: Bind operations are applyed before creating deep insert entities


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/189de7b2
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/189de7b2
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/189de7b2

Branch: refs/heads/OLINGO-573
Commit: 189de7b2d70f84260d76ed323e22d85bf9cd6d57
Parents: 502f7ce
Author: Christian Holzer <c....@sap.com>
Authored: Thu Apr 2 15:04:00 2015 +0200
Committer: Christian Holzer <ch...@t-online.de>
Committed: Fri Apr 3 12:42:00 2015 +0200

----------------------------------------------------------------------
 .../olingo/fit/tecsvc/client/BindingITCase.java | 47 ++++++++++++++++++++
 .../olingo/server/tecsvc/data/DataProvider.java | 15 ++++---
 2 files changed, 56 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/189de7b2/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BindingITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BindingITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BindingITCase.java
index d0435b2..75cadd0 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BindingITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BindingITCase.java
@@ -25,6 +25,7 @@ import java.net.URI;
 import java.util.HashMap;
 import java.util.Iterator;
 
+import org.apache.olingo.client.api.EdmEnabledODataClient;
 import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.communication.ODataClientErrorException;
 import org.apache.olingo.client.api.communication.request.cud.UpdateType;
@@ -34,6 +35,7 @@ import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResp
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
 import org.apache.olingo.client.core.ODataClientFactory;
 import org.apache.olingo.commons.api.domain.ODataEntity;
+import org.apache.olingo.commons.api.domain.ODataInlineEntity;
 import org.apache.olingo.commons.api.domain.ODataLink;
 import org.apache.olingo.commons.api.domain.ODataObjectFactory;
 import org.apache.olingo.commons.api.domain.ODataProperty;
@@ -310,6 +312,51 @@ public class BindingITCase extends AbstractBaseTestITCase {
     }
   }
   
+  @Test
+  public void testDeepInsertWithBindingSameNavigationProperty() {
+   final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+   client.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
+   final ODataObjectFactory of = client.getObjectFactory();
+   
+   final ODataEntity entity = of.newEntity(ET_KEY_NAV);
+   entity.getProperties().add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder()
+         .buildString("1")));
+   entity.getProperties().add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
+       .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short)1)))
+       .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("1")))));
+   
+   final ODataEntity innerEntity = of.newEntity(ET_KEY_NAV);
+   innerEntity.getProperties().add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder()
+        .buildString("2")));
+   innerEntity.getProperties().add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
+        .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 1)))
+        .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("2")))));
+   
+   final ODataInlineEntity inlineLink = of.newDeepInsertEntity(NAV_PROPERTY_ET_KEY_NAV_ONE, innerEntity);
+   entity.addLink(inlineLink);
+   
+   final URI bindingURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
+                                                           .appendKeySegment(3)
+                                                           .build();
+   
+   entity.addLink(of.newEntityNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE, bindingURI));
+   
+   final URI targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
+   final ODataEntityCreateResponse<ODataEntity> response = 
+       client.getCUDRequestFactory().getEntityCreateRequest(targetURI, entity).execute();
+   
+   assertEquals(HttpStatusCode.CREATED.getStatusCode(), response.getStatusCode());
+   
+   assertEquals(1, response.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE)
+                                      .asInlineEntity()
+                                      .getEntity()
+              .getProperty(PROPERTY_COMP_TWO_PRIM)
+                    .getComplexValue()
+                                      .get(PROPERTY_INT16)
+                                      .getPrimitiveValue()
+                                      .toValue());
+  }
+  
   @Override
   protected ODataClient getClient() {
     ODataClient odata = ODataClientFactory.getClient();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/189de7b2/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
index e4bb0a2..96f0cd7 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
@@ -243,18 +243,21 @@ public class DataProvider {
             patch);
       }
     }
-
+    
+    // For insert operations collection navigation property bind operations and deep insert operations can be combined. 
+    // In this case, the bind operations MUST appear before the deep insert operations in the payload.
+    // => Apply bindings first
+    final boolean navigationBindingsAvailable = !changedEntity.getNavigationBindings().isEmpty();
+    if (navigationBindingsAvailable) {
+      applyNavigationBinding(rawBaseUri, edmEntitySet, entity, changedEntity.getNavigationBindings());
+    }
+    
     // Deep insert (only if not an update)
     if (isInsert) {
       handleDeepInsert(rawBaseUri, edmEntitySet, entity, changedEntity);
     } else {
       handleDeleteSingleNavigationProperties(edmEntitySet, entity, changedEntity);
     }
-
-    final boolean navigationBindingsAvailable = !changedEntity.getNavigationBindings().isEmpty();
-    if (navigationBindingsAvailable) {
-      applyNavigationBinding(rawBaseUri, edmEntitySet, entity, changedEntity.getNavigationBindings());
-    }
   }
 
   private void handleDeleteSingleNavigationProperties(EdmEntitySet edmEntitySet, Entity entity, Entity changedEntity)


[09/22] olingo-odata4 git commit: [OLINGO-603] Delete core dependecies in Tec Scenario

Posted by ra...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntitySetImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntitySetImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntitySetImpl.java
deleted file mode 100755
index 7898a8c..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntitySetImpl.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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 WARRANTIES OR 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.olingo.commons.core.data;
-
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-public class EntitySetImpl extends AbstractODataObject implements EntitySet {
-
-  private Integer count;
-
-  private final List<Entity> entities = new ArrayList<Entity>();
-
-  private URI next;
-
-  private URI deltaLink;
-
-  @Override
-  public void setCount(final Integer count) {
-    this.count = count;
-  }
-
-  @Override
-  public Integer getCount() {
-    return count;
-  }
-
-  @Override
-  public List<Entity> getEntities() {
-    return entities;
-  }
-
-  @Override
-  public void setNext(final URI next) {
-    this.next = next;
-  }
-
-  @Override
-  public URI getNext() {
-    return next;
-  }
-
-  @Override
-  public URI getDeltaLink() {
-    return deltaLink;
-  }
-
-  @Override
-  public void setDeltaLink(final URI deltaLink) {
-    this.deltaLink = deltaLink;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java
deleted file mode 100644
index 5d096d6..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * 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 WARRANTIES OR 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.olingo.commons.core.data;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.data.Link;
-
-public class LinkImpl extends AbstractAnnotatedObject implements Link {
-
-  private String title;
-  private String rel;
-  private String href;
-  private String type;
-  private String mediaETag;
-  private Entity entity;
-  private EntitySet entitySet;
-  private String bindingLink;
-  private List<String> bindingLinks = new ArrayList<String>();
-
-  @Override
-  public String getTitle() {
-    return title;
-  }
-
-  @Override
-  public void setTitle(final String title) {
-    this.title = title;
-  }
-
-  @Override
-  public String getRel() {
-    return rel;
-  }
-
-  @Override
-  public void setRel(final String rel) {
-    this.rel = rel;
-  }
-
-  @Override
-  public String getHref() {
-    return href;
-  }
-
-  @Override
-  public void setHref(final String href) {
-    this.href = href;
-  }
-
-  @Override
-  public String getType() {
-    return type;
-  }
-
-  @Override
-  public void setType(final String type) {
-    this.type = type;
-  }
-
-  @Override
-  public String getMediaETag() {
-    return mediaETag;
-  }
-
-  @Override
-  public void setMediaETag(final String mediaETag) {
-    this.mediaETag = mediaETag;
-  }
-
-  @Override
-  public Entity getInlineEntity() {
-    return entity;
-  }
-
-  @Override
-  public void setInlineEntity(final Entity entity) {
-    this.entity = entity;
-  }
-
-  @Override
-  public EntitySet getInlineEntitySet() {
-    return entitySet;
-  }
-
-  @Override
-  public void setInlineEntitySet(final EntitySet entitySet) {
-    this.entitySet = entitySet;
-  }
-
-  @Override
-  public String getBindingLink() {
-    return bindingLink;
-  }
-
-  @Override
-  public List<String> getBindingLinks() {
-    return bindingLinks;
-  }
-
-  @Override
-  public void setBindingLink(String bindingLink) {
-    this.bindingLink = bindingLink;
-  }
-
-  @Override
-  public void setBindingLinks(List<String> bindingLinks) {
-    this.bindingLinks = bindingLinks;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ParameterImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ParameterImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ParameterImpl.java
deleted file mode 100644
index fc2a1a9..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ParameterImpl.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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 WARRANTIES OR 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.olingo.commons.core.data;
-
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.Parameter;
-import org.apache.olingo.commons.api.data.ValueType;
-
-public class ParameterImpl extends AbstractValuable implements Parameter {
-
-  String name;
-
-  @Override
-  public String getName() {
-    return name;
-  }
-
-  public void setName(String name) {
-    this.name = name;
-  }
-
-  @Override
-  public boolean isEntity() {
-    return getValueType() == ValueType.ENTITY;
-  }
-
-  @Override
-  public Entity asEntity() {
-    return isEntity() ? (Entity) getValue() : null;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
deleted file mode 100755
index 7b31da7..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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 WARRANTIES OR 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.olingo.commons.core.data;
-
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ValueType;
-
-public class PropertyImpl extends AbstractValuable implements Property {
-
-  private String name;
-
-  public PropertyImpl() {}
-
-  public PropertyImpl(final String type, final String name) {
-    this.name = name;
-    super.setType(type);
-  }
-
-  public PropertyImpl(String type, String name, ValueType valueType, Object value) {
-    this(type, name);
-    setValue(valueType, value);
-  }
-
-  @Override
-  public String getName() {
-    return name;
-  }
-
-  @Override
-  public void setName(final String name) {
-    this.name = name;
-  }
-
-  @Override
-  public boolean isNull() {
-    return getValue() == null || "Edm.Null".equals(getType());
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
index 1a50c26..cd5210a 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java
@@ -36,12 +36,16 @@ import javax.xml.stream.events.XMLEvent;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.AbstractODataObject;
 import org.apache.olingo.commons.api.data.Annotation;
 import org.apache.olingo.commons.api.data.ComplexValue;
+import org.apache.olingo.commons.api.data.DeletedEntity;
 import org.apache.olingo.commons.api.data.DeletedEntity.Reason;
 import org.apache.olingo.commons.api.data.Delta;
+import org.apache.olingo.commons.api.data.DeltaLink;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.data.Valuable;
@@ -56,16 +60,6 @@ import org.apache.olingo.commons.api.edm.geo.Geospatial;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.serialization.ODataDeserializer;
 import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-import org.apache.olingo.commons.core.data.AbstractODataObject;
-import org.apache.olingo.commons.core.data.AnnotationImpl;
-import org.apache.olingo.commons.core.data.ComplexValueImpl;
-import org.apache.olingo.commons.core.data.DeletedEntityImpl;
-import org.apache.olingo.commons.core.data.DeltaImpl;
-import org.apache.olingo.commons.core.data.DeltaLinkImpl;
-import org.apache.olingo.commons.core.data.EntityImpl;
-import org.apache.olingo.commons.core.data.EntitySetImpl;
-import org.apache.olingo.commons.core.data.LinkImpl;
-import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.commons.core.edm.provider.EdmTypeInfo;
 
 import com.fasterxml.aalto.stax.InputFactoryImpl;
@@ -128,11 +122,11 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
 
       if (event.isStartElement()) {
         if (value == null) {
-          value = new ComplexValueImpl();
+          value = new ComplexValue();
         }
 
         if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
-          final LinkImpl link = new LinkImpl();
+          final Link link = new Link();
           final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
           if (rel != null) {
             link.setRel(rel.getValue());
@@ -260,7 +254,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
   private Property property(final XMLEventReader reader, final StartElement start)
       throws XMLStreamException, EdmPrimitiveTypeException {
 
-    final PropertyImpl property = new PropertyImpl();
+    final Property property = new Property();
 
     if (propertyValueQName.equals(start.getName())) {
       // retrieve name from context
@@ -379,7 +373,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
     }
   }
 
-  private void inline(final XMLEventReader reader, final StartElement start, final LinkImpl link)
+  private void inline(final XMLEventReader reader, final StartElement start, final Link link)
       throws XMLStreamException, EdmPrimitiveTypeException {
 
     boolean foundEndElement = false;
@@ -434,7 +428,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
     if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
       return null;
     }
-    final DeltaImpl delta = new DeltaImpl();
+    final Delta delta = new Delta();
     final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
     if (xmlBase != null) {
       delta.setBaseURI(xmlBase.getValue());
@@ -473,7 +467,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
         } else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(event.asStartElement().getName())) {
           delta.getEntities().add(entity(reader, event.asStartElement()));
         } else if (deletedEntryQName.equals(event.asStartElement().getName())) {
-          final DeletedEntityImpl deletedEntity = new DeletedEntityImpl();
+          final DeletedEntity deletedEntity = new DeletedEntity();
 
           final Attribute ref = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REF));
           if (ref != null) {
@@ -488,7 +482,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
         } else if (linkQName.equals(event.asStartElement().getName())
             || deletedLinkQName.equals(event.asStartElement().getName())) {
 
-          final DeltaLinkImpl link = new DeltaLinkImpl();
+          final DeltaLink link = new DeltaLink();
 
           final Attribute source = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_SOURCE));
           if (source != null) {
@@ -520,7 +514,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
     return delta;
   }
 
-  private void properties(final XMLEventReader reader, final StartElement start, final EntityImpl entity)
+  private void properties(final XMLEventReader reader, final StartElement start, final Entity entity)
       throws XMLStreamException, EdmPrimitiveTypeException {
 
     final Map<String, List<Annotation>> annotations = new HashMap<String, List<Annotation>>();
@@ -557,7 +551,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
   private Annotation annotation(final XMLEventReader reader, final StartElement start)
       throws XMLStreamException, EdmPrimitiveTypeException {
 
-    final Annotation annotation = new AnnotationImpl();
+    final Annotation annotation = new Annotation();
 
     annotation.setTerm(start.getAttributeByName(QName.valueOf(Constants.ATOM_ATTR_TERM)).getValue());
     valuable(annotation, reader, start);
@@ -565,8 +559,8 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
     return annotation;
   }
 
-  private EntityImpl entityRef(final StartElement start) throws XMLStreamException {
-    final EntityImpl entity = new EntityImpl();
+  private Entity entityRef(final StartElement start) throws XMLStreamException {
+    final Entity entity = new Entity();
 
     final Attribute entityRefId = start.getAttributeByName(Constants.QNAME_ATOM_ATTR_ID);
     if (entityRefId != null) {
@@ -578,11 +572,11 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
 
   private Entity entity(final XMLEventReader reader, final StartElement start)
       throws XMLStreamException, EdmPrimitiveTypeException {
-    final EntityImpl entity;
+    final Entity entity;
     if (entryRefQName.equals(start.getName())) {
       entity = entityRef(start);
     } else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(start.getName())) {
-      entity = new EntityImpl();
+      entity = new Entity();
       final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
       if (xmlBase != null) {
         entity.setBaseURI(xmlBase.getValue());
@@ -612,7 +606,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
               entity.setType(new EdmTypeInfo.Builder().setTypeExpression(term.getValue()).build().internal());
             }
           } else if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
-            final LinkImpl link = new LinkImpl();
+            final Link link = new Link();
             final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
             if (rel != null) {
               link.setRel(rel.getValue());
@@ -740,7 +734,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
     if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
       return null;
     }
-    final EntitySetImpl entitySet = new EntitySetImpl();
+    final EntitySet entitySet = new EntitySet();
     final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
     if (xmlBase != null) {
       entitySet.setBaseURI(xmlBase.getValue());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
index de06008..196a46e 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java
@@ -31,6 +31,7 @@ import javax.xml.stream.XMLStreamWriter;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.ODataRuntimeException;
+import org.apache.olingo.commons.api.data.AbstractODataObject;
 import org.apache.olingo.commons.api.data.Annotation;
 import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.ContextURL;
@@ -47,10 +48,6 @@ import org.apache.olingo.commons.api.edm.geo.Geospatial;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.serialization.ODataSerializer;
 import org.apache.olingo.commons.api.serialization.ODataSerializerException;
-import org.apache.olingo.commons.core.data.AbstractODataObject;
-import org.apache.olingo.commons.core.data.EntityImpl;
-import org.apache.olingo.commons.core.data.EntitySetImpl;
-import org.apache.olingo.commons.core.data.LinkImpl;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 import org.apache.olingo.commons.core.edm.provider.EdmTypeInfo;
 
@@ -288,9 +285,7 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
     }
     writer.writeEndElement();
 
-    if (entity instanceof AbstractODataObject) {
-      common(writer, (AbstractODataObject) entity);
-    }
+    common(writer, entity);
 
     if (serverMode) {
       if (entity.getEditLink() != null) {
@@ -416,9 +411,7 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
       writer.writeEndElement();
     }
 
-    if (entitySet instanceof AbstractODataObject) {
-      common(writer, (AbstractODataObject) entitySet);
-    }
+    common(writer, entitySet);
 
     for (Entity entity : entitySet.getEntities()) {
       if (entity.getType() == null && entity.getProperties().isEmpty()) {
@@ -433,14 +426,14 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
 
     if (serverMode) {
       if (entitySet.getNext() != null) {
-        final LinkImpl next = new LinkImpl();
+        final Link next = new Link();
         next.setRel(Constants.NEXT_LINK_REL);
         next.setHref(entitySet.getNext().toASCIIString());
 
         links(writer, Collections.<Link> singletonList(next));
       }
       if (entitySet.getDeltaLink() != null) {
-        final LinkImpl next = new LinkImpl();
+        final Link next = new Link();
         next.setRel(Constants.NS_DELTA_LINK_REL);
         next.setHref(entitySet.getDeltaLink().toASCIIString());
 
@@ -559,10 +552,10 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
       final ContextURL contextURL = ContextURLParser.parse(container.getContextURL());
       String base = contextURL.getServiceRoot().toASCIIString();
       if (container.getPayload() instanceof EntitySet) {
-        ((EntitySetImpl) container.getPayload()).setBaseURI(base);
+        ((EntitySet) container.getPayload()).setBaseURI(base);
       }
       if (container.getPayload() instanceof Entity) {
-        ((EntityImpl) container.getPayload()).setBaseURI(base);
+        ((Entity) container.getPayload()).setBaseURI(base);
       }
 
       writer.writeAttribute(namespaceMetadata, Constants.CONTEXT,

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeltaDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeltaDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeltaDeserializer.java
index de79cf7..313d32d 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeltaDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeltaDeserializer.java
@@ -25,12 +25,11 @@ import java.net.URI;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.ContextURL;
+import org.apache.olingo.commons.api.data.DeletedEntity;
 import org.apache.olingo.commons.api.data.Delta;
+import org.apache.olingo.commons.api.data.DeltaLink;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-import org.apache.olingo.commons.core.data.DeletedEntityImpl;
-import org.apache.olingo.commons.core.data.DeltaImpl;
-import org.apache.olingo.commons.core.data.DeltaLinkImpl;
 
 import com.fasterxml.jackson.core.JsonFactory;
 import com.fasterxml.jackson.core.JsonParser;
@@ -48,7 +47,7 @@ public class JsonDeltaDeserializer extends JsonDeserializer {
 
     final ObjectNode tree = parser.getCodec().readTree(parser);
 
-    final DeltaImpl delta = new DeltaImpl();
+    final Delta delta = new Delta();
 
     final URI contextURL = tree.hasNonNull(Constants.JSON_CONTEXT) ?
         URI.create(tree.get(Constants.JSON_CONTEXT).textValue()) : null;
@@ -77,11 +76,11 @@ public class JsonDeltaDeserializer extends JsonDeserializer {
         if (itemContextURL == null || itemContextURL.isEntity()) {
           delta.getEntities().add(entityDeserializer.doDeserialize(item.traverse(parser.getCodec())).getPayload());
         } else if (itemContextURL.isDeltaDeletedEntity()) {
-          delta.getDeletedEntities().add(parser.getCodec().treeToValue(item, DeletedEntityImpl.class));
+          delta.getDeletedEntities().add(parser.getCodec().treeToValue(item, DeletedEntity.class));
         } else if (itemContextURL.isDeltaLink()) {
-          delta.getAddedLinks().add(parser.getCodec().treeToValue(item, DeltaLinkImpl.class));
+          delta.getAddedLinks().add(parser.getCodec().treeToValue(item, DeltaLink.class));
         } else if (itemContextURL.isDeltaDeletedLink()) {
-          delta.getDeletedLinks().add(parser.getCodec().treeToValue(item, DeltaLinkImpl.class));
+          delta.getDeletedLinks().add(parser.getCodec().treeToValue(item, DeltaLink.class));
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
index 9641623..1db725b 100755
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
@@ -37,6 +37,7 @@ import org.apache.olingo.commons.api.data.Annotation;
 import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Linked;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ResWrap;
@@ -51,11 +52,6 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.geo.Geospatial;
 import org.apache.olingo.commons.api.serialization.ODataDeserializer;
 import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-import org.apache.olingo.commons.core.data.AnnotationImpl;
-import org.apache.olingo.commons.core.data.ComplexValueImpl;
-import org.apache.olingo.commons.core.data.EntitySetImpl;
-import org.apache.olingo.commons.core.data.LinkImpl;
-import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.commons.core.edm.provider.EdmTypeInfo;
 
 import com.fasterxml.jackson.core.JsonFactory;
@@ -96,7 +92,7 @@ public class JsonDeserializer implements ODataDeserializer {
   }
 
   protected String setInline(final String name, final String suffix, final JsonNode tree,
-      final ObjectCodec codec, final LinkImpl link) throws IOException {
+      final ObjectCodec codec, final Link link) throws IOException {
 
     final String entityNamePrefix = name.substring(0, name.indexOf(suffix));
     if (tree.has(entityNamePrefix)) {
@@ -110,7 +106,7 @@ public class JsonDeserializer implements ODataDeserializer {
       } else if (inline instanceof ArrayNode) {
         link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
 
-        final EntitySet entitySet = new EntitySetImpl();
+        final EntitySet entitySet = new EntitySet();
         for (final Iterator<JsonNode> entries = inline.elements(); entries.hasNext();) {
           entitySet.getEntities().add(entityDeserializer.doDeserialize(entries.next().traverse(codec)).getPayload());
         }
@@ -134,7 +130,7 @@ public class JsonDeserializer implements ODataDeserializer {
       final JsonNode tree, final ObjectCodec codec) throws IOException {
 
     if (field.getKey().endsWith(Constants.JSON_NAVIGATION_LINK)) {
-      final LinkImpl link = new LinkImpl();
+      final Link link = new Link();
       link.setTitle(getTitle(field));
       link.setRel(Constants.NS_NAVIGATION_LINK_REL + getTitle(field));
 
@@ -148,7 +144,7 @@ public class JsonDeserializer implements ODataDeserializer {
       toRemove.add(field.getKey());
       toRemove.add(setInline(field.getKey(), Constants.JSON_NAVIGATION_LINK, tree, codec, link));
     } else if (field.getKey().endsWith(Constants.JSON_ASSOCIATION_LINK)) {
-      final LinkImpl link = new LinkImpl();
+      final Link link = new Link();
       link.setTitle(getTitle(field));
       link.setRel(Constants.NS_ASSOCIATION_LINK_REL + getTitle(field));
       link.setHref(field.getValue().textValue());
@@ -168,7 +164,7 @@ public class JsonDeserializer implements ODataDeserializer {
       if (field.getValue().isValueNode()) {
         final String suffix = field.getKey().replaceAll("^.*@", "@");
 
-        final LinkImpl link = new LinkImpl();
+        final Link link = new Link();
         link.setTitle(getTitle(field));
         link.setRel(Constants.NS_NAVIGATION_LINK_REL + getTitle(field));
         link.setHref(field.getValue().textValue());
@@ -180,7 +176,7 @@ public class JsonDeserializer implements ODataDeserializer {
         for (final Iterator<JsonNode> itor = field.getValue().elements(); itor.hasNext();) {
           final JsonNode node = itor.next();
 
-          final LinkImpl link = new LinkImpl();
+          final Link link = new Link();
           link.setTitle(getTitle(field));
           link.setRel(Constants.NS_NAVIGATION_LINK_REL + getTitle(field));
           link.setHref(node.asText());
@@ -243,7 +239,7 @@ public class JsonDeserializer implements ODataDeserializer {
       final Matcher customAnnotation = CUSTOM_ANNOTATION.matcher(field.getKey());
 
       if (field.getKey().charAt(0) == '@') {
-        final Annotation entityAnnot = new AnnotationImpl();
+        final Annotation entityAnnot = new Annotation();
         entityAnnot.setTerm(field.getKey().substring(1));
 
         value(entityAnnot, field.getValue(), codec);
@@ -253,11 +249,11 @@ public class JsonDeserializer implements ODataDeserializer {
       } else if (type == null && field.getKey().endsWith(getJSONAnnotation(Constants.JSON_TYPE))) {
         type = field.getValue().asText();
       } else if (annotation == null && customAnnotation.matches() && !"odata".equals(customAnnotation.group(2))) {
-        annotation = new AnnotationImpl();
+        annotation = new Annotation();
         annotation.setTerm(customAnnotation.group(2) + "." + customAnnotation.group(3));
         value(annotation, field.getValue(), codec);
       } else {
-        final PropertyImpl property = new PropertyImpl();
+        final Property property = new Property();
         property.setName(field.getKey());
         property.setType(type == null
             ? null
@@ -289,7 +285,7 @@ public class JsonDeserializer implements ODataDeserializer {
   private Object fromComplex(final ObjectNode node, final ObjectCodec codec)
       throws IOException, EdmPrimitiveTypeException {
 
-    final ComplexValue complexValue = new ComplexValueImpl();
+    final ComplexValue complexValue = new ComplexValue();
     final Set<String> toRemove = new HashSet<String>();
     for (final Iterator<Map.Entry<String, JsonNode>> itor = node.fields(); itor.hasNext();) {
       final Map.Entry<String, JsonNode> field = itor.next();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntityDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntityDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntityDeserializer.java
index 228ac06..bf54cda 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntityDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntityDeserializer.java
@@ -38,9 +38,6 @@ import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.ODataLinkType;
 import org.apache.olingo.commons.api.domain.ODataOperation;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.core.data.AnnotationImpl;
-import org.apache.olingo.commons.core.data.EntityImpl;
-import org.apache.olingo.commons.core.data.LinkImpl;
 import org.apache.olingo.commons.core.edm.provider.EdmTypeInfo;
 
 import com.fasterxml.jackson.core.JsonParseException;
@@ -67,7 +64,7 @@ public class JsonEntityDeserializer extends JsonDeserializer {
       throw new JsonParseException("Expected OData Entity, found EntitySet", parser.getCurrentLocation());
     }
 
-    final EntityImpl entity = new EntityImpl();
+    final Entity entity = new Entity();
 
     final URI contextURL;
     if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
@@ -108,7 +105,7 @@ public class JsonEntityDeserializer extends JsonDeserializer {
     }
 
     if (tree.hasNonNull(Constants.JSON_READ_LINK)) {
-      final LinkImpl link = new LinkImpl();
+      final Link link = new Link();
       link.setRel(Constants.SELF_LINK_REL);
       link.setHref(tree.get(Constants.JSON_READ_LINK).textValue());
       entity.setSelfLink(link);
@@ -117,7 +114,7 @@ public class JsonEntityDeserializer extends JsonDeserializer {
     }
 
     if (tree.hasNonNull(Constants.JSON_EDIT_LINK)) {
-      final LinkImpl link = new LinkImpl();
+      final Link link = new Link();
       if (serverMode) {
         link.setRel(Constants.EDIT_LINK_REL);
       }
@@ -153,7 +150,7 @@ public class JsonEntityDeserializer extends JsonDeserializer {
 
       links(field, entity, toRemove, tree, parser.getCodec());
       if (field.getKey().endsWith(getJSONAnnotation(Constants.JSON_MEDIA_EDIT_LINK))) {
-        final LinkImpl link = new LinkImpl();
+        final Link link = new Link();
         link.setTitle(getTitle(field));
         link.setRel(Constants.NS_MEDIA_EDIT_LINK_REL + getTitle(field));
         link.setHref(field.getValue().textValue());
@@ -188,7 +185,7 @@ public class JsonEntityDeserializer extends JsonDeserializer {
 
         toRemove.add(field.getKey());
       } else if (customAnnotation.matches() && !"odata".equals(customAnnotation.group(2))) {
-        final Annotation annotation = new AnnotationImpl();
+        final Annotation annotation = new Annotation();
         annotation.setTerm(customAnnotation.group(2) + "." + customAnnotation.group(3));
         try {
           value(annotation, field.getValue(), parser.getCodec());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java
index 1e844b5..f260369 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java
@@ -29,8 +29,6 @@ import org.apache.olingo.commons.api.data.Annotation;
 import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.core.data.AnnotationImpl;
-import org.apache.olingo.commons.core.data.EntitySetImpl;
 
 import com.fasterxml.jackson.core.JsonParser;
 import com.fasterxml.jackson.databind.JsonNode;
@@ -55,7 +53,7 @@ public class JsonEntitySetDeserializer extends JsonDeserializer {
       return null;
     }
 
-    final EntitySetImpl entitySet = new EntitySetImpl();
+    final EntitySet entitySet = new EntitySet();
 
     URI contextURL;
     if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
@@ -105,7 +103,7 @@ public class JsonEntitySetDeserializer extends JsonDeserializer {
     for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
       final Map.Entry<String, JsonNode> field = itor.next();
       if (field.getKey().charAt(0) == '@') {
-        final Annotation annotation = new AnnotationImpl();
+        final Annotation annotation = new Annotation();
         annotation.setTerm(field.getKey().substring(1));
 
         try {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertyDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertyDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertyDeserializer.java
index e0732d5..47c4387 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertyDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertyDeserializer.java
@@ -30,8 +30,6 @@ import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.data.ValueType;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.core.data.AnnotationImpl;
-import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.commons.core.edm.provider.EdmTypeInfo;
 
 import com.fasterxml.jackson.core.JsonParser;
@@ -53,7 +51,7 @@ public class JsonPropertyDeserializer extends JsonDeserializer {
 
     final String metadataETag;
     final URI contextURL;
-    final PropertyImpl property = new PropertyImpl();
+    final Property property = new Property();
 
     if (tree.hasNonNull(Constants.JSON_METADATA_ETAG)) {
       metadataETag = tree.get(Constants.JSON_METADATA_ETAG).textValue();
@@ -99,7 +97,7 @@ public class JsonPropertyDeserializer extends JsonDeserializer {
     for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
       final Map.Entry<String, JsonNode> field = itor.next();
       if (field.getKey().charAt(0) == '@') {
-        final Annotation annotation = new AnnotationImpl();
+        final Annotation annotation = new Annotation();
         annotation.setTerm(field.getKey().substring(1));
 
         try {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java
index fd3fda1..e749736 100755
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonSerializer.java
@@ -205,13 +205,13 @@ public class JsonSerializer implements ODataSerializer {
   }
 
   protected void serverLinks(final Linked linked, final JsonGenerator jgen)
-          throws IOException, EdmPrimitiveTypeException {
+      throws IOException, EdmPrimitiveTypeException {
     if (linked instanceof Entity) {
       for (Link link : ((Entity) linked).getMediaEditLinks()) {
         if (StringUtils.isNotBlank(link.getHref())) {
           jgen.writeStringField(
-                  link.getTitle() + StringUtils.prependIfMissing(Constants.JSON_MEDIA_EDIT_LINK, "@"),
-                  link.getHref());
+              link.getTitle() + StringUtils.prependIfMissing(Constants.JSON_MEDIA_EDIT_LINK, "@"),
+              link.getHref());
         }
       }
     }
@@ -219,8 +219,8 @@ public class JsonSerializer implements ODataSerializer {
     for (Link link : linked.getAssociationLinks()) {
       if (StringUtils.isNotBlank(link.getHref())) {
         jgen.writeStringField(
-                link.getTitle() + Constants.JSON_ASSOCIATION_LINK,
-                link.getHref());
+            link.getTitle() + Constants.JSON_ASSOCIATION_LINK,
+            link.getHref());
       }
     }
 
@@ -231,8 +231,8 @@ public class JsonSerializer implements ODataSerializer {
 
       if (StringUtils.isNotBlank(link.getHref())) {
         jgen.writeStringField(
-                link.getTitle() + Constants.JSON_NAVIGATION_LINK,
-                link.getHref());
+            link.getTitle() + Constants.JSON_NAVIGATION_LINK,
+            link.getHref());
       }
 
       if (link.getInlineEntity() != null) {
@@ -359,8 +359,8 @@ public class JsonSerializer implements ODataSerializer {
 
       String type = valuable.getType();
       if ((!valuable.isCollection() &&
-              StringUtils.isBlank(type) &&
-              valuable.isPrimitive()) || valuable.isNull()) {
+          StringUtils.isBlank(type) &&
+          valuable.isPrimitive()) || valuable.isNull()) {
         type = EdmPrimitiveTypeKind.String.getFullQualifiedName().toString();
       }
       if (StringUtils.isNotBlank(type) && format != ODataFormat.JSON_NO_METADATA) {
@@ -370,10 +370,8 @@ public class JsonSerializer implements ODataSerializer {
       }
     }
 
-    if (valuable instanceof Annotatable) {
-      for (Annotation annotation : ((Annotatable) valuable).getAnnotations()) {
-        valuable(jgen, annotation, name + "@" + annotation.getTerm());
-      }
+    for (Annotation annotation : ((Annotatable) valuable).getAnnotations()) {
+      valuable(jgen, annotation, name + "@" + annotation.getTerm());
     }
 
     jgen.writeFieldName(name);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java
index 8db1ada..1f6ff8e 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java
@@ -21,6 +21,8 @@ package org.apache.olingo.server.api;
 import java.util.List;
 
 import org.apache.olingo.commons.api.ODataRuntimeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.provider.EdmProvider;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.server.api.deserializer.DeserializerException;
@@ -99,5 +101,17 @@ public abstract class OData {
    */
   public abstract UriHelper createUriHelper();
 
+  /**
+   * Creates a new deserializer object for reading content in the specified format.
+   * Deserializer are used in Processor implementations.
+   *
+   * @param format any format supported by Olingo (XML, JSON ...)
+   */
   public abstract ODataDeserializer createDeserializer(ODataFormat format) throws DeserializerException;
+  
+  /**
+   * @param kind
+   * @return a {@link EdmPrimitiveType} instance for the type kind
+   */
+  public abstract EdmPrimitiveType createPrimitiveTypeInstance(EdmPrimitiveTypeKind kind);
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
index c05b4ae..80bed2f 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
@@ -20,8 +20,11 @@ package org.apache.olingo.server.core;
 
 import java.util.List;
 
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.provider.EdmProvider;
 import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataHttpHandler;
 import org.apache.olingo.server.api.ServiceMetadata;
@@ -105,4 +108,9 @@ public class ODataImpl extends OData {
 
     return serializer;
   }
+
+  @Override
+  public EdmPrimitiveType createPrimitiveTypeInstance(EdmPrimitiveTypeKind kind) {
+    return EdmPrimitiveTypeFactory.getInstance(kind);
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
index 538e95c..fa2f6a5 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
@@ -50,12 +50,6 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.commons.api.edm.EdmType;
 import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
-import org.apache.olingo.commons.core.data.ComplexValueImpl;
-import org.apache.olingo.commons.core.data.EntityImpl;
-import org.apache.olingo.commons.core.data.EntitySetImpl;
-import org.apache.olingo.commons.core.data.LinkImpl;
-import org.apache.olingo.commons.core.data.ParameterImpl;
-import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.server.api.deserializer.DeserializerException;
 import org.apache.olingo.server.api.deserializer.DeserializerResult;
 import org.apache.olingo.server.api.deserializer.ODataDeserializer;
@@ -80,13 +74,13 @@ public class ODataJsonDeserializer implements ODataDeserializer {
   private static final String ODATA_CONTROL_INFORMATION_PREFIX = "@odata.";
 
   @Override
-  public DeserializerResult entityCollection(InputStream stream, EdmEntityType edmEntityType) 
+  public DeserializerResult entityCollection(InputStream stream, EdmEntityType edmEntityType)
       throws DeserializerException {
     try {
       final ObjectNode tree = parseJsonTree(stream);
-      
+
       return DeserializerResultImpl.with().entityCollection(consumeEntitySetNode(edmEntityType, tree, null))
-                                          .build();
+          .build();
     } catch (JsonParseException e) {
       throw new DeserializerException("An JsonParseException occurred", e,
           DeserializerException.MessageKeys.JSON_SYNTAX_EXCEPTION);
@@ -98,9 +92,9 @@ public class ODataJsonDeserializer implements ODataDeserializer {
     }
   }
 
-  private EntitySet consumeEntitySetNode(EdmEntityType edmEntityType, final ObjectNode tree, 
+  private EntitySet consumeEntitySetNode(EdmEntityType edmEntityType, final ObjectNode tree,
       final ExpandTreeBuilder expandBuilder) throws DeserializerException {
-    EntitySetImpl entitySet = new EntitySetImpl();
+    EntitySet entitySet = new EntitySet();
 
     // Consume entities
     JsonNode jsonNode = tree.get(Constants.VALUE);
@@ -137,7 +131,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
     return entitySet;
   }
 
-  private List<Entity> consumeEntitySetArray(EdmEntityType edmEntityType, JsonNode jsonNode, 
+  private List<Entity> consumeEntitySetArray(EdmEntityType edmEntityType, JsonNode jsonNode,
       final ExpandTreeBuilder expandBuilder) throws DeserializerException {
     List<Entity> entities = new ArrayList<Entity>();
     for (JsonNode arrayElement : jsonNode) {
@@ -156,10 +150,10 @@ public class ODataJsonDeserializer implements ODataDeserializer {
     try {
       final ObjectNode tree = parseJsonTree(stream);
       final ExpandTreeBuilderImpl expandBuilder = new ExpandTreeBuilderImpl();
-      
+
       return DeserializerResultImpl.with().entity(consumeEntityNode(edmEntityType, tree, expandBuilder))
-                                          .expandOption(expandBuilder.build())
-                                          .build();
+          .expandOption(expandBuilder.build())
+          .build();
 
     } catch (JsonParseException e) {
       throw new DeserializerException("An JsonParseException occurred", e,
@@ -173,9 +167,9 @@ public class ODataJsonDeserializer implements ODataDeserializer {
 
   }
 
-  private Entity consumeEntityNode(EdmEntityType edmEntityType, final ObjectNode tree, 
+  private Entity consumeEntityNode(EdmEntityType edmEntityType, final ObjectNode tree,
       final ExpandTreeBuilder expandBuilder) throws DeserializerException {
-    EntityImpl entity = new EntityImpl();
+    Entity entity = new Entity();
     entity.setType(edmEntityType.getFullQualifiedName().getFullQualifiedNameAsString());
 
     // Check and consume all Properties
@@ -193,7 +187,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
   }
 
   @Override
-  public DeserializerResult actionParameters(InputStream stream, final EdmAction edmAction) 
+  public DeserializerResult actionParameters(InputStream stream, final EdmAction edmAction)
       throws DeserializerException {
     try {
       ObjectNode tree = parseJsonTree(stream);
@@ -214,7 +208,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
     }
   }
 
-  private ObjectNode parseJsonTree(InputStream stream) 
+  private ObjectNode parseJsonTree(InputStream stream)
       throws IOException, JsonParseException, JsonProcessingException {
     ObjectMapper objectMapper = new ObjectMapper();
     objectMapper.configure(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY, true);
@@ -232,7 +226,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
     }
     for (final String name : parameterNames) {
       final EdmParameter edmParameter = edmAction.getParameter(name);
-      ParameterImpl parameter = new ParameterImpl();
+      Parameter parameter = new Parameter();
       parameter.setName(name);
       JsonNode jsonNode = node.get(name);
 
@@ -281,7 +275,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
    * @throws DeserializerException if an exception during consummation occurs
    */
   private void consumeRemainingJsonNodeFields(final EdmEntityType edmEntityType, final ObjectNode node,
-      final EntityImpl entity) throws DeserializerException {
+      final Entity entity) throws DeserializerException {
     final List<String> toRemove = new ArrayList<String>();
     Iterator<Entry<String, JsonNode>> fieldsIterator = node.fields();
     while (fieldsIterator.hasNext()) {
@@ -304,7 +298,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
   }
 
   private void consumeEntityProperties(final EdmEntityType edmEntityType, final ObjectNode node,
-      final EntityImpl entity) throws DeserializerException {
+      final Entity entity) throws DeserializerException {
     List<String> propertyNames = edmEntityType.getPropertyNames();
     for (String propertyName : propertyNames) {
       JsonNode jsonNode = node.get(propertyName);
@@ -326,7 +320,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
   }
 
   private void consumeExpandedNavigationProperties(final EdmEntityType edmEntityType, final ObjectNode node,
-      final EntityImpl entity, final ExpandTreeBuilder expandBuilder) throws DeserializerException {
+      final Entity entity, final ExpandTreeBuilder expandBuilder) throws DeserializerException {
     List<String> navigationPropertyNames = edmEntityType.getNavigationPropertyNames();
     for (String navigationPropertyName : navigationPropertyNames) {
       // read expanded navigation property
@@ -339,22 +333,22 @@ public class ODataJsonDeserializer implements ODataDeserializer {
               DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, navigationPropertyName);
         }
 
-        LinkImpl link = new LinkImpl();
+        Link link = new Link();
         link.setTitle(navigationPropertyName);
-        final ExpandTreeBuilder childExpandBuilder = (expandBuilder != null) ? 
-                                                                expandBuilder.expand(edmNavigationProperty) : null;
+        final ExpandTreeBuilder childExpandBuilder = (expandBuilder != null) ?
+            expandBuilder.expand(edmNavigationProperty) : null;
         if (jsonNode.isArray() && edmNavigationProperty.isCollection()) {
           link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
-          EntitySetImpl inlineEntitySet = new EntitySetImpl();
-          inlineEntitySet.getEntities().addAll(consumeEntitySetArray(edmNavigationProperty.getType(), jsonNode, 
-                                                                     childExpandBuilder));
+          EntitySet inlineEntitySet = new EntitySet();
+          inlineEntitySet.getEntities().addAll(consumeEntitySetArray(edmNavigationProperty.getType(), jsonNode,
+              childExpandBuilder));
           link.setInlineEntitySet(inlineEntitySet);
         } else if (!jsonNode.isArray() && (!jsonNode.isValueNode() || jsonNode.isNull())
             && !edmNavigationProperty.isCollection()) {
           link.setType(ODataLinkType.ENTITY_NAVIGATION.toString());
           if (!jsonNode.isNull()) {
-            Entity inlineEntity = consumeEntityNode(edmNavigationProperty.getType(), (ObjectNode) jsonNode, 
-                                                    childExpandBuilder);
+            Entity inlineEntity = consumeEntityNode(edmNavigationProperty.getType(), (ObjectNode) jsonNode,
+                childExpandBuilder);
             link.setInlineEntity(inlineEntity);
           }
         } else {
@@ -377,7 +371,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
       throw new DeserializerException("Invalid navigationPropertyName: " + navigationPropertyName,
           DeserializerException.MessageKeys.NAVIGATION_PROPERTY_NOT_FOUND, navigationPropertyName);
     }
-    LinkImpl bindingLink = new LinkImpl();
+    Link bindingLink = new Link();
     bindingLink.setTitle(navigationPropertyName);
 
     if (edmNavigationProperty.isCollection()) {
@@ -419,7 +413,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
   private Property consumePropertyNode(final String name, final EdmType type, final boolean isCollection,
       final boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale,
       final boolean isUnicode, final EdmMapping mapping, JsonNode jsonNode) throws DeserializerException {
-    Property property = new PropertyImpl();
+    Property property = new Property();
     property.setName(name);
     property.setType(type.getFullQualifiedName().getFullQualifiedNameAsString());
     if (isCollection) {
@@ -552,7 +546,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
           DeserializerException.MessageKeys.INVALID_JSON_TYPE_FOR_PROPERTY, name);
     }
     // Even if there are no properties defined we have to give back an empty list
-    ComplexValueImpl complexValue = new ComplexValueImpl();
+    ComplexValue complexValue = new ComplexValue();
     EdmComplexType edmType = (EdmComplexType) type;
     // Check and consume all Properties
     for (String propertyName : edmType.getPropertyNames()) {
@@ -795,9 +789,9 @@ public class ODataJsonDeserializer implements ODataDeserializer {
       JsonNode jsonNode = tree.get(Constants.VALUE);
       if (jsonNode != null) {
         if (jsonNode.isArray()) {
-          ArrayNode arrayNode = (ArrayNode)jsonNode;
+          ArrayNode arrayNode = (ArrayNode) jsonNode;
           Iterator<JsonNode> it = arrayNode.iterator();
-          while(it.hasNext()) {
+          while (it.hasNext()) {
             parsedValues.add(new URI(it.next().get(key).asText()));
           }
         } else {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
index 1fc89e8..c7ae99d 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
@@ -33,8 +33,6 @@ import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ValueType;
 import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.core.data.ComplexValueImpl;
-import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.server.api.serializer.ComplexSerializerOptions;
 import org.junit.Test;
 
@@ -44,7 +42,7 @@ public class ODataJsonSerializerTest {
     final List<ComplexValue> col = new ArrayList<ComplexValue>();
     col.add(getValues(1));
     col.add(getValues(2));
-    final Property complexCollection = new PropertyImpl(null, "ComplexCol", ValueType.COLLECTION_COMPLEX, col);
+    final Property complexCollection = new Property(null, "ComplexCol", ValueType.COLLECTION_COMPLEX, col);
     
     final ODataJsonSerializer serializer = new ODataJsonSerializer(ODataFormat.APPLICATION_JSON);
     final ComplexSerializerOptions options = ComplexSerializerOptions.with()
@@ -66,9 +64,9 @@ public class ODataJsonSerializerTest {
   }
 
   private ComplexValue getValues(int i) {
-    ComplexValue value = new ComplexValueImpl();
-    value.getValue().add(new PropertyImpl(null, "prop1", ValueType.PRIMITIVE, "test" + i));
-    value.getValue().add(new PropertyImpl(null, "prop2", ValueType.PRIMITIVE, "test" + i + i));
+    ComplexValue value = new ComplexValue();
+    value.getValue().add(new Property(null, "prop1", ValueType.PRIMITIVE, "test" + i));
+    value.getValue().add(new Property(null, "prop2", ValueType.PRIMITIVE, "test" + i + i));
     return value;
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-tecsvc/pom.xml
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/pom.xml b/lib/server-tecsvc/pom.xml
index f74f78c..817745f 100644
--- a/lib/server-tecsvc/pom.xml
+++ b/lib/server-tecsvc/pom.xml
@@ -133,6 +133,7 @@
       <groupId>org.apache.olingo</groupId>
       <artifactId>odata-commons-core</artifactId>
       <version>${project.version}</version>
+	  <scope>runtime</scope>
     </dependency>
 
     <dependency>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/Encoder.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/Encoder.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/Encoder.java
new file mode 100644
index 0000000..82bb775
--- /dev/null
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/Encoder.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * 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 WARRANTIES OR 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.olingo.server.tecsvc;
+
+import java.io.UnsupportedEncodingException;
+
+/**
+ * Encodes a Java String (in its internal UTF-16 encoding) into its
+ * percent-encoded UTF-8 representation according to
+ * <a href="http://www.ietf.org/rfc/rfc3986.txt">RFC 3986</a>
+ * (with consideration of its predecessor RFC 2396).
+ * 
+ */
+public class Encoder {
+
+  //TODO: Should we really copy this class?
+  
+  /**
+   * Encodes a Java String (in its internal UTF-16 encoding) into its
+   * percent-encoded UTF-8 representation according to
+   * <a href="http://www.ietf.org/rfc/rfc3986.txt">RFC 3986</a>,
+   * suitable for parts of an OData path segment.
+   * @param value the Java String
+   * @return the encoded String
+   */
+  public static String encode(final String value) {
+    return encoder.encodeInternal(value);
+  }
+
+  // OData has special handling for "'", so we allow that to remain unencoded.
+  // Other sub-delims not used neither by JAX-RS nor by OData could be added
+  // if the encoding is considered to be too aggressive.
+  // RFC 3986 would also allow the gen-delims ":" and "@" to appear literally
+  // in path-segment parts.
+  private static final String ODATA_UNENCODED = "'";
+
+  // Character classes from RFC 3986
+  private final static String UNRESERVED = "-._~"; // + ALPHA + DIGIT
+  // RFC 3986 says: "For consistency, URI producers and normalizers should
+  // use uppercase hexadecimal digits for all percent-encodings."
+  private final static String[] hex = { "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", "%08", "%09", "%0A",
+      "%0B", "%0C", "%0D", "%0E", "%0F", "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", "%18", "%19", "%1A",
+      "%1B", "%1C", "%1D", "%1E", "%1F", "%20", "%21", "%22", "%23", "%24", "%25", "%26", "%27", "%28", "%29", "%2A",
+      "%2B", "%2C", "%2D", "%2E", "%2F", "%30", "%31", "%32", "%33", "%34", "%35", "%36", "%37", "%38", "%39", "%3A",
+      "%3B", "%3C", "%3D", "%3E", "%3F", "%40", "%41", "%42", "%43", "%44", "%45", "%46", "%47", "%48", "%49", "%4A",
+      "%4B", "%4C", "%4D", "%4E", "%4F", "%50", "%51", "%52", "%53", "%54", "%55", "%56", "%57", "%58", "%59", "%5A",
+      "%5B", "%5C", "%5D", "%5E", "%5F", "%60", "%61", "%62", "%63", "%64", "%65", "%66", "%67", "%68", "%69", "%6A",
+      "%6B", "%6C", "%6D", "%6E", "%6F", "%70", "%71", "%72", "%73", "%74", "%75", "%76", "%77", "%78", "%79", "%7A",
+      "%7B", "%7C", "%7D", "%7E", "%7F", "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87", "%88",
+      "%89", "%8A", "%8B", "%8C", "%8D", "%8E", "%8F", "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", "%98",
+      "%99", "%9A", "%9B", "%9C", "%9D", "%9E", "%9F", "%A0", "%A1", "%A2", "%A3", "%A4", "%A5", "%A6", "%A7", "%A8",
+      "%A9", "%AA", "%AB", "%AC", "%AD", "%AE", "%AF", "%B0", "%B1", "%B2", "%B3", "%B4", "%B5", "%B6", "%B7", "%B8",
+      "%B9", "%BA", "%BB", "%BC", "%BD", "%BE", "%BF", "%C0", "%C1", "%C2", "%C3", "%C4", "%C5", "%C6", "%C7", "%C8",
+      "%C9", "%CA", "%CB", "%CC", "%CD", "%CE", "%CF", "%D0", "%D1", "%D2", "%D3", "%D4", "%D5", "%D6", "%D7", "%D8",
+      "%D9", "%DA", "%DB", "%DC", "%DD", "%DE", "%DF", "%E0", "%E1", "%E2", "%E3", "%E4", "%E5", "%E6", "%E7", "%E8",
+      "%E9", "%EA", "%EB", "%EC", "%ED", "%EE", "%EF", "%F0", "%F1", "%F2", "%F3", "%F4", "%F5", "%F6", "%F7", "%F8",
+      "%F9", "%FA", "%FB", "%FC", "%FD", "%FE", "%FF" };
+
+  private static final Encoder encoder = new Encoder(ODATA_UNENCODED);
+
+  /** characters to remain unencoded in addition to {@link #UNRESERVED} */
+  private final String unencoded;
+
+  private Encoder(final String unencoded) {
+    this.unencoded = unencoded == null ? "" : unencoded;
+  }
+
+  /**
+   * <p>Returns the percent-encoded UTF-8 representation of a String.</p>
+   * <p>In order to avoid producing percent-encoded CESU-8 (as described in
+   * the Unicode Consortium's <a href="http://www.unicode.org/reports/tr26/">
+   * Technical Report #26</a>), this is done in two steps:
+   * <ol>
+   * <li>Re-encode the characters from their Java-internal UTF-16 representations
+   * into their UTF-8 representations.</li>
+   * <li>Percent-encode each of the bytes in the UTF-8 representation.
+   * This is possible on byte level because all characters that do not have
+   * a <code>%xx</code> representation are represented in one byte in UTF-8.</li>
+   * </ol></p>
+   * @param input input String
+   * @return encoded representation
+   */
+  private String encodeInternal(final String input) {
+    StringBuilder resultStr = new StringBuilder();
+
+    try {
+      for (byte utf8Byte : input.getBytes("UTF-8")) {
+        final char character = (char) utf8Byte;
+        if (isUnreserved(character)) {
+          resultStr.append(character);
+        } else if (isUnencoded(character)) {
+          resultStr.append(character);
+        } else if (utf8Byte >= 0) {
+          resultStr.append(hex[utf8Byte]);
+        } else {
+          // case UTF-8 continuation byte
+          resultStr.append(hex[256 + utf8Byte]); // index adjusted for the usage of signed bytes
+        }
+      }
+    } catch (final UnsupportedEncodingException e) { // should never happen; UTF-8 is always there
+      return null;
+    }
+    return resultStr.toString();
+  }
+
+  private static boolean isUnreserved(final char character) {
+    return 'A' <= character && character <= 'Z' // case A..Z
+        || 'a' <= character && character <= 'z' // case a..z
+        || '0' <= character && character <= '9' // case 0..9
+        || UNRESERVED.indexOf(character) >= 0;
+  }
+
+  private boolean isUnencoded(final char character) {
+    return unencoded.indexOf(character) >= 0;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/05935a0c/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
index 7de80e7..06da176 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
@@ -36,11 +36,6 @@ import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ValueType;
 import org.apache.olingo.commons.api.domain.ODataLinkType;
-import org.apache.olingo.commons.core.data.ComplexValueImpl;
-import org.apache.olingo.commons.core.data.EntityImpl;
-import org.apache.olingo.commons.core.data.EntitySetImpl;
-import org.apache.olingo.commons.core.data.LinkImpl;
-import org.apache.olingo.commons.core.data.PropertyImpl;
 
 public class DataCreator {
 
@@ -64,19 +59,19 @@ public class DataCreator {
     data.put("ESServerSidePaging", createESServerSidePaging());
 
     // No data available but to allow an insert operation create empty EntitySets
-    data.put("ESAllNullable", new EntitySetImpl());
-    data.put("ESMixEnumDefCollComp", new EntitySetImpl());
-    data.put("ESTwoBase", new EntitySetImpl());
-    data.put("ESBaseTwoKeyNav", new EntitySetImpl());
-    data.put("ESBaseTwoKeyTwoPrim", new EntitySetImpl());
-    data.put("ESTwoKeyTwoPrim", new EntitySetImpl());
-    data.put("ESCompCollAllPrim", new EntitySetImpl());
-    data.put("ESKeyTwoKeyComp", new EntitySetImpl());
-    data.put("ESFourKeyAlias", new EntitySetImpl());
-    data.put("ESBase", new EntitySetImpl());
-    data.put("ESTwoBaseTwoKeyTwoPrim", new EntitySetImpl());
-    data.put("ESInvisible", new EntitySetImpl());
-    data.put("ESCompMixPrimCollComp", new EntitySetImpl());
+    data.put("ESAllNullable", new EntitySet());
+    data.put("ESMixEnumDefCollComp", new EntitySet());
+    data.put("ESTwoBase", new EntitySet());
+    data.put("ESBaseTwoKeyNav", new EntitySet());
+    data.put("ESBaseTwoKeyTwoPrim", new EntitySet());
+    data.put("ESTwoKeyTwoPrim", new EntitySet());
+    data.put("ESCompCollAllPrim", new EntitySet());
+    data.put("ESKeyTwoKeyComp", new EntitySet());
+    data.put("ESFourKeyAlias", new EntitySet());
+    data.put("ESBase", new EntitySet());
+    data.put("ESTwoBaseTwoKeyTwoPrim", new EntitySet());
+    data.put("ESInvisible", new EntitySet());
+    data.put("ESCompMixPrimCollComp", new EntitySet());
 
     linkESTwoPrim(data);
     linkESAllPrim(data);
@@ -89,10 +84,10 @@ public class DataCreator {
   }
 
   private EntitySet createESServerSidePaging() {
-    EntitySet entitySet = new EntitySetImpl();
+    EntitySet entitySet = new EntitySet();
 
     for (int i = 1; i <= 503; i++) {
-      entitySet.getEntities().add(new EntityImpl().addProperty(createPrimitive("PropertyInt16", i))
+      entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", i))
           .addProperty(createPrimitive("PropertyString", "Number:" + i)));
     }
 
@@ -100,7 +95,7 @@ public class DataCreator {
   }
 
   private EntitySet createESKeyNav() {
-    final EntitySet entitySet = new EntitySetImpl();
+    final EntitySet entitySet = new EntitySet();
 
     entitySet.getEntities().add(createETKeyNavEntity(1, "I am String Property 1"));
     entitySet.getEntities().add(createETKeyNavEntity(2, "I am String Property 2"));
@@ -111,7 +106,7 @@ public class DataCreator {
 
   @SuppressWarnings("unchecked")
   private Entity createETKeyNavEntity(int propertyInt16, String propertyString) {
-    return new EntityImpl().addProperty(createPrimitive("PropertyInt16", propertyInt16))
+    return new Entity().addProperty(createPrimitive("PropertyInt16", propertyInt16))
         .addProperty(createPrimitive("PropertyString", propertyString))
         .addProperty(createComplex("PropertyCompNav", createPrimitive("PropertyInt16", 1)))
         .addProperty(createKeyNavAllPrimComplexValue("PropertyCompAllPrim")).addProperty(
@@ -129,7 +124,7 @@ public class DataCreator {
   }
 
   private EntitySet createESTwoKeyNav() {
-    final EntitySet entitySet = new EntitySetImpl();
+    final EntitySet entitySet = new EntitySet();
 
     entitySet.getEntities().add(createESTwoKeyNavEntity(1, "1"));
     entitySet.getEntities().add(createESTwoKeyNavEntity(1, "2"));
@@ -141,7 +136,7 @@ public class DataCreator {
 
   @SuppressWarnings("unchecked")
   private Entity createESTwoKeyNavEntity(int propertyInt16, String propertyString) {
-    return new EntityImpl().addProperty(createPrimitive("PropertyInt16", propertyInt16))
+    return new Entity().addProperty(createPrimitive("PropertyInt16", propertyInt16))
         .addProperty(createPrimitive("PropertyString", propertyString)).addProperty(
             createComplex("PropertyComp", createPrimitive("PropertyInt16", 11),
                 createComplex("PropertyComp", createPrimitive("PropertyString", "StringValue"),
@@ -180,9 +175,9 @@ public class DataCreator {
 
   @SuppressWarnings("unchecked")
   private EntitySet createESCompCollComp() {
-    final EntitySet entitySet = new EntitySetImpl();
+    final EntitySet entitySet = new EntitySet();
 
-    entitySet.getEntities().add(new EntityImpl().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
+    entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
         .addProperty(createComplex("PropertyComp", createComplexCollection("CollPropertyComp", Arrays
             .asList(createPrimitive("PropertyInt16", 555),
                 createPrimitive("PropertyString", "1 Test Complex in Complex Property")), Arrays
@@ -191,7 +186,7 @@ public class DataCreator {
             .asList(createPrimitive("PropertyInt16", 777),
                 createPrimitive("PropertyString", "3 Test Complex in Complex Property"))))));
 
-    entitySet.getEntities().add(new EntityImpl().addProperty(createPrimitive("PropertyInt16", 12345)).addProperty(
+    entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", 12345)).addProperty(
         createComplex("PropertyComp", createComplexCollection("CollPropertyComp", Arrays
             .asList(createPrimitive("PropertyInt16", 888),
                 createPrimitive("PropertyString", "11 Test Complex in Complex Property")), Arrays
@@ -204,27 +199,27 @@ public class DataCreator {
   }
 
   private EntitySet createESTwoPrim() {
-    EntitySet entitySet = new EntitySetImpl();
+    EntitySet entitySet = new EntitySet();
 
-    entitySet.getEntities().add(new EntityImpl().addProperty(createPrimitive("PropertyInt16", 32766))
+    entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", 32766))
         .addProperty(createPrimitive("PropertyString", "Test String1")));
 
-    entitySet.getEntities().add(new EntityImpl().addProperty(createPrimitive("PropertyInt16", -365))
+    entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", -365))
         .addProperty(createPrimitive("PropertyString", "Test String2")));
 
-    entitySet.getEntities().add(new EntityImpl().addProperty(createPrimitive("PropertyInt16", -32766))
+    entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", -32766))
         .addProperty(createPrimitive("PropertyString", null)));
 
-    entitySet.getEntities().add(new EntityImpl().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
+    entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
         .addProperty(createPrimitive("PropertyString", "Test String4")));
 
     return entitySet;
   }
 
   private EntitySet createESAllPrim() {
-    EntitySet entitySet = new EntitySetImpl();
+    EntitySet entitySet = new EntitySet();
 
-    entitySet.getEntities().add(new EntityImpl().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
+    entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
         .addProperty(createPrimitive("PropertyString", "First Resource - positive values"))
         .addProperty(createPrimitive("PropertyBoolean", true)).addProperty(createPrimitive("PropertyByte", 255))
         .addProperty(createPrimitive("PropertySByte", Byte.MAX_VALUE))
@@ -239,7 +234,7 @@ public class DataCreator {
         .addProperty(createPrimitive("PropertyDuration", 6)).addProperty(createPrimitive("PropertyGuid", GUID))
         .addProperty(createPrimitive("PropertyTimeOfDay", getTime(3, 26, 5))));
 
-    entitySet.getEntities().add(new EntityImpl().addProperty(createPrimitive("PropertyInt16", Short.MIN_VALUE))
+    entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", Short.MIN_VALUE))
         .addProperty(createPrimitive("PropertyString", "Second Resource - negative values"))
         .addProperty(createPrimitive("PropertyBoolean", false)).addProperty(createPrimitive("PropertyByte", 0))
         .addProperty(createPrimitive("PropertySByte", Byte.MIN_VALUE))
@@ -255,7 +250,7 @@ public class DataCreator {
         .addProperty(createPrimitive("PropertyGuid", UUID.fromString("76543201-23ab-cdef-0123-456789dddfff")))
         .addProperty(createPrimitive("PropertyTimeOfDay", getTime(23, 49, 14))));
 
-    entitySet.getEntities().add(new EntityImpl().addProperty(createPrimitive("PropertyInt16", 0))
+    entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", 0))
         .addProperty(createPrimitive("PropertyString", "")).addProperty(createPrimitive("PropertyBoolean", false))
         .addProperty(createPrimitive("PropertyByte", 0)).addProperty(createPrimitive("PropertySByte", 0))
         .addProperty(createPrimitive("PropertyInt32", 0)).addProperty(createPrimitive("PropertyInt64", 0))
@@ -272,9 +267,9 @@ public class DataCreator {
   }
 
   private EntitySet createESCompAllPrim() {
-    EntitySet entitySet = new EntitySetImpl();
+    EntitySet entitySet = new EntitySet();
 
-    Entity entity = new EntityImpl();
+    Entity entity = new Entity();
     entity.addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE));
     entity.addProperty(createComplex("PropertyComp", createPrimitive("PropertyString", "First Resource - first"),
         createPrimitive("PropertyBinary",
@@ -289,7 +284,7 @@ public class DataCreator {
         createPrimitive("PropertySByte", Byte.MAX_VALUE), createPrimitive("PropertyTimeOfDay", getTime(1, 0, 1))));
     entitySet.getEntities().add(entity);
 
-    entity = new EntityImpl();
+    entity = new Entity();
     entity.addProperty(createPrimitive("PropertyInt16", 7));
     entity.addProperty(createComplex("PropertyComp", createPrimitive("PropertyString", "Second Resource - second"),
         createPrimitive("PropertyBinary",
@@ -305,7 +300,7 @@ public class DataCreator {
         createPrimitive("PropertyTimeOfDay", getTimestamp(1, 1, 1, 7, 45, 12, 765432100))));
     entitySet.getEntities().add(entity);
 
-    entity = new EntityImpl();
+    entity = new Entity();
     entity.addProperty(createPrimitive("PropertyInt16", 0));
     entity.addProperty(createComplex("PropertyComp", createPrimitive("PropertyString", "Third Resource - third"),
         createPrimitive("PropertyBinary",
@@ -324,9 +319,9 @@ public class DataCreator {
   }
 
   private EntitySet createESCollAllPrim() {
-    EntitySet entitySet = new EntitySetImpl();
+    EntitySet entitySet = new EntitySet();
 
-    entitySet.getEntities().add(new EntityImpl().addProperty(createPrimitive("PropertyInt16", 1)).addProperty(
+    entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", 1)).addProperty(
         createPrimitiveCollection("CollPropertyString", "Employee1@company.example", "Employee2@company.example",
             "Employee3@company.example"))
         .addProperty(createPrimitiveCollection("CollPropertyBoolean", true, false, true))
@@ -353,12 +348,12 @@ public class DataCreator {
             createPrimitiveCollection("CollPropertyTimeOfDay", getTime(4, 14, 13), getTime(23, 59, 59),
                 getTime(1, 12, 33))));
 
-    Entity entity = new EntityImpl();
+    Entity entity = new Entity();
     entity.getProperties().addAll(entitySet.getEntities().get(0).getProperties());
     entity.getProperties().set(0, createPrimitive("PropertyInt16", 2));
     entitySet.getEntities().add(entity);
 
-    entity = new EntityImpl();
+    entity = new Entity();
     entity.getProperties().addAll(entitySet.getEntities().get(0).getProperties());
     entity.getProperties().set(0, createPrimitive("PropertyInt16", 3));
     entitySet.getEntities().add(entity);
@@ -372,22 +367,22 @@ public class DataCreator {
         Arrays.asList(createPrimitive("PropertyInt16", 456), createPrimitive("PropertyString", "TEST 2")),
         Arrays.asList(createPrimitive("PropertyInt16", 789), createPrimitive("PropertyString", "TEST 3")));
 
-    EntitySet entitySet = new EntitySetImpl();
+    EntitySet entitySet = new EntitySet();
 
-    entitySet.getEntities().add(new EntityImpl().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
+    entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
         .addProperty(
             createPrimitiveCollection("CollPropertyString", "Employee1@company.example", "Employee2@company.example",
                 "Employee3@company.example")).addProperty(
             createComplex("PropertyComp", createPrimitive("PropertyInt16", 111),
                 createPrimitive("PropertyString", "TEST A"))).addProperty(complexCollection));
 
-    entitySet.getEntities().add(new EntityImpl().addProperty(createPrimitive("PropertyInt16", 7)).addProperty(
+    entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", 7)).addProperty(
         createPrimitiveCollection("CollPropertyString", "Employee1@company.example", "Employee2@company.example",
             "Employee3@company.example")).addProperty(
         createComplex("PropertyComp", createPrimitive("PropertyInt16", 222),
             createPrimitive("PropertyString", "TEST B"))).addProperty(complexCollection));
 
-    entitySet.getEntities().add(new EntityImpl().addProperty(createPrimitive("PropertyInt16", 0)).addProperty(
+    entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyInt16", 0)).addProperty(
         createPrimitiveCollection("CollPropertyString", "Employee1@company.example", "Employee2@company.example",
             "Employee3@company.example")).addProperty(
         createComplex("PropertyComp", createPrimitive("PropertyInt16", 333),
@@ -397,9 +392,9 @@ public class DataCreator {
   }
 
   private EntitySet createESAllKey() {
-    EntitySet entitySet = new EntitySetImpl();
+    EntitySet entitySet = new EntitySet();
 
-    entitySet.getEntities().add(new EntityImpl().addProperty(createPrimitive("PropertyString", "First"))
+    entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyString", "First"))
         .addProperty(createPrimitive("PropertyBoolean", true)).addProperty(createPrimitive("PropertyByte", 255))
         .addProperty(createPrimitive("PropertySByte", Byte.MAX_VALUE))
         .addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
@@ -411,7 +406,7 @@ public class DataCreator {
         .addProperty(createPrimitive("PropertyDuration", 6)).addProperty(createPrimitive("PropertyGuid", GUID))
         .addProperty(createPrimitive("PropertyTimeOfDay", getTime(2, 48, 21))));
 
-    entitySet.getEntities().add(new EntityImpl().addProperty(createPrimitive("PropertyString", "Second"))
+    entitySet.getEntities().add(new Entity().addProperty(createPrimitive("PropertyString", "Second"))
         .addProperty(createPrimitive("PropertyBoolean", true)).addProperty(createPrimitive("PropertyByte", 254))
         .addProperty(createPrimitive("PropertySByte", 124)).addProperty(createPrimitive("PropertyInt16", 32764))
         .addProperty(createPrimitive("PropertyInt32", 2147483644))
@@ -426,16 +421,16 @@ public class DataCreator {
   }
 
   private EntitySet createESCompComp() {
-    EntitySet entitySet = new EntitySetImpl();
+    EntitySet entitySet = new EntitySet();
 
-    Entity entity = new EntityImpl();
+    Entity entity = new Entity();
     entity.addProperty(createPrimitive("PropertyInt16", 1));
     entity.addProperty(createComplex("PropertyComp",
         createComplex("PropertyComp", createPrimitive("PropertyInt16", 123),
             createPrimitive("PropertyString", "String 1"))));
     entitySet.getEntities().add(entity);
 
-    entity = new EntityImpl();
+    entity = new Entity();
     entity.addProperty(createPrimitive("PropertyInt16", 2));
     entity.addProperty(createComplex("PropertyComp",
         createComplex("PropertyComp", createPrimitive("PropertyInt16", 987),
@@ -446,24 +441,24 @@ public class DataCreator {
   }
 
   private EntitySet createESMedia() {
-    EntitySet entitySet = new EntitySetImpl();
+    EntitySet entitySet = new EntitySet();
 
-    Entity entity = new EntityImpl().addProperty(createPrimitive("PropertyInt16", 1))
+    Entity entity = new Entity().addProperty(createPrimitive("PropertyInt16", 1))
         .addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("darkturquoise")));
     entity.setMediaContentType("image/svg+xml");
     entitySet.getEntities().add(entity);
 
-    entity = new EntityImpl().addProperty(createPrimitive("PropertyInt16", 2))
+    entity = new Entity().addProperty(createPrimitive("PropertyInt16", 2))
         .addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("royalblue")));
     entity.setMediaContentType("image/svg+xml");
     entitySet.getEntities().add(entity);
 
-    entity = new EntityImpl().addProperty(createPrimitive("PropertyInt16", 3))
+    entity = new Entity().addProperty(createPrimitive("PropertyInt16", 3))
         .addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("crimson")));
     entity.setMediaContentType("image/svg+xml");
     entitySet.getEntities().add(entity);
 
-    entity = new EntityImpl().addProperty(createPrimitive("PropertyInt16", 4))
+    entity = new Entity().addProperty(createPrimitive("PropertyInt16", 4))
         .addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("black")));
     entity.setMediaContentType("image/svg+xml");
     entitySet.getEntities().add(entity);
@@ -558,29 +553,29 @@ public class DataCreator {
   }
 
   protected static Property createPrimitive(final String name, final Object value) {
-    return new PropertyImpl(null, name, ValueType.PRIMITIVE, value);
+    return new Property(null, name, ValueType.PRIMITIVE, value);
   }
 
   protected static Property createPrimitiveCollection(final String name, final Object... values) {
-    return new PropertyImpl(null, name, ValueType.COLLECTION_PRIMITIVE, Arrays.asList(values));
+    return new Property(null, name, ValueType.COLLECTION_PRIMITIVE, Arrays.asList(values));
   }
 
   protected static Property createComplex(final String name, final Property... properties) {
-    ComplexValue complexValue = new ComplexValueImpl();
+    ComplexValue complexValue = new ComplexValue();
     for (final Property property : properties) {
       complexValue.getValue().add(property);
     }
-    return new PropertyImpl(null, name, ValueType.COMPLEX, complexValue);
+    return new Property(null, name, ValueType.COMPLEX, complexValue);
   }
 
   protected static Property createComplexCollection(final String name, final List<Property>... propertiesList) {
     List<ComplexValue> complexCollection = new ArrayList<ComplexValue>();
     for (final List<Property> properties : propertiesList) {
-      ComplexValue complexValue = new ComplexValueImpl();
+      ComplexValue complexValue = new ComplexValue();
       complexValue.getValue().addAll(properties);
       complexCollection.add(complexValue);
     }
-    return new PropertyImpl(null, name, ValueType.COLLECTION_COMPLEX, complexCollection);
+    return new Property(null, name, ValueType.COLLECTION_COMPLEX, complexCollection);
   }
 
   private Calendar getDateTime(final int year, final int month, final int day,
@@ -610,7 +605,7 @@ public class DataCreator {
   protected static void setLink(Entity entity, final String navigationPropertyName, final Entity target) {
     Link link = entity.getNavigationLink(navigationPropertyName);
     if (link == null) {
-      link = new LinkImpl();
+      link = new Link();
       link.setType(ODataLinkType.ENTITY_NAVIGATION.toString());
       link.setTitle(navigationPropertyName);
       entity.getNavigationLinks().add(link);
@@ -621,10 +616,10 @@ public class DataCreator {
   protected static void setLinks(Entity entity, final String navigationPropertyName, final Entity... targets) {
     Link link = entity.getNavigationLink(navigationPropertyName);
     if (link == null) {
-      link = new LinkImpl();
+      link = new Link();
       link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
       link.setTitle(navigationPropertyName);
-      EntitySet target = new EntitySetImpl();
+      EntitySet target = new EntitySet();
       target.getEntities().addAll(Arrays.asList(targets));
       link.setInlineEntitySet(target);
       entity.getNavigationLinks().add(link);


[05/22] olingo-odata4 git commit: [OLINGO-545] TecSvc: Request validation added

Posted by ra...@apache.org.
[OLINGO-545] TecSvc: Request validation added


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/583c4bd0
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/583c4bd0
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/583c4bd0

Branch: refs/heads/OLINGO-573
Commit: 583c4bd07886ce38dae7fa41bcfbd8404d1b6abf
Parents: 97a0178
Author: Christian Holzer <c....@sap.com>
Authored: Mon Apr 6 08:25:00 2015 +0200
Committer: Christian Holzer <c....@sap.com>
Committed: Tue Apr 7 08:25:43 2015 +0200

----------------------------------------------------------------------
 .../olingo/fit/tecsvc/client/BasicITCase.java   |  38 +++
 .../olingo/fit/tecsvc/client/BindingITCase.java |  35 ++-
 .../fit/tecsvc/client/DeepInsertITCase.java     | 176 ++++++++++++-
 .../tecsvc/client/FilterSystemQueryITCase.java  |  25 +-
 .../olingo/server/tecsvc/data/DataProvider.java |  26 +-
 .../server/tecsvc/data/RequestValidator.java    | 255 +++++++++++++++++++
 .../processor/TechnicalEntityProcessor.java     |  27 +-
 7 files changed, 548 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/583c4bd0/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
index b7bac00..5b8949a 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
@@ -30,8 +30,10 @@ import static org.junit.Assert.fail;
 import java.net.URI;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.List;
 
+import org.apache.olingo.client.api.EdmEnabledODataClient;
 import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.communication.ODataClientErrorException;
 import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
@@ -266,6 +268,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
     ODataEntity newEntity = factory.newEntity(new FullQualifiedName("olingo.odata.test1", "ETAllPrim"));
     newEntity.getProperties().add(factory.newPrimitiveProperty("PropertyInt64",
         factory.newPrimitiveValueBuilder().buildInt32(42)));
+    
     final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESAllPrim").appendKeySegment(32767)
         .build();
     final ODataEntityUpdateRequest<ODataEntity> request = client.getCUDRequestFactory().getEntityUpdateRequest(
@@ -373,6 +376,12 @@ public class BasicITCase extends AbstractBaseTestITCase {
     ODataEntity newEntity = factory.newEntity(new FullQualifiedName("olingo.odata.test1", "ETAllPrim"));
     newEntity.getProperties().add(factory.newPrimitiveProperty("PropertyInt64",
         factory.newPrimitiveValueBuilder().buildInt32(42)));
+    newEntity.addLink(factory.newEntityNavigationLink("NavPropertyETTwoPrimOne", 
+                          client.newURIBuilder(SERVICE_URI)
+                                .appendEntitySetSegment("ESTwoPrim")
+                                .appendKeySegment(32766)
+                                .build()));
+    
     final ODataEntityCreateRequest<ODataEntity> createRequest = client.getCUDRequestFactory().getEntityCreateRequest(
         client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESAllPrim").build(),
         newEntity);
@@ -518,6 +527,18 @@ public class BasicITCase extends AbstractBaseTestITCase {
                   .add(of.newPrimitiveProperty("PropertyInt16", of.newPrimitiveValueBuilder().buildInt16((short) 2)))
                   .add(of.newPrimitiveProperty("PropertySingle", of.newPrimitiveValueBuilder().buildSingle(2.0f))))))));
     
+    entity.addLink(of.newEntityNavigationLink("NavPropertyETTwoKeyNavOne",
+        getClient().newURIBuilder(SERVICE_URI)
+            .appendEntitySetSegment("ESTwoKeyNav")
+            .appendKeySegment(new LinkedHashMap<String, Object>() {
+              private static final long serialVersionUID = 1L;
+
+              {
+                put("PropertyInt16", 1);
+                put("PropertyString", "1");
+              }
+            }).build()));
+    
     final ODataEntityCreateResponse<ODataEntity> response = getClient().getCUDRequestFactory().getEntityCreateRequest(
         getClient().newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESKeyNav").build(),
         entity).execute();
@@ -576,6 +597,23 @@ public class BasicITCase extends AbstractBaseTestITCase {
     assertNull(innerComplexProperty2.get("NotAvailableProperty"));
   }
   
+  @Test
+  public void testComplexPropertyWithNotNullablePrimitiveValue() {
+    final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+    final ODataObjectFactory of = client.getObjectFactory();
+    
+    // PropertyComp is null, but the primitive values in PropertyComp must not be null
+    final ODataEntity entity = of.newEntity(new FullQualifiedName("olingo.odata.test1", "ETMixPrimCollComp"));
+    final URI targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESMixPrimCollComp").build();
+    
+    try {
+      client.getCUDRequestFactory().getEntityCreateRequest(targetURI, entity).execute();
+      fail("Expecting bad request");
+    } catch (ODataClientErrorException e) {
+      assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), e.getStatusLine().getStatusCode());
+    }
+  }
+  
   @Override
   protected ODataClient getClient() {
     ODataClient odata = ODataClientFactory.getClient();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/583c4bd0/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BindingITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BindingITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BindingITCase.java
index 75cadd0..74b7718 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BindingITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BindingITCase.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.fail;
 import java.net.URI;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 
 import org.apache.olingo.client.api.EdmEnabledODataClient;
 import org.apache.olingo.client.api.ODataClient;
@@ -69,9 +70,9 @@ public class BindingITCase extends AbstractBaseTestITCase {
   private static final String PROPERTY_COMP_ALL_PRIM = "PropertyCompAllPrim";
   private static final String NAV_PROPERTY_ET_KEY_NAV_ONE = "NavPropertyETKeyNavOne";
   private static final String NAV_PROPERTY_ET_KEY_NAV_MANY = "NavPropertyETKeyNavMany";
+  private static final String NAV_PROPERTY_ET_TWO_KEY_NAV_ONE = "NavPropertyETTwoKeyNavOne";
   private static final String NAV_PROPERTY_ET_TWO_KEY_NAV_MANY = "NavPropertyETTwoKeyNavMany";
 
-
   @Test
   public void testCreateBindingSimple() throws EdmPrimitiveTypeException {
     final ODataClient client = getClient();
@@ -101,6 +102,17 @@ public class BindingITCase extends AbstractBaseTestITCase {
                 .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))))));
 
     // Bind existing entities via binding synatx
+    entity.addLink(of.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, 
+        client.newURIBuilder(SERVICE_URI)
+              .appendEntitySetSegment(ES_TWO_KEY_NAV)
+              .appendKeySegment(new LinkedHashMap<String, Object>() {
+                private static final long serialVersionUID = 3109256773218160485L;
+                {
+                  put(PROPERTY_INT16, 3);
+                  put(PROPERTY_STRING, "1");
+                }
+              }).build()));
+    
     final ODataLink navLinkOne =
         of.newEntityNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE, client.newURIBuilder(SERVICE_URI)
             .appendEntitySetSegment(
@@ -331,10 +343,31 @@ public class BindingITCase extends AbstractBaseTestITCase {
    innerEntity.getProperties().add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
         .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 1)))
         .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("2")))));
+   innerEntity.addLink(of.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, 
+       client.newURIBuilder(SERVICE_URI)
+             .appendEntitySetSegment(ES_TWO_KEY_NAV)
+             .appendKeySegment(new LinkedHashMap<String, Object>() {
+               private static final long serialVersionUID = 3109256773218160485L;
+               {
+                 put(PROPERTY_INT16, 3);
+                 put(PROPERTY_STRING, "1");
+               }
+             }).build()));
    
    final ODataInlineEntity inlineLink = of.newDeepInsertEntity(NAV_PROPERTY_ET_KEY_NAV_ONE, innerEntity);
    entity.addLink(inlineLink);
    
+   entity.addLink(of.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, 
+       client.newURIBuilder(SERVICE_URI)
+             .appendEntitySetSegment(ES_TWO_KEY_NAV)
+             .appendKeySegment(new LinkedHashMap<String, Object>() {
+               private static final long serialVersionUID = 3109256773218160485L;
+               {
+                 put(PROPERTY_INT16, 3);
+                 put(PROPERTY_STRING, "1");
+               }
+             }).build()));
+   
    final URI bindingURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
                                                            .appendKeySegment(3)
                                                            .build();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/583c4bd0/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
index ba33e3f..5255712 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
@@ -20,6 +20,7 @@ package org.apache.olingo.fit.tecsvc.client;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
 
 import java.net.URI;
 import java.util.HashMap;
@@ -27,8 +28,12 @@ import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
+import org.apache.olingo.client.api.EdmEnabledODataClient;
 import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.communication.ODataClientErrorException;
+import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
 import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
 import org.apache.olingo.client.core.ODataClientFactory;
@@ -62,8 +67,10 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
   private static final String CT_TWO_PRIM = "CTTwoPrim";
   private static final String CT_ALL_PRIM = "CTAllPrim";
   private static final String CT_NAV_FIVE_PROP = "CTNavFiveProp";
+  private static final String CT_BASE_PRIM_COMP_NAV = "CTBasePrimCompNav";
   private static final String PROPERTY_INT16 = "PropertyInt16";
   private static final String PROPERTY_STRING = "PropertyString";
+  private static final String PROPERTY_COMP = "PropertyComp";
   private static final String PROPERTY_COMP_NAV = "PropertyCompNav";
   private static final String PROPERTY_COMP_COMP_NAV = "PropertyCompCompNav";
   private static final String PROPERTY_COMP_TWO_PRIM = "PropertyCompTwoPrim";
@@ -71,6 +78,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
   private static final String NAV_PROPERTY_ET_KEY_NAV_ONE = "NavPropertyETKeyNavOne";
   private static final String NAV_PROPERTY_ET_TWO_KEY_NAV_ONE = "NavPropertyETTwoKeyNavOne";
   private static final String NAV_PROPERTY_ET_TWO_KEY_NAV_MANY = "NavPropertyETTwoKeyNavMany";
+  private static final String COL_PROPERTY_STRING = "CollPropertyString";
+  private static final String EDM_STRING = "Edm.String";
 
   @Test
   public void testDeepInsertExpandedResponse() {
@@ -96,6 +105,10 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
             .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))
             .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
                 "String Property level 1, complex level 1")))));
+    firstLevelTwoKeyNav.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
+    firstLevelTwoKeyNav.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
     final ODataInlineEntity firstLevelTwoKeyOneInline =
         of.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, firstLevelTwoKeyNav);
     entity.addLink(firstLevelTwoKeyOneInline);
@@ -107,7 +120,11 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
             .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 421)))
             .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
                 "String Property level 2, complex level 1")))));
-
+    secondLevelTwoKeyNav.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
+    secondLevelTwoKeyNav.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
+    
     // Binding links
     secondLevelTwoKeyNav.addLink(of.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, client.newURIBuilder(
         SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(new LinkedHashMap<String, Object>() {
@@ -129,14 +146,22 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
             .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 431)))
             .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
                 "String Property level 3, complex level 1")))));
-
+    thirdLevelTwoKeyNavMany1.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
+    thirdLevelTwoKeyNavMany1.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
+    
     final ODataEntity thirdLevelTwoKeyNavMany2 = of.newEntity(ET_TWO_KEY_NAV);
     thirdLevelTwoKeyNavMany2.getProperties().add(
         of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
             .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 432)))
             .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
                 "String Property level 3, complex level 1")))));
-
+    thirdLevelTwoKeyNavMany2.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
+    thirdLevelTwoKeyNavMany2.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
+    
     final ODataEntitySet entitySetThirdLevelTwoKeyNavMany = of.newEntitySet();
     entitySetThirdLevelTwoKeyNavMany.getEntities().add(thirdLevelTwoKeyNavMany1);
     entitySetThirdLevelTwoKeyNavMany.getEntities().add(thirdLevelTwoKeyNavMany2);
@@ -150,7 +175,11 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
             .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 422)))
             .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
                 "String Property level 1, complex level 1")))));
-
+    firstLevelTwoKeyNavMany1.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
+    firstLevelTwoKeyNavMany1.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
+    
     final ODataEntitySet entitySetfirstLevelTwoKeyNavMany = of.newEntitySet();
     entitySetfirstLevelTwoKeyNavMany.getEntities().add(firstLevelTwoKeyNavMany1);
     entity.addLink(of.newDeepInsertEntitySet(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY,
@@ -172,7 +201,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
         resultEntityFirstLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE).asInlineEntity().getEntity();
     assertEquals(421, resultEntitySecondLevel.getProperty(PROPERTY_COMP_TWO_PRIM).getComplexValue().get(PROPERTY_INT16)
         .getPrimitiveValue().toValue());
-    assertEquals("String Property level 2, complex level 1", resultEntitySecondLevel.getProperty(PROPERTY_COMP_TWO_PRIM)
+    assertEquals("String Property level 2, complex level 1", resultEntitySecondLevel
+        .getProperty(PROPERTY_COMP_TWO_PRIM)
         .getComplexValue().get(PROPERTY_STRING)
         .getPrimitiveValue().toValue());
 
@@ -198,7 +228,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
     assertEquals("String Property level 1, complex level 1", firstLevelEntitySetNavMany.getEntities().get(0)
         .getProperty(PROPERTY_COMP_TWO_PRIM).getComplexValue().get(PROPERTY_STRING).getPrimitiveValue().toValue());
   }
-  
+
   @Test
   public void testSimpleDeepInsert() throws EdmPrimitiveTypeException {
     final ODataClient client = getClient();
@@ -234,6 +264,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
         .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 43)));
     inlineEntitySingle.getProperties()
         .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("43")));
+    inlineEntitySingle.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
     inlineEntitySingle.getProperties()
         .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
             .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 431)))));
@@ -253,6 +285,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
     inlineEntityCol1.getProperties()
         .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
             .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 441)))));
+    inlineEntityCol1.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
     inlineEntityCol1.getProperties()
         .add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
             .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 442)))
@@ -266,6 +300,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
     inlineEntityCol2.getProperties()
         .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
             .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 451)))));
+    inlineEntityCol2.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
     inlineEntityCol2.getProperties()
         .add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
             .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 452)))
@@ -412,6 +448,18 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
             .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")))
             .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_NAV_FIVE_PROP)
                 .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))))));
+    entity.addLink(of.newEntityNavigationLink("NavPropertyETTwoKeyNavOne",
+        client.newURIBuilder(SERVICE_URI)
+            .appendEntitySetSegment(ES_TWO_KEY_NAV)
+            .appendKeySegment(new LinkedHashMap<String, Object>() {
+              private static final long serialVersionUID = 1L;
+
+              {
+                put(PROPERTY_INT16, 1);
+                put(PROPERTY_STRING, "1");
+              }
+            })
+            .build()));
 
     // Prepare inline entity(EntitySet: ESKeyNav, Type: ETKeyNav)
     final ODataEntity innerEntity = of.newEntity(ET_KEY_NAV);
@@ -436,7 +484,19 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
             .add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_NAV_FIVE_PROP)
                 .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder()
                     .buildInt16((short) 431)))))));
-
+    innerEntity.addLink(of.newEntityNavigationLink("NavPropertyETTwoKeyNavOne",
+        client.newURIBuilder(SERVICE_URI)
+            .appendEntitySetSegment(ES_TWO_KEY_NAV)
+            .appendKeySegment(new LinkedHashMap<String, Object>() {
+              private static final long serialVersionUID = 1L;
+
+              {
+                put(PROPERTY_INT16, 1);
+                put(PROPERTY_STRING, "1");
+              }
+            })
+            .build()));
+    
     ODataInlineEntity inlineEntity = of.newDeepInsertEntity(NAV_PROPERTY_ET_KEY_NAV_ONE, innerEntity);
     entity.addLink(inlineEntity);
 
@@ -475,6 +535,108 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
         .getPrimitiveValue().toValue());
   }
 
+  @Test
+  public void testConsistency() throws EdmPrimitiveTypeException {
+    final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+    final ODataObjectFactory of = client.getObjectFactory();
+    final String cookie = getCookie();
+    
+    // Do not set PropertyString(Nullable=false)
+    final ODataEntity entity = of.newEntity(ET_KEY_NAV);
+    entity.getProperties().add(
+        of.newCollectionProperty(COL_PROPERTY_STRING,
+            of.newCollectionValue(EDM_STRING).add(
+                of.newPrimitiveValueBuilder().buildString("Test"))));
+
+    final URI targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
+
+    try {
+      ODataEntityCreateRequest<ODataEntity> request = client.getCUDRequestFactory()
+          .getEntityCreateRequest(targetURI, entity);
+      request.addCustomHeader(HttpHeader.COOKIE, cookie);
+      request.execute();
+      fail("Expecting bad request");
+    } catch (ODataClientErrorException e) {
+      assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), e.getStatusLine().getStatusCode());
+    }
+
+    // Entity must not be created
+    validateSet(targetURI, cookie, (short) 1, (short) 2, (short) 3);
+  }
+
+  @Test
+  public void testInvalidType() throws EdmPrimitiveTypeException {
+    final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+    final ODataObjectFactory of = client.getObjectFactory();
+    final String cookie = getCookie();
+
+    final ODataEntity entity = of.newEntity(ET_KEY_NAV);
+    entity.getProperties().add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildInt32(1)));
+    final URI targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
+
+    try {
+      ODataEntityCreateRequest<ODataEntity> request = client.getCUDRequestFactory()
+          .getEntityCreateRequest(targetURI, entity);
+      request.addCustomHeader(HttpHeader.COOKIE, cookie);
+      request.execute();
+    } catch (ODataClientErrorException e) {
+      assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), e.getStatusLine().getStatusCode());
+    }
+
+    validateSet(targetURI, cookie, (short) 1, (short) 2, (short) 3);
+
+    entity.getProperties().add(
+        of.newCollectionProperty(PROPERTY_STRING,
+            of.newCollectionValue(EDM_STRING).add(
+                of.newPrimitiveValueBuilder().buildString("Test"))));
+
+    try {
+      ODataEntityCreateRequest<ODataEntity> request = client.getCUDRequestFactory()
+          .getEntityCreateRequest(targetURI, entity);
+      request.addCustomHeader(HttpHeader.COOKIE, cookie);
+      request.execute();
+    } catch (ODataClientErrorException e) {
+      assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), e.getStatusLine().getStatusCode());
+    }
+
+    validateSet(targetURI, cookie, (short) 1, (short) 2, (short) 3);
+  }
+
+  private String getCookie() {
+    final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+    final ODataRetrieveResponse<ODataEntitySet> response = client.getRetrieveRequestFactory()
+        .getEntitySetRequest(client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build())
+        .execute();
+
+    return response.getHeader(HttpHeader.SET_COOKIE).iterator().next();
+  }
+
+  private void validateSet(final URI uri, final String cookie, final short... keys) throws EdmPrimitiveTypeException {
+    final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+    final ODataEntitySetRequest<ODataEntitySet> request = client.getRetrieveRequestFactory()
+        .getEntitySetRequest(uri);
+    request.addCustomHeader(HttpHeader.COOKIE, cookie);
+    final ODataRetrieveResponse<ODataEntitySet> response = request.execute();
+
+    assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
+    assertEquals(3, response.getBody().getEntities().size());
+
+    for (final ODataEntity responseEntity : response.getBody().getEntities()) {
+      short propertyInt16 = responseEntity.getProperty(PROPERTY_INT16).getPrimitiveValue().toCastValue(Short.class);
+
+      boolean found = false;
+      for (int i = 0; i < keys.length && !found; i++) {
+        if (propertyInt16 == keys[i]) {
+          found = true;
+        }
+      }
+
+      if (!found) {
+        fail("Invalid key " + propertyInt16);
+      }
+    }
+  }
+
   @Override
   protected ODataClient getClient() {
     ODataClient odata = ODataClientFactory.getClient();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/583c4bd0/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/FilterSystemQueryITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/FilterSystemQueryITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/FilterSystemQueryITCase.java
index 8cb249d..16529dd 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/FilterSystemQueryITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/FilterSystemQueryITCase.java
@@ -21,6 +21,7 @@ package org.apache.olingo.fit.tecsvc.client;
 import static org.junit.Assert.assertEquals;
 
 import java.net.URI;
+import java.util.LinkedHashMap;
 
 import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.communication.ODataClientErrorException;
@@ -289,7 +290,12 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
     entity.getProperties().add(
         objectFactory.newPrimitiveProperty("PropertyInt16", objectFactory.newPrimitiveValueBuilder()
             .buildInt16((short) 1)));
-
+    entity.addLink(objectFactory.newEntityNavigationLink("NavPropertyETTwoPrimOne", 
+        client.newURIBuilder(SERVICE_URI)
+              .appendEntitySetSegment("ESTwoPrim")
+              .appendKeySegment(32766)
+              .build()));
+    
     final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESAllPrim").build();
     ODataEntityCreateResponse<ODataEntity> createResponse =
         client.getCUDRequestFactory().getEntityCreateRequest(uri, entity).execute();
@@ -921,7 +927,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
   @Test
   public void testNullComplexProperty() {
     // Create a new entry.The complex property PropertyCompComp is set to null. So the structure of the property
-    // is still there, but filled is null value (primitive types)
+    // is still there, but filled is null values (primitive types)
     // We define a filter, which returns all entry where PropertyCompComp/PropertyComp/PropertyInt16 is equals to 1
 
     final ODataClient client = getClient();
@@ -948,7 +954,20 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
                 .add(factory.newPrimitiveProperty(
                     "PropertyString",
                     factory.newPrimitiveValueBuilder().buildString("Test2")))));
-
+    
+    newEntity.addLink(factory.newEntityNavigationLink("NavPropertyETTwoKeyNavOne",
+        client.newURIBuilder(SERVICE_URI)
+            .appendEntitySetSegment(ES_TWO_KEY_NAV)
+            .appendKeySegment(new LinkedHashMap<String, Object>() {
+              private static final long serialVersionUID = 1L;
+
+              {
+                put("PropertyInt16", 1);
+                put("PropertyString", "1");
+              }
+            })
+            .build()));
+    
     final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESKeyNav").build();
     ODataEntityCreateRequest<ODataEntity> request =
         client.getCUDRequestFactory().getEntityCreateRequest(uri, newEntity);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/583c4bd0/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
index 96f0cd7..d47aa46 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
@@ -6,9 +6,9 @@
  * 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 WARRANTIES OR CONDITIONS OF ANY
@@ -152,7 +152,6 @@ public class DataProvider {
   private Map<String, Object> findFreeComposedKey(final List<Entity> entities, final EdmEntityType entityType)
       throws DataProviderException {
     // Weak key construction
-    // 3e € entity: (V k € keys: k !€ e.ki) => e.(k1, k2, k3) !€ entitySet
     final HashMap<String, Object> keys = new HashMap<String, Object>();
     for (final String keyName : entityType.getKeyPredicateNames()) {
       final EdmType type = entityType.getProperty(keyName).getType();
@@ -243,15 +242,15 @@ public class DataProvider {
             patch);
       }
     }
-    
-    // For insert operations collection navigation property bind operations and deep insert operations can be combined. 
+
+    // For insert operations collection navigation property bind operations and deep insert operations can be combined.
     // In this case, the bind operations MUST appear before the deep insert operations in the payload.
     // => Apply bindings first
     final boolean navigationBindingsAvailable = !changedEntity.getNavigationBindings().isEmpty();
     if (navigationBindingsAvailable) {
       applyNavigationBinding(rawBaseUri, edmEntitySet, entity, changedEntity.getNavigationBindings());
     }
-    
+
     // Deep insert (only if not an update)
     if (isInsert) {
       handleDeepInsert(rawBaseUri, edmEntitySet, entity, changedEntity);
@@ -311,10 +310,6 @@ public class DataProvider {
           .getKeyPredicatesFromEntityLink(edm, bindingLink, rawBaseUri);
       final Entity entity = read(edmEntitySetTarget, keys);
 
-      if (entity == null) {
-        throw new DataProviderException("Entity " + bindingLink + " not found", HttpStatusCode.NOT_FOUND);
-      }
-
       return entity;
     } catch (DeserializerException e) {
       throw new DataProviderException("Invalid entity binding link", HttpStatusCode.BAD_REQUEST);
@@ -400,9 +395,6 @@ public class DataProvider {
     if (edmProperty.isPrimitive()) {
       if (newProperty != null || !patch) {
         final Object value = newProperty == null ? null : newProperty.getValue();
-        if (value == null && !edmProperty.isNullable()) {
-          throw new DataProviderException("Cannot null non-nullable property!", HttpStatusCode.BAD_REQUEST);
-        }
         property.setValue(property.getValueType(), value);
       }
     } else if (edmProperty.isCollection()) {
@@ -440,7 +432,7 @@ public class DataProvider {
   private ComplexValue createComplexValue(final EdmProperty edmProperty, final ComplexValue complexValue,
       final boolean patch) throws DataProviderException {
     final ComplexValueImpl result = new ComplexValueImpl();
-    final EdmComplexType edmType =  (EdmComplexType) edmProperty.getType();
+    final EdmComplexType edmType = (EdmComplexType) edmProperty.getType();
     final List<Property> givenProperties = complexValue.getValue();
 
     // Create ALL properties, even if no value is given. Check if null is allowed
@@ -454,12 +446,10 @@ public class DataProvider {
         updateProperty(innerEdmProperty, newProperty, currentProperty, patch);
       } else {
         if (innerEdmProperty.isNullable()) {
-          // Check complex properties ... may be null is not allowed
-          if(edmProperty.getType().getKind() == EdmTypeKind.COMPLEX)  {
+          // Check complex properties ... maybe null is not allowed
+          if (edmProperty.getType().getKind() == EdmTypeKind.COMPLEX) {
             updateProperty(innerEdmProperty, newProperty, null, patch);
           }
-        } else {
-          throw new DataProviderException("Null is not allowed for property " + edmProperty.getName());
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/583c4bd0/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/RequestValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/RequestValidator.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/RequestValidator.java
new file mode 100644
index 0000000..113b252
--- /dev/null
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/RequestValidator.java
@@ -0,0 +1,255 @@
+/*
+ * 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 WARRANTIES OR 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.olingo.server.tecsvc.data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.commons.api.data.ComplexValue;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.Linked;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmBindingTarget;
+import org.apache.olingo.commons.api.edm.EdmComplexType;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
+import org.apache.olingo.commons.api.edm.EdmProperty;
+import org.apache.olingo.commons.api.edm.EdmStructuredType;
+import org.apache.olingo.commons.api.http.HttpStatusCode;
+import org.apache.olingo.server.api.deserializer.DeserializerException;
+import org.apache.olingo.server.api.uri.UriHelper;
+import org.apache.olingo.server.api.uri.UriParameter;
+import org.apache.olingo.server.tecsvc.data.DataProvider.DataProviderException;
+
+public class RequestValidator {
+  private DataProvider provider;
+  private boolean isInsert;
+  private UriHelper uriHelper;
+  private Edm edm;
+  private String rawServiceRoot;
+
+  public RequestValidator(final DataProvider provider, final boolean isInsert, final UriHelper uriHelper,
+      final Edm edm, final String rawServiceRoot) {
+    this.provider = provider;
+    this.isInsert = isInsert;
+    this.uriHelper = uriHelper;
+    this.edm = edm;
+    this.rawServiceRoot = rawServiceRoot;
+  }
+
+  public void validate(final EdmBindingTarget edmBindingTarget, final Entity entity) 
+      throws DataProviderException {
+    final List<String> path = new ArrayList<String>();
+    
+    validateEntitySetProperties(entity.getProperties(), edmBindingTarget, edmBindingTarget.getEntityType(), path);
+    validateNavigationProperties(entity, edmBindingTarget, edmBindingTarget.getEntityType(), path); 
+  }
+  
+  private void validateNavigationProperties(final Linked entity, final EdmBindingTarget edmBindingTarget, 
+      final EdmStructuredType edmType, final List<String> path) throws DataProviderException {
+    for (final String navPropertyName : edmType.getNavigationPropertyNames()) {
+      final EdmNavigationProperty edmProperty = edmType.getNavigationProperty(navPropertyName);
+      if(entity == null && !edmProperty.isNullable()) {
+        throw new DataProviderException("Navigation property " + navPropertyName + " must not be null",
+            HttpStatusCode.BAD_REQUEST);
+      } else if(entity != null) {
+        final Link navigationBinding = entity.getNavigationBinding(navPropertyName);
+        final Link navigationLink = entity.getNavigationLink(navPropertyName);
+        final List<String> newPath = new ArrayList<String>(path);
+        newPath.add(edmProperty.getName());
+        final EdmBindingTarget target = edmBindingTarget.getRelatedBindingTarget(buildPath(newPath));
+  
+        final ValidatioResult bindingResult = validateBinding(navigationBinding, edmProperty, target);
+        final ValidatioResult linkResult = validateNavigationLink(navigationLink, 
+                                                                  edmProperty, 
+                                                                  target);
+  
+        if ((   isInsert  && !edmProperty.isNullable() && (bindingResult != ValidatioResult.FOUND 
+                                                        && linkResult != ValidatioResult.FOUND))
+            || (!isInsert && !edmProperty.isNullable() && linkResult == ValidatioResult.EMPTY)) {
+          throw new DataProviderException("Navigation property " + navPropertyName + " must not be null",
+              HttpStatusCode.BAD_REQUEST);
+        }
+      }
+    }
+  }
+  
+  private String buildPath(final List<String> path) {
+    final StringBuilder builder = new StringBuilder();
+    
+    for(final String segment : path) {
+      if(builder.length() > 0) {
+        builder.append("/");
+      }
+      
+      builder.append(segment);
+    }
+    
+    return builder.toString();
+  }
+
+  private ValidatioResult validateBinding(final Link navigationBindung, final EdmNavigationProperty edmProperty, 
+      final EdmBindingTarget edmBindingTarget) throws DataProviderException {
+    if(navigationBindung == null) {
+      return ValidatioResult.NOT_FOUND;
+    }
+    
+    if (edmProperty.isCollection()) {
+      if(navigationBindung.getBindingLinks().size() == 0) {
+        return ValidatioResult.EMPTY;
+      }
+      
+      for (final String bindingLink : navigationBindung.getBindingLinks()) {
+        validateLink(bindingLink, edmBindingTarget);
+      }
+    } else {
+      if(navigationBindung.getBindingLink() == null) {
+        return ValidatioResult.EMPTY;
+      }
+      
+      validateLink(navigationBindung.getBindingLink(), edmBindingTarget);
+    }
+    
+    return ValidatioResult.FOUND;
+  }
+  
+  private ValidatioResult validateNavigationLink(final Link navigationLink, final EdmNavigationProperty edmProperty, 
+      final EdmBindingTarget edmBindingTarget) throws DataProviderException {
+    if(navigationLink == null) {
+      return ValidatioResult.NOT_FOUND;
+    }
+    
+    if(edmProperty.isCollection()) {
+      final EntitySet inlineEntitySet = navigationLink.getInlineEntitySet();
+      if(!isInsert && inlineEntitySet.getEntities().size() > 0) {
+        throw new DataProvider.DataProviderException("Deep update is not allowed", HttpStatusCode.BAD_REQUEST);
+      } else {
+        for(final Entity entity : navigationLink.getInlineEntitySet().getEntities()) {
+          validate(edmBindingTarget, entity);
+        }
+      }
+    } else {
+      final Entity inlineEntity = navigationLink.getInlineEntity();
+      if(!isInsert && inlineEntity != null) {
+        throw new DataProvider.DataProviderException("Deep update is not allowed", HttpStatusCode.BAD_REQUEST);
+      } else if(inlineEntity != null) {
+        validate(edmBindingTarget, navigationLink.getInlineEntity());
+      }
+    }
+    
+    return ValidatioResult.FOUND;
+  }
+  
+  private void validateLink(final String bindingLink, final EdmBindingTarget edmBindungTarget) 
+      throws DataProviderException {
+    try {
+      final List<UriParameter> keys = uriHelper.getKeyPredicatesFromEntityLink(edm, bindingLink, rawServiceRoot);
+      final Entity entity = provider.read((EdmEntitySet)edmBindungTarget, keys);
+
+      if (entity == null) {
+        throw new DataProviderException("Entity not found", HttpStatusCode.NOT_FOUND);
+      }
+    } catch (DeserializerException e) {
+      throw new DataProviderException("Invalid binding link", HttpStatusCode.BAD_REQUEST);
+    }
+  }
+
+  private void validateEntitySetProperties(final List<Property> properties, final EdmBindingTarget edmBindingTarget, 
+      final EdmEntityType edmType, final List<String> path) throws DataProviderException {
+    validateProperties(properties, edmBindingTarget, edmType, edmType.getKeyPredicateNames(), path);
+  }
+  
+  private void validateProperties(final List<Property> properties, final EdmBindingTarget edmBingingTarget, 
+      final EdmStructuredType edmType, final List<String> keyPredicateNames, final List<String> path) 
+          throws DataProviderException {
+    
+    for(final String propertyName : edmType.getPropertyNames()) {
+      final EdmProperty edmProperty = (EdmProperty) edmType.getProperty(propertyName);
+      
+      // Ignore key properties, they are set automatically
+      if(!keyPredicateNames.contains(propertyName)) {
+        final Property property = getProperty(properties, propertyName);
+        
+        // Check if all "not nullable" properties are set
+        if(!edmProperty.isNullable()) {
+          if((property != null && property.isNull())    // Update,insert; Property is explicit set to null
+            || (isInsert && property == null) ) {       // Insert; Property not provided
+            throw new DataProviderException("Property " + propertyName + " must not be null", 
+                HttpStatusCode.BAD_REQUEST);
+          }
+        }
+        
+        // Validate property value
+        validatePropertyValue(property, edmProperty, edmBingingTarget, path);
+      }
+    }
+  }
+  
+  private void validatePropertyValue(final Property property, final EdmProperty edmProperty, 
+      final EdmBindingTarget edmBindingTarget, final List<String> path) throws DataProviderException {
+    
+    final ArrayList<String> newPath = new ArrayList<String>(path);
+    newPath.add(edmProperty.getName());
+
+    if (edmProperty.isCollection()) {
+      if (edmProperty.getType() instanceof EdmComplexType && property != null) {
+        for (final Object value : property.asCollection()) {
+          validateComplexValue((ComplexValue) value, 
+                               edmBindingTarget, 
+                               (EdmComplexType) edmProperty.getType(), 
+                               newPath);
+        }
+      }
+    } else if (edmProperty.getType() instanceof EdmComplexType) {
+      validateComplexValue((property == null) ? null : property.asComplex(), 
+                           edmBindingTarget,
+                           (EdmComplexType) edmProperty.getType(), 
+                           newPath);
+    }
+  }
+
+  private void validateComplexValue(final ComplexValue value, final EdmBindingTarget edmBindingTarget, 
+      final EdmComplexType edmType, final List<String> path) throws DataProviderException {
+    // The whole complex property can be nullable but nested primitive, navigation properties can be not nullable
+    final List<Property> properties = (value == null) ? new ArrayList<Property>() : value.getValue();
+
+    validateProperties(properties, edmBindingTarget, edmType, new ArrayList<String>(0), path);
+    validateNavigationProperties(value, edmBindingTarget, edmType, path);
+  }
+
+  private Property getProperty(final List<Property> properties, final String name) {
+    for(final Property property : properties) {
+      if(property.getName().equals(name)) {
+        return property;
+      }
+    }
+    
+    return null;
+  }
+  
+  private static enum ValidatioResult {
+    FOUND,
+    NOT_FOUND,
+    EMPTY
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/583c4bd0/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
index e105a2f..ed120b9 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
@@ -60,6 +60,7 @@ import org.apache.olingo.server.api.uri.UriResourceFunction;
 import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
 import org.apache.olingo.server.api.uri.queryoption.SelectOption;
 import org.apache.olingo.server.tecsvc.data.DataProvider;
+import org.apache.olingo.server.tecsvc.data.RequestValidator;
 import org.apache.olingo.server.tecsvc.processor.queryoptions.ExpandSystemQueryOptionHandler;
 import org.apache.olingo.server.tecsvc.processor.queryoptions.options.CountHandler;
 import org.apache.olingo.server.tecsvc.processor.queryoptions.options.FilterHandler;
@@ -230,17 +231,25 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
     final UriResourceEntitySet resourceEntitySet = (UriResourceEntitySet) uriInfo.getUriResourceParts().get(0);
     final EdmEntitySet edmEntitySet = resourceEntitySet.getEntitySet();
     final EdmEntityType edmEntityType = edmEntitySet.getEntityType();
-
-    Entity entity = dataProvider.create(edmEntitySet);
+    
+    final Entity entity;
     ExpandOption expand = null;
     if (edmEntityType.hasStream()) { // called from createMediaEntity(...), not directly
+      entity = dataProvider.create(edmEntitySet);
       dataProvider.setMedia(entity, odata.createFixedFormatDeserializer().binary(request.getBody()),
           requestFormat.toContentTypeString());
     } else {
       final DeserializerResult deserializerResult = odata.createDeserializer(ODataFormat.fromContentType(requestFormat))
                                                          .entity(request.getBody(), edmEntityType);
-      dataProvider.update(request.getRawBaseUri(), edmEntitySet, entity,
-          deserializerResult.getEntity(), false, true);
+      new RequestValidator(dataProvider, 
+                           true,        // Insert
+                           odata.createUriHelper(), 
+                           serviceMetadata.getEdm(), 
+                           request.getRawBaseUri()
+                           ).validate(edmEntitySet, deserializerResult.getEntity());
+      
+      entity = dataProvider.create(edmEntitySet);
+      dataProvider.update(request.getRawBaseUri(), edmEntitySet, entity, deserializerResult.getEntity(), false, true);
       expand = deserializerResult.getExpandTree();
     }
 
@@ -265,8 +274,16 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
     final EdmEntitySet edmEntitySet = getEdmEntitySet(uriInfo);
     Entity entity = readEntity(uriInfo);
     checkRequestFormat(requestFormat);
-    ODataDeserializer deserializer = odata.createDeserializer(ODataFormat.fromContentType(requestFormat));
+    final ODataDeserializer deserializer = odata.createDeserializer(ODataFormat.fromContentType(requestFormat));
     final Entity changedEntity = deserializer.entity(request.getBody(), edmEntitySet.getEntityType()).getEntity();
+    
+    new RequestValidator(dataProvider, 
+                         false,        // Update
+                         odata.createUriHelper(), 
+                         serviceMetadata.getEdm(), 
+                         request.getRawBaseUri()
+                         ).validate(edmEntitySet, changedEntity);
+    
     dataProvider.update(request.getRawBaseUri(), edmEntitySet, entity, changedEntity,
         request.getMethod() == HttpMethod.PATCH, false);
     response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());


[16/22] olingo-odata4 git commit: [OLINGO-613] break when property or link is found

Posted by ra...@apache.org.
[OLINGO-613] break when property or link is found


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/29e28335
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/29e28335
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/29e28335

Branch: refs/heads/OLINGO-573
Commit: 29e2833541052c895490a1bb85ba8db2eeb6e1c6
Parents: b76ebe9
Author: Christian Amend <ch...@apache.org>
Authored: Tue Apr 14 18:09:37 2015 +0200
Committer: Christian Amend <ch...@apache.org>
Committed: Tue Apr 14 18:09:37 2015 +0200

----------------------------------------------------------------------
 .../apache/olingo/commons/core/domain/ODataComplexValueImpl.java  | 1 +
 .../org/apache/olingo/commons/core/domain/ODataEntityImpl.java    | 3 +++
 2 files changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/29e28335/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataComplexValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataComplexValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataComplexValueImpl.java
index b862b71..677d34b 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataComplexValueImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataComplexValueImpl.java
@@ -111,6 +111,7 @@ public class ODataComplexValueImpl extends AbstractODataValue implements ODataCo
     for (ODataLink link : links) {
       if (name.equals(link.getName())) {
         result = link;
+        break;
       }
     }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/29e28335/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntityImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntityImpl.java
index ab6ddec..f3bbe0c 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntityImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataEntityImpl.java
@@ -111,6 +111,7 @@ public class ODataEntityImpl  extends AbstractODataPayload implements ODataEntit
     for (ODataOperation operation : operations) {
       if (title.equals(operation.getTitle())) {
         result = operation;
+        break;
       }
     }
 
@@ -136,6 +137,7 @@ public class ODataEntityImpl  extends AbstractODataPayload implements ODataEntit
       for (ODataProperty property : getProperties()) {
         if (name.equals(property.getName())) {
           result = property;
+          break;
         }
       }
     }
@@ -177,6 +179,7 @@ public class ODataEntityImpl  extends AbstractODataPayload implements ODataEntit
     for (ODataLink link : links) {
       if (name.equals(link.getName())) {
         result = link;
+        break;
       }
     }
 


[02/22] olingo-odata4 git commit: [OLINGO-617] Derserializer and Serializer result refactoring, ExpandBuilder

Posted by ra...@apache.org.
[OLINGO-617] Derserializer and Serializer result refactoring, ExpandBuilder


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/502f7ced
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/502f7ced
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/502f7ced

Branch: refs/heads/OLINGO-573
Commit: 502f7cedee18749ab92fd55b700cf64b75a11a16
Parents: 61b0daa
Author: Christian Holzer <c....@sap.com>
Authored: Thu Apr 2 14:55:51 2015 +0200
Committer: Christian Holzer <ch...@t-online.de>
Committed: Fri Apr 3 12:41:55 2015 +0200

----------------------------------------------------------------------
 .../fit/tecsvc/client/DeepInsertITCase.java     | 132 ++++++++++++++++++-
 .../api/deserializer/DeserializerResult.java    |  69 ++++++++++
 .../api/deserializer/ODataDeserializer.java     |  25 ++--
 .../server/api/processor/DefaultProcessor.java  |   6 +-
 .../server/api/serializer/ODataSerializer.java  |  18 +--
 .../server/api/serializer/SerializerResult.java |  32 +++++
 .../apache/olingo/server/core/ErrorHandler.java |   2 +-
 .../server/core/requests/DataRequest.java       |   6 +-
 .../server/core/responses/EntityResponse.java   |   4 +-
 .../core/responses/EntitySetResponse.java       |   3 +-
 .../server/core/responses/MetadataResponse.java |   2 +-
 .../server/core/responses/PropertyResponse.java |   8 +-
 .../core/responses/ServiceDocumentResponse.java |   2 +-
 .../olingo/server/example/TripPinDataModel.java |   2 +-
 .../deserializer/DeserializerResultImpl.java    | 126 ++++++++++++++++++
 .../deserializer/helper/ExpandTreeBuilder.java  |  40 ++++++
 .../helper/ExpandTreeBuilderImpl.java           |  67 ++++++++++
 .../json/ODataJsonDeserializer.java             |  66 ++++++----
 .../core/serializer/SerializerResultImpl.java   |  53 ++++++++
 .../serializer/json/ODataJsonSerializer.java    |  37 +++---
 .../serializer/xml/ODataXmlSerializerImpl.java  |  24 ++--
 .../json/ODataJsonDeserializerBasicTest.java    |   5 +-
 .../json/ODataErrorSerializerTest.java          |  14 +-
 .../json/ODataJsonSerializerTest.java           |   2 +-
 .../xml/MetadataDocumentXmlSerializerTest.java  |  10 +-
 .../processor/TechnicalEntityProcessor.java     |  18 ++-
 .../TechnicalPrimitiveComplexProcessor.java     |   8 +-
 .../json/ODataDeserializerDeepInsertTest.java   |   8 +-
 .../ODataDeserializerEntityCollectionTest.java  |   9 +-
 ...ataJsonDeserializerActionParametersTest.java |   4 +-
 .../json/ODataJsonDeserializerEntityTest.java   |  56 +++++---
 .../json/ODataJsonSerializerTest.java           |  48 +++----
 .../serializer/json/ServiceDocumentTest.java    |   2 +-
 .../serializer/xml/MetadataDocumentTest.java    |   2 +-
 .../server/sample/processor/CarsProcessor.java  |   8 +-
 35 files changed, 732 insertions(+), 186 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
index 4e15ca0..ba33e3f 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertNotNull;
 import java.net.URI;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.Map;
 
 import org.apache.olingo.client.api.ODataClient;
@@ -45,7 +46,6 @@ import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.fit.AbstractBaseTestITCase;
 import org.apache.olingo.fit.tecsvc.TecSvcConst;
-import org.junit.AfterClass;
 import org.junit.Test;
 
 public class DeepInsertITCase extends AbstractBaseTestITCase {
@@ -72,11 +72,133 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
   private static final String NAV_PROPERTY_ET_TWO_KEY_NAV_ONE = "NavPropertyETTwoKeyNavOne";
   private static final String NAV_PROPERTY_ET_TWO_KEY_NAV_MANY = "NavPropertyETTwoKeyNavMany";
 
-  @AfterClass
-  public static void tearDownAfterClass() throws Exception {
-  //Nothing needed here.
-  }
+  @Test
+  public void testDeepInsertExpandedResponse() {
+    final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+    client.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
+    final URI createURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
+    final ODataObjectFactory of = client.getObjectFactory();
+    final ODataEntity entity = of.newEntity(ET_KEY_NAV);
+
+    // Root entity
+    entity.getProperties().add(
+        of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("String Property level 0")));
+    entity.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
+            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 41)))
+            .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
+                "String Property level 0, complex level 1")))));
+
+    // First level NavPropertyETTwoKeyNavOne => Type ETTwoKeyNav
+    final ODataEntity firstLevelTwoKeyNav = of.newEntity(ET_TWO_KEY_NAV);
+    firstLevelTwoKeyNav.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
+            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))
+            .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
+                "String Property level 1, complex level 1")))));
+    final ODataInlineEntity firstLevelTwoKeyOneInline =
+        of.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, firstLevelTwoKeyNav);
+    entity.addLink(firstLevelTwoKeyOneInline);
+
+    // Second level NavPropertyETTwoKeyNavOne => Type ETTwoKeyNav
+    final ODataEntity secondLevelTwoKeyNav = of.newEntity(ET_TWO_KEY_NAV);
+    secondLevelTwoKeyNav.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
+            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 421)))
+            .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
+                "String Property level 2, complex level 1")))));
+
+    // Binding links
+    secondLevelTwoKeyNav.addLink(of.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, client.newURIBuilder(
+        SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(new LinkedHashMap<String, Object>() {
+      private static final long serialVersionUID = 3109256773218160485L;
+      {
+        put(PROPERTY_INT16, 3);
+        put(PROPERTY_STRING, "1");
+      }
+    }).build()));
+
+    final ODataInlineEntity secondLevelTwoKeyOneInline =
+        of.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, secondLevelTwoKeyNav);
+    firstLevelTwoKeyNav.addLink(secondLevelTwoKeyOneInline);
+
+    // Third level NavPropertyETTwoKeyNavMany => Type ETTwoKeyNav
+    final ODataEntity thirdLevelTwoKeyNavMany1 = of.newEntity(ET_TWO_KEY_NAV);
+    thirdLevelTwoKeyNavMany1.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
+            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 431)))
+            .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
+                "String Property level 3, complex level 1")))));
+
+    final ODataEntity thirdLevelTwoKeyNavMany2 = of.newEntity(ET_TWO_KEY_NAV);
+    thirdLevelTwoKeyNavMany2.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
+            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 432)))
+            .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
+                "String Property level 3, complex level 1")))));
+
+    final ODataEntitySet entitySetThirdLevelTwoKeyNavMany = of.newEntitySet();
+    entitySetThirdLevelTwoKeyNavMany.getEntities().add(thirdLevelTwoKeyNavMany1);
+    entitySetThirdLevelTwoKeyNavMany.getEntities().add(thirdLevelTwoKeyNavMany2);
+    secondLevelTwoKeyNav.addLink(of.newDeepInsertEntitySet(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY,
+        entitySetThirdLevelTwoKeyNavMany));
+
+    // First level NavPropertyETTwoKeyNavMany => Type ETTwoKeyNav
+    final ODataEntity firstLevelTwoKeyNavMany1 = of.newEntity(ET_TWO_KEY_NAV);
+    firstLevelTwoKeyNavMany1.getProperties().add(
+        of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
+            .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 422)))
+            .add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
+                "String Property level 1, complex level 1")))));
+
+    final ODataEntitySet entitySetfirstLevelTwoKeyNavMany = of.newEntitySet();
+    entitySetfirstLevelTwoKeyNavMany.getEntities().add(firstLevelTwoKeyNavMany1);
+    entity.addLink(of.newDeepInsertEntitySet(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY,
+        entitySetfirstLevelTwoKeyNavMany));
+
+    final ODataEntityCreateResponse<ODataEntity> createResponse =
+        client.getCUDRequestFactory().getEntityCreateRequest(createURI, entity).execute();
 
+    // Check response
+    final ODataEntity resultEntityFirstLevel =
+        createResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE).asInlineEntity().getEntity();
+    assertEquals(42, resultEntityFirstLevel.getProperty(PROPERTY_COMP_TWO_PRIM).getComplexValue().get(PROPERTY_INT16)
+        .getPrimitiveValue().toValue());
+    assertEquals("String Property level 1, complex level 1", resultEntityFirstLevel.getProperty(PROPERTY_COMP_TWO_PRIM)
+        .getComplexValue().get(PROPERTY_STRING)
+        .getPrimitiveValue().toValue());
+
+    final ODataEntity resultEntitySecondLevel =
+        resultEntityFirstLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE).asInlineEntity().getEntity();
+    assertEquals(421, resultEntitySecondLevel.getProperty(PROPERTY_COMP_TWO_PRIM).getComplexValue().get(PROPERTY_INT16)
+        .getPrimitiveValue().toValue());
+    assertEquals("String Property level 2, complex level 1", resultEntitySecondLevel.getProperty(PROPERTY_COMP_TWO_PRIM)
+        .getComplexValue().get(PROPERTY_STRING)
+        .getPrimitiveValue().toValue());
+
+    final ODataEntitySet thirdLevelEntitySetNavMany =
+        resultEntitySecondLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).asInlineEntitySet().getEntitySet();
+    assertEquals(2, thirdLevelEntitySetNavMany.getEntities().size());
+
+    assertEquals(431, thirdLevelEntitySetNavMany.getEntities().get(0).getProperty(PROPERTY_COMP_TWO_PRIM)
+        .getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertEquals("String Property level 3, complex level 1", thirdLevelEntitySetNavMany.getEntities().get(0)
+        .getProperty(PROPERTY_COMP_TWO_PRIM).getComplexValue().get(PROPERTY_STRING).getPrimitiveValue().toValue());
+
+    assertEquals(432, thirdLevelEntitySetNavMany.getEntities().get(1).getProperty(PROPERTY_COMP_TWO_PRIM)
+        .getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertEquals("String Property level 3, complex level 1", thirdLevelEntitySetNavMany.getEntities().get(1)
+        .getProperty(PROPERTY_COMP_TWO_PRIM).getComplexValue().get(PROPERTY_STRING).getPrimitiveValue().toValue());
+
+    final ODataEntitySet firstLevelEntitySetNavMany =
+        createResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).asInlineEntitySet().getEntitySet();
+    assertEquals(1, firstLevelEntitySetNavMany.getEntities().size());
+    assertEquals(422, firstLevelEntitySetNavMany.getEntities().get(0).getProperty(PROPERTY_COMP_TWO_PRIM)
+        .getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
+    assertEquals("String Property level 1, complex level 1", firstLevelEntitySetNavMany.getEntities().get(0)
+        .getProperty(PROPERTY_COMP_TWO_PRIM).getComplexValue().get(PROPERTY_STRING).getPrimitiveValue().toValue());
+  }
+  
   @Test
   public void testSimpleDeepInsert() throws EdmPrimitiveTypeException {
     final ODataClient client = getClient();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerResult.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerResult.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerResult.java
new file mode 100644
index 0000000..3f36939
--- /dev/null
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerResult.java
@@ -0,0 +1,69 @@
+/*
+ * 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 WARRANTIES OR 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.olingo.server.api.deserializer;
+
+import java.net.URI;
+import java.util.List;
+
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Parameter;
+import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
+import org.apache.olingo.commons.api.data.Property;
+
+/**
+ * Result type for {@link ODataDeserializer} methods
+ */
+public interface DeserializerResult {
+  /**
+   * Return an entity
+   * @return an {@link Entity} or null
+   */
+  Entity getEntity();
+
+  /**
+   * Returns a entity set
+   * @return an {@link EntitySet} or null
+   */
+  EntitySet getEntityCollection();
+
+  /**
+   * Returns the ExpandOptions for serialized entities
+   * @return an {@link ExpandOption} or null
+   */
+  ExpandOption getExpandTree();
+  
+  /**
+   * Returns the deserialized action-parameters of an {@link Entity} object.
+   * @return a collection {@link Parameter}
+   */
+  List<Parameter> getActionParameter();
+
+  /**
+   * Returns a Property or collections of properties (primitive & complex)
+   * @return {@link Property} or collections of properties (primitive & complex) or null
+   */
+  Property getProperty();
+
+  /**
+   * Returns the entity references from the provided document
+   * @return a collection of entity reference
+   */
+  List<URI> getEntityReferences();
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/ODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/ODataDeserializer.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/ODataDeserializer.java
index 9aabf33..f014ad6 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/ODataDeserializer.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/ODataDeserializer.java
@@ -19,13 +19,9 @@
 package org.apache.olingo.server.api.deserializer;
 
 import java.io.InputStream;
-import java.net.URI;
-import java.util.List;
 
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.data.Parameter;
-import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.edm.EdmAction;
 import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.EdmProperty;
@@ -38,47 +34,48 @@ public interface ODataDeserializer {
   /**
    * Deserializes an entity stream into an {@link Entity} object.
    * Validates: property types, no double properties, correct json types
+   * Returns a deserialized {@link Entity} object and an {@link ExpandOption} object
    * @param stream
    * @param edmEntityType
-   * @return deserialized {@link Entity} object
+   * @return {@link DeserializerResult#getEntity()} and {@link DeserializerResult#getExpandTree()}
    * @throws DeserializerException
    */
-  Entity entity(InputStream stream, EdmEntityType edmEntityType) throws DeserializerException;
+  DeserializerResult entity(InputStream stream, EdmEntityType edmEntityType) throws DeserializerException;
 
   /**
    * Deserializes an entity collection stream into an {@link EntitySet} object.
    * @param stream
    * @param edmEntityType
-   * @return deserialized {@link EntitySet} object
+   * @return {@link DeserializerResult#getEntityCollection()}
    * @throws DeserializerException
    */
-  EntitySet entityCollection(InputStream stream, EdmEntityType edmEntityType) throws DeserializerException;
+  DeserializerResult entityCollection(InputStream stream, EdmEntityType edmEntityType) throws DeserializerException;
 
   /**
    * Deserializes an action-parameters stream into an {@link Entity} object.
    * Validates: parameter types, no double parameters, correct json types.
    * @param stream
    * @param edmAction
-   * @return deserialized list of {@link Parameter} objects
+   * @return {@link DeserializerResult#getActionParameter()}
    * @throws DeserializerException
    */
-  List<Parameter> actionParameters(InputStream stream, EdmAction edmAction) throws DeserializerException;
+  DeserializerResult actionParameters(InputStream stream, EdmAction edmAction) throws DeserializerException;
 
   /**
    * Deserializes the Property or collections of properties (primitive & complex)
    * @param stream
    * @param edmProperty
-   * @return deserialized {@link Property}
+   * @return {@link DeserializerResult#getProperty()}
    * @throws DeserializerException
    */
-  Property property(InputStream stream, EdmProperty edmProperty) throws DeserializerException;
+  DeserializerResult property(InputStream stream, EdmProperty edmProperty) throws DeserializerException;
 
   /**
    * Read entity references from the provided document
    * @param stream
    * @param keys
-   * @return
+   * @return {@link DeserializerResult#getEntityReferences()}}
    * @throws DeserializerException
    */
-  List<URI> entityReferences(InputStream stream) throws DeserializerException;
+  DeserializerResult entityReferences(InputStream stream) throws DeserializerException;
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
index f62c6c7..f2da16e 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
@@ -56,7 +56,7 @@ public class DefaultProcessor implements MetadataProcessor, ServiceDocumentProce
   public void readServiceDocument(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
       final ContentType requestedContentType) throws ODataApplicationException, SerializerException {
     ODataSerializer serializer = odata.createSerializer(ODataFormat.fromContentType(requestedContentType));
-    response.setContent(serializer.serviceDocument(serviceMetadata.getEdm(), null));
+    response.setContent(serializer.serviceDocument(serviceMetadata.getEdm(), null).getContent());
     response.setStatusCode(HttpStatusCode.OK.getStatusCode());
     response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
   }
@@ -65,7 +65,7 @@ public class DefaultProcessor implements MetadataProcessor, ServiceDocumentProce
   public void readMetadata(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
       final ContentType requestedContentType) throws ODataApplicationException, SerializerException {
     ODataSerializer serializer = odata.createSerializer(ODataFormat.fromContentType(requestedContentType));
-    response.setContent(serializer.metadataDocument(serviceMetadata));
+    response.setContent(serializer.metadataDocument(serviceMetadata).getContent());
     response.setStatusCode(HttpStatusCode.OK.getStatusCode());
     response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
   }
@@ -75,7 +75,7 @@ public class DefaultProcessor implements MetadataProcessor, ServiceDocumentProce
                            ContentType requestedContentType) {
     try {
       ODataSerializer serializer = odata.createSerializer(ODataFormat.fromContentType(requestedContentType));
-      response.setContent(serializer.error(serverError));
+      response.setContent(serializer.error(serverError).getContent());
       response.setStatusCode(serverError.getStatusCode());
       response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
     } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java
index 55377ce..01db1a4 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java
@@ -41,20 +41,20 @@ public interface ODataSerializer {
    * @param edm         the Entity Data Model
    * @param serviceRoot the service-root URI of this OData service
    */
-  InputStream serviceDocument(Edm edm, String serviceRoot) throws SerializerException;
+  SerializerResult serviceDocument(Edm edm, String serviceRoot) throws SerializerException;
 
   /**
    * Writes the metadata document into an InputStream.
    * @param serviceMetadata the metadata information for the service
    */
-  InputStream metadataDocument(ServiceMetadata serviceMetadata) throws SerializerException;
+  SerializerResult metadataDocument(ServiceMetadata serviceMetadata) throws SerializerException;
 
   /**
    * Writes an ODataError into an InputStream.
    * @param error the main error
    * @return inputStream containing the OData-formatted error
    */
-  InputStream error(ODataServerError error) throws SerializerException;
+  SerializerResult error(ODataServerError error) throws SerializerException;
 
   /**
    * Writes entity-collection data into an InputStream.
@@ -63,7 +63,7 @@ public interface ODataSerializer {
    * @param entitySet  the data of the entity set
    * @param options    options for the serializer
    */
-  InputStream entityCollection(ServiceMetadata metadata, EdmEntityType entityType,
+  SerializerResult entityCollection(ServiceMetadata metadata, EdmEntityType entityType,
       EntitySet entitySet, EntityCollectionSerializerOptions options) throws SerializerException;
 
   /**
@@ -73,7 +73,7 @@ public interface ODataSerializer {
    * @param entity     the data of the entity
    * @param options    options for the serializer
    */
-  InputStream entity(ServiceMetadata metadata, EdmEntityType entityType, Entity entity,
+  SerializerResult entity(ServiceMetadata metadata, EdmEntityType entityType, Entity entity,
       EntitySerializerOptions options) throws SerializerException;
 
   /**
@@ -82,7 +82,7 @@ public interface ODataSerializer {
    * @param property property value
    * @param options options for the serializer
    */
-  InputStream primitive(EdmPrimitiveType type, Property property, PrimitiveSerializerOptions options)
+  SerializerResult primitive(EdmPrimitiveType type, Property property, PrimitiveSerializerOptions options)
       throws SerializerException;
 
   /**
@@ -92,7 +92,7 @@ public interface ODataSerializer {
    * @param property property value
    * @param options options for the serializer
    */
-  InputStream complex(ServiceMetadata metadata, EdmComplexType type, Property property,
+  SerializerResult complex(ServiceMetadata metadata, EdmComplexType type, Property property,
       ComplexSerializerOptions options) throws SerializerException;
 
   /**
@@ -101,7 +101,7 @@ public interface ODataSerializer {
    * @param property property value
    * @param options options for the serializer
    */
-  InputStream primitiveCollection(EdmPrimitiveType type, Property property, PrimitiveSerializerOptions options)
+  SerializerResult primitiveCollection(EdmPrimitiveType type, Property property, PrimitiveSerializerOptions options)
       throws SerializerException;
 
   /**
@@ -111,6 +111,6 @@ public interface ODataSerializer {
    * @param property property value
    * @param options options for the serializer
    */
-  InputStream complexCollection(ServiceMetadata metadata, EdmComplexType type, Property property,
+  SerializerResult complexCollection(ServiceMetadata metadata, EdmComplexType type, Property property,
       ComplexSerializerOptions options) throws SerializerException;
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/SerializerResult.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/SerializerResult.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/SerializerResult.java
new file mode 100644
index 0000000..5249bb4
--- /dev/null
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/SerializerResult.java
@@ -0,0 +1,32 @@
+/*
+ * 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 WARRANTIES OR 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.olingo.server.api.serializer;
+
+import java.io.InputStream;
+
+/**
+* Result type for {@link ODataSerializer} methods
+ */
+public interface SerializerResult {
+  /**
+   * Returns the serialized content
+   * @return  serialized content
+   */
+  InputStream getContent();
+} 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ErrorHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ErrorHandler.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ErrorHandler.java
index 199c62d..b83d383 100644
--- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ErrorHandler.java
+++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/ErrorHandler.java
@@ -108,7 +108,7 @@ public class ErrorHandler {
     try {
       ODataSerializer serializer = this.odata.createSerializer(ODataFormat
           .fromContentType(requestedContentType));
-      response.setContent(serializer.error(serverError));
+      response.setContent(serializer.error(serverError).getContent());
       response.setStatusCode(serverError.getStatusCode());
       response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
     } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/DataRequest.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/DataRequest.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/DataRequest.java
index 32bf26a..cebaf64 100644
--- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/DataRequest.java
+++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/requests/DataRequest.java
@@ -315,7 +315,7 @@ public class DataRequest extends ServiceRequest {
     private Entity getEntityFromClient() throws DeserializerException {
       ODataDeserializer deserializer = odata.createDeserializer(ODataFormat
           .fromContentType(getRequestContentType()));
-      return deserializer.entity(getODataRequest().getBody(), getEntitySet().getEntityType());
+      return deserializer.entity(getODataRequest().getBody(), getEntitySet().getEntityType()).getEntity();
     }
 
     @Override
@@ -431,7 +431,7 @@ public class DataRequest extends ServiceRequest {
     private List<URI> getPayload() throws DeserializerException {
       ODataDeserializer deserializer = odata.createDeserializer(ODataFormat
           .fromContentType(getRequestContentType()));
-      return deserializer.entityReferences(getODataRequest().getBody());
+      return deserializer.entityReferences(getODataRequest().getBody()).getEntityReferences();
     }
 
     @Override
@@ -664,7 +664,7 @@ public class DataRequest extends ServiceRequest {
     // for now it is responsibility of the user
     ODataDeserializer deserializer = odata.createDeserializer(ODataFormat
         .fromContentType(getRequestContentType()));
-    return deserializer.property(getODataRequest().getBody(), edmProperty);
+    return deserializer.property(getODataRequest().getBody(), edmProperty).getProperty();
   }
 
   static ContextURL.Builder buildEntitySetContextURL(UriHelper helper,

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/EntityResponse.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/EntityResponse.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/EntityResponse.java
index fd29bbd..e90681d 100644
--- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/EntityResponse.java
+++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/EntityResponse.java
@@ -82,7 +82,7 @@ public class EntityResponse extends ServiceResponse {
     }
 
     // write the entity to response
-    this.response.setContent(this.serializer.entity(this.metadata, entityType, entity, this.options));
+    this.response.setContent(this.serializer.entity(this.metadata, entityType, entity, this.options).getContent());
     writeOK(this.responseContentType.toContentTypeString());
     close();
   }
@@ -107,7 +107,7 @@ public class EntityResponse extends ServiceResponse {
     }
 
     // return the content of the created entity
-    this.response.setContent(this.serializer.entity(this.metadata, entityType, entity, this.options));
+    this.response.setContent(this.serializer.entity(this.metadata, entityType, entity, this.options).getContent());
     writeCreated(false);
     writeHeader(HttpHeader.LOCATION, locationHeader);
     writeHeader("Preference-Applied", "return=representation"); //$NON-NLS-1$ //$NON-NLS-2$

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/EntitySetResponse.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/EntitySetResponse.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/EntitySetResponse.java
index 40276d2..c70854b 100644
--- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/EntitySetResponse.java
+++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/EntitySetResponse.java
@@ -69,7 +69,8 @@ public class EntitySetResponse extends ServiceResponse {
     }
 
     // write the whole collection to response
-    this.response.setContent(this.serializer.entityCollection(metadata, entityType, entitySet, this.options));
+    this.response.setContent(this.serializer.entityCollection(metadata, entityType, entitySet, this.options)
+                                            .getContent());
     writeOK(this.responseContentType.toContentTypeString());
     close();
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/MetadataResponse.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/MetadataResponse.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/MetadataResponse.java
index 055c0b0..b325421 100644
--- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/MetadataResponse.java
+++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/MetadataResponse.java
@@ -49,7 +49,7 @@ public class MetadataResponse extends ServiceResponse {
 
   public void writeMetadata()throws ODataTranslatedException {
     assert (!isClosed());
-    this.response.setContent(this.serializer.metadataDocument(this.metadata));
+    this.response.setContent(this.serializer.metadataDocument(this.metadata).getContent());
     writeOK(this.responseContentType.toContentTypeString());
     close();
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/PropertyResponse.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/PropertyResponse.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/PropertyResponse.java
index e6b951d..79ac90d 100644
--- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/PropertyResponse.java
+++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/PropertyResponse.java
@@ -106,10 +106,10 @@ public class PropertyResponse extends ServiceResponse {
       throws SerializerException {
     if (this.collection) {
       this.response.setContent(this.serializer.complexCollection(this.metadata, type, property,
-          this.complexOptions));
+          this.complexOptions).getContent());
     } else {
       this.response.setContent(this.serializer.complex(this.metadata, type, property,
-          this.complexOptions));
+          this.complexOptions).getContent());
     }
     writeOK(this.responseContentType.toContentTypeString());
     close();
@@ -118,9 +118,9 @@ public class PropertyResponse extends ServiceResponse {
   private void writePrimitiveProperty(EdmPrimitiveType type, Property property)
       throws SerializerException {
     if(this.collection) {
-      this.response.setContent(this.serializer.primitiveCollection(type, property, this.primitiveOptions));
+      this.response.setContent(this.serializer.primitiveCollection(type, property, this.primitiveOptions).getContent());
     } else {
-      this.response.setContent(this.serializer.primitive(type, property, this.primitiveOptions));
+      this.response.setContent(this.serializer.primitive(type, property, this.primitiveOptions).getContent());
     }
     writeOK(this.responseContentType.toContentTypeString());
     close();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/ServiceDocumentResponse.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/ServiceDocumentResponse.java b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/ServiceDocumentResponse.java
index 86c420b..8b77684 100644
--- a/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/ServiceDocumentResponse.java
+++ b/lib/server-core-ext/src/main/java/org/apache/olingo/server/core/responses/ServiceDocumentResponse.java
@@ -50,7 +50,7 @@ public class ServiceDocumentResponse extends ServiceResponse {
   public void writeServiceDocument(String serviceRoot)
       throws ODataTranslatedException {
     assert (!isClosed());
-    this.response.setContent(this.serializer.serviceDocument(this.metadata.getEdm(), serviceRoot));
+    this.response.setContent(this.serializer.serviceDocument(this.metadata.getEdm(), serviceRoot).getContent());
     writeOK(this.responseContentType.toContentTypeString());
     close();
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinDataModel.java
----------------------------------------------------------------------
diff --git a/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinDataModel.java b/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinDataModel.java
index 904f4d8..055f073 100644
--- a/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinDataModel.java
+++ b/lib/server-core-ext/src/test/java/org/apache/olingo/server/example/TripPinDataModel.java
@@ -124,7 +124,7 @@ public class TripPinDataModel {
       ODataJsonDeserializer deserializer = new ODataJsonDeserializer();
 
       EntitySet set = deserializer.entityCollection(new FileInputStream(new File(
-          "src/test/resources/" + entitySetName.toLowerCase() + ".json")), type);
+          "src/test/resources/" + entitySetName.toLowerCase() + ".json")), type).getEntityCollection();
       // TODO: the count needs to be part of deserializer
       set.setCount(set.getEntities().size());
       for (Entity entity : set.getEntities()) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/DeserializerResultImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/DeserializerResultImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/DeserializerResultImpl.java
new file mode 100644
index 0000000..84d64ea
--- /dev/null
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/DeserializerResultImpl.java
@@ -0,0 +1,126 @@
+/*
+ * 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 WARRANTIES OR 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.olingo.server.core.deserializer;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Parameter;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.server.api.deserializer.DeserializerResult;
+import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
+
+public class DeserializerResultImpl implements DeserializerResult {
+  private Entity entity;
+  private EntitySet entitySet;
+  private ExpandOption expandOption;
+  private Property property;
+  private List<Parameter> actionParametes;
+  private List<URI> entityReferences;
+  
+  private DeserializerResultImpl() {}
+
+  @Override
+  public Entity getEntity() {
+    return entity;
+  }
+
+  @Override
+  public EntitySet getEntityCollection() {
+    return entitySet;
+  }
+
+  @Override
+  public ExpandOption getExpandTree() {
+    return expandOption;
+  }
+  
+  @Override
+  public List<Parameter> getActionParameter() {
+    return actionParametes;
+  }
+
+  @Override
+  public Property getProperty() {
+    return property;
+  }
+
+  @Override
+  public List<URI> getEntityReferences() {
+    return entityReferences;
+  }
+  
+  public static DeserializerResultBuilder with() {
+    return new DeserializerResultBuilder();
+  }
+  
+  public static class DeserializerResultBuilder {
+    private Entity entity;
+    private EntitySet entitySet;
+    private ExpandOption expandOption;
+    private Property property;
+    private List<Parameter> actionParametes;
+    private List<URI> entityReferences;
+    
+    public DeserializerResult build() {
+      DeserializerResultImpl result = new DeserializerResultImpl();
+      result.entity = entity;
+      result.entitySet = entitySet;
+      result.expandOption = expandOption;
+      result.property = property;
+      result.entityReferences = (entityReferences == null) ? new ArrayList<URI>() : entityReferences;
+      result.actionParametes = (actionParametes == null) ? new ArrayList<Parameter>() : actionParametes;
+      
+      return result;
+    }
+
+    public DeserializerResultBuilder entity(final Entity entity) {
+      this.entity = entity;
+      return this;
+    }
+
+    public DeserializerResultBuilder entityCollection(final EntitySet entitySet) {
+      this.entitySet = entitySet;
+      return this;
+    }
+
+    public DeserializerResultBuilder expandOption(final ExpandOption expandOption) {
+      this.expandOption = expandOption;
+      return this;
+    }
+    
+    public DeserializerResultBuilder property(final Property property) {
+      this.property = property;
+      return this;
+    }
+    
+    public DeserializerResultBuilder entityReferences(final List<URI> entityReferences) {
+      this.entityReferences = entityReferences;
+      return this;
+    }
+    
+    public DeserializerResultBuilder actionParameters(final List<Parameter> actionParameters) {
+      this.actionParametes = actionParameters;
+      return this;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/helper/ExpandTreeBuilder.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/helper/ExpandTreeBuilder.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/helper/ExpandTreeBuilder.java
new file mode 100644
index 0000000..5e279bd
--- /dev/null
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/helper/ExpandTreeBuilder.java
@@ -0,0 +1,40 @@
+/*
+ * 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 WARRANTIES OR 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.olingo.server.core.deserializer.helper;
+ 
+import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
+import org.apache.olingo.server.core.uri.UriInfoImpl;
+import org.apache.olingo.server.core.uri.UriResourceNavigationPropertyImpl;
+import org.apache.olingo.server.core.uri.queryoption.ExpandItemImpl;
+ 
+public abstract class ExpandTreeBuilder {
+  public abstract ExpandTreeBuilder expand(EdmNavigationProperty edmNavigationProperty);
+   
+  protected ExpandItemImpl buildExpandItem(final EdmNavigationProperty edmNavigationProperty) {
+    final ExpandItemImpl expandItem = new ExpandItemImpl();
+    final UriInfoImpl uriInfo = new UriInfoImpl();
+    final UriResourceNavigationPropertyImpl resourceNavigation = new UriResourceNavigationPropertyImpl();
+    
+    resourceNavigation.setNavigationProperty(edmNavigationProperty);
+    uriInfo.addResourcePart(resourceNavigation);
+    expandItem.setResourcePath(uriInfo);
+     
+    return expandItem;
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/helper/ExpandTreeBuilderImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/helper/ExpandTreeBuilderImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/helper/ExpandTreeBuilderImpl.java
new file mode 100644
index 0000000..4161af1
--- /dev/null
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/helper/ExpandTreeBuilderImpl.java
@@ -0,0 +1,67 @@
+/*
+ * 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 WARRANTIES OR 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.olingo.server.core.deserializer.helper;
+ 
+import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
+import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
+import org.apache.olingo.server.core.uri.queryoption.ExpandItemImpl;
+import org.apache.olingo.server.core.uri.queryoption.ExpandOptionImpl;
+ 
+public class ExpandTreeBuilderImpl extends ExpandTreeBuilder {
+   
+  private ExpandOptionImpl expandOption = null;
+   
+  @Override
+  public ExpandTreeBuilder expand(EdmNavigationProperty edmNavigationProperty) {
+    ExpandItemImpl expandItem = buildExpandItem(edmNavigationProperty);
+ 
+    if(expandOption == null) {
+      expandOption = new ExpandOptionImpl();
+    }
+    expandOption.addExpandItem(expandItem);
+     
+    return new ExpandTreeBuilderInner(expandItem);
+  }
+ 
+  public ExpandOption build() {
+    return expandOption;
+  }
+   
+  private class ExpandTreeBuilderInner extends ExpandTreeBuilder {
+    private ExpandItemImpl parent;
+     
+    public ExpandTreeBuilderInner(ExpandItemImpl expandItem) {
+      parent = expandItem;
+    }
+     
+    @Override
+    public ExpandTreeBuilder expand(EdmNavigationProperty edmNavigationProperty) {
+      if(parent.getExpandOption() == null) {
+        final ExpandOptionImpl expandOption = new ExpandOptionImpl();
+        parent.setSystemQueryOption(expandOption);
+      }
+       
+      final ExpandItemImpl expandItem = buildExpandItem(edmNavigationProperty);
+      ((ExpandOptionImpl)parent.getExpandOption()).addExpandItem(expandItem);
+       
+      return new ExpandTreeBuilderInner(expandItem);
+    }
+     
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
index 8d2701e..538e95c 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java
@@ -57,7 +57,11 @@ import org.apache.olingo.commons.core.data.LinkImpl;
 import org.apache.olingo.commons.core.data.ParameterImpl;
 import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.server.api.deserializer.DeserializerException;
+import org.apache.olingo.server.api.deserializer.DeserializerResult;
 import org.apache.olingo.server.api.deserializer.ODataDeserializer;
+import org.apache.olingo.server.core.deserializer.DeserializerResultImpl;
+import org.apache.olingo.server.core.deserializer.helper.ExpandTreeBuilder;
+import org.apache.olingo.server.core.deserializer.helper.ExpandTreeBuilderImpl;
 
 import com.fasterxml.jackson.core.JsonFactory;
 import com.fasterxml.jackson.core.JsonParseException;
@@ -76,11 +80,13 @@ public class ODataJsonDeserializer implements ODataDeserializer {
   private static final String ODATA_CONTROL_INFORMATION_PREFIX = "@odata.";
 
   @Override
-  public EntitySet entityCollection(InputStream stream, EdmEntityType edmEntityType) throws DeserializerException {
+  public DeserializerResult entityCollection(InputStream stream, EdmEntityType edmEntityType) 
+      throws DeserializerException {
     try {
       final ObjectNode tree = parseJsonTree(stream);
-
-      return consumeEntitySetNode(edmEntityType, tree);
+      
+      return DeserializerResultImpl.with().entityCollection(consumeEntitySetNode(edmEntityType, tree, null))
+                                          .build();
     } catch (JsonParseException e) {
       throw new DeserializerException("An JsonParseException occurred", e,
           DeserializerException.MessageKeys.JSON_SYNTAX_EXCEPTION);
@@ -92,8 +98,8 @@ public class ODataJsonDeserializer implements ODataDeserializer {
     }
   }
 
-  private EntitySet consumeEntitySetNode(EdmEntityType edmEntityType, final ObjectNode tree)
-      throws DeserializerException {
+  private EntitySet consumeEntitySetNode(EdmEntityType edmEntityType, final ObjectNode tree, 
+      final ExpandTreeBuilder expandBuilder) throws DeserializerException {
     EntitySetImpl entitySet = new EntitySetImpl();
 
     // Consume entities
@@ -104,7 +110,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
             DeserializerException.MessageKeys.VALUE_TAG_MUST_BE_AN_ARRAY);
       }
 
-      entitySet.getEntities().addAll(consumeEntitySetArray(edmEntityType, jsonNode));
+      entitySet.getEntities().addAll(consumeEntitySetArray(edmEntityType, jsonNode, expandBuilder));
       tree.remove(Constants.VALUE);
     } else {
       throw new DeserializerException("Could not find value array.",
@@ -131,8 +137,8 @@ public class ODataJsonDeserializer implements ODataDeserializer {
     return entitySet;
   }
 
-  private List<Entity> consumeEntitySetArray(EdmEntityType edmEntityType, JsonNode jsonNode)
-      throws DeserializerException {
+  private List<Entity> consumeEntitySetArray(EdmEntityType edmEntityType, JsonNode jsonNode, 
+      final ExpandTreeBuilder expandBuilder) throws DeserializerException {
     List<Entity> entities = new ArrayList<Entity>();
     for (JsonNode arrayElement : jsonNode) {
       if (arrayElement.isArray() || arrayElement.isValueNode()) {
@@ -140,17 +146,20 @@ public class ODataJsonDeserializer implements ODataDeserializer {
             DeserializerException.MessageKeys.INVALID_ENTITY);
       }
 
-      entities.add(consumeEntityNode(edmEntityType, (ObjectNode) arrayElement));
+      entities.add(consumeEntityNode(edmEntityType, (ObjectNode) arrayElement, expandBuilder));
     }
     return entities;
   }
 
   @Override
-  public Entity entity(InputStream stream, EdmEntityType edmEntityType) throws DeserializerException {
+  public DeserializerResult entity(InputStream stream, EdmEntityType edmEntityType) throws DeserializerException {
     try {
       final ObjectNode tree = parseJsonTree(stream);
-
-      return consumeEntityNode(edmEntityType, tree);
+      final ExpandTreeBuilderImpl expandBuilder = new ExpandTreeBuilderImpl();
+      
+      return DeserializerResultImpl.with().entity(consumeEntityNode(edmEntityType, tree, expandBuilder))
+                                          .expandOption(expandBuilder.build())
+                                          .build();
 
     } catch (JsonParseException e) {
       throw new DeserializerException("An JsonParseException occurred", e,
@@ -164,7 +173,8 @@ public class ODataJsonDeserializer implements ODataDeserializer {
 
   }
 
-  private Entity consumeEntityNode(EdmEntityType edmEntityType, final ObjectNode tree) throws DeserializerException {
+  private Entity consumeEntityNode(EdmEntityType edmEntityType, final ObjectNode tree, 
+      final ExpandTreeBuilder expandBuilder) throws DeserializerException {
     EntityImpl entity = new EntityImpl();
     entity.setType(edmEntityType.getFullQualifiedName().getFullQualifiedNameAsString());
 
@@ -172,7 +182,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
     consumeEntityProperties(edmEntityType, tree, entity);
 
     // Check and consume all expanded Navigation Properties
-    consumeExpandedNavigationProperties(edmEntityType, tree, entity);
+    consumeExpandedNavigationProperties(edmEntityType, tree, entity, expandBuilder);
 
     // consume remaining json node fields
     consumeRemainingJsonNodeFields(edmEntityType, tree, entity);
@@ -183,13 +193,14 @@ public class ODataJsonDeserializer implements ODataDeserializer {
   }
 
   @Override
-  public List<Parameter> actionParameters(InputStream stream, final EdmAction edmAction) throws DeserializerException {
+  public DeserializerResult actionParameters(InputStream stream, final EdmAction edmAction) 
+      throws DeserializerException {
     try {
       ObjectNode tree = parseJsonTree(stream);
       List<Parameter> parameters = new ArrayList<Parameter>();
       consumeParameters(edmAction, tree, parameters);
       assertJsonNodeIsEmpty(tree);
-      return parameters;
+      return DeserializerResultImpl.with().actionParameters(parameters).build();
 
     } catch (final JsonParseException e) {
       throw new DeserializerException("An JsonParseException occurred", e,
@@ -203,7 +214,8 @@ public class ODataJsonDeserializer implements ODataDeserializer {
     }
   }
 
-  private ObjectNode parseJsonTree(InputStream stream) throws IOException, JsonParseException, JsonProcessingException {
+  private ObjectNode parseJsonTree(InputStream stream) 
+      throws IOException, JsonParseException, JsonProcessingException {
     ObjectMapper objectMapper = new ObjectMapper();
     objectMapper.configure(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY, true);
     JsonParser parser = new JsonFactory(objectMapper).createParser(stream);
@@ -314,7 +326,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
   }
 
   private void consumeExpandedNavigationProperties(final EdmEntityType edmEntityType, final ObjectNode node,
-      final EntityImpl entity) throws DeserializerException {
+      final EntityImpl entity, final ExpandTreeBuilder expandBuilder) throws DeserializerException {
     List<String> navigationPropertyNames = edmEntityType.getNavigationPropertyNames();
     for (String navigationPropertyName : navigationPropertyNames) {
       // read expanded navigation property
@@ -329,16 +341,20 @@ public class ODataJsonDeserializer implements ODataDeserializer {
 
         LinkImpl link = new LinkImpl();
         link.setTitle(navigationPropertyName);
+        final ExpandTreeBuilder childExpandBuilder = (expandBuilder != null) ? 
+                                                                expandBuilder.expand(edmNavigationProperty) : null;
         if (jsonNode.isArray() && edmNavigationProperty.isCollection()) {
           link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
           EntitySetImpl inlineEntitySet = new EntitySetImpl();
-          inlineEntitySet.getEntities().addAll(consumeEntitySetArray(edmNavigationProperty.getType(), jsonNode));
+          inlineEntitySet.getEntities().addAll(consumeEntitySetArray(edmNavigationProperty.getType(), jsonNode, 
+                                                                     childExpandBuilder));
           link.setInlineEntitySet(inlineEntitySet);
         } else if (!jsonNode.isArray() && (!jsonNode.isValueNode() || jsonNode.isNull())
             && !edmNavigationProperty.isCollection()) {
           link.setType(ODataLinkType.ENTITY_NAVIGATION.toString());
           if (!jsonNode.isNull()) {
-            Entity inlineEntity = consumeEntityNode(edmNavigationProperty.getType(), (ObjectNode) jsonNode);
+            Entity inlineEntity = consumeEntityNode(edmNavigationProperty.getType(), (ObjectNode) jsonNode, 
+                                                    childExpandBuilder);
             link.setInlineEntity(inlineEntity);
           }
         } else {
@@ -732,7 +748,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
   }
 
   @Override
-  public Property property(InputStream stream, EdmProperty edmProperty)
+  public DeserializerResult property(InputStream stream, EdmProperty edmProperty)
       throws DeserializerException {
     try {
       ObjectMapper objectMapper = new ObjectMapper();
@@ -756,7 +772,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
             edmProperty.isUnicode(), edmProperty.getMapping(),
             tree);
       }
-      return property;
+      return DeserializerResultImpl.with().property(property).build();
     } catch (JsonParseException e) {
       throw new DeserializerException("An JsonParseException occurred", e,
           DeserializerException.MessageKeys.JSON_SYNTAX_EXCEPTION);
@@ -768,7 +784,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
     }
   }
 
-  public List<URI> entityReferences(InputStream stream) throws DeserializerException {
+  public DeserializerResult entityReferences(InputStream stream) throws DeserializerException {
     try {
       ArrayList<URI> parsedValues = new ArrayList<URI>();
       ObjectMapper objectMapper = new ObjectMapper();
@@ -789,10 +805,10 @@ public class ODataJsonDeserializer implements ODataDeserializer {
         }
         tree.remove(Constants.VALUE);
         // if this is value there can be only one property
-        return parsedValues;
+        return DeserializerResultImpl.with().entityReferences(parsedValues).build();
       }
       parsedValues.add(new URI(tree.get(key).asText()));
-      return parsedValues;
+      return DeserializerResultImpl.with().entityReferences(parsedValues).build();
     } catch (JsonParseException e) {
       throw new DeserializerException("An JsonParseException occurred", e,
           DeserializerException.MessageKeys.JSON_SYNTAX_EXCEPTION);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/SerializerResultImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/SerializerResultImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/SerializerResultImpl.java
new file mode 100644
index 0000000..b7b16a2
--- /dev/null
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/SerializerResultImpl.java
@@ -0,0 +1,53 @@
+/*
+ * 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 WARRANTIES OR 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.olingo.server.core.serializer;
+
+import java.io.InputStream;
+
+import org.apache.olingo.server.api.serializer.SerializerResult;
+
+public class SerializerResultImpl implements SerializerResult {
+  private InputStream content;
+  
+  @Override
+  public InputStream getContent() {
+    return content;
+  }
+  
+  public static SerializerResultBuilder with() {
+    return new SerializerResultBuilder();
+  }
+  
+  public static class SerializerResultBuilder {
+    private InputStream content;
+    
+    public SerializerResultBuilder content(final InputStream input) {
+      content = input;
+      
+      return this;
+    }
+    
+    public SerializerResult build() {
+      SerializerResultImpl result = new SerializerResultImpl();
+      result.content = content;
+      
+      return result;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
index a7ce16b..c9944c7 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
@@ -19,7 +19,6 @@
 package org.apache.olingo.server.core.serializer.json;
 
 import java.io.IOException;
-import java.io.InputStream;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
@@ -52,9 +51,11 @@ import org.apache.olingo.server.api.serializer.EntitySerializerOptions;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.api.serializer.PrimitiveSerializerOptions;
 import org.apache.olingo.server.api.serializer.SerializerException;
+import org.apache.olingo.server.api.serializer.SerializerResult;
 import org.apache.olingo.server.api.uri.queryoption.ExpandItem;
 import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
 import org.apache.olingo.server.api.uri.queryoption.SelectOption;
+import org.apache.olingo.server.core.serializer.SerializerResultImpl;
 import org.apache.olingo.server.core.serializer.utils.CircleStreamBuffer;
 import org.apache.olingo.server.core.serializer.utils.ContextURLBuilder;
 import org.apache.olingo.server.core.serializer.utils.ExpandSelectHelper;
@@ -76,7 +77,7 @@ public class ODataJsonSerializer implements ODataSerializer {
   }
 
   @Override
-  public InputStream serviceDocument(final Edm edm, final String serviceRoot) throws SerializerException {
+  public SerializerResult serviceDocument(final Edm edm, final String serviceRoot) throws SerializerException {
     CircleStreamBuffer buffer;
     JsonGenerator gen = null;
 
@@ -89,7 +90,7 @@ public class ODataJsonSerializer implements ODataSerializer {
 
       gen.close();
 
-      return buffer.getInputStream();
+      return SerializerResultImpl.with().content(buffer.getInputStream()).build();
 
     } catch (final IOException e) {
       log.error(e.getMessage(), e);
@@ -108,13 +109,13 @@ public class ODataJsonSerializer implements ODataSerializer {
   }
 
   @Override
-  public InputStream metadataDocument(final ServiceMetadata serviceMetadata) throws SerializerException {
+  public SerializerResult metadataDocument(final ServiceMetadata serviceMetadata) throws SerializerException {
     throw new SerializerException("Metadata in JSON format not supported!",
         SerializerException.MessageKeys.JSON_METADATA);
   }
 
   @Override
-  public InputStream error(final ODataServerError error) throws SerializerException {
+  public SerializerResult error(final ODataServerError error) throws SerializerException {
     CircleStreamBuffer buffer = new CircleStreamBuffer();
     try {
       JsonGenerator json = new JsonFactory().createGenerator(buffer.getOutputStream());
@@ -124,11 +125,11 @@ public class ODataJsonSerializer implements ODataSerializer {
       throw new SerializerException("An I/O exception occurred.", e,
           SerializerException.MessageKeys.IO_EXCEPTION);
     }
-    return buffer.getInputStream();
+    return SerializerResultImpl.with().content(buffer.getInputStream()).build();
   }
 
   @Override
-  public InputStream entityCollection(final ServiceMetadata metadata,
+  public SerializerResult entityCollection(final ServiceMetadata metadata,
       final EdmEntityType entityType, final EntitySet entitySet,
       final EntityCollectionSerializerOptions options) throws SerializerException {
     CircleStreamBuffer buffer = new CircleStreamBuffer();
@@ -161,11 +162,11 @@ public class ODataJsonSerializer implements ODataSerializer {
       throw new SerializerException("An I/O exception occurred.", e,
           SerializerException.MessageKeys.IO_EXCEPTION);
     }
-    return buffer.getInputStream();
+    return SerializerResultImpl.with().content(buffer.getInputStream()).build();
   }
 
   @Override
-  public InputStream entity(final ServiceMetadata metadata, final EdmEntityType entityType,
+  public SerializerResult entity(final ServiceMetadata metadata, final EdmEntityType entityType,
       final Entity entity, final EntitySerializerOptions options) throws SerializerException {
     final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL());
     CircleStreamBuffer buffer = new CircleStreamBuffer();
@@ -180,7 +181,7 @@ public class ODataJsonSerializer implements ODataSerializer {
       throw new SerializerException("An I/O exception occurred.", e,
           SerializerException.MessageKeys.IO_EXCEPTION);
     }
-    return buffer.getInputStream();
+    return SerializerResultImpl.with().content(buffer.getInputStream()).build();
   }
 
   private ContextURL checkContextURL(final ContextURL contextURL) throws SerializerException {
@@ -515,7 +516,7 @@ public class ODataJsonSerializer implements ODataSerializer {
   }
 
   @Override
-  public InputStream primitive(final EdmPrimitiveType type, final Property property,
+  public SerializerResult primitive(final EdmPrimitiveType type, final Property property,
       final PrimitiveSerializerOptions options) throws SerializerException {
     final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL());
     CircleStreamBuffer buffer = new CircleStreamBuffer();
@@ -544,11 +545,11 @@ public class ODataJsonSerializer implements ODataSerializer {
           SerializerException.MessageKeys.WRONG_PROPERTY_VALUE,
           property.getName(), property.getValue().toString());
     }
-    return buffer.getInputStream();
+    return SerializerResultImpl.with().content(buffer.getInputStream()).build();
   }
 
   @Override
-  public InputStream complex(final ServiceMetadata metadata, final EdmComplexType type,
+  public SerializerResult complex(final ServiceMetadata metadata, final EdmComplexType type,
       final Property property, final ComplexSerializerOptions options) throws SerializerException {
     final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL());
     CircleStreamBuffer buffer = new CircleStreamBuffer();
@@ -575,11 +576,11 @@ public class ODataJsonSerializer implements ODataSerializer {
       throw new SerializerException("An I/O exception occurred.", e,
           SerializerException.MessageKeys.IO_EXCEPTION);
     }
-    return buffer.getInputStream();
+    return SerializerResultImpl.with().content(buffer.getInputStream()).build();
   }
 
   @Override
-  public InputStream primitiveCollection(final EdmPrimitiveType type, final Property property,
+  public SerializerResult primitiveCollection(final EdmPrimitiveType type, final Property property,
       final PrimitiveSerializerOptions options) throws SerializerException {
     final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL());
     CircleStreamBuffer buffer = new CircleStreamBuffer();
@@ -604,11 +605,11 @@ public class ODataJsonSerializer implements ODataSerializer {
           SerializerException.MessageKeys.WRONG_PROPERTY_VALUE,
           property.getName(), property.getValue().toString());
     }
-    return buffer.getInputStream();
+    return SerializerResultImpl.with().content(buffer.getInputStream()).build();
   }
 
   @Override
-  public InputStream complexCollection(final ServiceMetadata metadata, final EdmComplexType type,
+  public SerializerResult complexCollection(final ServiceMetadata metadata, final EdmComplexType type,
       final Property property, final ComplexSerializerOptions options) throws SerializerException {
     final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL());
     CircleStreamBuffer buffer = new CircleStreamBuffer();
@@ -630,6 +631,6 @@ public class ODataJsonSerializer implements ODataSerializer {
           SerializerException.MessageKeys.WRONG_PROPERTY_VALUE,
           property.getName(), property.getValue().toString());
     }
-    return buffer.getInputStream();
+    return SerializerResultImpl.with().content(buffer.getInputStream()).build();
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializerImpl.java
index 34756c1..6143727 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializerImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializerImpl.java
@@ -18,8 +18,6 @@
  */
 package org.apache.olingo.server.core.serializer.xml;
 
-import java.io.InputStream;
-
 import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
@@ -39,6 +37,8 @@ import org.apache.olingo.server.api.serializer.EntitySerializerOptions;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.api.serializer.PrimitiveSerializerOptions;
 import org.apache.olingo.server.api.serializer.SerializerException;
+import org.apache.olingo.server.api.serializer.SerializerResult;
+import org.apache.olingo.server.core.serializer.SerializerResultImpl;
 import org.apache.olingo.server.core.serializer.utils.CircleStreamBuffer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -51,13 +51,13 @@ public class ODataXmlSerializerImpl implements ODataSerializer {
   private static final Logger log = LoggerFactory.getLogger(ODataXmlSerializerImpl.class);
 
   @Override
-  public InputStream serviceDocument(final Edm edm, final String serviceRoot) throws SerializerException {
+  public SerializerResultImpl serviceDocument(final Edm edm, final String serviceRoot) throws SerializerException {
     throw new SerializerException("Service Document not implemented for XML format",
         SerializerException.MessageKeys.NOT_IMPLEMENTED);
   }
 
   @Override
-  public InputStream metadataDocument(final ServiceMetadata serviceMetadata) throws SerializerException {
+  public SerializerResult metadataDocument(final ServiceMetadata serviceMetadata) throws SerializerException {
     CircleStreamBuffer buffer;
     XMLStreamWriter xmlStreamWriter = null;
 
@@ -69,7 +69,7 @@ public class ODataXmlSerializerImpl implements ODataSerializer {
       xmlStreamWriter.flush();
       xmlStreamWriter.close();
 
-      return buffer.getInputStream();
+      return SerializerResultImpl.with().content(buffer.getInputStream()).build();
     } catch (final XMLStreamException e) {
       log.error(e.getMessage(), e);
       throw new SerializerException("An I/O exception occurred.", e,
@@ -87,14 +87,14 @@ public class ODataXmlSerializerImpl implements ODataSerializer {
   }
 
   @Override
-  public InputStream entity(final ServiceMetadata metadata, final EdmEntityType entityType,
+  public SerializerResult entity(final ServiceMetadata metadata, final EdmEntityType entityType,
       final Entity entity, final EntitySerializerOptions options) throws SerializerException {
     throw new SerializerException("Entity serialization not implemented for XML format",
         SerializerException.MessageKeys.NOT_IMPLEMENTED);
   }
 
   @Override
-  public InputStream entityCollection(final ServiceMetadata metadata,
+  public SerializerResult entityCollection(final ServiceMetadata metadata,
       final EdmEntityType entityType, final EntitySet entitySet,
       final EntityCollectionSerializerOptions options) throws SerializerException {
     throw new SerializerException("Entityset serialization not implemented for XML format",
@@ -102,34 +102,34 @@ public class ODataXmlSerializerImpl implements ODataSerializer {
   }
 
   @Override
-  public InputStream error(ODataServerError error) throws SerializerException {
+  public SerializerResult error(ODataServerError error) throws SerializerException {
     throw new SerializerException("error serialization not implemented for XML format",
         SerializerException.MessageKeys.NOT_IMPLEMENTED);
   }
 
   @Override
-  public InputStream primitive(final EdmPrimitiveType type, final Property property,
+  public SerializerResult primitive(final EdmPrimitiveType type, final Property property,
       final PrimitiveSerializerOptions options) throws SerializerException {
     throw new SerializerException("Serialization not implemented for XML format.",
         SerializerException.MessageKeys.NOT_IMPLEMENTED);
   }
 
   @Override
-  public InputStream complex(final ServiceMetadata metadata, final EdmComplexType type,
+  public SerializerResult complex(final ServiceMetadata metadata, final EdmComplexType type,
       final Property property, final ComplexSerializerOptions options) throws SerializerException {
     throw new SerializerException("Serialization not implemented for XML format.",
         SerializerException.MessageKeys.NOT_IMPLEMENTED);
   }
 
   @Override
-  public InputStream primitiveCollection(final EdmPrimitiveType type, final Property property,
+  public SerializerResult primitiveCollection(final EdmPrimitiveType type, final Property property,
       final PrimitiveSerializerOptions options) throws SerializerException {
     throw new SerializerException("Serialization not implemented for XML format.",
         SerializerException.MessageKeys.NOT_IMPLEMENTED);
   }
 
   @Override
-  public InputStream complexCollection(final ServiceMetadata metadata, final EdmComplexType type,
+  public SerializerResult complexCollection(final ServiceMetadata metadata, final EdmComplexType type,
       final Property property, final ComplexSerializerOptions options) throws SerializerException {
     throw new SerializerException("Serialization not implemented for XML format.",
         SerializerException.MessageKeys.NOT_IMPLEMENTED);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerBasicTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerBasicTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerBasicTest.java
index a301c3d..b63181d 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerBasicTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerBasicTest.java
@@ -57,7 +57,8 @@ public class ODataJsonDeserializerBasicTest {
         "  ]\n" +
         "}";
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
-    List<URI> values = deserializer.entityReferences(new ByteArrayInputStream(payload.getBytes()));
+    List<URI> values = deserializer.entityReferences(new ByteArrayInputStream(payload.getBytes()))
+                                   .getEntityReferences();
     assertEquals(2, values.size());
     assertEquals("Orders(10643)", values.get(0).toASCIIString());
     assertEquals("Orders(10759)", values.get(1).toASCIIString());
@@ -71,7 +72,7 @@ public class ODataJsonDeserializerBasicTest {
         "}";
     ODataDeserializer deserializer = OData.newInstance().createDeserializer(ODataFormat.JSON);
     List<URI> values = deserializer.entityReferences(new ByteArrayInputStream(payload
-        .getBytes()));
+        .getBytes())).getEntityReferences();
     assertEquals(1, values.size());
     assertEquals("Orders(10643)", values.get(0).toASCIIString());
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializerTest.java
index 4e44db4..de5a25e 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializerTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataErrorSerializerTest.java
@@ -52,7 +52,7 @@ public class ODataErrorSerializerTest {
   public void basicODataErrorNoCode() throws Exception {
     ODataServerError error = new ODataServerError();
     error.setMessage("ErrorMessage");
-    InputStream stream = ser.error(error);
+    InputStream stream = ser.error(error).getContent();
     String jsonString = IOUtils.toString(stream);
     assertEquals("{\"error\":{\"code\":null,\"message\":\"ErrorMessage\"}}", jsonString);
   }
@@ -61,7 +61,7 @@ public class ODataErrorSerializerTest {
   public void basicODataErrorWithCode() throws Exception {
     ODataServerError error = new ODataServerError();
     error.setCode("Code").setMessage("ErrorMessage");
-    InputStream stream = ser.error(error);
+    InputStream stream = ser.error(error).getContent();
     String jsonString = IOUtils.toString(stream);
     assertEquals("{\"error\":{\"code\":\"Code\",\"message\":\"ErrorMessage\"}}", jsonString);
   }
@@ -70,7 +70,7 @@ public class ODataErrorSerializerTest {
   public void basicODataErrorWithCodeAndTarget() throws Exception {
     ODataServerError error = new ODataServerError();
     error.setCode("Code").setMessage("ErrorMessage").setTarget("Target");
-    InputStream stream = ser.error(error);
+    InputStream stream = ser.error(error).getContent();
     String jsonString = IOUtils.toString(stream);
     assertEquals("{\"error\":{\"code\":\"Code\",\"message\":\"ErrorMessage\",\"target\":\"Target\"}}", jsonString);
   }
@@ -84,7 +84,7 @@ public class ODataErrorSerializerTest {
   public void emptyDetailsList() throws Exception {
     ODataServerError error = new ODataServerError();
     error.setMessage("ErrorMessage").setDetails(new ArrayList<ODataErrorDetail>());
-    InputStream stream = ser.error(error);
+    InputStream stream = ser.error(error).getContent();
     String jsonString = IOUtils.toString(stream);
     assertEquals("{\"error\":{\"code\":null,\"message\":\"ErrorMessage\",\"details\":[]}}", jsonString);
   }
@@ -92,7 +92,7 @@ public class ODataErrorSerializerTest {
   @Test
   public void nothingSetAtODataErrorObject() throws Exception {
     ODataServerError error = new ODataServerError();
-    InputStream stream = ser.error(error);
+    InputStream stream = ser.error(error).getContent();
     String jsonString = IOUtils.toString(stream);
     assertEquals("{\"error\":{\"code\":null,\"message\":null}}", jsonString);
   }
@@ -102,7 +102,7 @@ public class ODataErrorSerializerTest {
     List<ODataErrorDetail> details = new ArrayList<ODataErrorDetail>();
     details.add(new ODataErrorDetail());
     ODataServerError error = new ODataServerError().setDetails(details);
-    InputStream stream = ser.error(error);
+    InputStream stream = ser.error(error).getContent();
     String jsonString = IOUtils.toString(stream);
     assertEquals("{\"error\":{\"code\":null,\"message\":null,\"details\":[{\"code\":null,\"message\":null}]}}",
         jsonString);
@@ -114,7 +114,7 @@ public class ODataErrorSerializerTest {
     details.add(new ODataErrorDetail().setCode("detailCode").setMessage("detailMessage").setTarget("detailTarget"));
     ODataServerError error =
         new ODataServerError().setCode("Code").setMessage("Message").setTarget("Target").setDetails(details);
-    InputStream stream = ser.error(error);
+    InputStream stream = ser.error(error).getContent();
     JsonNode tree = new ObjectMapper().readTree(stream);
     assertNotNull(tree);
     tree = tree.get("error");

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
index 1e4537f..1fc89e8 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
@@ -50,7 +50,7 @@ public class ODataJsonSerializerTest {
     final ComplexSerializerOptions options = ComplexSerializerOptions.with()
         .contextURL(ContextURL.with().selectList("ComplexCollection").build()).build();
     final InputStream in = serializer.complexCollection(null, ComplexTypeHelper.createType(),
-        complexCollection, options);
+        complexCollection, options).getContent();
     final BufferedReader reader = new BufferedReader(new InputStreamReader(in));
 
     String line;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/502f7ced/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java
index d092ae9..a7bd86e 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java
@@ -88,7 +88,7 @@ public class MetadataDocumentXmlSerializerTest {
     assertEquals("<?xml version='1.0' encoding='UTF-8'?>"
         + "<edmx:Edmx Version=\"4.0\" xmlns:edmx=\"http://docs.oasis-open.org/odata/ns/edmx\">"
         + "<edmx:DataServices/></edmx:Edmx>",
-        IOUtils.toString(serializer.metadataDocument(metadata)));
+        IOUtils.toString(serializer.metadataDocument(metadata).getContent()));
   }
 
   /** Writes simplest (empty) Schema. */
@@ -101,7 +101,7 @@ public class MetadataDocumentXmlSerializerTest {
     ServiceMetadata serviceMetadata = mock(ServiceMetadata.class);
     when(serviceMetadata.getEdm()).thenReturn(edm);
 
-    InputStream metadata = serializer.metadataDocument(serviceMetadata);
+    InputStream metadata = serializer.metadataDocument(serviceMetadata).getContent();
     assertNotNull(metadata);
     assertEquals("<?xml version='1.0' encoding='UTF-8'?>" +
         "<edmx:Edmx Version=\"4.0\" xmlns:edmx=\"http://docs.oasis-open.org/odata/ns/edmx\">" +
@@ -167,7 +167,7 @@ public class MetadataDocumentXmlSerializerTest {
     when(serviceMetadata.getEdm()).thenReturn(edm);
     when(serviceMetadata.getReferences()).thenReturn(edmxReferences);
 
-    InputStream metadata = serializer.metadataDocument(serviceMetadata);
+    InputStream metadata = serializer.metadataDocument(serviceMetadata).getContent();
     assertNotNull(metadata);
     final String metadataString = IOUtils.toString(metadata);
     // edmx reference
@@ -214,7 +214,7 @@ public class MetadataDocumentXmlSerializerTest {
   public void aliasTest() throws Exception {
     EdmProvider provider = new LocalProvider();
     ServiceMetadata serviceMetadata = new ServiceMetadataImpl(provider, Collections.<EdmxReference> emptyList());
-    InputStream metadataStream = serializer.metadataDocument(serviceMetadata);
+    InputStream metadataStream = serializer.metadataDocument(serviceMetadata).getContent();
     String metadata = IOUtils.toString(metadataStream);
     assertNotNull(metadata);
 
@@ -255,7 +255,7 @@ public class MetadataDocumentXmlSerializerTest {
 
     when(schema.getComplexTypes()).thenReturn(complexTypes);
 
-    InputStream metadataStream = serializer.metadataDocument(serviceMetadata);
+    InputStream metadataStream = serializer.metadataDocument(serviceMetadata).getContent();
     String metadata = IOUtils.toString(metadataStream);
     assertTrue(metadata.contains("<ComplexType Name=\"ComplexType\" Abstract=\"true\">"
         + "<Property Name=\"prop1\" Type=\"Edm.String\"/>"