You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2014/07/07 07:56:50 UTC

[1/6] git commit: [OLINGO-317] Added additional tests

Repository: olingo-odata4
Updated Branches:
  refs/heads/master 098ed145d -> 95e2d8d33


[OLINGO-317] Added additional tests


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

Branch: refs/heads/master
Commit: 839e96045a1240a1e35743b5da7ea3a34e806905
Parents: 4c4f82e
Author: mibo <mi...@mirb.de>
Authored: Mon Jun 30 15:01:28 2014 +0200
Committer: mibo <mi...@mirb.de>
Committed: Mon Jun 30 15:15:28 2014 +0200

----------------------------------------------------------------------
 .../olingo/commons/core/data/PropertyImpl.java  |   2 +-
 .../core/edm/primitivetype/EdmString.java       |   3 +-
 .../json/ODataJsonSerializerTest.java           | 312 +++++++++++++++++--
 3 files changed, 294 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/839e9604/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
index b6f2f36..4ad374d 100755
--- 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
@@ -35,7 +35,7 @@ public class PropertyImpl extends AbstractValuable implements Property {
   }
 
   public PropertyImpl(String type, String name, ValueType valueType, Object value) {
-    this(name, type);
+    this(type, name);
     setValue(valueType, value);
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/839e9604/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmString.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmString.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmString.java
index 4defe91..600467a 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmString.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmString.java
@@ -74,7 +74,8 @@ public final class EdmString extends SingletonPrimitiveType {
     if (isUnicode != null && !isUnicode && !PATTERN_ASCII.matcher(result).matches()
         || maxLength != null && maxLength < result.length()) {
       throw new EdmPrimitiveTypeException(
-              "EdmPrimitiveTypeException.VALUE_FACETS_NOT_MATCHED.addContent(value, facets)");
+              "EdmPrimitiveTypeException.VALUE_FACETS_NOT_MATCHED.addContent('" +
+                  value + "', facets)");
     }
 
     return result;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/839e9604/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 79a1b65..1008c5f 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
@@ -18,14 +18,20 @@
  */
 package org.apache.olingo.server.core.serializer.json;
 
+import org.apache.olingo.commons.api.ODataRuntimeException;
 import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.ValueType;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.edm.EdmEntityType;
+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.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.PropertyImpl;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmString;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -36,50 +42,314 @@ import org.slf4j.LoggerFactory;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Calendar;
 import java.util.List;
+import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 public class ODataJsonSerializerTest {
 
-  public static final String PROPERTY_1 = "Property1";
+  private static final String ETAllPrim = "ETAllPrim";
+  private static final String ETCompAllPrim = "ETCompAllPrim";
+  private static final String CTAllPrim = "CTAllPrim";
+  private static final String CTAllPrim_Type = "com.sap.odata.test1.CTAllPrim";
+
+  interface TechProperty {
+    String getName();
+    String getTypeName();
+    EdmPrimitiveTypeKind getType();
+  }
+
+  public static class TecComplexProperty implements TechProperty {
+
+    final String name;
+    final String typeName;
+    public TecComplexProperty(String typeName, String name) {
+      this.name = name;
+      this.typeName = typeName;
+    }
+    @Override
+    public String getName() {
+      return name;
+    }
+    @Override
+    public String getTypeName() {
+      return typeName;
+    }
+    @Override
+    public EdmPrimitiveTypeKind getType() {
+      return null;
+    }
+  }
+
+  enum TecSimpleProperty implements TechProperty {
+    Int16("PropertyInt16", EdmPrimitiveTypeKind.Int16),
+    String("PropertyString", EdmPrimitiveTypeKind.String),
+    Boolean("PropertyBoolean", EdmPrimitiveTypeKind.Boolean),
+    Byte("PropertyByte", EdmPrimitiveTypeKind.Byte),
+    SByte("PropertySByte", EdmPrimitiveTypeKind.SByte),
+    Int32("PropertyInt32", EdmPrimitiveTypeKind.Int32),
+    Int64("PropertyInt64", EdmPrimitiveTypeKind.Int64),
+    Single("PropertySingle", EdmPrimitiveTypeKind.Single),
+    Double("PropertyDouble", EdmPrimitiveTypeKind.Double),
+    Decimal("PropertyDecimal", EdmPrimitiveTypeKind.Decimal),
+    Binary("PropertyBinary", EdmPrimitiveTypeKind.Binary),
+    Date("PropertyDate", EdmPrimitiveTypeKind.Date),
+    DateTimeOffset("PropertyDateTimeOffset", EdmPrimitiveTypeKind.DateTimeOffset),
+    Duration("PropertyDuration", EdmPrimitiveTypeKind.Duration),
+    Guid("PropertyGuid", EdmPrimitiveTypeKind.Guid),
+    TimeOfDay("PropertyTimeOfDay", EdmPrimitiveTypeKind.TimeOfDay);
+    //  <NavigationProperty Name="NavPropertyETTwoPrimOne" Type="test1.ETTwoPrim" Nullable="false"/>
+//    NavETTwoPrimOne = "NavPropertyETTwoPrimOne", EdmPrimitiveTypeKind.),
+    //  <NavigationProperty Name="NavPropertyETTwoPrimMany" Type="Collection(test1.ETTwoPrim)" Nullable="false"/>
+//    NavETTwoPrimMany("NavPropertyETTwoPrimMany", EdmCom.);
+
+    final String name;
+    final EdmPrimitiveTypeKind type;
+
+    TecSimpleProperty(String name, EdmPrimitiveTypeKind type) {
+      this.name = name;
+      this.type = type;
+    }
+
+    @Override
+    public String getTypeName() {
+      return type.name();
+    }
+
+    @Override
+    public EdmPrimitiveTypeKind getType() {
+      return type;
+    }
+    @Override
+    public String getName() {
+      return name;
+    }
+  }
 
   private ContextURL contextUrl;
-  private EdmEntityType edmEntityType;
-  private final Logger LOG = LoggerFactory.getLogger(ODataJsonSerializerTest.class);
+  private EdmEntitySet edmESAllPrim;
+  private EdmEntityType edmETAllPrim;
+  private EdmEntityType edmETCompAllPrim;
 
   private ODataJsonSerializer serializer = new ODataJsonSerializer();
 
   @Before
   public void prepare() throws Exception {
     contextUrl = ContextURL.getInstance(new URI("http://localhost:8080/test.svc"));
-    edmEntityType = Mockito.mock(EdmEntityType.class);
-    List<String> propertyNames = Arrays.asList(PROPERTY_1);
-    Mockito.when(edmEntityType.getPropertyNames()).thenReturn(propertyNames);
 
+    edmETAllPrim = Mockito.mock(EdmEntityType.class);
+    Mockito.when(edmETAllPrim.getName()).thenReturn(ETAllPrim);
+    List<EdmProperty> properties = Arrays.asList(
+        mockProperty(TecSimpleProperty.Int16, false),
+        mockProperty(TecSimpleProperty.String),
+        mockProperty(TecSimpleProperty.Boolean),
+        mockProperty(TecSimpleProperty.Byte),
+        mockProperty(TecSimpleProperty.SByte),
+        mockProperty(TecSimpleProperty.Int32),
+        mockProperty(TecSimpleProperty.Int64),
+        mockProperty(TecSimpleProperty.Single),
+        mockProperty(TecSimpleProperty.Double),
+        mockProperty(TecSimpleProperty.Decimal),
+        mockProperty(TecSimpleProperty.Binary),
+        mockProperty(TecSimpleProperty.Date),
+        mockProperty(TecSimpleProperty.DateTimeOffset),
+        mockProperty(TecSimpleProperty.Duration),
+        mockProperty(TecSimpleProperty.Guid),
+        mockProperty(TecSimpleProperty.TimeOfDay)
+//        mockProperty(NavPropertyETTwoPrimOne, false),
+//        mockProperty(NavPropertyETTwoPrimMany, false)
+    );
+    List<String> propertyNames = new ArrayList<String>();
+
+    for (EdmProperty property : properties) {
+      propertyNames.add(property.getName());
+      Mockito.when(edmETAllPrim.getProperty(property.getName())).thenReturn(property);
+    }
+    Mockito.when(edmETAllPrim.getPropertyNames()).thenReturn(propertyNames);
+
+    // Entity Set All Primitive
+    edmESAllPrim = Mockito.mock(EdmEntitySet.class);
+    Mockito.when(edmESAllPrim.getName()).thenReturn("ESAllPrim");
+    Mockito.when(edmESAllPrim.getEntityType()).thenReturn(edmETAllPrim);
+
+    // Entity Type Complex All Primitive
+    edmETCompAllPrim = Mockito.mock(EdmEntityType.class);
+    Mockito.when(edmETCompAllPrim.getName()).thenReturn(ETCompAllPrim);
+    List<EdmProperty> capProperties = Arrays.asList(
+        mockProperty(TecSimpleProperty.Int16, false),
+        mockProperty(new TecComplexProperty(CTAllPrim_Type, CTAllPrim), false, true)
+    );
+    List<String> capPropertyNames = new ArrayList<String>();
+
+    for (EdmProperty property : capProperties) {
+      capPropertyNames.add(property.getName());
+      Mockito.when(edmETCompAllPrim.getProperty(property.getName())).thenReturn(property);
+    }
+    Mockito.when(edmETCompAllPrim.getPropertyNames()).thenReturn(capPropertyNames);
+  }
+
+  private EdmProperty mockProperty(TechProperty name) {
+    return mockProperty(name, true, false);
+  }
+
+  private EdmProperty mockProperty(TechProperty name, boolean nullable) {
+    return mockProperty(name, nullable, false);
+  }
+
+  private EdmProperty mockProperty(TechProperty tecProperty, boolean nullable, boolean complex) {
     EdmProperty edmElement = Mockito.mock(EdmProperty.class);
-    Mockito.when(edmElement.getName()).thenReturn(PROPERTY_1);
-    Mockito.when(edmElement.isPrimitive()).thenReturn(true);
-    Mockito.when(edmElement.getMaxLength()).thenReturn(20);
-    Mockito.when(edmElement.getType()).thenReturn(EdmString.getInstance());
-    Mockito.when(edmEntityType.getProperty(PROPERTY_1)).thenReturn(edmElement);
+    Mockito.when(edmElement.getName()).thenReturn(tecProperty.getName());
+    if(complex) {
+      Mockito.when(edmElement.isPrimitive()).thenReturn(false);
+      EdmType type = Mockito.mock(EdmType.class);
+      Mockito.when(type.getKind()).thenReturn(EdmTypeKind.COMPLEX);
+      Mockito.when(type.getName()).thenReturn(tecProperty.getTypeName());
+      Mockito.when(edmElement.getType()).thenReturn(type);
+    } else {
+      Mockito.when(edmElement.isPrimitive()).thenReturn(true);
+      // TODO: set default values
+      Mockito.when(edmElement.getMaxLength()).thenReturn(40);
+      Mockito.when(edmElement.getPrecision()).thenReturn(10);
+      Mockito.when(edmElement.getScale()).thenReturn(10);
+      Mockito.when(edmElement.getType()).thenReturn(EdmPrimitiveTypeFactory.getInstance(tecProperty.getType()));
+    }
+    Mockito.when(edmElement.isNullable()).thenReturn(nullable);
+    return edmElement;
+  }
+
+  private PropertyImpl createProperty(TechProperty property, ValueType vType, Object value) {
+    return new PropertyImpl(property.getTypeName(), property.getName(), vType, value);
+  }
 
+  private PropertyImpl createProperty(String type, TecSimpleProperty property, ValueType vType, Object value) {
+    return new PropertyImpl(type, property.name, vType, value);
   }
 
   @Test
   public void entitySimple() throws Exception {
+    Entity entity = createETAllPrim();
+
+    InputStream result = serializer.entity(edmETAllPrim, entity, contextUrl);
+    String resultString = streamToString(result);
+    String expectedResult = "{" +
+        "\"@odata.context\":\"http://localhost:8080/test.svc\"," +
+        "\"PropertyInt16\":4711," +
+        "\"PropertyString\":\"StringValue\"," +
+        "\"PropertyBoolean\":true," +
+        "\"PropertyByte\":19," +
+        "\"PropertySByte\":1," +
+        "\"PropertyInt32\":2147483647," +
+        "\"PropertyInt64\":9223372036854775807," +
+        "\"PropertySingle\":47.11," +
+        "\"PropertyDouble\":4.711," +
+        "\"PropertyDecimal\":4711.1174," +
+        "\"PropertyBinary\":\"BAcBAQ==\"," +
+        "\"PropertyDate\":\"2014-03-19\"," +
+        "\"PropertyDateTimeOffset\":\"2014-03-19T10:12:00+01:00\"," +
+        "\"PropertyDuration\":\"P16148383DT8H0S\"," +
+        "\"PropertyGuid\":\"0000aaaa-00bb-00cc-00dd-000000ffffff\"," +
+        "\"PropertyTimeOfDay\":\"10:12:00\"" +
+        "}";
+    Assert.assertEquals(expectedResult, resultString);
+  }
+
+
+  @Test
+  public void entitySetETAllPrim() throws Exception {
+    EdmEntitySet edmEntitySet = edmESAllPrim;
+    EntitySetImpl entitySet = new EntitySetImpl();
+    for (int i = 0; i < 100; i++) {
+      entitySet.getEntities().add(createETAllPrim(i));
+    }
+    entitySet.setCount(entitySet.getEntities().size());
+    entitySet.setNext(URI.create(contextUrl.getURI().toASCIIString() + "/next"));
+
+    InputStream result = serializer.entitySet(edmEntitySet, entitySet, contextUrl);
+    String resultString = streamToString(result);
+
+    Assert.assertTrue(resultString.matches("\\{" +
+        "\"@odata\\.context\":\"http://localhost:8080/test.svc\"," +
+        "\"@odata\\.count\":100," +
+        "\"value\":\\[.*\\]," +
+        "\"@odata\\.nextLink\":\"http://localhost:8080/test.svc/next\"" +
+        "\\}"));
+
+    Matcher matcher = Pattern.compile("(\\{[a-z0-9:\\=\"\\-,\\.\\+]*\\})",
+        Pattern.CASE_INSENSITIVE).matcher(resultString);
+    int count = 0;
+    while(matcher.find()) {
+      Assert.assertTrue(matcher.group().contains("PropertyInt16\":" + count++));
+    }
+    Assert.assertEquals(100, count);
+  }
+
+  @Test(expected = ODataRuntimeException.class)
+  public void entityETCompAllPrim() throws Exception {
+    Entity complexCtAllPrim = createETAllPrim();
 
-//    Entity entity = new EntityImpl();
-//    entity.addProperty(new PropertyImpl("Edm.String", PROPERTY_1, ValueType.PRIMITIVE, "Value_1"));
     Entity entity = new EntityImpl();
-    PropertyImpl property = new PropertyImpl("Edm.String", PROPERTY_1);
-    property.setValue(ValueType.PRIMITIVE, "Value_1");
-    entity.addProperty(property);
+    entity.addProperty(new PropertyImpl("Edm.Int16", TecSimpleProperty.Int16.name, ValueType.PRIMITIVE, 4711));
+    entity.addProperty(createProperty(new TecComplexProperty(CTAllPrim_Type, CTAllPrim),
+        ValueType.COMPLEX, complexCtAllPrim));
 
-    InputStream result = serializer.entity(edmEntityType, entity, contextUrl);
+    InputStream result = serializer.entity(edmETCompAllPrim, entity, contextUrl);
     String resultString = streamToString(result);
-//    System.out.println(resultString);
-    Assert.assertEquals("{\"@odata.context\":\"http://localhost:8080/test.svc\",\"Property1\":\"Value_1\"}",
-            resultString);
+    String expectedResult = "{" +
+        "\"@odata.context\":\"http://localhost:8080/test.svc\"," +
+        "\"PropertyInt16\":4711," +
+        "\"PropertyString\":\"StringValue\"," +
+        "\"PropertyBoolean\":true," +
+        "\"PropertyByte\":19," +
+        "\"PropertySByte\":1," +
+        "\"PropertyInt32\":2147483647," +
+        "\"PropertyInt64\":9223372036854775807," +
+        "\"PropertySingle\":47.11," +
+        "\"PropertyDouble\":4.711," +
+        "\"PropertyDecimal\":4711.1174," +
+        "\"PropertyBinary\":\"BAcBAQ==\"," +
+        "\"PropertyDate\":\"2014-03-19\"," +
+        "\"PropertyDateTimeOffset\":\"2014-03-19T10:12:00+01:00\"," +
+        "\"PropertyDuration\":\"P16148383DT8H0S\"," +
+        "\"PropertyGuid\":\"0000aaaa-00bb-00cc-00dd-000000ffffff\"," +
+        "\"PropertyTimeOfDay\":\"10:12:00\"" +
+        "}";
+    Assert.assertEquals(expectedResult, resultString);
+  }
+
+  private Entity createETAllPrim() {
+    return createETAllPrim(4711);
+  }
+
+  private Entity createETAllPrim(int id) {
+    Entity entity = new EntityImpl();
+    Calendar date = Calendar.getInstance();
+    date.set(2014, Calendar.MARCH, 19, 10, 12, 0);
+    date.set(Calendar.MILLISECOND, 0);
+    entity.addProperty(createProperty("Edm.Int16", TecSimpleProperty.Int16, ValueType.PRIMITIVE, id));
+    entity.addProperty(createProperty("Edm.String", TecSimpleProperty.String, ValueType.PRIMITIVE, "StringValue"));
+    entity.addProperty(createProperty("Edm.Boolean", TecSimpleProperty.Boolean, ValueType.PRIMITIVE, Boolean.TRUE));
+    entity.addProperty(createProperty("Edm.Byte", TecSimpleProperty.Byte, ValueType.PRIMITIVE, Byte.valueOf("19")));
+    entity.addProperty(createProperty("Edm.SByte", TecSimpleProperty.SByte, ValueType.PRIMITIVE, Short.valueOf("1")));
+    entity.addProperty(createProperty("Edm.Int32", TecSimpleProperty.Int32, ValueType.PRIMITIVE, Integer.MAX_VALUE));
+    entity.addProperty(createProperty("Edm.Int64", TecSimpleProperty.Int64, ValueType.PRIMITIVE, Long.MAX_VALUE));
+    entity.addProperty(createProperty("Edm.Single", TecSimpleProperty.Single, ValueType.PRIMITIVE, 47.11));
+    entity.addProperty(createProperty("Edm.Double", TecSimpleProperty.Double, ValueType.PRIMITIVE, 4.711));
+    entity.addProperty(createProperty("Edm.Decimal", TecSimpleProperty.Decimal, ValueType.PRIMITIVE, 4711.1174));
+    entity.addProperty(createProperty("Edm.Binary", TecSimpleProperty.Binary, ValueType.PRIMITIVE,
+        new byte[]{0x04, 0x07, 0x01, 0x01}));
+    entity.addProperty(createProperty("Edm.Date", TecSimpleProperty.Date, ValueType.PRIMITIVE, date));
+    entity.addProperty(createProperty("Edm.DateTimeOffset", TecSimpleProperty.DateTimeOffset, ValueType.PRIMITIVE,
+        date.getTime()));
+    entity.addProperty(createProperty("Edm.Duration", TecSimpleProperty.Duration, ValueType.PRIMITIVE,
+        date.getTimeInMillis()));
+    entity.addProperty(createProperty("Edm.Guid", TecSimpleProperty.Guid, ValueType.PRIMITIVE,
+        UUID.fromString("AAAA-BB-CC-DD-FFFFFF")));
+    entity.addProperty(createProperty("Edm.TimeOfDay", TecSimpleProperty.TimeOfDay, ValueType.PRIMITIVE, date));
+    return entity;
   }
 
   private String streamToString(InputStream result) throws IOException {


[4/6] git commit: [OLINGO-317] Minor code clean up in test

Posted by mi...@apache.org.
[OLINGO-317] Minor code clean up in test


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

Branch: refs/heads/master
Commit: 876655fd26d1fc1bfe45347b921a8c63889398b9
Parents: da8cf72
Author: Michael Bolz <mi...@sap.com>
Authored: Thu Jul 3 07:21:06 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Thu Jul 3 07:32:25 2014 +0200

----------------------------------------------------------------------
 .../serializer/json/ODataJsonSerializer.java    |   3 +-
 .../json/ODataJsonSerializerTest.java           | 202 ++++++++++---------
 2 files changed, 111 insertions(+), 94 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/876655fd/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 1c61cc0..536ead1 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
@@ -238,8 +238,7 @@ public class ODataJsonSerializer implements ODataSerializer {
       JsonGenerator json = new JsonFactory().createGenerator(buffer.getOutputStream());
       json.writeStartObject();
       if (contextURL != null) {
-        String context = "$metadata#" + edmEntitySet.getName();
-        json.writeStringField(Constants.JSON_CONTEXT, context);
+        json.writeStringField(Constants.JSON_CONTEXT, contextURL.getURI().toASCIIString());
       }
       if (entitySet.getCount() != null) {
         json.writeNumberField("@odata.count", entitySet.getCount());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/876655fd/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 b791cc6..91e49b9 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
@@ -35,6 +35,7 @@ import org.mockito.Mockito;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -47,29 +48,29 @@ public class ODataJsonSerializerTest {
   private static final String CTAllPrim = "CTAllPrim";
   private static final String CTAllPrim_Type = "com.sap.odata.test1.CTAllPrim";
 
-  interface TechProperty {
+  interface TecSvcProperty {
     String getName();
     String getTypeName();
     EdmPrimitiveTypeKind getType();
     boolean isCollection();
   }
 
-  public static class TecComplexProperty implements TechProperty {
+  public static class TecSvcComplexProperty implements TecSvcProperty {
 
     final String typeName;
     final String name;
     final List<EdmProperty> properties = new ArrayList<EdmProperty>();
     boolean collection = false;
 
-    public TecComplexProperty(String typeName, String name) {
+    public TecSvcComplexProperty(String typeName, String name) {
       this.typeName = typeName;
       this.name = name;
     }
-    TechProperty addProperties(List<EdmProperty> properties) {
+    TecSvcProperty addProperties(List<EdmProperty> properties) {
       this.properties.addAll(properties);
       return this;
     }
-    TechProperty asCollection() {
+    TecSvcProperty asCollection() {
       this.collection = true;
       return this;
     }
@@ -94,7 +95,7 @@ public class ODataJsonSerializerTest {
     }
   }
 
-  enum TecSimpleProperty implements TechProperty {
+  enum TecSvcSimpleProperty implements TecSvcProperty {
     Int16("PropertyInt16", EdmPrimitiveTypeKind.Int16),
     String("PropertyString", EdmPrimitiveTypeKind.String),
     Boolean("PropertyBoolean", EdmPrimitiveTypeKind.Boolean),
@@ -136,10 +137,10 @@ public class ODataJsonSerializerTest {
     final EdmPrimitiveTypeKind type;
     final boolean isCollection;
 
-    TecSimpleProperty(String name, EdmPrimitiveTypeKind type) {
+    TecSvcSimpleProperty(String name, EdmPrimitiveTypeKind type) {
       this(name, type, false);
     }
-    TecSimpleProperty(String name, EdmPrimitiveTypeKind type, boolean collection) {
+    TecSvcSimpleProperty(String name, EdmPrimitiveTypeKind type, boolean collection) {
       this.name = name;
       this.type = type;
       this.isCollection = collection;
@@ -162,7 +163,6 @@ public class ODataJsonSerializerTest {
     }
   }
 
-  private ContextURL contextUrl;
   private EdmEntitySet edmESAllPrim;
   private EdmEntitySet edmESCompAllPrim;
   private EdmEntitySet edmESCollAllPrim;
@@ -174,28 +174,26 @@ public class ODataJsonSerializerTest {
 
   @Before
   public void prepare() throws Exception {
-    contextUrl = ContextURL.getInstance(new URI("http://localhost:8080/test.svc"));
-
     // entity all primitive
     edmETAllPrim = Mockito.mock(EdmEntityType.class);
     Mockito.when(edmETAllPrim.getName()).thenReturn(ETAllPrim);
     List<EdmProperty> properties = Arrays.asList(
-        mockProperty(TecSimpleProperty.Int16, false),
-        mockProperty(TecSimpleProperty.String),
-        mockProperty(TecSimpleProperty.Boolean),
-        mockProperty(TecSimpleProperty.Byte),
-        mockProperty(TecSimpleProperty.SByte),
-        mockProperty(TecSimpleProperty.Int32),
-        mockProperty(TecSimpleProperty.Int64),
-        mockProperty(TecSimpleProperty.Single),
-        mockProperty(TecSimpleProperty.Double),
-        mockProperty(TecSimpleProperty.Decimal),
-        mockProperty(TecSimpleProperty.Binary),
-        mockProperty(TecSimpleProperty.Date),
-        mockProperty(TecSimpleProperty.DateTimeOffset),
-        mockProperty(TecSimpleProperty.Duration),
-        mockProperty(TecSimpleProperty.Guid),
-        mockProperty(TecSimpleProperty.TimeOfDay)
+        mockProperty(TecSvcSimpleProperty.Int16, false),
+        mockProperty(TecSvcSimpleProperty.String),
+        mockProperty(TecSvcSimpleProperty.Boolean),
+        mockProperty(TecSvcSimpleProperty.Byte),
+        mockProperty(TecSvcSimpleProperty.SByte),
+        mockProperty(TecSvcSimpleProperty.Int32),
+        mockProperty(TecSvcSimpleProperty.Int64),
+        mockProperty(TecSvcSimpleProperty.Single),
+        mockProperty(TecSvcSimpleProperty.Double),
+        mockProperty(TecSvcSimpleProperty.Decimal),
+        mockProperty(TecSvcSimpleProperty.Binary),
+        mockProperty(TecSvcSimpleProperty.Date),
+        mockProperty(TecSvcSimpleProperty.DateTimeOffset),
+        mockProperty(TecSvcSimpleProperty.Duration),
+        mockProperty(TecSvcSimpleProperty.Guid),
+        mockProperty(TecSvcSimpleProperty.TimeOfDay)
 //        mockProperty(NavPropertyETTwoPrimOne, false),
 //        mockProperty(NavPropertyETTwoPrimMany, false)
     );
@@ -211,13 +209,21 @@ public class ODataJsonSerializerTest {
     edmESAllPrim = Mockito.mock(EdmEntitySet.class);
     Mockito.when(edmESAllPrim.getName()).thenReturn("ESAllPrim");
     Mockito.when(edmESAllPrim.getEntityType()).thenReturn(edmETAllPrim);
+    // Entity Set All Primitive
+    edmESCompAllPrim = Mockito.mock(EdmEntitySet.class);
+    Mockito.when(edmESCompAllPrim.getName()).thenReturn("ESCompAllPrim");
+    Mockito.when(edmESCompAllPrim.getEntityType()).thenReturn(edmETCompAllPrim);
+    // Entity Set All Primitive
+    edmESCollAllPrim = Mockito.mock(EdmEntitySet.class);
+    Mockito.when(edmESCollAllPrim.getName()).thenReturn("ESCollAllPrim");
+    Mockito.when(edmESCollAllPrim.getEntityType()).thenReturn(edmETCollAllPrim);
 
     // Entity Type Complex All Primitive
     edmETCompAllPrim = Mockito.mock(EdmEntityType.class);
     Mockito.when(edmETCompAllPrim.getName()).thenReturn(ETCompAllPrim);
     List<EdmProperty> capProperties = Arrays.asList(
-        mockProperty(TecSimpleProperty.Int16, false),
-        mockProperty(new TecComplexProperty(CTAllPrim_Type, CTAllPrim).addProperties(properties), false)
+        mockProperty(TecSvcSimpleProperty.Int16, false),
+        mockProperty(new TecSvcComplexProperty(CTAllPrim_Type, CTAllPrim).addProperties(properties), false)
     );
     List<String> capPropertyNames = new ArrayList<String>();
 
@@ -232,22 +238,22 @@ public class ODataJsonSerializerTest {
     edmETCollAllPrim = Mockito.mock(EdmEntityType.class);
     Mockito.when(edmETCollAllPrim.getName()).thenReturn(ETCollAllPrim);
     List<EdmProperty> allCollProperties = Arrays.asList(
-            mockProperty(TecSimpleProperty.Int16, false),
-            mockProperty(TecSimpleProperty.Collection_String),
-            mockProperty(TecSimpleProperty.Collection_Boolean),
-            mockProperty(TecSimpleProperty.Collection_Byte),
-            mockProperty(TecSimpleProperty.Collection_SByte),
-            mockProperty(TecSimpleProperty.Collection_Int32),
-            mockProperty(TecSimpleProperty.Collection_Int64),
-            mockProperty(TecSimpleProperty.Collection_Single),
-            mockProperty(TecSimpleProperty.Collection_Double),
-            mockProperty(TecSimpleProperty.Collection_Decimal),
-            mockProperty(TecSimpleProperty.Collection_Binary),
-            mockProperty(TecSimpleProperty.Collection_Date),
-            mockProperty(TecSimpleProperty.Collection_DateTimeOffset),
-            mockProperty(TecSimpleProperty.Collection_Duration),
-            mockProperty(TecSimpleProperty.Collection_Guid),
-            mockProperty(TecSimpleProperty.Collection_TimeOfDay)
+            mockProperty(TecSvcSimpleProperty.Int16, false),
+            mockProperty(TecSvcSimpleProperty.Collection_String),
+            mockProperty(TecSvcSimpleProperty.Collection_Boolean),
+            mockProperty(TecSvcSimpleProperty.Collection_Byte),
+            mockProperty(TecSvcSimpleProperty.Collection_SByte),
+            mockProperty(TecSvcSimpleProperty.Collection_Int32),
+            mockProperty(TecSvcSimpleProperty.Collection_Int64),
+            mockProperty(TecSvcSimpleProperty.Collection_Single),
+            mockProperty(TecSvcSimpleProperty.Collection_Double),
+            mockProperty(TecSvcSimpleProperty.Collection_Decimal),
+            mockProperty(TecSvcSimpleProperty.Collection_Binary),
+            mockProperty(TecSvcSimpleProperty.Collection_Date),
+            mockProperty(TecSvcSimpleProperty.Collection_DateTimeOffset),
+            mockProperty(TecSvcSimpleProperty.Collection_Duration),
+            mockProperty(TecSvcSimpleProperty.Collection_Guid),
+            mockProperty(TecSvcSimpleProperty.Collection_TimeOfDay)
     );
     List<String> etCollAllPrimPropertyNames = new ArrayList<String>();
 
@@ -260,15 +266,15 @@ public class ODataJsonSerializerTest {
     // Entity Set all primitive collection
   }
 
-  private EdmProperty mockProperty(TechProperty name) {
+  private EdmProperty mockProperty(TecSvcProperty name) {
     return mockProperty(name, true);
   }
 
-  private EdmProperty mockProperty(TechProperty tecProperty, boolean nullable) {
+  private EdmProperty mockProperty(TecSvcProperty tecProperty, boolean nullable) {
     EdmProperty edmElement = Mockito.mock(EdmProperty.class);
     Mockito.when(edmElement.getName()).thenReturn(tecProperty.getName());
-    if (tecProperty instanceof TecComplexProperty) {
-      TecComplexProperty complexProperty = (TecComplexProperty) tecProperty;
+    if (tecProperty instanceof TecSvcComplexProperty) {
+      TecSvcComplexProperty complexProperty = (TecSvcComplexProperty) tecProperty;
       Mockito.when(edmElement.isPrimitive()).thenReturn(false);
       EdmComplexType type = Mockito.mock(EdmComplexType.class);
       Mockito.when(type.getKind()).thenReturn(EdmTypeKind.COMPLEX);
@@ -295,11 +301,11 @@ public class ODataJsonSerializerTest {
     return edmElement;
   }
 
-  private PropertyImpl createProperty(TechProperty property, ValueType vType, Object value) {
+  private PropertyImpl createProperty(TecSvcProperty property, ValueType vType, Object value) {
     return new PropertyImpl(property.getTypeName(), property.getName(), vType, value);
   }
 
-  private PropertyImpl createProperty(String type, TecSimpleProperty property, ValueType vType, Object ... value) {
+  private PropertyImpl createProperty(String type, TecSvcSimpleProperty property, ValueType vType, Object ... value) {
     final Object propValue;
     if(value == null || value.length ==0) {
       propValue = null;
@@ -315,10 +321,10 @@ public class ODataJsonSerializerTest {
   public void entitySimple() throws Exception {
     Entity entity = createETAllPrim();
 
-    InputStream result = serializer.entity(edmETAllPrim, entity, contextUrl);
+    InputStream result = serializer.entity(edmETAllPrim, entity, createContextURL(edmESAllPrim, true));
     String resultString = streamToString(result);
     String expectedResult = "{" +
-        "\"@odata.context\":\"http://localhost:8080/test.svc\"," +
+        "\"@odata.context\":\"$metadata#ESAllPrim/$entity\"," +
         "\"PropertyInt16\":4711," +
         "\"PropertyString\":\"StringValue\"," +
         "\"PropertyBoolean\":true," +
@@ -347,16 +353,17 @@ public class ODataJsonSerializerTest {
       entitySet.getEntities().add(createETAllPrim(i));
     }
     entitySet.setCount(entitySet.getEntities().size());
+    ContextURL contextUrl = createContextURL(edmESAllPrim, false);
     entitySet.setNext(URI.create(contextUrl.getURI().toASCIIString() + "/next"));
 
     InputStream result = serializer.entitySet(edmEntitySet, entitySet, contextUrl);
     String resultString = streamToString(result);
 
     Assert.assertTrue(resultString.matches("\\{" +
-        "\"@odata\\.context\":\"http://localhost:8080/test.svc\"," +
+        "\"@odata\\.context\":\"\\$metadata#ESAllPrim\"," +
         "\"@odata\\.count\":100," +
         "\"value\":\\[.*\\]," +
-        "\"@odata\\.nextLink\":\"http://localhost:8080/test.svc/next\"" +
+        "\"@odata\\.nextLink\":\"\\$metadata#ESAllPrim/next\"" +
         "\\}"));
 
     Matcher matcher = Pattern.compile("(\\{[a-z0-9:\\=\"\\-,\\.\\+]*\\})",
@@ -372,10 +379,11 @@ public class ODataJsonSerializerTest {
   public void entityCollAllPrim() throws Exception {
     Entity entity = createETCollAllPrim(4711);
 
+    ContextURL contextUrl = createContextURL(edmESCollAllPrim, true);
     InputStream result = serializer.entity(edmETCollAllPrim, entity, contextUrl);
     String resultString = streamToString(result);
     String expectedResult = "{" +
-        "\"@odata.context\":\"http://localhost:8080/test.svc\"," +
+        "\"@odata.context\":\"$metadata#ESCollAllPrim/$entity\"," +
         "\"PropertyInt16\":4711," +
         "\"CollPropertyString\":[\"StringValue_1\",\"StringValue_2\"]," +
         "\"CollPropertyBoolean\":[true,false]," +
@@ -401,15 +409,16 @@ public class ODataJsonSerializerTest {
     Entity complexCtAllPrim = createETAllPrim();
 
     Entity entity = new EntityImpl();
-    entity.addProperty(new PropertyImpl("Edm.Int16", TecSimpleProperty.Int16.name, ValueType.PRIMITIVE, 4711));
+    entity.addProperty(new PropertyImpl("Edm.Int16", TecSvcSimpleProperty.Int16.name, ValueType.PRIMITIVE, 4711));
     entity.addProperty(createProperty(
-            new TecComplexProperty(CTAllPrim_Type, CTAllPrim),
+            new TecSvcComplexProperty(CTAllPrim_Type, CTAllPrim),
             ValueType.COMPLEX, complexCtAllPrim.getProperties()));
 
+    ContextURL contextUrl = createContextURL(edmESCompAllPrim, true);
     InputStream result = serializer.entity(edmETCompAllPrim, entity, contextUrl);
     String resultString = streamToString(result);
     String expectedResult = "{" +
-        "\"@odata.context\":\"http://localhost:8080/test.svc\"," +
+        "\"@odata.context\":\"$metadata#ESCompAllPrim/$entity\"," +
         "\"PropertyInt16\":4711," +
         "\"CTAllPrim\":{" +
         "\"PropertyInt16\":4711," +
@@ -432,6 +441,13 @@ public class ODataJsonSerializerTest {
     Assert.assertEquals(expectedResult, resultString);
   }
 
+  private ContextURL createContextURL(EdmEntitySet entitySet, boolean isEntity) throws URISyntaxException {
+    StringBuilder sb = new StringBuilder("$metadata#" + entitySet.getName());
+    if(isEntity) {
+      sb.append("/$entity");
+    }
+    return ContextURL.getInstance(new URI(sb.toString()));
+  }
 
   private Entity createETAllPrim() {
     return createETAllPrim(4711);
@@ -446,41 +462,41 @@ public class ODataJsonSerializerTest {
     date2.set(2014, Calendar.JULY, 2, 13, 30, 0);
     date2.set(Calendar.MILLISECOND, 0);
     //
-    entity.addProperty(createProperty("Edm.Int16", TecSimpleProperty.Int16, ValueType.PRIMITIVE, id));
+    entity.addProperty(createProperty("Edm.Int16", TecSvcSimpleProperty.Int16, ValueType.PRIMITIVE, id));
     //
-    entity.addProperty(createProperty("Collection(Edm.Int16)", TecSimpleProperty.Collection_Int16,
+    entity.addProperty(createProperty("Collection(Edm.Int16)", TecSvcSimpleProperty.Collection_Int16,
             ValueType.COLLECTION_PRIMITIVE, id));
-    entity.addProperty(createProperty("Collection(Edm.String)", TecSimpleProperty.Collection_String,
+    entity.addProperty(createProperty("Collection(Edm.String)", TecSvcSimpleProperty.Collection_String,
             ValueType.COLLECTION_PRIMITIVE, "StringValue_1", "StringValue_2"));
-    entity.addProperty(createProperty("Collection(Edm.Boolean)", TecSimpleProperty.Collection_Boolean,
+    entity.addProperty(createProperty("Collection(Edm.Boolean)", TecSvcSimpleProperty.Collection_Boolean,
             ValueType.COLLECTION_PRIMITIVE, Boolean.TRUE, Boolean.FALSE));
-    entity.addProperty(createProperty("Collection(Edm.Byte)", TecSimpleProperty.Collection_Byte,
+    entity.addProperty(createProperty("Collection(Edm.Byte)", TecSvcSimpleProperty.Collection_Byte,
             ValueType.COLLECTION_PRIMITIVE, Byte.valueOf("19"), Byte.valueOf("42")));
-    entity.addProperty(createProperty("Collection(Edm.SByte)", TecSimpleProperty.Collection_SByte,
+    entity.addProperty(createProperty("Collection(Edm.SByte)", TecSvcSimpleProperty.Collection_SByte,
             ValueType.COLLECTION_PRIMITIVE, Short.valueOf("1"), Short.valueOf("2")));
-    entity.addProperty(createProperty("Collection(Edm.Int32)", TecSimpleProperty.Collection_Int32,
+    entity.addProperty(createProperty("Collection(Edm.Int32)", TecSvcSimpleProperty.Collection_Int32,
             ValueType.COLLECTION_PRIMITIVE, Integer.MAX_VALUE, Integer.MIN_VALUE));
-    entity.addProperty(createProperty("Collection(Edm.Int64)", TecSimpleProperty.Collection_Int64,
+    entity.addProperty(createProperty("Collection(Edm.Int64)", TecSvcSimpleProperty.Collection_Int64,
             ValueType.COLLECTION_PRIMITIVE, Long.MAX_VALUE, Long.MIN_VALUE));
-    entity.addProperty(createProperty("Collection(Edm.Single)", TecSimpleProperty.Collection_Single,
+    entity.addProperty(createProperty("Collection(Edm.Single)", TecSvcSimpleProperty.Collection_Single,
             ValueType.COLLECTION_PRIMITIVE, 47.11, 11.47));
-    entity.addProperty(createProperty("Collection(Edm.Double)", TecSimpleProperty.Collection_Double,
+    entity.addProperty(createProperty("Collection(Edm.Double)", TecSvcSimpleProperty.Collection_Double,
             ValueType.COLLECTION_PRIMITIVE, 4.711, 711.4));
-    entity.addProperty(createProperty("Collection(Edm.Decimal)", TecSimpleProperty.Collection_Decimal,
+    entity.addProperty(createProperty("Collection(Edm.Decimal)", TecSvcSimpleProperty.Collection_Decimal,
             ValueType.COLLECTION_PRIMITIVE, 4711.1174, 1174.4711));
-    entity.addProperty(createProperty("Collection(Edm.Binary)", TecSimpleProperty.Collection_Binary,
+    entity.addProperty(createProperty("Collection(Edm.Binary)", TecSvcSimpleProperty.Collection_Binary,
             ValueType.COLLECTION_PRIMITIVE, new byte[]{0x04, 0x07, 0x01, 0x01}, "test".getBytes()));
-    entity.addProperty(createProperty("Collection(Edm.Date)", TecSimpleProperty.Collection_Date,
+    entity.addProperty(createProperty("Collection(Edm.Date)", TecSvcSimpleProperty.Collection_Date,
             ValueType.COLLECTION_PRIMITIVE, date, date2));
-    entity.addProperty(createProperty("Collection(Edm.DateTimeOffset)", TecSimpleProperty.Collection_DateTimeOffset,
+    entity.addProperty(createProperty("Collection(Edm.DateTimeOffset)", TecSvcSimpleProperty.Collection_DateTimeOffset,
             ValueType.COLLECTION_PRIMITIVE, date.getTime(), date2.getTime()));
-    entity.addProperty(createProperty("Collection(Edm.Duration)", TecSimpleProperty.Collection_Duration,
+    entity.addProperty(createProperty("Collection(Edm.Duration)", TecSvcSimpleProperty.Collection_Duration,
             ValueType.COLLECTION_PRIMITIVE, date.getTimeInMillis(), date2.getTimeInMillis()));
-    entity.addProperty(createProperty("Collection(Edm.Guid)", TecSimpleProperty.Collection_Guid,
+    entity.addProperty(createProperty("Collection(Edm.Guid)", TecSvcSimpleProperty.Collection_Guid,
             ValueType.COLLECTION_PRIMITIVE,
             UUID.fromString("AAAA-BB-CC-DD-FFFFFF"),
             UUID.fromString("FFFF-DD-CC-BB-AAAAAA")));
-    entity.addProperty(createProperty("Collection(Edm.TimeOfDay)", TecSimpleProperty.Collection_TimeOfDay,
+    entity.addProperty(createProperty("Collection(Edm.TimeOfDay)", TecSvcSimpleProperty.Collection_TimeOfDay,
             ValueType.COLLECTION_PRIMITIVE, date, date2));
     return entity;
   }
@@ -490,26 +506,28 @@ public class ODataJsonSerializerTest {
     Calendar date = Calendar.getInstance();
     date.set(2014, Calendar.MARCH, 19, 10, 12, 0);
     date.set(Calendar.MILLISECOND, 0);
-    entity.addProperty(createProperty("Edm.Int16", TecSimpleProperty.Int16, ValueType.PRIMITIVE, id));
-    entity.addProperty(createProperty("Edm.String", TecSimpleProperty.String, ValueType.PRIMITIVE, "StringValue"));
-    entity.addProperty(createProperty("Edm.Boolean", TecSimpleProperty.Boolean, ValueType.PRIMITIVE, Boolean.TRUE));
-    entity.addProperty(createProperty("Edm.Byte", TecSimpleProperty.Byte, ValueType.PRIMITIVE, Byte.valueOf("19")));
-    entity.addProperty(createProperty("Edm.SByte", TecSimpleProperty.SByte, ValueType.PRIMITIVE, Short.valueOf("1")));
-    entity.addProperty(createProperty("Edm.Int32", TecSimpleProperty.Int32, ValueType.PRIMITIVE, Integer.MAX_VALUE));
-    entity.addProperty(createProperty("Edm.Int64", TecSimpleProperty.Int64, ValueType.PRIMITIVE, Long.MAX_VALUE));
-    entity.addProperty(createProperty("Edm.Single", TecSimpleProperty.Single, ValueType.PRIMITIVE, 47.11));
-    entity.addProperty(createProperty("Edm.Double", TecSimpleProperty.Double, ValueType.PRIMITIVE, 4.711));
-    entity.addProperty(createProperty("Edm.Decimal", TecSimpleProperty.Decimal, ValueType.PRIMITIVE, 4711.1174));
-    entity.addProperty(createProperty("Edm.Binary", TecSimpleProperty.Binary, ValueType.PRIMITIVE,
+    entity.addProperty(createProperty("Edm.Int16", TecSvcSimpleProperty.Int16, ValueType.PRIMITIVE, id));
+    entity.addProperty(createProperty("Edm.String", TecSvcSimpleProperty.String, ValueType.PRIMITIVE, "StringValue"));
+    entity.addProperty(createProperty("Edm.Boolean", TecSvcSimpleProperty.Boolean, ValueType.PRIMITIVE, Boolean.TRUE));
+    entity.addProperty(createProperty("Edm.Byte", TecSvcSimpleProperty.Byte, ValueType.PRIMITIVE, Byte.valueOf("19")));
+    entity.addProperty(createProperty("Edm.SByte",
+            TecSvcSimpleProperty.SByte, ValueType.PRIMITIVE, Short.valueOf("1")));
+    entity.addProperty(createProperty("Edm.Int32",
+            TecSvcSimpleProperty.Int32, ValueType.PRIMITIVE, Integer.MAX_VALUE));
+    entity.addProperty(createProperty("Edm.Int64", TecSvcSimpleProperty.Int64, ValueType.PRIMITIVE, Long.MAX_VALUE));
+    entity.addProperty(createProperty("Edm.Single", TecSvcSimpleProperty.Single, ValueType.PRIMITIVE, 47.11));
+    entity.addProperty(createProperty("Edm.Double", TecSvcSimpleProperty.Double, ValueType.PRIMITIVE, 4.711));
+    entity.addProperty(createProperty("Edm.Decimal", TecSvcSimpleProperty.Decimal, ValueType.PRIMITIVE, 4711.1174));
+    entity.addProperty(createProperty("Edm.Binary", TecSvcSimpleProperty.Binary, ValueType.PRIMITIVE,
         new byte[]{0x04, 0x07, 0x01, 0x01}));
-    entity.addProperty(createProperty("Edm.Date", TecSimpleProperty.Date, ValueType.PRIMITIVE, date));
-    entity.addProperty(createProperty("Edm.DateTimeOffset", TecSimpleProperty.DateTimeOffset, ValueType.PRIMITIVE,
+    entity.addProperty(createProperty("Edm.Date", TecSvcSimpleProperty.Date, ValueType.PRIMITIVE, date));
+    entity.addProperty(createProperty("Edm.DateTimeOffset", TecSvcSimpleProperty.DateTimeOffset, ValueType.PRIMITIVE,
         date.getTime()));
-    entity.addProperty(createProperty("Edm.Duration", TecSimpleProperty.Duration, ValueType.PRIMITIVE,
+    entity.addProperty(createProperty("Edm.Duration", TecSvcSimpleProperty.Duration, ValueType.PRIMITIVE,
         date.getTimeInMillis()));
-    entity.addProperty(createProperty("Edm.Guid", TecSimpleProperty.Guid, ValueType.PRIMITIVE,
+    entity.addProperty(createProperty("Edm.Guid", TecSvcSimpleProperty.Guid, ValueType.PRIMITIVE,
         UUID.fromString("AAAA-BB-CC-DD-FFFFFF")));
-    entity.addProperty(createProperty("Edm.TimeOfDay", TecSimpleProperty.TimeOfDay, ValueType.PRIMITIVE, date));
+    entity.addProperty(createProperty("Edm.TimeOfDay", TecSvcSimpleProperty.TimeOfDay, ValueType.PRIMITIVE, date));
     return entity;
   }
 


[5/6] git commit: [OLINGO-317] Merge with current master

Posted by mi...@apache.org.
[OLINGO-317] Merge with current 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/66f26e5b
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/66f26e5b
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/66f26e5b

Branch: refs/heads/master
Commit: 66f26e5b6ac3e2e3dd9c69bb6f2fbbe69baee87d
Parents: 876655f 2bd0662
Author: Michael Bolz <mi...@sap.com>
Authored: Thu Jul 3 09:04:49 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Thu Jul 3 09:04:49 2014 +0200

----------------------------------------------------------------------
 fit/pom.xml                                     |    2 +-
 .../org/apache/olingo/fit/AbstractServices.java |  735 +++++------
 .../fit/UnsupportedMediaTypeException.java      |   21 +-
 .../apache/olingo/fit/V3ActionOverloading.java  |   72 +-
 .../org/apache/olingo/fit/V3KeyAsSegment.java   |  132 +-
 .../java/org/apache/olingo/fit/V3OpenType.java  |   64 +-
 .../org/apache/olingo/fit/V3PrimitiveKeys.java  |   19 +-
 .../java/org/apache/olingo/fit/V3Services.java  |  200 +--
 .../main/java/org/apache/olingo/fit/V4Demo.java |  104 +-
 .../org/apache/olingo/fit/V4KeyAsSegment.java   |   90 +-
 .../java/org/apache/olingo/fit/V4NorthWind.java |   17 +-
 .../org/apache/olingo/fit/V4NorthWindExt.java   |   19 +-
 .../java/org/apache/olingo/fit/V4OpenType.java  |   60 +-
 .../java/org/apache/olingo/fit/V4Services.java  |  266 ++--
 .../org/apache/olingo/fit/V4Vocabularies.java   |   41 +-
 .../fit/metadata/AbstractMetadataElement.java   |   14 +-
 .../apache/olingo/fit/metadata/Association.java |   14 +-
 .../olingo/fit/metadata/AssociationSet.java     |   14 +-
 .../apache/olingo/fit/metadata/Container.java   |   14 +-
 .../apache/olingo/fit/metadata/EntitySet.java   |   23 +-
 .../apache/olingo/fit/metadata/EntityType.java  |   18 +-
 .../apache/olingo/fit/metadata/Metadata.java    |   62 +-
 .../olingo/fit/metadata/NavigationProperty.java |   24 +-
 .../apache/olingo/fit/metadata/Property.java    |   20 +-
 .../org/apache/olingo/fit/metadata/Schema.java  |   18 +-
 .../org/apache/olingo/fit/methods/MERGE.java    |   20 +-
 .../org/apache/olingo/fit/methods/PATCH.java    |   20 +-
 .../apache/olingo/fit/rproxy/LinkRewrite.java   |   17 +-
 .../olingo/fit/rproxy/LinkRewriteRenderer.java  |   23 +-
 .../fit/serializer/FITAtomDeserializer.java     |   14 +-
 .../olingo/fit/utils/AbstractUtilities.java     |   39 +-
 .../org/apache/olingo/fit/utils/Accept.java     |   25 +-
 .../org/apache/olingo/fit/utils/Commons.java    |  108 +-
 .../apache/olingo/fit/utils/ConstantKey.java    |   14 +-
 .../org/apache/olingo/fit/utils/Constants.java  |   25 +-
 .../org/apache/olingo/fit/utils/FSManager.java  |   14 +-
 .../fit/utils/InjectableSerializerProvider.java |   18 +-
 .../apache/olingo/fit/utils/JSONUtilities.java  |   80 +-
 .../org/apache/olingo/fit/utils/LinkInfo.java   |   16 +-
 .../olingo/fit/utils/MetadataLinkInfo.java      |   35 +-
 .../olingo/fit/utils/NavigationLinks.java       |   27 +-
 .../utils/ResolvingReferencesInterceptor.java   |   20 +-
 .../fit/utils/XHTTPMethodInterceptor.java       |   17 +-
 .../org/apache/olingo/fit/utils/XMLElement.java |   18 +-
 .../olingo/fit/utils/XMLEventReaderWrapper.java |   42 +-
 .../apache/olingo/fit/utils/XMLUtilities.java   |  268 ++--
 .../olingo/fit/AbstractBaseTestITCase.java      |   14 +-
 .../olingo/fit/proxy/v3/AbstractTestITCase.java |   56 +-
 .../proxy/v3/ActionOverloadingTestITCase.java   |   50 +-
 .../olingo/fit/proxy/v3/AsyncTestITCase.java    |   71 +-
 .../olingo/fit/proxy/v3/ContextTestITCase.java  |  127 +-
 .../fit/proxy/v3/EntityCreateTestITCase.java    |   34 +-
 .../fit/proxy/v3/EntityRetrieveTestITCase.java  |   94 +-
 .../fit/proxy/v3/EntitySetTestITCase.java       |   15 +-
 .../fit/proxy/v3/EntityUpdateTestITCase.java    |  154 ++-
 .../olingo/fit/proxy/v3/FilterTestITCase.java   |   41 +-
 .../olingo/fit/proxy/v3/InvokeTestITCase.java   |   34 +-
 .../fit/proxy/v3/MediaEntityTestITCase.java     |   19 +-
 .../olingo/fit/proxy/v3/OpenTypeTestITCase.java |   25 +-
 .../fit/proxy/v3/PrimitiveKeysTestITCase.java   |   27 +-
 .../olingo/fit/proxy/v3/PropertyTestITCase.java |   50 +-
 .../AllGeoCollectionTypesSet.java               |   56 +-
 .../astoriadefaultservice/AllGeoTypesSet.java   |   50 +-
 .../services/astoriadefaultservice/Car.java     |   50 +-
 .../astoriadefaultservice/Computer.java         |   50 +-
 .../astoriadefaultservice/ComputerDetail.java   |   50 +-
 .../astoriadefaultservice/Customer.java         |   50 +-
 .../astoriadefaultservice/CustomerInfo.java     |   50 +-
 .../astoriadefaultservice/DefaultContainer.java |  211 ++--
 .../services/astoriadefaultservice/Driver.java  |   50 +-
 .../astoriadefaultservice/LastLogin.java        |   50 +-
 .../services/astoriadefaultservice/License.java |   50 +-
 .../services/astoriadefaultservice/Login.java   |   50 +-
 .../astoriadefaultservice/MappedEntityType.java |   50 +-
 .../services/astoriadefaultservice/Message.java |   51 +-
 .../MessageAttachment.java                      |   50 +-
 .../services/astoriadefaultservice/Order.java   |   50 +-
 .../astoriadefaultservice/OrderLine.java        |   69 +-
 .../astoriadefaultservice/PageView.java         |   56 +-
 .../services/astoriadefaultservice/Person.java  |   76 +-
 .../astoriadefaultservice/PersonMetadata.java   |   50 +-
 .../services/astoriadefaultservice/Product.java |   56 +-
 .../astoriadefaultservice/ProductDetail.java    |   50 +-
 .../astoriadefaultservice/ProductPhoto.java     |   51 +-
 .../astoriadefaultservice/ProductReview.java    |   51 +-
 .../astoriadefaultservice/RSAToken.java         |   50 +-
 .../astoriadefaultservice/package-info.java     |   16 +-
 .../astoriadefaultservice/types/Aliases.java    |   62 +-
 .../types/AllSpatialCollectionTypes.java        |  139 +--
 .../AllSpatialCollectionTypesCollection.java    |   44 +-
 .../types/AllSpatialCollectionTypes_Simple.java |  470 ++++---
 ...SpatialCollectionTypes_SimpleCollection.java |   44 +-
 .../types/AllSpatialTypes.java                  |  985 +++++++--------
 .../types/AllSpatialTypesCollection.java        |   44 +-
 .../astoriadefaultservice/types/AuditInfo.java  |   89 +-
 .../types/BackOrderLine.java                    |  457 +++----
 .../types/BackOrderLine2.java                   |  457 +++----
 .../types/BackOrderLine2Collection.java         |   44 +-
 .../types/BackOrderLineCollection.java          |   44 +-
 .../astoriadefaultservice/types/Car.java        |  305 ++---
 .../types/CarCollection.java                    |   44 +-
 .../types/ComplexToCategory.java                |   77 +-
 .../astoriadefaultservice/types/Computer.java   |  222 ++--
 .../types/ComputerCollection.java               |   44 +-
 .../types/ComputerDetail.java                   |  500 ++++----
 .../types/ComputerDetailCollection.java         |   44 +-
 .../types/ConcurrencyInfo.java                  |   70 +-
 .../types/ContactDetails.java                   |  147 +--
 .../astoriadefaultservice/types/Contractor.java |  477 ++++---
 .../types/ContractorCollection.java             |   44 +-
 .../astoriadefaultservice/types/Customer.java   |  648 +++++-----
 .../types/CustomerCollection.java               |   44 +-
 .../types/CustomerInfo.java                     |  199 ++-
 .../types/CustomerInfoCollection.java           |   44 +-
 .../astoriadefaultservice/types/Dimensions.java |   77 +-
 .../types/DiscontinuedProduct.java              |  901 +++++++-------
 .../types/DiscontinuedProductCollection.java    |   44 +-
 .../astoriadefaultservice/types/Driver.java     |  222 ++--
 .../types/DriverCollection.java                 |   44 +-
 .../astoriadefaultservice/types/Employee.java   |  470 ++++---
 .../types/EmployeeCollection.java               |   58 +-
 .../astoriadefaultservice/types/LastLogin.java  |  328 +++--
 .../types/LastLoginCollection.java              |   44 +-
 .../astoriadefaultservice/types/License.java    |  381 +++---
 .../types/LicenseCollection.java                |   44 +-
 .../astoriadefaultservice/types/Login.java      |  346 +++---
 .../types/LoginCollection.java                  |   44 +-
 .../types/MappedEntityType.java                 | 1173 +++++++++---------
 .../types/MappedEntityTypeCollection.java       |   44 +-
 .../astoriadefaultservice/types/Message.java    |  548 ++++----
 .../types/MessageAttachment.java                |  192 ++-
 .../types/MessageAttachmentCollection.java      |   44 +-
 .../types/MessageCollection.java                |   44 +-
 .../astoriadefaultservice/types/MessageKey.java |   76 +-
 .../astoriadefaultservice/types/Order.java      |  319 +++--
 .../types/OrderCollection.java                  |   44 +-
 .../astoriadefaultservice/types/OrderLine.java  |  435 +++----
 .../types/OrderLineCollection.java              |   44 +-
 .../types/OrderLineKey.java                     |   76 +-
 .../astoriadefaultservice/types/PageView.java   |  381 +++---
 .../types/PageViewCollection.java               |   44 +-
 .../astoriadefaultservice/types/Person.java     |  242 ++--
 .../types/PersonCollection.java                 |   44 +-
 .../types/PersonMetadata.java                   |  328 +++--
 .../types/PersonMetadataCollection.java         |   44 +-
 .../astoriadefaultservice/types/Phone.java      |   69 +-
 .../astoriadefaultservice/types/Product.java    |  639 +++++-----
 .../types/ProductCollection.java                |   44 +-
 .../types/ProductDetail.java                    |  222 ++--
 .../types/ProductDetailCollection.java          |   44 +-
 .../types/ProductPageView.java                  |  514 ++++----
 .../types/ProductPageViewCollection.java        |   44 +-
 .../types/ProductPhoto.java                     |  244 ++--
 .../types/ProductPhotoCollection.java           |   44 +-
 .../types/ProductPhotoKey.java                  |   76 +-
 .../types/ProductReview.java                    |  328 +++--
 .../types/ProductReviewCollection.java          |   44 +-
 .../types/ProductReviewKey.java                 |   92 +-
 .../astoriadefaultservice/types/RSAToken.java   |  222 ++--
 .../types/RSATokenCollection.java               |   44 +-
 .../types/SpecialEmployee.java                  |  669 +++++-----
 .../types/SpecialEmployeeCollection.java        |   58 +-
 .../types/package-info.java                     |   16 +-
 .../opentypesservicev3/DefaultContainer.java    |   66 +-
 .../odata/services/opentypesservicev3/Row.java  |   55 +-
 .../services/opentypesservicev3/RowIndex.java   |   49 +-
 .../opentypesservicev3/package-info.java        |   16 +-
 .../types/ContactDetails.java                   |  151 +--
 .../opentypesservicev3/types/IndexedRow.java    |  149 +--
 .../types/IndexedRowCollection.java             |   44 +-
 .../services/opentypesservicev3/types/Row.java  |  140 +--
 .../opentypesservicev3/types/RowCollection.java |   44 +-
 .../opentypesservicev3/types/RowIndex.java      |  170 ++-
 .../types/RowIndexCollection.java               |   44 +-
 .../opentypesservicev3/types/package-info.java  |   16 +-
 .../primitivekeysservice/EdmBinarySet.java      |   50 +-
 .../primitivekeysservice/EdmBooleanSet.java     |   50 +-
 .../primitivekeysservice/EdmByteSet.java        |   50 +-
 .../EdmDateTimeOffsetSet.java                   |   50 +-
 .../primitivekeysservice/EdmDateTimeSet.java    |   50 +-
 .../primitivekeysservice/EdmDecimalSet.java     |   50 +-
 .../primitivekeysservice/EdmDoubleSet.java      |   50 +-
 .../primitivekeysservice/EdmGuidSet.java        |   50 +-
 .../primitivekeysservice/EdmInt16Set.java       |   50 +-
 .../primitivekeysservice/EdmInt32Set.java       |   50 +-
 .../primitivekeysservice/EdmInt64Set.java       |   50 +-
 .../primitivekeysservice/EdmSingleSet.java      |   50 +-
 .../primitivekeysservice/EdmStringSet.java      |   50 +-
 .../primitivekeysservice/EdmTimeSet.java        |   50 +-
 .../services/primitivekeysservice/Folders.java  |   50 +-
 .../primitivekeysservice/TestContext.java       |   88 +-
 .../primitivekeysservice/package-info.java      |   16 +-
 .../primitivekeysservice/types/EdmBinary.java   |  139 +--
 .../types/EdmBinaryCollection.java              |   44 +-
 .../primitivekeysservice/types/EdmBoolean.java  |  139 +--
 .../types/EdmBooleanCollection.java             |   44 +-
 .../primitivekeysservice/types/EdmByte.java     |  139 +--
 .../types/EdmByteCollection.java                |   44 +-
 .../primitivekeysservice/types/EdmDateTime.java |  139 +--
 .../types/EdmDateTimeCollection.java            |   44 +-
 .../types/EdmDateTimeOffset.java                |  139 +--
 .../types/EdmDateTimeOffsetCollection.java      |   44 +-
 .../primitivekeysservice/types/EdmDecimal.java  |  139 +--
 .../types/EdmDecimalCollection.java             |   44 +-
 .../primitivekeysservice/types/EdmDouble.java   |  139 +--
 .../types/EdmDoubleCollection.java              |   44 +-
 .../primitivekeysservice/types/EdmGuid.java     |  139 +--
 .../types/EdmGuidCollection.java                |   44 +-
 .../primitivekeysservice/types/EdmInt16.java    |  139 +--
 .../types/EdmInt16Collection.java               |   44 +-
 .../primitivekeysservice/types/EdmInt32.java    |  139 +--
 .../types/EdmInt32Collection.java               |   44 +-
 .../primitivekeysservice/types/EdmInt64.java    |  139 +--
 .../types/EdmInt64Collection.java               |   44 +-
 .../primitivekeysservice/types/EdmSingle.java   |  139 +--
 .../types/EdmSingleCollection.java              |   44 +-
 .../primitivekeysservice/types/EdmString.java   |  139 +--
 .../types/EdmStringCollection.java              |   44 +-
 .../primitivekeysservice/types/EdmTime.java     |  139 +--
 .../types/EdmTimeCollection.java                |   44 +-
 .../primitivekeysservice/types/Folder.java      |  222 ++--
 .../types/FolderCollection.java                 |   44 +-
 .../types/package-info.java                     |   16 +-
 .../AllGeoCollectionTypesSet.java               |   56 +-
 .../astoriadefaultservice/AllGeoTypesSet.java   |   50 +-
 .../services/astoriadefaultservice/Car.java     |   49 +-
 .../astoriadefaultservice/Computer.java         |   50 +-
 .../astoriadefaultservice/ComputerDetail.java   |   50 +-
 .../astoriadefaultservice/Customer.java         |   50 +-
 .../astoriadefaultservice/CustomerInfo.java     |   50 +-
 .../astoriadefaultservice/DefaultContainer.java |  299 ++---
 .../services/astoriadefaultservice/Driver.java  |   50 +-
 .../astoriadefaultservice/LastLogin.java        |   50 +-
 .../services/astoriadefaultservice/License.java |   50 +-
 .../services/astoriadefaultservice/Login.java   |   50 +-
 .../astoriadefaultservice/MappedEntityType.java |   50 +-
 .../services/astoriadefaultservice/Message.java |   51 +-
 .../MessageAttachment.java                      |   50 +-
 .../services/astoriadefaultservice/Order.java   |   50 +-
 .../astoriadefaultservice/OrderLine.java        |   69 +-
 .../astoriadefaultservice/PageView.java         |   56 +-
 .../services/astoriadefaultservice/Person.java  |   76 +-
 .../astoriadefaultservice/PersonMetadata.java   |   50 +-
 .../services/astoriadefaultservice/Product.java |   56 +-
 .../astoriadefaultservice/ProductDetail.java    |   50 +-
 .../astoriadefaultservice/ProductPhoto.java     |   51 +-
 .../astoriadefaultservice/ProductReview.java    |   51 +-
 .../astoriadefaultservice/RSAToken.java         |   50 +-
 .../astoriadefaultservice/package-info.java     |   16 +-
 .../astoriadefaultservice/types/Aliases.java    |   62 +-
 .../types/AllSpatialCollectionTypes.java        |  139 +--
 .../AllSpatialCollectionTypesCollection.java    |   44 +-
 .../types/AllSpatialCollectionTypes_Simple.java |  470 ++++---
 ...SpatialCollectionTypes_SimpleCollection.java |   44 +-
 .../types/AllSpatialTypes.java                  |  985 +++++++--------
 .../types/AllSpatialTypesCollection.java        |   44 +-
 .../astoriadefaultservice/types/AuditInfo.java  |   89 +-
 .../types/BackOrderLine.java                    |  441 ++++---
 .../types/BackOrderLine2.java                   |  442 +++----
 .../types/BackOrderLine2Collection.java         |   44 +-
 .../types/BackOrderLineCollection.java          |   44 +-
 .../astoriadefaultservice/types/Car.java        |  305 ++---
 .../types/CarCollection.java                    |   44 +-
 .../types/ComplexToCategory.java                |   77 +-
 .../types/ComplexWithAllPrimitiveTypes.java     |  167 +--
 .../astoriadefaultservice/types/Computer.java   |  245 ++--
 .../types/ComputerCollection.java               |   44 +-
 .../types/ComputerDetail.java                   |  526 ++++----
 .../types/ComputerDetailCollection.java         |   44 +-
 .../types/ConcurrencyInfo.java                  |   70 +-
 .../types/ContactDetails.java                   |  147 +--
 .../astoriadefaultservice/types/Contractor.java |  452 ++++---
 .../types/ContractorCollection.java             |   44 +-
 .../astoriadefaultservice/types/Customer.java   |  648 +++++-----
 .../types/CustomerCollection.java               |   44 +-
 .../types/CustomerInfo.java                     |  199 ++-
 .../types/CustomerInfoCollection.java           |   44 +-
 .../astoriadefaultservice/types/Dimensions.java |   77 +-
 .../types/DiscontinuedProduct.java              |  901 +++++++-------
 .../types/DiscontinuedProductCollection.java    |   44 +-
 .../astoriadefaultservice/types/Driver.java     |  222 ++--
 .../types/DriverCollection.java                 |   44 +-
 .../astoriadefaultservice/types/Employee.java   |  450 ++++---
 .../types/EmployeeCollection.java               |   58 +-
 .../astoriadefaultservice/types/LastLogin.java  |  328 +++--
 .../types/LastLoginCollection.java              |   44 +-
 .../astoriadefaultservice/types/License.java    |  381 +++---
 .../types/LicenseCollection.java                |   44 +-
 .../astoriadefaultservice/types/Login.java      |  346 +++---
 .../types/LoginCollection.java                  |   44 +-
 .../types/MappedEntityType.java                 | 1173 +++++++++---------
 .../types/MappedEntityTypeCollection.java       |   44 +-
 .../astoriadefaultservice/types/Message.java    |  548 ++++----
 .../types/MessageAttachment.java                |  192 ++-
 .../types/MessageAttachmentCollection.java      |   44 +-
 .../types/MessageCollection.java                |   44 +-
 .../astoriadefaultservice/types/MessageKey.java |   76 +-
 .../astoriadefaultservice/types/Order.java      |  319 +++--
 .../types/OrderCollection.java                  |   44 +-
 .../astoriadefaultservice/types/OrderLine.java  |  411 +++---
 .../types/OrderLineCollection.java              |   44 +-
 .../types/OrderLineKey.java                     |   76 +-
 .../astoriadefaultservice/types/PageView.java   |  381 +++---
 .../types/PageViewCollection.java               |   44 +-
 .../astoriadefaultservice/types/Person.java     |  222 ++--
 .../types/PersonCollection.java                 |   44 +-
 .../types/PersonMetadata.java                   |  328 +++--
 .../types/PersonMetadataCollection.java         |   44 +-
 .../astoriadefaultservice/types/Phone.java      |   69 +-
 .../astoriadefaultservice/types/Product.java    |  642 +++++-----
 .../types/ProductCollection.java                |   44 +-
 .../types/ProductDetail.java                    |  222 ++--
 .../types/ProductDetailCollection.java          |   44 +-
 .../types/ProductPageView.java                  |  514 ++++----
 .../types/ProductPageViewCollection.java        |   44 +-
 .../types/ProductPhoto.java                     |  244 ++--
 .../types/ProductPhotoCollection.java           |   44 +-
 .../types/ProductPhotoKey.java                  |   76 +-
 .../types/ProductReview.java                    |  328 +++--
 .../types/ProductReviewCollection.java          |   44 +-
 .../types/ProductReviewKey.java                 |   92 +-
 .../astoriadefaultservice/types/RSAToken.java   |  222 ++--
 .../types/RSATokenCollection.java               |   44 +-
 .../types/SpecialEmployee.java                  |  645 +++++-----
 .../types/SpecialEmployeeCollection.java        |   44 +-
 .../types/package-info.java                     |   16 +-
 .../olingo/fit/proxy/v4/AbstractTestITCase.java |   25 +-
 .../olingo/fit/proxy/v4/AsyncTestITCase.java    |   34 +-
 .../proxy/v4/AuthEntityCreateTestITCase.java    |   22 +-
 .../proxy/v4/AuthEntityRetrieveTestITCase.java  |   17 +-
 .../v4/BoundOperationInvokeTestITCase.java      |   28 +-
 .../fit/proxy/v4/DerivedTypeTestITCase.java     |   32 +-
 .../fit/proxy/v4/EntityCreateTestITCase.java    |   44 +-
 .../fit/proxy/v4/EntityRetrieveTestITCase.java  |   29 +-
 .../fit/proxy/v4/EntitySetTestITCase.java       |   14 +-
 .../fit/proxy/v4/EntityUpdateTestITCase.java    |   39 +-
 .../olingo/fit/proxy/v4/FilterTestITCase.java   |   28 +-
 .../fit/proxy/v4/KeyAsSegmentTestITCase.java    |   14 +-
 .../fit/proxy/v4/MediaEntityTestITCase.java     |   15 +-
 ...TransactionalAuthEntityCreateTestITCase.java |   22 +-
 .../NonTransactionalEntityCreateTestITCase.java |   17 +-
 .../NonTransactionalEntityUpdateTestITCase.java |   17 +-
 .../NonTransactionalMediaEntityTestITCase.java  |   14 +-
 .../olingo/fit/proxy/v4/OpenTypeTestITCase.java |   27 +-
 .../v4/OperationImportInvokeTestITCase.java     |   22 +-
 .../olingo/fit/proxy/v4/PropertyTestITCase.java |   14 +-
 .../fit/proxy/v4/SingletonTestITCase.java       |   14 +-
 .../v4/UnauthorizedEntityCreateTestITCase.java  |   19 +-
 .../proxy/v4/demo/odatademo/Advertisements.java |   48 +-
 .../fit/proxy/v4/demo/odatademo/Categories.java |   48 +-
 .../proxy/v4/demo/odatademo/DemoService.java    |   97 +-
 .../proxy/v4/demo/odatademo/PersonDetails.java  |   48 +-
 .../fit/proxy/v4/demo/odatademo/Persons.java    |   62 +-
 .../proxy/v4/demo/odatademo/ProductDetails.java |   48 +-
 .../fit/proxy/v4/demo/odatademo/Products.java   |   52 +-
 .../fit/proxy/v4/demo/odatademo/Suppliers.java  |   48 +-
 .../proxy/v4/demo/odatademo/package-info.java   |   16 +-
 .../proxy/v4/demo/odatademo/types/Address.java  |  272 ++--
 .../v4/demo/odatademo/types/Advertisement.java  |  279 ++---
 .../types/AdvertisementCollection.java          |   43 +-
 .../proxy/v4/demo/odatademo/types/Category.java |  220 ++--
 .../odatademo/types/CategoryCollection.java     |   43 +-
 .../proxy/v4/demo/odatademo/types/Customer.java |  285 ++---
 .../odatademo/types/CustomerCollection.java     |   43 +-
 .../proxy/v4/demo/odatademo/types/Employee.java |  391 +++---
 .../odatademo/types/EmployeeCollection.java     |   43 +-
 .../demo/odatademo/types/FeaturedProduct.java   |  615 +++++----
 .../types/FeaturedProductCollection.java        |   43 +-
 .../proxy/v4/demo/odatademo/types/Person.java   |  219 ++--
 .../demo/odatademo/types/PersonCollection.java  |   43 +-
 .../v4/demo/odatademo/types/PersonDetail.java   |  440 +++----
 .../odatademo/types/PersonDetailCollection.java |   43 +-
 .../proxy/v4/demo/odatademo/types/Product.java  |  566 ++++-----
 .../demo/odatademo/types/ProductCollection.java |   43 +-
 .../v4/demo/odatademo/types/ProductDetail.java  |  219 ++--
 .../types/ProductDetailCollection.java          |   43 +-
 .../proxy/v4/demo/odatademo/types/Supplier.java |  387 +++---
 .../odatademo/types/SupplierCollection.java     |   43 +-
 .../v4/demo/odatademo/types/package-info.java   |   16 +-
 .../opentypesservicev4/DefaultContainer.java    |   72 +-
 .../odata/services/opentypesservicev4/Row.java  |   55 +-
 .../services/opentypesservicev4/RowIndex.java   |   49 +-
 .../opentypesservicev4/package-info.java        |   16 +-
 .../opentypesservicev4/types/AccountInfo.java   |  155 +--
 .../opentypesservicev4/types/Color.java         |   45 +-
 .../types/ContactDetails.java                   |  552 ++++-----
 .../opentypesservicev4/types/IndexedRow.java    |  149 +--
 .../types/IndexedRowCollection.java             |   44 +-
 .../services/opentypesservicev4/types/Row.java  |  140 +--
 .../opentypesservicev4/types/RowCollection.java |   44 +-
 .../opentypesservicev4/types/RowIndex.java      |  168 +--
 .../types/RowIndexCollection.java               |   44 +-
 .../opentypesservicev4/types/package-info.java  |   16 +-
 .../services/odatawcfservice/Accounts.java      |   49 +-
 .../odata/services/odatawcfservice/Boss.java    |   44 +-
 .../odata/services/odatawcfservice/Company.java |   44 +-
 .../services/odatawcfservice/Customers.java     |   50 +-
 .../odatawcfservice/DefaultStoredPI.java        |   44 +-
 .../services/odatawcfservice/Departments.java   |   50 +-
 .../services/odatawcfservice/Employees.java     |   50 +-
 .../odatawcfservice/InMemoryEntities.java       |  294 ++---
 .../services/odatawcfservice/LabourUnion.java   |   44 +-
 .../services/odatawcfservice/OrderDetails.java  |   51 +-
 .../odata/services/odatawcfservice/Orders.java  |   49 +-
 .../odata/services/odatawcfservice/People.java  |   67 +-
 .../odatawcfservice/ProductDetails.java         |   51 +-
 .../odatawcfservice/ProductReviews.java         |   51 +-
 .../services/odatawcfservice/Products.java      |   49 +-
 .../services/odatawcfservice/PublicCompany.java |   44 +-
 .../services/odatawcfservice/StoredPIs.java     |   50 +-
 .../odatawcfservice/SubscriptionTemplates.java  |   50 +-
 .../services/odatawcfservice/VipCustomer.java   |   44 +-
 .../services/odatawcfservice/package-info.java  |   16 +-
 .../odatawcfservice/types/AccessLevel.java      |   49 +-
 .../services/odatawcfservice/types/Account.java |  488 ++++----
 .../types/AccountCollection.java                |   44 +-
 .../odatawcfservice/types/AccountInfo.java      |  155 +--
 .../services/odatawcfservice/types/Address.java |  192 ++-
 .../services/odatawcfservice/types/Asset.java   |  245 ++--
 .../odatawcfservice/types/AssetCollection.java  |   44 +-
 .../services/odatawcfservice/types/Club.java    |  192 ++-
 .../odatawcfservice/types/ClubCollection.java   |   44 +-
 .../services/odatawcfservice/types/Color.java   |   45 +-
 .../services/odatawcfservice/types/Company.java |  528 ++++----
 .../odatawcfservice/types/CompanyAddress.java   |  254 ++--
 .../odatawcfservice/types/CompanyCategory.java  |   47 +-
 .../types/CompanyCollection.java                |   44 +-
 .../odatawcfservice/types/CreditCardPI.java     |  658 +++++-----
 .../types/CreditCardPICollection.java           |   44 +-
 .../odatawcfservice/types/CreditRecord.java     |  298 ++---
 .../types/CreditRecordCollection.java           |   44 +-
 .../odatawcfservice/types/Customer.java         |  823 ++++++------
 .../types/CustomerCollection.java               |   44 +-
 .../odatawcfservice/types/Department.java       |  274 ++--
 .../types/DepartmentCollection.java             |   44 +-
 .../odatawcfservice/types/Employee.java         |  739 +++++------
 .../types/EmployeeCollection.java               |   44 +-
 .../odatawcfservice/types/GiftCard.java         |  377 +++---
 .../types/GiftCardCollection.java               |   44 +-
 .../odatawcfservice/types/HomeAddress.java      |  254 ++--
 .../services/odatawcfservice/types/IsBoss.java  |   25 +-
 .../odatawcfservice/types/LabourUnion.java      |  192 ++-
 .../types/LabourUnionCollection.java            |   44 +-
 .../services/odatawcfservice/types/Order.java   |  390 +++---
 .../odatawcfservice/types/OrderCollection.java  |   44 +-
 .../odatawcfservice/types/OrderDetail.java      |  411 +++---
 .../types/OrderDetailCollection.java            |   44 +-
 .../odatawcfservice/types/OrderDetailKey.java   |   76 +-
 .../types/PaymentInstrument.java                |  359 +++---
 .../types/PaymentInstrumentCollection.java      |   44 +-
 .../services/odatawcfservice/types/Person.java  |  594 +++++----
 .../odatawcfservice/types/PersonCollection.java |   44 +-
 .../services/odatawcfservice/types/Product.java |  644 +++++-----
 .../types/ProductCollection.java                |   61 +-
 .../odatawcfservice/types/ProductDetail.java    |  384 +++---
 .../types/ProductDetailCollection.java          |   44 +-
 .../odatawcfservice/types/ProductDetailKey.java |   76 +-
 .../odatawcfservice/types/ProductReview.java    |  405 +++---
 .../types/ProductReviewCollection.java          |   44 +-
 .../odatawcfservice/types/ProductReviewKey.java |  108 +-
 .../odatawcfservice/types/PublicCompany.java    |  700 ++++++-----
 .../types/PublicCompanyCollection.java          |   44 +-
 .../odatawcfservice/types/Statement.java        |  298 ++---
 .../types/StatementCollection.java              |   44 +-
 .../odatawcfservice/types/StoredPI.java         |  298 ++---
 .../types/StoredPICollection.java               |   44 +-
 .../odatawcfservice/types/Subscription.java     |  351 +++---
 .../types/SubscriptionCollection.java           |   44 +-
 .../odatawcfservice/types/package-info.java     |   16 +-
 .../apache/olingo/fit/tecsvc/BasicITCase.java   |    8 +-
 .../apache/olingo/fit/tecsvc/PingITCase.java    |   15 +-
 .../apache/olingo/fit/tecsvc/TecSvcConst.java   |   25 +
 .../olingo/fit/v3/AbstractTestITCase.java       |  128 +-
 .../fit/v3/ActionOverloadingTestITCase.java     |   57 +-
 .../apache/olingo/fit/v3/AsyncTestITCase.java   |   33 +-
 .../fit/v3/AuthEntityRetrieveTestITCase.java    |   14 +-
 .../apache/olingo/fit/v3/BatchTestITCase.java   |  115 +-
 .../apache/olingo/fit/v3/CountTestITCase.java   |   18 +-
 .../olingo/fit/v3/EntityCreateTestITCase.java   |  120 +-
 .../olingo/fit/v3/EntityRetrieveTestITCase.java |   30 +-
 .../olingo/fit/v3/EntitySetTestITCase.java      |   18 +-
 .../olingo/fit/v3/EntityUpdateTestITCase.java   |   60 +-
 .../apache/olingo/fit/v3/ErrorTestITCase.java   |   18 +-
 .../olingo/fit/v3/FilterFactoryTestITCase.java  |   70 +-
 .../apache/olingo/fit/v3/FilterTestITCase.java  |   18 +-
 .../apache/olingo/fit/v3/InvokeTestITCase.java  |   73 +-
 .../olingo/fit/v3/KeyAsSegmentTestITCase.java   |   20 +-
 .../apache/olingo/fit/v3/LinkTestITCase.java    |   37 +-
 .../olingo/fit/v3/MediaEntityTestITCase.java    |   30 +-
 .../olingo/fit/v3/MetadataTestITCase.java       |   19 +-
 .../olingo/fit/v3/OpenTypeTestITCase.java       |   96 +-
 .../olingo/fit/v3/PrimitiveKeysTestITCase.java  |   16 +-
 .../fit/v3/PropertyRetrieveTestITCase.java      |  124 +-
 .../olingo/fit/v3/PropertyTestITCase.java       |   68 +-
 .../olingo/fit/v3/PropertyValueTestITCase.java  |   44 +-
 .../olingo/fit/v3/QueryOptionsTestITCase.java   |   32 +-
 .../fit/v3/ServiceDocumentTestITCase.java       |   19 +-
 .../v3/XHTTPMethodEntityUpdateTestITCase.java   |   14 +-
 .../v3/XHTTPMethodPropertyUpdateTestITCase.java |   14 +-
 .../olingo/fit/v4/AbstractTestITCase.java       |   38 +-
 .../apache/olingo/fit/v4/AsyncTestITCase.java   |   44 +-
 .../olingo/fit/v4/AuthBatchTestITCase.java      |   16 +-
 .../apache/olingo/fit/v4/BatchTestITCase.java   |  112 +-
 .../fit/v4/BoundOperationInvokeTestITCase.java  |  232 ++--
 .../olingo/fit/v4/ConformanceTestITCase.java    |  106 +-
 .../apache/olingo/fit/v4/DeltaTestITCase.java   |   18 +-
 .../olingo/fit/v4/DerivedTypeTestITCase.java    |   66 +-
 .../olingo/fit/v4/EntityCreateTestITCase.java   |   76 +-
 .../olingo/fit/v4/EntityRetrieveTestITCase.java |   60 +-
 .../olingo/fit/v4/EntitySetTestITCase.java      |   22 +-
 .../olingo/fit/v4/EntityUpdateTestITCase.java   |   50 +-
 .../olingo/fit/v4/ErrorResponseTestITCase.java  |   22 +-
 .../olingo/fit/v4/FilterFactoryTestITCase.java  |   20 +-
 .../fit/v4/JSONFormatConformanceTestITCase.java |  164 +--
 .../olingo/fit/v4/KeyAsSegmentTestITCase.java   |   24 +-
 .../olingo/fit/v4/MediaEntityTestITCase.java    |   40 +-
 .../olingo/fit/v4/MetadataTestITCase.java       |   34 +-
 .../olingo/fit/v4/OpenTypeTestITCase.java       |   98 +-
 .../fit/v4/OperationImportInvokeTestITCase.java |  128 +-
 .../olingo/fit/v4/PropertyTestITCase.java       |   55 +-
 .../olingo/fit/v4/PropertyValueTestITCase.java  |   38 +-
 .../olingo/fit/v4/QueryOptionsTestITCase.java   |   54 +-
 .../fit/v4/ServiceDocumentTestITCase.java       |   23 +-
 .../olingo/fit/v4/SingletonTestITCase.java      |   36 +-
 .../apache/olingo/commons/api/Constants.java    |   14 +-
 .../commons/api/ODataApplicationException.java  |   16 +-
 .../olingo/commons/api/ODataException.java      |   16 +-
 .../api/ODataNotImplementedException.java       |   16 +-
 .../commons/api/ODataRuntimeException.java      |    6 +-
 .../olingo/commons/api/data/Annotatable.java    |   14 +-
 .../olingo/commons/api/data/Annotation.java     |   14 +-
 .../olingo/commons/api/data/ContextURL.java     |   25 +-
 .../olingo/commons/api/data/DeletedEntity.java  |   14 +-
 .../apache/olingo/commons/api/data/Delta.java   |   14 +-
 .../olingo/commons/api/data/DeltaLink.java      |   14 +-
 .../apache/olingo/commons/api/data/Entity.java  |   61 +-
 .../olingo/commons/api/data/EntitySet.java      |   32 +-
 .../olingo/commons/api/data/GeoUtils.java       |   70 +-
 .../apache/olingo/commons/api/data/Link.java    |   42 +-
 .../apache/olingo/commons/api/data/Linked.java  |   22 +-
 .../commons/api/data/LinkedComplexValue.java    |   14 +-
 .../olingo/commons/api/data/Property.java       |   14 +-
 .../apache/olingo/commons/api/data/ResWrap.java |   22 +-
 .../olingo/commons/api/data/Valuable.java       |   27 +-
 .../olingo/commons/api/data/ValueType.java      |   16 +-
 .../commons/api/data/v3/LinkCollection.java     |   22 +-
 .../api/domain/AbstractODataPayload.java        |   16 +-
 .../commons/api/domain/AbstractODataValue.java  |   26 +-
 .../commons/api/domain/CommonODataEntity.java   |   53 +-
 .../api/domain/CommonODataEntitySet.java        |   22 +-
 .../api/domain/CommonODataObjectFactory.java    |   37 +-
 .../commons/api/domain/CommonODataProperty.java |   28 +-
 .../api/domain/ODataCollectionValue.java        |   24 +-
 .../commons/api/domain/ODataComplexValue.java   |   24 +-
 .../olingo/commons/api/domain/ODataError.java   |   24 +-
 .../commons/api/domain/ODataErrorDetail.java    |   20 +-
 .../commons/api/domain/ODataInlineEntity.java   |   25 +-
 .../api/domain/ODataInlineEntitySet.java        |   25 +-
 .../commons/api/domain/ODataInvokeResult.java   |   19 +-
 .../olingo/commons/api/domain/ODataItem.java    |   19 +-
 .../olingo/commons/api/domain/ODataLink.java    |   60 +-
 .../commons/api/domain/ODataLinkType.java       |   20 +-
 .../olingo/commons/api/domain/ODataLinked.java  |   26 +-
 .../commons/api/domain/ODataOperation.java      |   26 +-
 .../commons/api/domain/ODataPrimitiveValue.java |   21 +-
 .../commons/api/domain/ODataPropertyType.java   |   14 +-
 .../api/domain/ODataServiceDocument.java        |   38 +-
 .../olingo/commons/api/domain/ODataValue.java   |   28 +-
 .../commons/api/domain/v3/ODataEntity.java      |   15 +-
 .../commons/api/domain/v3/ODataEntitySet.java   |   15 +-
 .../api/domain/v3/ODataObjectFactory.java       |   17 +-
 .../commons/api/domain/v3/ODataProperty.java    |   18 +-
 .../commons/api/domain/v4/ODataAnnotatable.java |   14 +-
 .../commons/api/domain/v4/ODataAnnotation.java  |   16 +-
 .../api/domain/v4/ODataDeletedEntity.java       |   14 +-
 .../commons/api/domain/v4/ODataDelta.java       |   14 +-
 .../commons/api/domain/v4/ODataDeltaLink.java   |   14 +-
 .../commons/api/domain/v4/ODataEntity.java      |   17 +-
 .../commons/api/domain/v4/ODataEntitySet.java   |   19 +-
 .../commons/api/domain/v4/ODataEnumValue.java   |   14 +-
 .../olingo/commons/api/domain/v4/ODataLink.java |   15 +-
 .../api/domain/v4/ODataLinkedComplexValue.java  |   16 +-
 .../api/domain/v4/ODataObjectFactory.java       |   17 +-
 .../commons/api/domain/v4/ODataProperty.java    |   17 +-
 .../commons/api/domain/v4/ODataSingleton.java   |   17 +-
 .../commons/api/domain/v4/ODataValuable.java    |   36 +-
 .../commons/api/domain/v4/ODataValue.java       |   22 +-
 .../org/apache/olingo/commons/api/edm/Edm.java  |   54 +-
 .../olingo/commons/api/edm/EdmAction.java       |   16 +-
 .../olingo/commons/api/edm/EdmActionImport.java |   18 +-
 .../commons/api/edm/EdmActionImportInfo.java    |   18 +-
 .../olingo/commons/api/edm/EdmAnnotatable.java  |   16 +-
 .../olingo/commons/api/edm/EdmAnnotation.java   |   14 +-
 .../olingo/commons/api/edm/EdmAnnotations.java  |   16 +-
 .../commons/api/edm/EdmAnnotationsTarget.java   |   18 +-
 .../commons/api/edm/EdmBindingTarget.java       |   22 +-
 .../olingo/commons/api/edm/EdmComplexType.java  |   16 +-
 .../olingo/commons/api/edm/EdmElement.java      |   16 +-
 .../commons/api/edm/EdmEntityContainer.java     |   20 +-
 .../olingo/commons/api/edm/EdmEntitySet.java    |   16 +-
 .../commons/api/edm/EdmEntitySetInfo.java       |   18 +-
 .../olingo/commons/api/edm/EdmEntityType.java   |   26 +-
 .../olingo/commons/api/edm/EdmEnumType.java     |   16 +-
 .../olingo/commons/api/edm/EdmException.java    |   16 +-
 .../olingo/commons/api/edm/EdmFunction.java     |   16 +-
 .../commons/api/edm/EdmFunctionImport.java      |   20 +-
 .../commons/api/edm/EdmFunctionImportInfo.java  |   18 +-
 .../commons/api/edm/EdmKeyPropertyRef.java      |   16 +-
 .../olingo/commons/api/edm/EdmMappable.java     |   18 +-
 .../olingo/commons/api/edm/EdmMapping.java      |   24 +-
 .../olingo/commons/api/edm/EdmMember.java       |   16 +-
 .../apache/olingo/commons/api/edm/EdmNamed.java |   16 +-
 .../api/edm/EdmNavigationPropertyBinding.java   |    8 +-
 .../olingo/commons/api/edm/EdmOperation.java    |   24 +-
 .../commons/api/edm/EdmOperationImport.java     |   16 +-
 .../commons/api/edm/EdmOperationImportInfo.java |   16 +-
 .../olingo/commons/api/edm/EdmParameter.java    |   16 +-
 .../commons/api/edm/EdmPrimitiveType.java       |   40 +-
 .../api/edm/EdmPrimitiveTypeException.java      |   16 +-
 .../commons/api/edm/EdmPrimitiveTypeKind.java   |   39 +-
 .../olingo/commons/api/edm/EdmProperty.java     |   20 +-
 .../olingo/commons/api/edm/EdmReturnType.java   |   16 +-
 .../olingo/commons/api/edm/EdmSchema.java       |   20 +-
 .../commons/api/edm/EdmServiceMetadata.java     |   17 +-
 .../olingo/commons/api/edm/EdmSingleton.java    |   16 +-
 .../commons/api/edm/EdmSingletonInfo.java       |   18 +-
 .../commons/api/edm/EdmStructuredType.java      |   36 +-
 .../apache/olingo/commons/api/edm/EdmTerm.java  |   19 +-
 .../apache/olingo/commons/api/edm/EdmType.java  |   18 +-
 .../commons/api/edm/EdmTypeDefinition.java      |   16 +-
 .../apache/olingo/commons/api/edm/EdmTyped.java |   18 +-
 .../commons/api/edm/FullQualifiedName.java      |   10 +-
 .../apache/olingo/commons/api/edm/Target.java   |    4 +-
 .../commons/api/edm/annotation/EdmAnd.java      |   14 +-
 .../edm/annotation/EdmAnnotationExpression.java |   14 +-
 .../api/edm/annotation/EdmAnnotationPath.java   |   14 +-
 .../commons/api/edm/annotation/EdmApply.java    |   17 +-
 .../commons/api/edm/annotation/EdmCast.java     |   14 +-
 .../api/edm/annotation/EdmCollection.java       |   14 +-
 .../EdmConstantAnnotationExpression.java        |   14 +-
 .../EdmDynamicAnnotationExpression.java         |   14 +-
 .../commons/api/edm/annotation/EdmEq.java       |   14 +-
 .../commons/api/edm/annotation/EdmGe.java       |   14 +-
 .../commons/api/edm/annotation/EdmGt.java       |   14 +-
 .../commons/api/edm/annotation/EdmIf.java       |   14 +-
 .../commons/api/edm/annotation/EdmIsOf.java     |   14 +-
 .../api/edm/annotation/EdmLabeledElement.java   |   14 +-
 .../annotation/EdmLabeledElementReference.java  |   14 +-
 .../commons/api/edm/annotation/EdmLe.java       |   14 +-
 .../commons/api/edm/annotation/EdmLt.java       |   14 +-
 .../annotation/EdmNavigationPropertyPath.java   |   14 +-
 .../commons/api/edm/annotation/EdmNe.java       |   14 +-
 .../commons/api/edm/annotation/EdmNot.java      |   14 +-
 .../commons/api/edm/annotation/EdmNull.java     |   14 +-
 .../commons/api/edm/annotation/EdmOr.java       |   14 +-
 .../commons/api/edm/annotation/EdmPath.java     |   14 +-
 .../api/edm/annotation/EdmPropertyPath.java     |   14 +-
 .../api/edm/annotation/EdmPropertyValue.java    |   14 +-
 .../commons/api/edm/annotation/EdmRecord.java   |   15 +-
 ...mTwoParamsOpDynamicAnnotationExpression.java |   14 +-
 .../commons/api/edm/annotation/EdmUrlRef.java   |   14 +-
 .../api/edm/constants/EdmContentKind.java       |   14 +-
 .../commons/api/edm/constants/EdmOnDelete.java  |   16 +-
 .../commons/api/edm/constants/EdmTypeKind.java  |   16 +-
 .../api/edm/constants/ODataServiceVersion.java  |   35 +-
 .../commons/api/edm/geo/ComposedGeospatial.java |   18 +-
 .../olingo/commons/api/edm/geo/Geospatial.java  |   26 +-
 .../api/edm/geo/GeospatialCollection.java       |   19 +-
 .../olingo/commons/api/edm/geo/LineString.java  |   19 +-
 .../commons/api/edm/geo/MultiLineString.java    |   19 +-
 .../olingo/commons/api/edm/geo/MultiPoint.java  |   19 +-
 .../commons/api/edm/geo/MultiPolygon.java       |   19 +-
 .../olingo/commons/api/edm/geo/Point.java       |   24 +-
 .../olingo/commons/api/edm/geo/Polygon.java     |   29 +-
 .../apache/olingo/commons/api/edm/geo/SRID.java |   24 +-
 .../olingo/commons/api/edm/package-info.java    |   17 +-
 .../olingo/commons/api/format/AcceptType.java   |   42 +-
 .../olingo/commons/api/format/ContentType.java  |   55 +-
 .../olingo/commons/api/format/ODataFormat.java  |   46 +-
 .../olingo/commons/api/http/HttpHeader.java     |    2 +-
 .../olingo/commons/api/http/HttpMethod.java     |   14 +-
 .../api/serialization/ODataDeserializer.java    |   22 +-
 .../ODataDeserializerException.java             |   14 +-
 .../api/serialization/ODataSerializer.java      |   14 +-
 .../serialization/ODataSerializerException.java |   14 +-
 .../olingo/commons/api/data/ContextURLTest.java |   37 +-
 .../commons/api/format/AcceptTypeTest.java      |   60 +
 .../core/data/AbstractAnnotatedObject.java      |   14 +-
 .../commons/core/data/AbstractODataObject.java  |   18 +-
 .../commons/core/data/AbstractValuable.java     |   16 +-
 .../commons/core/data/AnnotationImpl.java       |   14 +-
 .../commons/core/data/DeletedEntityImpl.java    |   15 +-
 .../olingo/commons/core/data/DeltaLinkImpl.java |   15 +-
 .../olingo/commons/core/data/EntityImpl.java    |   25 +-
 .../olingo/commons/core/data/EntitySetImpl.java |   15 +-
 .../olingo/commons/core/data/LinkImpl.java      |   14 +-
 .../core/data/LinkedComplexValueImpl.java       |   14 +-
 .../commons/core/data/ODataErrorDetailImpl.java |   14 +-
 .../commons/core/data/ODataErrorImpl.java       |   16 +-
 .../olingo/commons/core/data/PropertyImpl.java  |   21 +-
 .../core/data/v3/LinkCollectionImpl.java        |   21 +-
 .../olingo/commons/core/data/v4/DeltaImpl.java  |   15 +-
 .../domain/AbstractODataCollectionValue.java    |   31 +-
 .../core/domain/AbstractODataComplexValue.java  |   31 +-
 .../core/domain/AbstractODataEntity.java        |   49 +-
 .../core/domain/AbstractODataEntitySet.java     |   17 +-
 .../core/domain/AbstractODataObjectFactory.java |   20 +-
 .../domain/AbstractODataPrimitiveValue.java     |   22 +-
 .../core/domain/AbstractODataProperty.java      |   42 +-
 .../domain/v3/ODataCollectionValueImpl.java     |   14 +-
 .../core/domain/v3/ODataComplexValueImpl.java   |   14 +-
 .../commons/core/domain/v3/ODataEntityImpl.java |   15 +-
 .../core/domain/v3/ODataEntitySetImpl.java      |   18 +-
 .../core/domain/v3/ODataObjectFactoryImpl.java  |   29 +-
 .../core/domain/v3/ODataPrimitiveValueImpl.java |   16 +-
 .../core/domain/v3/ODataPropertyImpl.java       |   18 +-
 .../core/domain/v4/ODataAnnotationImpl.java     |   22 +-
 .../domain/v4/ODataCollectionValueImpl.java     |   17 +-
 .../core/domain/v4/ODataComplexValueImpl.java   |   37 +-
 .../core/domain/v4/ODataDeletedEntityImpl.java  |   15 +-
 .../commons/core/domain/v4/ODataDeltaImpl.java  |   17 +-
 .../core/domain/v4/ODataDeltaLinkImpl.java      |   15 +-
 .../commons/core/domain/v4/ODataEntityImpl.java |   15 +-
 .../core/domain/v4/ODataEntitySetImpl.java      |   15 +-
 .../core/domain/v4/ODataEnumValueImpl.java      |   16 +-
 .../core/domain/v4/ODataObjectFactoryImpl.java  |   33 +-
 .../core/domain/v4/ODataPrimitiveValueImpl.java |   18 +-
 .../core/domain/v4/ODataPropertyImpl.java       |   25 +-
 .../core/domain/v4/ODataValuableImpl.java       |   40 +-
 .../olingo/commons/core/edm/AbstractEdm.java    |   42 +-
 .../core/edm/AbstractEdmBindingTarget.java      |   23 +-
 .../core/edm/AbstractEdmComplexType.java        |    8 +-
 .../core/edm/AbstractEdmEntityContainer.java    |    2 +-
 .../commons/core/edm/AbstractEdmEntityType.java |   23 +-
 .../commons/core/edm/AbstractEdmEnumType.java   |   40 +-
 .../core/edm/AbstractEdmKeyPropertyRef.java     |   22 +-
 .../commons/core/edm/AbstractEdmMember.java     |   16 +-
 .../core/edm/AbstractEdmNavigationProperty.java |    2 +-
 .../commons/core/edm/AbstractEdmOperation.java  |   22 +-
 .../core/edm/AbstractEdmOperationImport.java    |   24 +-
 .../commons/core/edm/AbstractEdmParameter.java  |   16 +-
 .../commons/core/edm/AbstractEdmProperty.java   |   14 +-
 .../commons/core/edm/AbstractEdmReturnType.java |   16 +-
 .../commons/core/edm/AbstractEdmSchema.java     |   24 +-
 .../core/edm/AbstractEdmStructuredType.java     |   10 +-
 .../core/edm/AbstractEdmTypeDefinition.java     |   30 +-
 .../olingo/commons/core/edm/ActionMapKey.java   |   24 +-
 .../core/edm/EdmActionImportInfoImpl.java       |   16 +-
 .../commons/core/edm/EdmAnnotationHelper.java   |   17 +-
 .../olingo/commons/core/edm/EdmElementImpl.java |   16 +-
 .../commons/core/edm/EdmEntitySetInfoImpl.java  |   16 +-
 .../core/edm/EdmFunctionImportInfoImpl.java     |   16 +-
 .../olingo/commons/core/edm/EdmNamedImpl.java   |   14 +-
 .../edm/EdmNavigationPropertyBindingImpl.java   |    4 +-
 .../core/edm/EdmOperationImportInfoImpl.java    |   16 +-
 .../commons/core/edm/EdmSingletonInfoImpl.java  |   16 +-
 .../core/edm/EdmStructuredTypeHelper.java       |   14 +-
 .../olingo/commons/core/edm/EdmTypeInfo.java    |   73 +-
 .../olingo/commons/core/edm/FunctionMapKey.java |   34 +-
 ...mAnnotatableDynamicAnnotationExpression.java |   17 +-
 .../AbstractEdmAnnotationEspression.java        |   14 +-
 .../AbstractEdmDynamicAnnotationExpression.java |   16 +-
 .../AbstractEdmElementOrAttributeNotation.java  |   14 +-
 ...mTwoParamsOpDynamicAnnotationExpression.java |   18 +-
 .../commons/core/edm/annotation/EdmAndImpl.java |   14 +-
 .../edm/annotation/EdmAnnotationPathImpl.java   |   14 +-
 .../core/edm/annotation/EdmApplyImpl.java       |   15 +-
 .../core/edm/annotation/EdmCollectionImpl.java  |   15 +-
 .../commons/core/edm/annotation/EdmEqImpl.java  |   14 +-
 .../commons/core/edm/annotation/EdmGeImpl.java  |   14 +-
 .../commons/core/edm/annotation/EdmGtImpl.java  |   14 +-
 .../commons/core/edm/annotation/EdmIfImpl.java  |   16 +-
 .../edm/annotation/EdmLabeledElementImpl.java   |   16 +-
 .../EdmLabeledElementReferenceImpl.java         |   16 +-
 .../commons/core/edm/annotation/EdmLeImpl.java  |   14 +-
 .../commons/core/edm/annotation/EdmLtImpl.java  |   14 +-
 .../EdmNavigationPropertyPathImpl.java          |   16 +-
 .../commons/core/edm/annotation/EdmNeImpl.java  |   14 +-
 .../commons/core/edm/annotation/EdmNotImpl.java |   14 +-
 .../core/edm/annotation/EdmNullImpl.java        |   14 +-
 .../commons/core/edm/annotation/EdmOrImpl.java  |   14 +-
 .../core/edm/annotation/EdmPathImpl.java        |   14 +-
 .../edm/annotation/EdmPropertyPathImpl.java     |   14 +-
 .../edm/annotation/EdmPropertyValueImpl.java    |   16 +-
 .../core/edm/annotation/EdmUrlRefImpl.java      |   14 +-
 .../primitivetype/AbstractGeospatialType.java   |  345 +++---
 .../primitivetype/AbstractPrimitiveType.java    |   44 +-
 .../core/edm/primitivetype/EdmBinary.java       |   42 +-
 .../core/edm/primitivetype/EdmBoolean.java      |   34 +-
 .../commons/core/edm/primitivetype/EdmByte.java |   40 +-
 .../commons/core/edm/primitivetype/EdmDate.java |   34 +-
 .../core/edm/primitivetype/EdmDateTime.java     |   34 +-
 .../edm/primitivetype/EdmDateTimeOffset.java    |   76 +-
 .../core/edm/primitivetype/EdmDecimal.java      |   74 +-
 .../core/edm/primitivetype/EdmDouble.java       |   54 +-
 .../core/edm/primitivetype/EdmDuration.java     |   52 +-
 .../core/edm/primitivetype/EdmGeography.java    |   24 +-
 .../primitivetype/EdmGeographyCollection.java   |   26 +-
 .../primitivetype/EdmGeographyLineString.java   |   24 +-
 .../EdmGeographyMultiLineString.java            |   26 +-
 .../primitivetype/EdmGeographyMultiPoint.java   |   24 +-
 .../primitivetype/EdmGeographyMultiPolygon.java |   24 +-
 .../edm/primitivetype/EdmGeographyPoint.java    |   24 +-
 .../edm/primitivetype/EdmGeographyPolygon.java  |   24 +-
 .../core/edm/primitivetype/EdmGeometry.java     |   24 +-
 .../primitivetype/EdmGeometryCollection.java    |   26 +-
 .../primitivetype/EdmGeometryLineString.java    |   24 +-
 .../EdmGeometryMultiLineString.java             |   26 +-
 .../primitivetype/EdmGeometryMultiPoint.java    |   24 +-
 .../primitivetype/EdmGeometryMultiPolygon.java  |   26 +-
 .../edm/primitivetype/EdmGeometryPoint.java     |   24 +-
 .../edm/primitivetype/EdmGeometryPolygon.java   |   24 +-
 .../commons/core/edm/primitivetype/EdmGuid.java |   36 +-
 .../core/edm/primitivetype/EdmInt16.java        |   42 +-
 .../core/edm/primitivetype/EdmInt32.java        |   42 +-
 .../core/edm/primitivetype/EdmInt64.java        |   48 +-
 .../primitivetype/EdmPrimitiveTypeFactory.java  |  160 +--
 .../core/edm/primitivetype/EdmSByte.java        |   36 +-
 .../core/edm/primitivetype/EdmSingle.java       |   48 +-
 .../core/edm/primitivetype/EdmStream.java       |   31 +-
 .../core/edm/primitivetype/EdmString.java       |   31 +-
 .../commons/core/edm/primitivetype/EdmTime.java |   16 +-
 .../core/edm/primitivetype/EdmTimeOfDay.java    |   34 +-
 .../primitivetype/SingletonPrimitiveType.java   |   16 +-
 .../commons/core/edm/primitivetype/Uint7.java   |   28 +-
 .../core/serialization/AbstractAtomDealer.java  |  105 +-
 .../core/serialization/AtomDeserializer.java    |   34 +-
 .../serialization/AtomGeoValueDeserializer.java |  114 +-
 .../serialization/AtomGeoValueSerializer.java   |  164 +--
 .../core/serialization/AtomSerializer.java      |   32 +-
 .../serialization/JsonDeltaDeserializer.java    |   21 +-
 .../core/serialization/JsonDeserializer.java    |   26 +-
 .../serialization/JsonEntityDeserializer.java   |   14 +-
 .../serialization/JsonEntitySerializer.java     |   14 +-
 .../JsonEntitySetDeserializer.java              |   18 +-
 .../serialization/JsonEntitySetSerializer.java  |   14 +-
 .../serialization/JsonGeoValueDeserializer.java |  122 +-
 .../serialization/JsonGeoValueSerializer.java   |  140 +--
 .../JsonLinkCollectionDeserializer.java         |   16 +-
 .../JsonODataErrorDeserializer.java             |   18 +-
 .../JsonODataErrorDetailDeserializer.java       |   14 +-
 .../serialization/JsonPropertyDeserializer.java |   16 +-
 .../serialization/JsonPropertySerializer.java   |   26 +-
 .../core/serialization/JsonSerializer.java      |   22 +-
 .../apache/olingo/commons/core/EncoderTest.java |    2 +-
 .../commons/core/edm/ActionMapKeyTest.java      |   19 +-
 .../commons/core/edm/EdmImplCachingTest.java    |   24 +-
 .../commons/core/edm/EdmImplCallCreateTest.java |   24 +-
 .../commons/core/edm/FunctionMapKeyTest.java    |   17 +-
 .../primitivetype/CommonPrimitiveTypeTest.java  |   40 +-
 .../core/edm/primitivetype/EdmBinaryTest.java   |   42 +-
 .../core/edm/primitivetype/EdmBooleanTest.java  |   16 +-
 .../core/edm/primitivetype/EdmByteTest.java     |   16 +-
 .../core/edm/primitivetype/EdmDateTest.java     |   16 +-
 .../primitivetype/EdmDateTimeOffsetTest.java    |   26 +-
 .../core/edm/primitivetype/EdmDecimalTest.java  |   16 +-
 .../core/edm/primitivetype/EdmDoubleTest.java   |   16 +-
 .../core/edm/primitivetype/EdmDurationTest.java |   16 +-
 .../core/edm/primitivetype/EdmGeoTest.java      |   49 +-
 .../core/edm/primitivetype/EdmGuidTest.java     |   16 +-
 .../core/edm/primitivetype/EdmInt16Test.java    |   16 +-
 .../core/edm/primitivetype/EdmInt32Test.java    |   16 +-
 .../core/edm/primitivetype/EdmInt64Test.java    |   16 +-
 .../core/edm/primitivetype/EdmNullTest.java     |   16 +-
 .../core/edm/primitivetype/EdmSByteTest.java    |   16 +-
 .../core/edm/primitivetype/EdmSingleTest.java   |   28 +-
 .../core/edm/primitivetype/EdmStringTest.java   |   16 +-
 .../edm/primitivetype/EdmTimeOfDayTest.java     |   18 +-
 .../primitivetype/PrimitiveTypeBaseTest.java    |   54 +-
 .../core/edm/primitivetype/UInt7Test.java       |   20 +-
 lib/server-api/pom.xml                          |    4 +
 .../apache/olingo/server/api/ODataRequest.java  |   37 +-
 .../api/processor/CollectionProcessor.java      |   29 +
 .../api/processor/CustomContentTypeSupport.java |   28 +
 .../server/api/processor/DefaultProcessor.java  |   10 +-
 .../api/processor/EntitySetProcessor.java       |   29 -
 .../api/processor/FormatContentTypeMapping.java |   53 +
 .../server/api/processor/MetadataProcessor.java |    2 +-
 .../olingo/server/api/ODataRequestTest.java     |   66 +
 .../olingo/server/core/ContentNegotiator.java   |  158 +++
 .../server/core/DefaultRedirectProcessor.java   |   16 +-
 .../apache/olingo/server/core/ODataHandler.java |   86 +-
 .../server/core/ODataHttpHandlerImpl.java       |   12 +-
 .../apache/olingo/server/core/ODataImpl.java    |    2 +-
 .../core/serializer/ODataXmlSerializerImpl.java |    5 +-
 .../serializer/json/ODataJsonSerializer.java    |    9 +-
 .../json/ServiceDocumentJsonSerializer.java     |    2 +-
 .../xml/MetadataDocumentXmlSerializer.java      |    3 +-
 .../server/core/ContentNegotiatorTest.java      |  233 ++++
 .../server/core/edm/provider/EdmEnumTest.java   |    2 +-
 .../core/edm/provider/EdmMemberImplTest.java    |    6 +-
 lib/server-tecsvc/pom.xml                       |   34 -
 .../olingo/server/tecsvc/TechnicalServlet.java  |   48 +-
 .../server/tecsvc/data/model/EtAllPrim.java     |   36 +-
 .../server/tecsvc/data/model/EtTwoPrim.java     |    8 +-
 .../tecsvc/processor/SampleJsonProcessor.java   |   82 +-
 .../tecsvc/processor/TechnicalProcessor.java    |   23 +-
 .../tecsvc/provider/ContainerProvider.java      |    4 +-
 .../src/main/webapp/META-INF/MANIFEST.MF        |    8 +-
 .../olingo/server/api/ODataRequestTest.java     |   45 -
 .../olingo/server/core/ODataHandlerTest.java    |   22 +-
 .../core/uri/testutil/ResourceValidator.java    |    2 +-
 .../core/uri/validator/UriValidatorTest.java    |    7 +-
 903 files changed, 34701 insertions(+), 41979 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/66f26e5b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/66f26e5b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
----------------------------------------------------------------------
diff --cc lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
index 536ead1,21304b6..2ea5b9e
--- 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
@@@ -135,60 -147,48 +135,61 @@@ public class ODataJsonSerializer implem
          json.writeNull();
        }
      } else {
 -      if (edmProperty.isPrimitive()) {
 -        if (property.isPrimitive()) {
 -          writePrimitiveValue(edmProperty, property.asPrimitive(), json);
 -        } else if (property.isGeospatial()) {
 -          throw new ODataRuntimeException("Property type not yet supported!");
 -        } else if (property.isEnum()) {
 -          json.writeString(property.asEnum().toString());
 -        } else {
 -          throw new ODataRuntimeException("Inconsistent property type!");
 -        }
 -      } else if (edmProperty.isCollection()) {
 -        json.writeStartArray();
 -        for (Object value : property.asCollection()) {
 -          switch (property.getValueType()) {
 -          case COLLECTION_PRIMITIVE:
 -            writePrimitiveValue(edmProperty, value, json);
 -            break;
 -          case COLLECTION_GEOSPATIAL:
 -            throw new ODataRuntimeException("Property type not yet supported!");
 -          case COLLECTION_ENUM:
 -            json.writeString(value.toString());
 -            break;
 -          case COLLECTION_LINKED_COMPLEX:
 -            writeLinkedComplexValue(edmProperty, (LinkedComplexValue) value, json);
 -            break;
 -          default:
 -            throw new ODataRuntimeException("Property type not yet supported!");
 -          }
 -        }
 -        json.writeEndArray();
 +      if (edmProperty.isCollection()) {
 +        handleCollection(edmProperty, property, json);
 +      } else if (edmProperty.isPrimitive()) {
 +        handlePrimitive(edmProperty, property, json);
 +      } else if (property.isLinkedComplex()) {
 +        writeComplexValue(edmProperty, property.asLinkedComplex().getValue(), json);
 +      } else if(property.isComplex()) {
 +        writeComplexValue(edmProperty, property.asComplex(), json);
        } else {
 -        if (property.isLinkedComplex()) {
 -          writeLinkedComplexValue(edmProperty, property.asLinkedComplex(), json);
 -        } else {
 -          throw new ODataRuntimeException("Property type not yet supported!");
 -        }
 +        throw new ODataRuntimeException("Property type not yet supported!");
 +      }
 +    }
 +  }
 +
 +  private void handleCollection(EdmProperty edmProperty, Property property, JsonGenerator json)
 +          throws IOException, EdmPrimitiveTypeException {
 +    json.writeStartArray();
 +    for (Object value : property.asCollection()) {
 +      switch (property.getValueType()) {
 +      case COLLECTION_PRIMITIVE:
 +        writePrimitiveValue(edmProperty, value, json);
 +        break;
 +      case COLLECTION_GEOSPATIAL:
 +        throw new ODataRuntimeException("Property type not yet supported!");
 +      case COLLECTION_ENUM:
 +        json.writeString(value.toString());
 +        break;
 +      case COLLECTION_LINKED_COMPLEX:
 +        writeComplexValue(edmProperty, ((LinkedComplexValue) value).getValue(), json);
 +        break;
 +      case COLLECTION_COMPLEX:
 +        writeComplexValue(edmProperty, property.asComplex(), json);
 +        break;
 +      default:
 +        throw new ODataRuntimeException("Property type not yet supported!");
        }
      }
 +    json.writeEndArray();
 +  }
 +
 +  private void handlePrimitive(EdmProperty edmProperty, Property property, JsonGenerator json)
 +          throws EdmPrimitiveTypeException, IOException {
 +    if (property.isPrimitive()) {
 +      writePrimitiveValue(edmProperty, property.asPrimitive(), json);
 +    } else if (property.isGeospatial()) {
 +      throw new ODataRuntimeException("Property type not yet supported!");
 +    } else if (property.isEnum()) {
 +      json.writeString(property.asEnum().toString());
 +    } else {
 +      throw new ODataRuntimeException("Inconsistent property type!");
 +    }
    }
  
-   protected void writePrimitiveValue(final EdmProperty edmProperty, final Object primitiveValue, JsonGenerator json)
+   protected void writePrimitiveValue(final EdmProperty edmProperty, final Object primitiveValue,
+       final JsonGenerator json)
        throws EdmPrimitiveTypeException, IOException {
      final EdmPrimitiveType type = (EdmPrimitiveType) edmProperty.getType();
      final String value = type.valueToString(primitiveValue,

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/66f26e5b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
----------------------------------------------------------------------
diff --cc lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
index bfdede8,e7d6717..e34fd42
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
@@@ -27,10 -27,7 +27,9 @@@ import org.apache.olingo.commons.api.da
  import org.apache.olingo.commons.api.data.Property;
  import org.apache.olingo.commons.api.data.ValueType;
  import org.apache.olingo.commons.api.edm.Edm;
 +import org.apache.olingo.commons.api.edm.EdmEntitySet;
 +import org.apache.olingo.commons.api.edm.EdmEntityType;
  import org.apache.olingo.commons.api.edm.FullQualifiedName;
- import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
  import org.apache.olingo.commons.api.format.ContentType;
  import org.apache.olingo.commons.api.format.ODataFormat;
  import org.apache.olingo.commons.api.http.HttpStatusCode;
@@@ -40,88 -37,67 +39,88 @@@ import org.apache.olingo.commons.core.d
  import org.apache.olingo.server.api.OData;
  import org.apache.olingo.server.api.ODataRequest;
  import org.apache.olingo.server.api.ODataResponse;
+ import org.apache.olingo.server.api.processor.CollectionProcessor;
  import org.apache.olingo.server.api.processor.EntityProcessor;
- import org.apache.olingo.server.api.processor.EntitySetProcessor;
  import org.apache.olingo.server.api.serializer.ODataSerializer;
  import org.apache.olingo.server.api.uri.UriInfo;
 +import org.apache.olingo.server.api.uri.UriResource;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
- public class SampleJsonProcessor implements EntitySetProcessor, EntityProcessor {
-     private static final Logger LOG = LoggerFactory.getLogger(SampleJsonProcessor.class);
+ public class SampleJsonProcessor implements CollectionProcessor, EntityProcessor {
+   private static final Logger LOG = LoggerFactory.getLogger(SampleJsonProcessor.class);
  
-     private OData odata;
-     private Edm edm;
+   private OData odata;
+   private Edm edm;
  
-     @Override
-     public void init(OData odata, Edm edm) {
-       this.odata = odata;
-       this.edm = edm;
-     }
+   @Override
 -  public void init(final OData odata, final Edm edm) {
++  public void init(OData odata, Edm edm) {
+     this.odata = odata;
+     this.edm = edm;
+   }
  
-     @Override
-     public void readEntitySet(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
-       long time = System.nanoTime();
- 
-       LOG.info((System.nanoTime() - time) / 1000 + " microseconds");
-       time = System.nanoTime();
-       ODataSerializer serializer = odata.createSerializer(ODataFormat.JSON);
-       EdmEntitySet edmEntitySet = getEntitySet(uriInfo);
-       ContextURL contextUrl = getContextUrl(request, edmEntitySet.getEntityType());
-       EntitySet entitySet = createEntitySet(edmEntitySet.getEntityType(), contextUrl.getURI().toASCIIString());
-       response.setContent(serializer.entitySet(edmEntitySet, entitySet, contextUrl));
-       LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
- 
-       response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-       response.setHeader("Content-Type", ContentType.APPLICATION_JSON.toContentTypeString());
-     }
+   @Override
 -  public void readCollection(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
 -      final String format) {
++  public void readCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
+     long time = System.nanoTime();
+ 
 -    EntitySet entitySet = createEntitySet();
 -
+     LOG.info((System.nanoTime() - time) / 1000 + " microseconds");
+     time = System.nanoTime();
+     ODataSerializer serializer = odata.createSerializer(ODataFormat.JSON);
 -    response.setContent(serializer.entitySet(
 -        edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
 -            .getEntitySet("ESAllPrim"),
 -        entitySet,
 -        ContextURL.getInstance(URI.create("dummyContextURL"))));
++    EdmEntitySet edmEntitySet = getEntitySet(uriInfo);
++    ContextURL contextUrl = getContextUrl(request, edmEntitySet.getEntityType());
++    EntitySet entitySet = createEntitySet(edmEntitySet.getEntityType(), contextUrl.getURI().toASCIIString());
++    response.setContent(serializer.entitySet(edmEntitySet, entitySet, contextUrl));
+     LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
+ 
+     response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+     response.setHeader("Content-Type", ContentType.APPLICATION_JSON.toContentTypeString());
+   }
  
-     @Override
-     public void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
-       long time = System.nanoTime();
+   @Override
 -  public void readEntity(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
 -      final String format) {
++  public void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
+     long time = System.nanoTime();
 -    Entity entity = createEntity();
  
-       LOG.info((System.nanoTime() - time) / 1000 + " microseconds");
-       time = System.nanoTime();
-       ODataSerializer serializer = odata.createSerializer(ODataFormat.JSON);
-       EdmEntityType entityType = getEntityType(uriInfo);
-       Entity entity = createEntity(entityType);
+     LOG.info((System.nanoTime() - time) / 1000 + " microseconds");
+     time = System.nanoTime();
+     ODataSerializer serializer = odata.createSerializer(ODataFormat.JSON);
 -    response.setContent(serializer.entity(
 -        edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
 -            .getEntitySet("ESAllPrim").getEntityType(),
 -        entity,
 -        ContextURL.getInstance(URI.create("dummyContextURL"))));
++    EdmEntityType entityType = getEntityType(uriInfo);
++    Entity entity = createEntity(entityType);
 +
-       response.setContent(serializer.entity(entityType, entity,
-               getContextUrl(request, entityType)));
-       LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
++    response.setContent(serializer.entity(entityType, entity,
++            getContextUrl(request, entityType)));
+     LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
  
-       response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-       response.setHeader("Content-Type", ContentType.APPLICATION_JSON.toContentTypeString());
-     }
+     response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+     response.setHeader("Content-Type", ContentType.APPLICATION_JSON.toContentTypeString());
+   }
  
 -  protected Entity createEntity() {
 +  private ContextURL getContextUrl(ODataRequest request, EdmEntityType entityType) {
 +    return ContextURL.getInstance(URI.create(request.getRawBaseUri() + "/" + entityType.getName()));
 +  }
 +
 +  public EdmEntityType getEntityType(UriInfo uriInfo) {
 +    return getEntitySet(uriInfo).getEntityType();
 +  }
 +
 +  public EdmEntitySet getEntitySet(UriInfo uriInfo) {
 +    List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
 +    if(resourcePaths.isEmpty()) {
 +      throw new RuntimeException("Invalid resource path.");
 +    }
 +    String entitySetName = resourcePaths.get(resourcePaths.size()-1).toString();
 +    return edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
 +            .getEntitySet(entitySetName);
 +  }
 +
 +  protected Entity createEntity(EdmEntityType entityType) {
 +    boolean complex = (entityType.getName().contains("Comp"));
 +    if(entityType.getName().contains("Coll")) {
 +      return createEntityWithCollection(complex);
 +    }
 +    return createEntity(complex);
 +  }
 +
 +  protected Entity createEntity(boolean complex) {
      Entity entity = new EntityImpl();
      Property property = new PropertyImpl();
      property.setName("PropertyString");
@@@ -143,88 -114,12 +142,87 @@@
      return entity;
    }
  
 -  protected EntitySet createEntitySet() {
 +  protected Entity createEntityWithCollection(boolean complex) {
 +    Entity entity = new EntityImpl();
 +    Property propertyInt = new PropertyImpl();
 +    propertyInt.setName("PropertyInt16");
 +    propertyInt.setValue(ValueType.PRIMITIVE, 42);
 +    Property property = new PropertyImpl();
 +    property.setName("CollPropertyString");
 +    property.setValue(ValueType.COLLECTION_PRIMITIVE, Arrays.asList("dummyValue", "dummyValue_2"));
 +    entity.getProperties().add(property);
 +    entity.getProperties().add(propertyInt);
 +    Property propertyGuid = new PropertyImpl();
 +    propertyGuid.setName("CollPropertyGuid");
 +    propertyGuid.setValue(ValueType.COLLECTION_PRIMITIVE, Arrays.asList(UUID.randomUUID(), UUID.randomUUID()));
 +    entity.getProperties().add(propertyGuid);
 +
 +    if(complex) {
 +      entity.addProperty(createCollectionOfComplexProperty());
 +    }
 +
 +    return entity;
 +  }
 +
 +  protected Property createComplexProperty() {
 +    List<Property> properties = new ArrayList<Property>();
 +    Property property = new PropertyImpl();
 +    property.setName("PropertyString");
 +    property.setValue(ValueType.PRIMITIVE, "dummyValue");
 +    properties.add(property);
 +    Property propertyInt = new PropertyImpl();
 +    propertyInt.setName("PropertyInt16");
 +    propertyInt.setValue(ValueType.PRIMITIVE, 42);
 +    properties.add(propertyInt);
 +    Property propertyGuid = new PropertyImpl();
 +    propertyGuid.setName("PropertyGuid");
 +    propertyGuid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
 +    properties.add(propertyGuid);
 +
 +    return new PropertyImpl("com.sap.odata.test1.ETCompAllPrim", "PropertyComplex", ValueType.COMPLEX,
 +            properties);
 +  }
 +
 +  protected Property createCollectionOfComplexProperty() {
 +    List<Property> properties = new ArrayList<Property>();
 +    Property property = new PropertyImpl();
 +    property.setName("PropertyString");
 +    property.setValue(ValueType.PRIMITIVE, "dummyValue");
 +    properties.add(property);
 +    Property propertyInt = new PropertyImpl();
 +    propertyInt.setName("PropertyInt16");
 +    propertyInt.setValue(ValueType.PRIMITIVE, 42);
 +    properties.add(propertyInt);
 +    Property propertyGuid = new PropertyImpl();
 +    propertyGuid.setName("PropertyGuid");
 +    propertyGuid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
 +    properties.add(propertyGuid);
 +
 +    List<Property> properties2 = new ArrayList<Property>();
 +    Property property2 = new PropertyImpl();
 +    property2.setName("PropertyString");
 +    property2.setValue(ValueType.PRIMITIVE, "dummyValue2");
 +    properties2.add(property2);
 +    Property property2Int = new PropertyImpl();
 +    property2Int.setName("PropertyInt16");
 +    property2Int.setValue(ValueType.PRIMITIVE, 44);
 +    properties2.add(property2Int);
 +    Property property2Guid = new PropertyImpl();
 +    property2Guid.setName("PropertyGuid");
 +    property2Guid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
 +    properties2.add(property2Guid);
 +
 +    return new PropertyImpl("com.sap.odata.test1.ETCompAllPrim", "PropertyComplex", ValueType.COMPLEX,
 +            Arrays.asList(properties, properties2));
 +  }
 +
- 
 +  protected EntitySet createEntitySet(EdmEntityType edmEntityType, String baseUri) {
      EntitySet entitySet = new EntitySetImpl();
 -    entitySet.setCount(4242);
 -    entitySet.setNext(URI.create("nextLinkURI"));
 -    for (int i = 0; i < 1000; i++) {
 -      entitySet.getEntities().add(createEntity());
 +    int count = (int) ((Math.random() * 50) + 1);
 +    entitySet.setCount(count);
 +    entitySet.setNext(URI.create(baseUri + "nextLink"));
 +    for (int i = 0; i < count; i++) {
 +      entitySet.getEntities().add(createEntity(edmEntityType));
      }
      return entitySet;
    }


[3/6] git commit: [OLINGO-317] Added collection type handling

Posted by mi...@apache.org.
[OLINGO-317] Added collection type handling


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

Branch: refs/heads/master
Commit: da8cf726bfb9eb63e8198b40ea600121e6d2697e
Parents: 71bdaed
Author: Michael Bolz <mi...@sap.com>
Authored: Wed Jul 2 09:28:26 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Wed Jul 2 12:39:47 2014 +0200

----------------------------------------------------------------------
 .../serializer/json/ODataJsonSerializer.java    |  24 +--
 .../json/ODataJsonSerializerTest.java           | 180 +++++++++++++++++--
 .../tecsvc/processor/SampleJsonProcessor.java   | 145 ++++++++++-----
 3 files changed, 283 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/da8cf726/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 c3fe720..1c61cc0 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
@@ -135,18 +135,16 @@ public class ODataJsonSerializer implements ODataSerializer {
         json.writeNull();
       }
     } else {
-      if (edmProperty.isPrimitive()) {
-        handlePrimitive(edmProperty, property, json);
-      } else if (edmProperty.isCollection()) {
+      if (edmProperty.isCollection()) {
         handleCollection(edmProperty, property, json);
+      } else if (edmProperty.isPrimitive()) {
+        handlePrimitive(edmProperty, property, json);
+      } else if (property.isLinkedComplex()) {
+        writeComplexValue(edmProperty, property.asLinkedComplex().getValue(), json);
+      } else if(property.isComplex()) {
+        writeComplexValue(edmProperty, property.asComplex(), json);
       } else {
-        if (property.isLinkedComplex()) {
-          writeComplexValue(edmProperty, property.asLinkedComplex().getValue(), json);
-        } else if(property.isComplex()) {
-          writeComplexValue(edmProperty, property.asComplex(), json);
-        } else {
-          throw new ODataRuntimeException("Property type not yet supported!");
-        }
+        throw new ODataRuntimeException("Property type not yet supported!");
       }
     }
   }
@@ -167,6 +165,9 @@ public class ODataJsonSerializer implements ODataSerializer {
       case COLLECTION_LINKED_COMPLEX:
         writeComplexValue(edmProperty, ((LinkedComplexValue) value).getValue(), json);
         break;
+      case COLLECTION_COMPLEX:
+        writeComplexValue(edmProperty, property.asComplex(), json);
+        break;
       default:
         throw new ODataRuntimeException("Property type not yet supported!");
       }
@@ -237,7 +238,8 @@ public class ODataJsonSerializer implements ODataSerializer {
       JsonGenerator json = new JsonFactory().createGenerator(buffer.getOutputStream());
       json.writeStartObject();
       if (contextURL != null) {
-        json.writeStringField(Constants.JSON_CONTEXT, contextURL.getURI().toASCIIString());
+        String context = "$metadata#" + edmEntitySet.getName();
+        json.writeStringField(Constants.JSON_CONTEXT, context);
       }
       if (entitySet.getCount() != null) {
         json.writeNumberField("@odata.count", entitySet.getCount());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/da8cf726/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 e7563b0..b791cc6 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
@@ -43,6 +43,7 @@ public class ODataJsonSerializerTest {
 
   private static final String ETAllPrim = "ETAllPrim";
   private static final String ETCompAllPrim = "ETCompAllPrim";
+  private static final String ETCollAllPrim = "ETCollAllPrim";
   private static final String CTAllPrim = "CTAllPrim";
   private static final String CTAllPrim_Type = "com.sap.odata.test1.CTAllPrim";
 
@@ -50,18 +51,31 @@ public class ODataJsonSerializerTest {
     String getName();
     String getTypeName();
     EdmPrimitiveTypeKind getType();
+    boolean isCollection();
   }
 
   public static class TecComplexProperty implements TechProperty {
 
     final String typeName;
     final String name;
-    final List<EdmProperty> properties;
+    final List<EdmProperty> properties = new ArrayList<EdmProperty>();
+    boolean collection = false;
 
-    public TecComplexProperty(String typeName, String name, List<EdmProperty> propertyNames) {
+    public TecComplexProperty(String typeName, String name) {
       this.typeName = typeName;
       this.name = name;
-      this.properties = new ArrayList<EdmProperty>(propertyNames);
+    }
+    TechProperty addProperties(List<EdmProperty> properties) {
+      this.properties.addAll(properties);
+      return this;
+    }
+    TechProperty asCollection() {
+      this.collection = true;
+      return this;
+    }
+    @Override
+    public boolean isCollection() {
+      return collection;
     }
     @Override
     public String getName() {
@@ -96,25 +110,44 @@ public class ODataJsonSerializerTest {
     DateTimeOffset("PropertyDateTimeOffset", EdmPrimitiveTypeKind.DateTimeOffset),
     Duration("PropertyDuration", EdmPrimitiveTypeKind.Duration),
     Guid("PropertyGuid", EdmPrimitiveTypeKind.Guid),
-    TimeOfDay("PropertyTimeOfDay", EdmPrimitiveTypeKind.TimeOfDay);
+    TimeOfDay("PropertyTimeOfDay", EdmPrimitiveTypeKind.TimeOfDay),
     //  <NavigationProperty Name="NavPropertyETTwoPrimOne" Type="test1.ETTwoPrim" Nullable="false"/>
 //    NavETTwoPrimOne = "NavPropertyETTwoPrimOne", EdmPrimitiveTypeKind.),
     //  <NavigationProperty Name="NavPropertyETTwoPrimMany" Type="Collection(test1.ETTwoPrim)" Nullable="false"/>
 //    NavETTwoPrimMany("NavPropertyETTwoPrimMany", EdmCom.);
+    Collection_Int16("CollPropertyInt16", EdmPrimitiveTypeKind.Int16, true),
+    Collection_String("CollPropertyString", EdmPrimitiveTypeKind.String, true),
+    Collection_Boolean("CollPropertyBoolean", EdmPrimitiveTypeKind.Boolean, true),
+    Collection_Byte("CollPropertyByte", EdmPrimitiveTypeKind.Byte, true),
+    Collection_SByte("CollPropertySByte", EdmPrimitiveTypeKind.SByte, true),
+    Collection_Int32("CollPropertyInt32", EdmPrimitiveTypeKind.Int32, true),
+    Collection_Int64("CollPropertyInt64", EdmPrimitiveTypeKind.Int64, true),
+    Collection_Single("CollPropertySingle", EdmPrimitiveTypeKind.Single, true),
+    Collection_Double("CollPropertyDouble", EdmPrimitiveTypeKind.Double, true),
+    Collection_Decimal("CollPropertyDecimal", EdmPrimitiveTypeKind.Decimal, true),
+    Collection_Binary("CollPropertyBinary", EdmPrimitiveTypeKind.Binary, true),
+    Collection_Date("CollPropertyDate", EdmPrimitiveTypeKind.Date, true),
+    Collection_DateTimeOffset("CollPropertyDateTimeOffset", EdmPrimitiveTypeKind.DateTimeOffset, true),
+    Collection_Duration("CollPropertyDuration", EdmPrimitiveTypeKind.Duration, true),
+    Collection_Guid("CollPropertyGuid", EdmPrimitiveTypeKind.Guid, true),
+    Collection_TimeOfDay("CollPropertyTimeOfDay", EdmPrimitiveTypeKind.TimeOfDay, true);
 
     final String name;
     final EdmPrimitiveTypeKind type;
+    final boolean isCollection;
 
     TecSimpleProperty(String name, EdmPrimitiveTypeKind type) {
+      this(name, type, false);
+    }
+    TecSimpleProperty(String name, EdmPrimitiveTypeKind type, boolean collection) {
       this.name = name;
       this.type = type;
+      this.isCollection = collection;
     }
-
     @Override
     public String getTypeName() {
       return type.name();
     }
-
     @Override
     public EdmPrimitiveTypeKind getType() {
       return type;
@@ -123,12 +156,19 @@ public class ODataJsonSerializerTest {
     public String getName() {
       return name;
     }
+    @Override
+    public boolean isCollection() {
+      return isCollection;
+    }
   }
 
   private ContextURL contextUrl;
   private EdmEntitySet edmESAllPrim;
+  private EdmEntitySet edmESCompAllPrim;
+  private EdmEntitySet edmESCollAllPrim;
   private EdmEntityType edmETAllPrim;
   private EdmEntityType edmETCompAllPrim;
+  private EdmEntityType edmETCollAllPrim;
 
   private ODataJsonSerializer serializer = new ODataJsonSerializer();
 
@@ -136,6 +176,7 @@ public class ODataJsonSerializerTest {
   public void prepare() throws Exception {
     contextUrl = ContextURL.getInstance(new URI("http://localhost:8080/test.svc"));
 
+    // entity all primitive
     edmETAllPrim = Mockito.mock(EdmEntityType.class);
     Mockito.when(edmETAllPrim.getName()).thenReturn(ETAllPrim);
     List<EdmProperty> properties = Arrays.asList(
@@ -176,7 +217,7 @@ public class ODataJsonSerializerTest {
     Mockito.when(edmETCompAllPrim.getName()).thenReturn(ETCompAllPrim);
     List<EdmProperty> capProperties = Arrays.asList(
         mockProperty(TecSimpleProperty.Int16, false),
-        mockProperty(new TecComplexProperty(CTAllPrim_Type, CTAllPrim, properties), false)
+        mockProperty(new TecComplexProperty(CTAllPrim_Type, CTAllPrim).addProperties(properties), false)
     );
     List<String> capPropertyNames = new ArrayList<String>();
 
@@ -185,6 +226,38 @@ public class ODataJsonSerializerTest {
       Mockito.when(edmETCompAllPrim.getProperty(property.getName())).thenReturn(property);
     }
     Mockito.when(edmETCompAllPrim.getPropertyNames()).thenReturn(capPropertyNames);
+
+    // entity type all primitive collections
+    //
+    edmETCollAllPrim = Mockito.mock(EdmEntityType.class);
+    Mockito.when(edmETCollAllPrim.getName()).thenReturn(ETCollAllPrim);
+    List<EdmProperty> allCollProperties = Arrays.asList(
+            mockProperty(TecSimpleProperty.Int16, false),
+            mockProperty(TecSimpleProperty.Collection_String),
+            mockProperty(TecSimpleProperty.Collection_Boolean),
+            mockProperty(TecSimpleProperty.Collection_Byte),
+            mockProperty(TecSimpleProperty.Collection_SByte),
+            mockProperty(TecSimpleProperty.Collection_Int32),
+            mockProperty(TecSimpleProperty.Collection_Int64),
+            mockProperty(TecSimpleProperty.Collection_Single),
+            mockProperty(TecSimpleProperty.Collection_Double),
+            mockProperty(TecSimpleProperty.Collection_Decimal),
+            mockProperty(TecSimpleProperty.Collection_Binary),
+            mockProperty(TecSimpleProperty.Collection_Date),
+            mockProperty(TecSimpleProperty.Collection_DateTimeOffset),
+            mockProperty(TecSimpleProperty.Collection_Duration),
+            mockProperty(TecSimpleProperty.Collection_Guid),
+            mockProperty(TecSimpleProperty.Collection_TimeOfDay)
+    );
+    List<String> etCollAllPrimPropertyNames = new ArrayList<String>();
+
+    for (EdmProperty property : allCollProperties) {
+      etCollAllPrimPropertyNames.add(property.getName());
+      Mockito.when(edmETCollAllPrim.getProperty(property.getName())).thenReturn(property);
+    }
+    Mockito.when(edmETCollAllPrim.getPropertyNames()).thenReturn(etCollAllPrimPropertyNames);
+
+    // Entity Set all primitive collection
   }
 
   private EdmProperty mockProperty(TechProperty name) {
@@ -217,6 +290,7 @@ public class ODataJsonSerializerTest {
       Mockito.when(edmElement.getScale()).thenReturn(10);
       Mockito.when(edmElement.getType()).thenReturn(EdmPrimitiveTypeFactory.getInstance(tecProperty.getType()));
     }
+    Mockito.when(edmElement.isCollection()).thenReturn(tecProperty.isCollection());
     Mockito.when(edmElement.isNullable()).thenReturn(nullable);
     return edmElement;
   }
@@ -225,8 +299,16 @@ public class ODataJsonSerializerTest {
     return new PropertyImpl(property.getTypeName(), property.getName(), vType, value);
   }
 
-  private PropertyImpl createProperty(String type, TecSimpleProperty property, ValueType vType, Object value) {
-    return new PropertyImpl(type, property.name, vType, value);
+  private PropertyImpl createProperty(String type, TecSimpleProperty property, ValueType vType, Object ... value) {
+    final Object propValue;
+    if(value == null || value.length ==0) {
+      propValue = null;
+    } else if(property.isCollection()) {
+      propValue = Arrays.asList(value);
+    } else {
+      propValue = value[0];
+    }
+    return new PropertyImpl(type, property.name, vType, propValue);
   }
 
   @Test
@@ -257,7 +339,6 @@ public class ODataJsonSerializerTest {
     Assert.assertEquals(expectedResult, resultString);
   }
 
-
   @Test
   public void entitySetETAllPrim() throws Exception {
     EdmEntitySet edmEntitySet = edmESAllPrim;
@@ -288,13 +369,41 @@ public class ODataJsonSerializerTest {
   }
 
   @Test
+  public void entityCollAllPrim() throws Exception {
+    Entity entity = createETCollAllPrim(4711);
+
+    InputStream result = serializer.entity(edmETCollAllPrim, entity, contextUrl);
+    String resultString = streamToString(result);
+    String expectedResult = "{" +
+        "\"@odata.context\":\"http://localhost:8080/test.svc\"," +
+        "\"PropertyInt16\":4711," +
+        "\"CollPropertyString\":[\"StringValue_1\",\"StringValue_2\"]," +
+        "\"CollPropertyBoolean\":[true,false]," +
+        "\"CollPropertyByte\":[19,42]," +
+        "\"CollPropertySByte\":[1,2]," +
+        "\"CollPropertyInt32\":[2147483647,-2147483648]," +
+        "\"CollPropertyInt64\":[9223372036854775807,-9223372036854775808]," +
+        "\"CollPropertySingle\":[47.11,11.47]," +
+        "\"CollPropertyDouble\":[4.711,711.4]," +
+        "\"CollPropertyDecimal\":[4711.1174,1174.4711]," +
+        "\"CollPropertyBinary\":[\"BAcBAQ==\",\"dGVzdA==\"]," +
+        "\"CollPropertyDate\":[\"2014-03-19\",\"2014-07-02\"]," +
+        "\"CollPropertyDateTimeOffset\":[\"2014-03-19T10:12:00+01:00\",\"2014-07-02T13:30:00+02:00\"]," +
+        "\"CollPropertyDuration\":[\"P16148383DT8H0S\",\"P16253479DT4H0S\"]," +
+        "\"CollPropertyGuid\":[\"0000aaaa-00bb-00cc-00dd-000000ffffff\",\"0000ffff-00dd-00cc-00bb-000000aaaaaa\"]," +
+        "\"CollPropertyTimeOfDay\":[\"10:12:00\",\"13:30:00\"]" +
+        "}";
+    Assert.assertEquals(expectedResult, resultString);
+  }
+
+  @Test
   public void entityETCompAllPrim() throws Exception {
     Entity complexCtAllPrim = createETAllPrim();
 
     Entity entity = new EntityImpl();
     entity.addProperty(new PropertyImpl("Edm.Int16", TecSimpleProperty.Int16.name, ValueType.PRIMITIVE, 4711));
     entity.addProperty(createProperty(
-            new TecComplexProperty(CTAllPrim_Type, CTAllPrim, Collections.<EdmProperty>emptyList()),
+            new TecComplexProperty(CTAllPrim_Type, CTAllPrim),
             ValueType.COMPLEX, complexCtAllPrim.getProperties()));
 
     InputStream result = serializer.entity(edmETCompAllPrim, entity, contextUrl);
@@ -323,10 +432,59 @@ public class ODataJsonSerializerTest {
     Assert.assertEquals(expectedResult, resultString);
   }
 
+
   private Entity createETAllPrim() {
     return createETAllPrim(4711);
   }
 
+  private Entity createETCollAllPrim(int id) {
+    Entity entity = new EntityImpl();
+    Calendar date = Calendar.getInstance();
+    date.set(2014, Calendar.MARCH, 19, 10, 12, 0);
+    date.set(Calendar.MILLISECOND, 0);
+    Calendar date2 = Calendar.getInstance();
+    date2.set(2014, Calendar.JULY, 2, 13, 30, 0);
+    date2.set(Calendar.MILLISECOND, 0);
+    //
+    entity.addProperty(createProperty("Edm.Int16", TecSimpleProperty.Int16, ValueType.PRIMITIVE, id));
+    //
+    entity.addProperty(createProperty("Collection(Edm.Int16)", TecSimpleProperty.Collection_Int16,
+            ValueType.COLLECTION_PRIMITIVE, id));
+    entity.addProperty(createProperty("Collection(Edm.String)", TecSimpleProperty.Collection_String,
+            ValueType.COLLECTION_PRIMITIVE, "StringValue_1", "StringValue_2"));
+    entity.addProperty(createProperty("Collection(Edm.Boolean)", TecSimpleProperty.Collection_Boolean,
+            ValueType.COLLECTION_PRIMITIVE, Boolean.TRUE, Boolean.FALSE));
+    entity.addProperty(createProperty("Collection(Edm.Byte)", TecSimpleProperty.Collection_Byte,
+            ValueType.COLLECTION_PRIMITIVE, Byte.valueOf("19"), Byte.valueOf("42")));
+    entity.addProperty(createProperty("Collection(Edm.SByte)", TecSimpleProperty.Collection_SByte,
+            ValueType.COLLECTION_PRIMITIVE, Short.valueOf("1"), Short.valueOf("2")));
+    entity.addProperty(createProperty("Collection(Edm.Int32)", TecSimpleProperty.Collection_Int32,
+            ValueType.COLLECTION_PRIMITIVE, Integer.MAX_VALUE, Integer.MIN_VALUE));
+    entity.addProperty(createProperty("Collection(Edm.Int64)", TecSimpleProperty.Collection_Int64,
+            ValueType.COLLECTION_PRIMITIVE, Long.MAX_VALUE, Long.MIN_VALUE));
+    entity.addProperty(createProperty("Collection(Edm.Single)", TecSimpleProperty.Collection_Single,
+            ValueType.COLLECTION_PRIMITIVE, 47.11, 11.47));
+    entity.addProperty(createProperty("Collection(Edm.Double)", TecSimpleProperty.Collection_Double,
+            ValueType.COLLECTION_PRIMITIVE, 4.711, 711.4));
+    entity.addProperty(createProperty("Collection(Edm.Decimal)", TecSimpleProperty.Collection_Decimal,
+            ValueType.COLLECTION_PRIMITIVE, 4711.1174, 1174.4711));
+    entity.addProperty(createProperty("Collection(Edm.Binary)", TecSimpleProperty.Collection_Binary,
+            ValueType.COLLECTION_PRIMITIVE, new byte[]{0x04, 0x07, 0x01, 0x01}, "test".getBytes()));
+    entity.addProperty(createProperty("Collection(Edm.Date)", TecSimpleProperty.Collection_Date,
+            ValueType.COLLECTION_PRIMITIVE, date, date2));
+    entity.addProperty(createProperty("Collection(Edm.DateTimeOffset)", TecSimpleProperty.Collection_DateTimeOffset,
+            ValueType.COLLECTION_PRIMITIVE, date.getTime(), date2.getTime()));
+    entity.addProperty(createProperty("Collection(Edm.Duration)", TecSimpleProperty.Collection_Duration,
+            ValueType.COLLECTION_PRIMITIVE, date.getTimeInMillis(), date2.getTimeInMillis()));
+    entity.addProperty(createProperty("Collection(Edm.Guid)", TecSimpleProperty.Collection_Guid,
+            ValueType.COLLECTION_PRIMITIVE,
+            UUID.fromString("AAAA-BB-CC-DD-FFFFFF"),
+            UUID.fromString("FFFF-DD-CC-BB-AAAAAA")));
+    entity.addProperty(createProperty("Collection(Edm.TimeOfDay)", TecSimpleProperty.Collection_TimeOfDay,
+            ValueType.COLLECTION_PRIMITIVE, date, date2));
+    return entity;
+  }
+
   private Entity createETAllPrim(int id) {
     Entity entity = new EntityImpl();
     Calendar date = Calendar.getInstance();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/da8cf726/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
index cf40489..bfdede8 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
@@ -19,9 +19,7 @@
 package org.apache.olingo.server.tecsvc.processor;
 
 import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
 
 import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.data.Entity;
@@ -70,9 +68,9 @@ public class SampleJsonProcessor implements EntitySetProcessor, EntityProcessor
       time = System.nanoTime();
       ODataSerializer serializer = odata.createSerializer(ODataFormat.JSON);
       EdmEntitySet edmEntitySet = getEntitySet(uriInfo);
-      EntitySet entitySet = createEntitySet(edmEntitySet.getEntityType());
-      response.setContent(serializer.entitySet(edmEntitySet, entitySet,
-              getContextUrl(request, edmEntitySet.getEntityType())));
+      ContextURL contextUrl = getContextUrl(request, edmEntitySet.getEntityType());
+      EntitySet entitySet = createEntitySet(edmEntitySet.getEntityType(), contextUrl.getURI().toASCIIString());
+      response.setContent(serializer.entitySet(edmEntitySet, entitySet, contextUrl));
       LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
 
       response.setStatusCode(HttpStatusCode.OK.getStatusCode());
@@ -106,42 +104,67 @@ public class SampleJsonProcessor implements EntitySetProcessor, EntityProcessor
   }
 
   public EdmEntitySet getEntitySet(UriInfo uriInfo) {
-      List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
-      if(resourcePaths.isEmpty()) {
-        throw new RuntimeException("Invalid resource path.");
-      }
-      String entitySetName = resourcePaths.get(resourcePaths.size()-1).toString();
-      return edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
-              .getEntitySet(entitySetName);
+    List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
+    if(resourcePaths.isEmpty()) {
+      throw new RuntimeException("Invalid resource path.");
     }
+    String entitySetName = resourcePaths.get(resourcePaths.size()-1).toString();
+    return edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
+            .getEntitySet(entitySetName);
+  }
 
-    protected Entity createEntity(EdmEntityType entityType) {
-      boolean complex = (entityType.getName().contains("Comp"));
-      return createEntity(complex);
+  protected Entity createEntity(EdmEntityType entityType) {
+    boolean complex = (entityType.getName().contains("Comp"));
+    if(entityType.getName().contains("Coll")) {
+      return createEntityWithCollection(complex);
     }
+    return createEntity(complex);
+  }
+
+  protected Entity createEntity(boolean complex) {
+    Entity entity = new EntityImpl();
+    Property property = new PropertyImpl();
+    property.setName("PropertyString");
+    property.setValue(ValueType.PRIMITIVE, "dummyValue");
+    entity.getProperties().add(property);
+    Property propertyInt = new PropertyImpl();
+    propertyInt.setName("PropertyInt16");
+    propertyInt.setValue(ValueType.PRIMITIVE, 42);
+    entity.getProperties().add(propertyInt);
+    Property propertyGuid = new PropertyImpl();
+    propertyGuid.setName("PropertyGuid");
+    propertyGuid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
+    entity.getProperties().add(propertyGuid);
+
+    if(complex) {
+      entity.addProperty(createComplexProperty());
+    }
+
+    return entity;
+  }
+
+  protected Entity createEntityWithCollection(boolean complex) {
+    Entity entity = new EntityImpl();
+    Property propertyInt = new PropertyImpl();
+    propertyInt.setName("PropertyInt16");
+    propertyInt.setValue(ValueType.PRIMITIVE, 42);
+    Property property = new PropertyImpl();
+    property.setName("CollPropertyString");
+    property.setValue(ValueType.COLLECTION_PRIMITIVE, Arrays.asList("dummyValue", "dummyValue_2"));
+    entity.getProperties().add(property);
+    entity.getProperties().add(propertyInt);
+    Property propertyGuid = new PropertyImpl();
+    propertyGuid.setName("CollPropertyGuid");
+    propertyGuid.setValue(ValueType.COLLECTION_PRIMITIVE, Arrays.asList(UUID.randomUUID(), UUID.randomUUID()));
+    entity.getProperties().add(propertyGuid);
 
-    protected Entity createEntity(boolean complex) {
-      Entity entity = new EntityImpl();
-      Property property = new PropertyImpl();
-      property.setName("PropertyString");
-      property.setValue(ValueType.PRIMITIVE, "dummyValue");
-      entity.getProperties().add(property);
-      Property propertyInt = new PropertyImpl();
-      propertyInt.setName("PropertyInt16");
-      propertyInt.setValue(ValueType.PRIMITIVE, 42);
-      entity.getProperties().add(propertyInt);
-      Property propertyGuid = new PropertyImpl();
-      propertyGuid.setName("PropertyGuid");
-      propertyGuid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
-      entity.getProperties().add(propertyGuid);
-
-      if(complex) {
-        entity.addProperty(createComplexProperty());
-      }
-
-      return entity;
+    if(complex) {
+      entity.addProperty(createCollectionOfComplexProperty());
     }
 
+    return entity;
+  }
+
   protected Property createComplexProperty() {
     List<Property> properties = new ArrayList<Property>();
     Property property = new PropertyImpl();
@@ -161,14 +184,48 @@ public class SampleJsonProcessor implements EntitySetProcessor, EntityProcessor
             properties);
   }
 
+  protected Property createCollectionOfComplexProperty() {
+    List<Property> properties = new ArrayList<Property>();
+    Property property = new PropertyImpl();
+    property.setName("PropertyString");
+    property.setValue(ValueType.PRIMITIVE, "dummyValue");
+    properties.add(property);
+    Property propertyInt = new PropertyImpl();
+    propertyInt.setName("PropertyInt16");
+    propertyInt.setValue(ValueType.PRIMITIVE, 42);
+    properties.add(propertyInt);
+    Property propertyGuid = new PropertyImpl();
+    propertyGuid.setName("PropertyGuid");
+    propertyGuid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
+    properties.add(propertyGuid);
+
+    List<Property> properties2 = new ArrayList<Property>();
+    Property property2 = new PropertyImpl();
+    property2.setName("PropertyString");
+    property2.setValue(ValueType.PRIMITIVE, "dummyValue2");
+    properties2.add(property2);
+    Property property2Int = new PropertyImpl();
+    property2Int.setName("PropertyInt16");
+    property2Int.setValue(ValueType.PRIMITIVE, 44);
+    properties2.add(property2Int);
+    Property property2Guid = new PropertyImpl();
+    property2Guid.setName("PropertyGuid");
+    property2Guid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
+    properties2.add(property2Guid);
+
+    return new PropertyImpl("com.sap.odata.test1.ETCompAllPrim", "PropertyComplex", ValueType.COMPLEX,
+            Arrays.asList(properties, properties2));
+  }
+
 
-  protected EntitySet createEntitySet(EdmEntityType edmEntityType) {
-      EntitySet entitySet = new EntitySetImpl();
-      entitySet.setCount(4242);
-      entitySet.setNext(URI.create("nextLinkURI"));
-      for (int i = 0; i < 1000; i++) {
-        entitySet.getEntities().add(createEntity(edmEntityType));
-      }
-      return entitySet;
+  protected EntitySet createEntitySet(EdmEntityType edmEntityType, String baseUri) {
+    EntitySet entitySet = new EntitySetImpl();
+    int count = (int) ((Math.random() * 50) + 1);
+    entitySet.setCount(count);
+    entitySet.setNext(URI.create(baseUri + "nextLink"));
+    for (int i = 0; i < count; i++) {
+      entitySet.getEntities().add(createEntity(edmEntityType));
     }
+    return entitySet;
   }
+}


[2/6] git commit: [OLINGO-317] Added complex type handling

Posted by mi...@apache.org.
[OLINGO-317] Added complex type handling


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

Branch: refs/heads/master
Commit: 71bdaed3003a6c903888a3465c9a338703596138
Parents: 839e960
Author: Michael Bolz <mi...@sap.com>
Authored: Tue Jul 1 13:11:36 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Tue Jul 1 16:21:42 2014 +0200

----------------------------------------------------------------------
 .../serializer/json/ODataJsonSerializer.java    | 107 +++++++++----------
 .../json/ODataJsonSerializerTest.java           |  61 ++++++-----
 .../tecsvc/processor/SampleJsonProcessor.java   |  82 +++++++++++---
 3 files changed, 151 insertions(+), 99 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/71bdaed3/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 8cb5f0c..c3fe720 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
@@ -18,36 +18,24 @@
  */
 package org.apache.olingo.server.core.serializer.json;
 
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.util.List;
-
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.ODataRuntimeException;
-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.LinkedComplexValue;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.edm.Edm;
-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.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.data.*;
+import org.apache.olingo.commons.api.edm.*;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.core.serializer.utils.CircleStreamBuffer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.util.List;
 
 public class ODataJsonSerializer implements ODataSerializer {
 
@@ -148,38 +136,14 @@ public class ODataJsonSerializer implements ODataSerializer {
       }
     } else {
       if (edmProperty.isPrimitive()) {
-        if (property.isPrimitive()) {
-          writePrimitiveValue(edmProperty, property.asPrimitive(), json);
-        } else if (property.isGeospatial()) {
-          throw new ODataRuntimeException("Property type not yet supported!");
-        } else if (property.isEnum()) {
-          json.writeString(property.asEnum().toString());
-        } else {
-          throw new ODataRuntimeException("Inconsistent property type!");
-        }
+        handlePrimitive(edmProperty, property, json);
       } else if (edmProperty.isCollection()) {
-        json.writeStartArray();
-        for (Object value : property.asCollection()) {
-          switch (property.getValueType()) {
-          case COLLECTION_PRIMITIVE:
-            writePrimitiveValue(edmProperty, value, json);
-            break;
-          case COLLECTION_GEOSPATIAL:
-            throw new ODataRuntimeException("Property type not yet supported!");
-          case COLLECTION_ENUM:
-            json.writeString(value.toString());
-            break;
-          case COLLECTION_LINKED_COMPLEX:
-            writeLinkedComplexValue(edmProperty, (LinkedComplexValue) value, json);
-            break;
-          default:
-            throw new ODataRuntimeException("Property type not yet supported!");
-          }
-        }
-        json.writeEndArray();
+        handleCollection(edmProperty, property, json);
       } else {
         if (property.isLinkedComplex()) {
-          writeLinkedComplexValue(edmProperty, property.asLinkedComplex(), json);
+          writeComplexValue(edmProperty, property.asLinkedComplex().getValue(), json);
+        } else if(property.isComplex()) {
+          writeComplexValue(edmProperty, property.asComplex(), json);
         } else {
           throw new ODataRuntimeException("Property type not yet supported!");
         }
@@ -187,6 +151,42 @@ public class ODataJsonSerializer implements ODataSerializer {
     }
   }
 
+  private void handleCollection(EdmProperty edmProperty, Property property, JsonGenerator json)
+          throws IOException, EdmPrimitiveTypeException {
+    json.writeStartArray();
+    for (Object value : property.asCollection()) {
+      switch (property.getValueType()) {
+      case COLLECTION_PRIMITIVE:
+        writePrimitiveValue(edmProperty, value, json);
+        break;
+      case COLLECTION_GEOSPATIAL:
+        throw new ODataRuntimeException("Property type not yet supported!");
+      case COLLECTION_ENUM:
+        json.writeString(value.toString());
+        break;
+      case COLLECTION_LINKED_COMPLEX:
+        writeComplexValue(edmProperty, ((LinkedComplexValue) value).getValue(), json);
+        break;
+      default:
+        throw new ODataRuntimeException("Property type not yet supported!");
+      }
+    }
+    json.writeEndArray();
+  }
+
+  private void handlePrimitive(EdmProperty edmProperty, Property property, JsonGenerator json)
+          throws EdmPrimitiveTypeException, IOException {
+    if (property.isPrimitive()) {
+      writePrimitiveValue(edmProperty, property.asPrimitive(), json);
+    } else if (property.isGeospatial()) {
+      throw new ODataRuntimeException("Property type not yet supported!");
+    } else if (property.isEnum()) {
+      json.writeString(property.asEnum().toString());
+    } else {
+      throw new ODataRuntimeException("Inconsistent property type!");
+    }
+  }
+
   protected void writePrimitiveValue(final EdmProperty edmProperty, final Object primitiveValue, JsonGenerator json)
       throws EdmPrimitiveTypeException, IOException {
     final EdmPrimitiveType type = (EdmPrimitiveType) edmProperty.getType();
@@ -209,10 +209,9 @@ public class ODataJsonSerializer implements ODataSerializer {
     }
   }
 
-  private void writeLinkedComplexValue(final EdmProperty edmProperty, final LinkedComplexValue linkedComplexValue,
-      JsonGenerator json) throws IOException, EdmPrimitiveTypeException {
+  private void writeComplexValue(final EdmProperty edmProperty, final List<Property> properties,
+                                       JsonGenerator json) throws IOException, EdmPrimitiveTypeException {
     final EdmComplexType type = (EdmComplexType) edmProperty.getType();
-    final List<Property> properties = linkedComplexValue.getValue();
     json.writeStartObject();
     for (final String propertyName : type.getPropertyNames()) {
       final Property property = findProperty(propertyName, properties);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/71bdaed3/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 1008c5f..e7563b0 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
@@ -18,15 +18,10 @@
  */
 package org.apache.olingo.server.core.serializer.json;
 
-import org.apache.olingo.commons.api.ODataRuntimeException;
 import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.ValueType;
-import org.apache.olingo.commons.api.edm.EdmEntitySet;
-import org.apache.olingo.commons.api.edm.EdmEntityType;
-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.*;
 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;
@@ -36,17 +31,11 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -65,11 +54,14 @@ public class ODataJsonSerializerTest {
 
   public static class TecComplexProperty implements TechProperty {
 
-    final String name;
     final String typeName;
-    public TecComplexProperty(String typeName, String name) {
-      this.name = name;
+    final String name;
+    final List<EdmProperty> properties;
+
+    public TecComplexProperty(String typeName, String name, List<EdmProperty> propertyNames) {
       this.typeName = typeName;
+      this.name = name;
+      this.properties = new ArrayList<EdmProperty>(propertyNames);
     }
     @Override
     public String getName() {
@@ -83,6 +75,9 @@ public class ODataJsonSerializerTest {
     public EdmPrimitiveTypeKind getType() {
       return null;
     }
+    public List<EdmProperty> getProperties() {
+      return properties;
+    }
   }
 
   enum TecSimpleProperty implements TechProperty {
@@ -181,7 +176,7 @@ public class ODataJsonSerializerTest {
     Mockito.when(edmETCompAllPrim.getName()).thenReturn(ETCompAllPrim);
     List<EdmProperty> capProperties = Arrays.asList(
         mockProperty(TecSimpleProperty.Int16, false),
-        mockProperty(new TecComplexProperty(CTAllPrim_Type, CTAllPrim), false, true)
+        mockProperty(new TecComplexProperty(CTAllPrim_Type, CTAllPrim, properties), false)
     );
     List<String> capPropertyNames = new ArrayList<String>();
 
@@ -193,22 +188,27 @@ public class ODataJsonSerializerTest {
   }
 
   private EdmProperty mockProperty(TechProperty name) {
-    return mockProperty(name, true, false);
+    return mockProperty(name, true);
   }
 
-  private EdmProperty mockProperty(TechProperty name, boolean nullable) {
-    return mockProperty(name, nullable, false);
-  }
-
-  private EdmProperty mockProperty(TechProperty tecProperty, boolean nullable, boolean complex) {
+  private EdmProperty mockProperty(TechProperty tecProperty, boolean nullable) {
     EdmProperty edmElement = Mockito.mock(EdmProperty.class);
     Mockito.when(edmElement.getName()).thenReturn(tecProperty.getName());
-    if(complex) {
+    if (tecProperty instanceof TecComplexProperty) {
+      TecComplexProperty complexProperty = (TecComplexProperty) tecProperty;
       Mockito.when(edmElement.isPrimitive()).thenReturn(false);
-      EdmType type = Mockito.mock(EdmType.class);
+      EdmComplexType type = Mockito.mock(EdmComplexType.class);
       Mockito.when(type.getKind()).thenReturn(EdmTypeKind.COMPLEX);
       Mockito.when(type.getName()).thenReturn(tecProperty.getTypeName());
       Mockito.when(edmElement.getType()).thenReturn(type);
+
+      List<String> propertyNames = new ArrayList<String>();
+      List<EdmProperty> properties = complexProperty.getProperties();
+      for (EdmProperty property : properties) {
+        propertyNames.add(property.getName());
+        Mockito.when(type.getProperty(property.getName())).thenReturn(property);
+      }
+      Mockito.when(type.getPropertyNames()).thenReturn(propertyNames);
     } else {
       Mockito.when(edmElement.isPrimitive()).thenReturn(true);
       // TODO: set default values
@@ -287,20 +287,23 @@ public class ODataJsonSerializerTest {
     Assert.assertEquals(100, count);
   }
 
-  @Test(expected = ODataRuntimeException.class)
+  @Test
   public void entityETCompAllPrim() throws Exception {
     Entity complexCtAllPrim = createETAllPrim();
 
     Entity entity = new EntityImpl();
     entity.addProperty(new PropertyImpl("Edm.Int16", TecSimpleProperty.Int16.name, ValueType.PRIMITIVE, 4711));
-    entity.addProperty(createProperty(new TecComplexProperty(CTAllPrim_Type, CTAllPrim),
-        ValueType.COMPLEX, complexCtAllPrim));
+    entity.addProperty(createProperty(
+            new TecComplexProperty(CTAllPrim_Type, CTAllPrim, Collections.<EdmProperty>emptyList()),
+            ValueType.COMPLEX, complexCtAllPrim.getProperties()));
 
     InputStream result = serializer.entity(edmETCompAllPrim, entity, contextUrl);
     String resultString = streamToString(result);
     String expectedResult = "{" +
         "\"@odata.context\":\"http://localhost:8080/test.svc\"," +
         "\"PropertyInt16\":4711," +
+        "\"CTAllPrim\":{" +
+        "\"PropertyInt16\":4711," +
         "\"PropertyString\":\"StringValue\"," +
         "\"PropertyBoolean\":true," +
         "\"PropertyByte\":19," +
@@ -316,7 +319,7 @@ public class ODataJsonSerializerTest {
         "\"PropertyDuration\":\"P16148383DT8H0S\"," +
         "\"PropertyGuid\":\"0000aaaa-00bb-00cc-00dd-000000ffffff\"," +
         "\"PropertyTimeOfDay\":\"10:12:00\"" +
-        "}";
+        "}}";
     Assert.assertEquals(expectedResult, resultString);
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/71bdaed3/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
index 8cf00e9..cf40489 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
@@ -19,6 +19,8 @@
 package org.apache.olingo.server.tecsvc.processor;
 
 import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.UUID;
 
 import org.apache.olingo.commons.api.data.ContextURL;
@@ -27,7 +29,10 @@ import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ValueType;
 import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
@@ -41,6 +46,7 @@ import org.apache.olingo.server.api.processor.EntityProcessor;
 import org.apache.olingo.server.api.processor.EntitySetProcessor;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.api.uri.UriInfo;
+import org.apache.olingo.server.api.uri.UriResource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -60,16 +66,13 @@ public class SampleJsonProcessor implements EntitySetProcessor, EntityProcessor
     public void readEntitySet(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
       long time = System.nanoTime();
 
-      EntitySet entitySet = createEntitySet();
-
       LOG.info((System.nanoTime() - time) / 1000 + " microseconds");
       time = System.nanoTime();
       ODataSerializer serializer = odata.createSerializer(ODataFormat.JSON);
-      response.setContent(serializer.entitySet(
-              edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
-                      .getEntitySet("ESAllPrim"),
-              entitySet,
-              ContextURL.getInstance(URI.create("dummyContextURL"))));
+      EdmEntitySet edmEntitySet = getEntitySet(uriInfo);
+      EntitySet entitySet = createEntitySet(edmEntitySet.getEntityType());
+      response.setContent(serializer.entitySet(edmEntitySet, entitySet,
+              getContextUrl(request, edmEntitySet.getEntityType())));
       LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
 
       response.setStatusCode(HttpStatusCode.OK.getStatusCode());
@@ -79,23 +82,45 @@ public class SampleJsonProcessor implements EntitySetProcessor, EntityProcessor
     @Override
     public void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
       long time = System.nanoTime();
-      Entity entity = createEntity();
 
       LOG.info((System.nanoTime() - time) / 1000 + " microseconds");
       time = System.nanoTime();
       ODataSerializer serializer = odata.createSerializer(ODataFormat.JSON);
-      response.setContent(serializer.entity(
-              edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
-                      .getEntitySet("ESAllPrim").getEntityType(),
-              entity,
-              ContextURL.getInstance(URI.create("dummyContextURL"))));
+      EdmEntityType entityType = getEntityType(uriInfo);
+      Entity entity = createEntity(entityType);
+
+      response.setContent(serializer.entity(entityType, entity,
+              getContextUrl(request, entityType)));
       LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
 
       response.setStatusCode(HttpStatusCode.OK.getStatusCode());
       response.setHeader("Content-Type", ContentType.APPLICATION_JSON.toContentTypeString());
     }
 
-    protected Entity createEntity() {
+  private ContextURL getContextUrl(ODataRequest request, EdmEntityType entityType) {
+    return ContextURL.getInstance(URI.create(request.getRawBaseUri() + "/" + entityType.getName()));
+  }
+
+  public EdmEntityType getEntityType(UriInfo uriInfo) {
+    return getEntitySet(uriInfo).getEntityType();
+  }
+
+  public EdmEntitySet getEntitySet(UriInfo uriInfo) {
+      List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
+      if(resourcePaths.isEmpty()) {
+        throw new RuntimeException("Invalid resource path.");
+      }
+      String entitySetName = resourcePaths.get(resourcePaths.size()-1).toString();
+      return edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
+              .getEntitySet(entitySetName);
+    }
+
+    protected Entity createEntity(EdmEntityType entityType) {
+      boolean complex = (entityType.getName().contains("Comp"));
+      return createEntity(complex);
+    }
+
+    protected Entity createEntity(boolean complex) {
       Entity entity = new EntityImpl();
       Property property = new PropertyImpl();
       property.setName("PropertyString");
@@ -109,15 +134,40 @@ public class SampleJsonProcessor implements EntitySetProcessor, EntityProcessor
       propertyGuid.setName("PropertyGuid");
       propertyGuid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
       entity.getProperties().add(propertyGuid);
+
+      if(complex) {
+        entity.addProperty(createComplexProperty());
+      }
+
       return entity;
     }
 
-    protected EntitySet createEntitySet() {
+  protected Property createComplexProperty() {
+    List<Property> properties = new ArrayList<Property>();
+    Property property = new PropertyImpl();
+    property.setName("PropertyString");
+    property.setValue(ValueType.PRIMITIVE, "dummyValue");
+    properties.add(property);
+    Property propertyInt = new PropertyImpl();
+    propertyInt.setName("PropertyInt16");
+    propertyInt.setValue(ValueType.PRIMITIVE, 42);
+    properties.add(propertyInt);
+    Property propertyGuid = new PropertyImpl();
+    propertyGuid.setName("PropertyGuid");
+    propertyGuid.setValue(ValueType.PRIMITIVE, UUID.randomUUID());
+    properties.add(propertyGuid);
+
+    return new PropertyImpl("com.sap.odata.test1.ETCompAllPrim", "PropertyComplex", ValueType.COMPLEX,
+            properties);
+  }
+
+
+  protected EntitySet createEntitySet(EdmEntityType edmEntityType) {
       EntitySet entitySet = new EntitySetImpl();
       entitySet.setCount(4242);
       entitySet.setNext(URI.create("nextLinkURI"));
       for (int i = 0; i < 1000; i++) {
-        entitySet.getEntities().add(createEntity());
+        entitySet.getEntities().add(createEntity(edmEntityType));
       }
       return entitySet;
     }


[6/6] git commit: [OLINGO-317] Merge with current master

Posted by mi...@apache.org.
[OLINGO-317] Merge with current 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/95e2d8d3
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/95e2d8d3
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/95e2d8d3

Branch: refs/heads/master
Commit: 95e2d8d33911872b606bd1da12c0fcf8271b6bb2
Parents: 66f26e5 098ed14
Author: Michael Bolz <mi...@sap.com>
Authored: Mon Jul 7 07:42:22 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Mon Jul 7 07:42:22 2014 +0200

----------------------------------------------------------------------
 .../apache/olingo/fit/tecsvc/BasicITCase.java   | 14 ++++++--
 .../retrieve/AbstractODataRetrieveRequest.java  |  6 +---
 .../retrieve/EdmMetadataRequestImpl.java        | 10 ++++++
 .../retrieve/v4/XMLMetadataRequestImpl.java     | 24 ++++++++------
 .../olingo/client/core/edm/EdmEnumTypeImpl.java |  9 +++---
 lib/server-tecsvc/pom.xml                       | 34 ++++++++++++++++++++
 6 files changed, 76 insertions(+), 21 deletions(-)
----------------------------------------------------------------------