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

[8/8] olingo-odata4 git commit: [OLINGO-431] Delete unnecessary v4 in package name

[OLINGO-431] Delete unnecessary v4 in package name


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

Branch: refs/heads/master
Commit: 752bfad367a905ad1284cf3116802dfae0937152
Parents: 1f9a28d
Author: Christian Amend <ch...@sap.com>
Authored: Fri Aug 21 14:03:20 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Fri Aug 21 14:03:20 2015 +0200

----------------------------------------------------------------------
 .../org/apache/olingo/client/core/AtomTest.java |  81 ++++
 .../olingo/client/core/EntitySetTest.java       |  96 ++++
 .../apache/olingo/client/core/EntityTest.java   | 390 +++++++++++++++
 .../apache/olingo/client/core/ErrorTest.java    |  61 +++
 .../org/apache/olingo/client/core/JSONTest.java | 257 ++++++++++
 .../apache/olingo/client/core/MetadataTest.java | 412 ++++++++++++++++
 .../olingo/client/core/PrimitiveValueTest.java  |  73 +++
 .../apache/olingo/client/core/PropertyTest.java | 138 ++++++
 .../olingo/client/core/ServiceDocumentTest.java |  74 +++
 .../client/core/uri/FilterFactoryTest.java      | 101 ++++
 .../olingo/client/core/uri/URIBuilderTest.java  | 244 ++++++++++
 .../client/core/uri/v4/FilterFactoryTest.java   | 101 ----
 .../client/core/uri/v4/URIBuilderTest.java      | 244 ----------
 .../apache/olingo/client/core/v4/AtomTest.java  |  82 ----
 .../olingo/client/core/v4/EntitySetTest.java    |  97 ----
 .../olingo/client/core/v4/EntityTest.java       | 391 ---------------
 .../apache/olingo/client/core/v4/ErrorTest.java |  62 ---
 .../apache/olingo/client/core/v4/JSONTest.java  | 258 ----------
 .../olingo/client/core/v4/MetadataTest.java     | 413 ----------------
 .../client/core/v4/PrimitiveValueTest.java      |  74 ---
 .../olingo/client/core/v4/PropertyTest.java     | 139 ------
 .../client/core/v4/ServiceDocumentTest.java     |  75 ---
 ...ccounts_101_expand_MyPaymentInstruments.json |  94 ++++
 ...Accounts_101_expand_MyPaymentInstruments.xml | 129 +++++
 ...ts_f89dee73-af9f-4cd4-b330-db93c25ff3c7.json |  16 +
 ...nts_f89dee73-af9f-4cd4-b330-db93c25ff3c7.xml |  46 ++
 .../org/apache/olingo/client/core/Customer.json |  37 ++
 .../org/apache/olingo/client/core/Customer.xml  |  46 ++
 .../apache/olingo/client/core/Customers.json    |  57 +++
 .../org/apache/olingo/client/core/Customers.xml | 111 +++++
 .../client/core/Employees_3_HomeAddress.json    |   6 +
 .../client/core/Employees_3_HomeAddress.xml     |  31 ++
 .../client/core/Metadata-With-Capabilities.xml  | 323 +++++++++++++
 .../olingo/client/core/PersonDetails_1.json     |  22 +
 .../olingo/client/core/PersonDetails_1.xml      |  55 +++
 .../apache/olingo/client/core/Products_5.json   |  29 ++
 .../apache/olingo/client/core/Products_5.xml    |  49 ++
 .../client/core/Products_5_CoverColors.json     |   5 +
 .../client/core/Products_5_CoverColors.xml      |  30 ++
 .../client/core/Products_5_SkinColor.json       |   5 +
 .../olingo/client/core/Products_5_SkinColor.xml |  27 ++
 .../apache/olingo/client/core/VipCustomer.json  |  50 ++
 .../apache/olingo/client/core/VipCustomer.xml   |  73 +++
 .../apache/olingo/client/core/annotated.json    |  62 +++
 .../org/apache/olingo/client/core/annotated.xml |  78 +++
 .../apache/olingo/client/core/atom_cleanup.xsl  |  49 ++
 .../core/collectionOfEntityReferences.json      |  11 +
 .../core/collectionOfEntityReferences.xml       |  25 +
 .../apache/olingo/client/core/crossjoin.json    |  18 +
 .../org/apache/olingo/client/core/delta.json    |  39 ++
 .../org/apache/olingo/client/core/delta.xml     |  87 ++++
 .../apache/olingo/client/core/demo-metadata.xml | 163 +++++++
 .../client/core/entity.collection.complex.json  |  14 +
 .../core/entity.collection.primitive.json       |   7 +
 .../olingo/client/core/entity.complex.json      |  12 +
 .../olingo/client/core/entity.minimal.json      |  15 +
 .../olingo/client/core/entity.primitive.json    |  22 +
 .../core/entity.withcomplexnavigation.json      |  22 +
 .../core/entity.withcomplexnavigation.xml       |  63 +++
 .../olingo/client/core/entityReference.json     |   4 +
 .../olingo/client/core/entityReference.xml      |  22 +
 .../org/apache/olingo/client/core/error.json    |  14 +
 .../org/apache/olingo/client/core/error.xml     |  31 ++
 .../olingo/client/core/fromdoc1-metadata.xml    | 126 +++++
 .../olingo/client/core/fromdoc2-metadata.xml    |  54 +++
 .../olingo/client/core/fromdoc3-metadata.xml    | 131 ++++++
 .../olingo/client/core/fromdoc4-metadata.xml    | 164 +++++++
 .../org/apache/olingo/client/core/metadata.xml  | 232 +++++++++
 .../olingo/client/core/minimalEntity.json       |  21 +
 .../olingo/client/core/northwind-metadata.xml   | 471 +++++++++++++++++++
 .../apache/olingo/client/core/olingo390.json    |  18 +
 .../olingo/client/core/serviceDocument.json     |  30 ++
 .../olingo/client/core/serviceDocument.xml      |  46 ++
 .../client/core/staticservice-metadata.xml      | 462 ++++++++++++++++++
 ...ccounts_101_expand_MyPaymentInstruments.json |  94 ----
 ...Accounts_101_expand_MyPaymentInstruments.xml | 129 -----
 ...ts_f89dee73-af9f-4cd4-b330-db93c25ff3c7.json |  16 -
 ...nts_f89dee73-af9f-4cd4-b330-db93c25ff3c7.xml |  46 --
 .../apache/olingo/client/core/v4/Customer.json  |  37 --
 .../apache/olingo/client/core/v4/Customer.xml   |  46 --
 .../apache/olingo/client/core/v4/Customers.json |  57 ---
 .../apache/olingo/client/core/v4/Customers.xml  | 111 -----
 .../client/core/v4/Employees_3_HomeAddress.json |   6 -
 .../client/core/v4/Employees_3_HomeAddress.xml  |  31 --
 .../core/v4/Metadata-With-Capabilities.xml      | 323 -------------
 .../olingo/client/core/v4/PersonDetails_1.json  |  22 -
 .../olingo/client/core/v4/PersonDetails_1.xml   |  55 ---
 .../olingo/client/core/v4/Products_5.json       |  29 --
 .../apache/olingo/client/core/v4/Products_5.xml |  49 --
 .../client/core/v4/Products_5_CoverColors.json  |   5 -
 .../client/core/v4/Products_5_CoverColors.xml   |  30 --
 .../client/core/v4/Products_5_SkinColor.json    |   5 -
 .../client/core/v4/Products_5_SkinColor.xml     |  27 --
 .../olingo/client/core/v4/VipCustomer.json      |  50 --
 .../olingo/client/core/v4/VipCustomer.xml       |  73 ---
 .../apache/olingo/client/core/v4/annotated.json |  62 ---
 .../apache/olingo/client/core/v4/annotated.xml  |  78 ---
 .../olingo/client/core/v4/atom_cleanup.xsl      |  49 --
 .../core/v4/collectionOfEntityReferences.json   |  11 -
 .../core/v4/collectionOfEntityReferences.xml    |  25 -
 .../apache/olingo/client/core/v4/crossjoin.json |  18 -
 .../org/apache/olingo/client/core/v4/delta.json |  39 --
 .../org/apache/olingo/client/core/v4/delta.xml  |  87 ----
 .../olingo/client/core/v4/demo-metadata.xml     | 163 -------
 .../core/v4/entity.collection.complex.json      |  14 -
 .../core/v4/entity.collection.primitive.json    |   7 -
 .../olingo/client/core/v4/entity.complex.json   |  12 -
 .../olingo/client/core/v4/entity.minimal.json   |  15 -
 .../olingo/client/core/v4/entity.primitive.json |  22 -
 .../core/v4/entity.withcomplexnavigation.json   |  22 -
 .../core/v4/entity.withcomplexnavigation.xml    |  63 ---
 .../olingo/client/core/v4/entityReference.json  |   4 -
 .../olingo/client/core/v4/entityReference.xml   |  22 -
 .../org/apache/olingo/client/core/v4/error.json |  14 -
 .../org/apache/olingo/client/core/v4/error.xml  |  31 --
 .../olingo/client/core/v4/fromdoc1-metadata.xml | 126 -----
 .../olingo/client/core/v4/fromdoc2-metadata.xml |  54 ---
 .../olingo/client/core/v4/fromdoc3-metadata.xml | 131 ------
 .../olingo/client/core/v4/fromdoc4-metadata.xml | 164 -------
 .../apache/olingo/client/core/v4/metadata.xml   | 232 ---------
 .../olingo/client/core/v4/minimalEntity.json    |  21 -
 .../client/core/v4/northwind-metadata.xml       | 471 -------------------
 .../apache/olingo/client/core/v4/olingo390.json |  18 -
 .../olingo/client/core/v4/serviceDocument.json  |  30 --
 .../olingo/client/core/v4/serviceDocument.xml   |  46 --
 .../client/core/v4/staticservice-metadata.xml   | 462 ------------------
 126 files changed, 5681 insertions(+), 5690 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/752bfad3/lib/client-core/src/test/java/org/apache/olingo/client/core/AtomTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/AtomTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/AtomTest.java
new file mode 100644
index 0000000..9d5346b
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/AtomTest.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.StringWriter;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.custommonkey.xmlunit.Diff;
+
+public class AtomTest extends JSONTest {
+
+  @Override
+  protected ODataClient getClient() {
+    return v4Client;
+  }
+
+  @Override
+  protected ContentType getODataPubFormat() {
+    return ContentType.APPLICATION_ATOM_XML;
+  }
+
+  @Override
+  protected ContentType getODataFormat() {
+    return ContentType.APPLICATION_XML;
+  }
+
+  private String cleanup(final String input) throws Exception {
+    final TransformerFactory factory = TransformerFactory.newInstance();
+    final Source xslt = new StreamSource(getClass().getResourceAsStream("atom_cleanup.xsl"));
+    final Transformer transformer = factory.newTransformer(xslt);
+
+    final StringWriter result = new StringWriter();
+    transformer.transform(new StreamSource(new ByteArrayInputStream(input.getBytes())), new StreamResult(result));
+    return result.toString();
+  }
+
+  @Override
+  protected void assertSimilar(final String filename, final String actual) throws Exception {
+    final Diff diff = new Diff(cleanup(IOUtils.toString(getClass().getResourceAsStream(filename))), actual);
+    diff.overrideElementQualifier(new AtomLinksQualifier());
+    assertTrue(diff.similar());
+  }
+
+  @Override
+  public void additionalEntities() throws Exception {
+    // no test
+  }
+
+  @Override
+  public void issueOLINGO390() throws Exception {
+    // no test
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/752bfad3/lib/client-core/src/test/java/org/apache/olingo/client/core/EntitySetTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/EntitySetTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/EntitySetTest.java
new file mode 100644
index 0000000..70f92cb
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/EntitySetTest.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.domain.ClientEntity;
+import org.apache.olingo.client.api.domain.ClientEntitySet;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
+import org.junit.Test;
+
+public class EntitySetTest extends AbstractTest {
+
+  @Override
+  protected ODataClient getClient() {
+    return v4Client;
+  }
+
+  private void read(final ContentType contentType) throws IOException, ODataDeserializerException {
+    final InputStream input = getClass().getResourceAsStream("Customers." + getSuffix(contentType));
+    final ClientEntitySet entitySet = getClient().getBinder().getODataEntitySet(
+        getClient().getDeserializer(contentType).toEntitySet(input));
+    assertNotNull(entitySet);
+
+    assertEquals(2, entitySet.getEntities().size());
+    assertNull(entitySet.getNext());
+
+    final ClientEntitySet written =
+        getClient().getBinder().getODataEntitySet(new ResWrap<EntityCollection>((URI) null, null,
+            getClient().getBinder().getEntitySet(entitySet)));
+    assertEquals(entitySet, written);
+  }
+
+  @Test
+  public void fromAtom() throws Exception {
+    read(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void fromJSON() throws Exception {
+    read(ContentType.JSON);
+  }
+
+  private void ref(final ContentType contentType) throws ODataDeserializerException {
+    final InputStream input = getClass().getResourceAsStream("collectionOfEntityReferences." + getSuffix(contentType));
+    final ClientEntitySet entitySet = getClient().getBinder().getODataEntitySet(
+        getClient().getDeserializer(contentType).toEntitySet(input));
+    assertNotNull(entitySet);
+
+    for (ClientEntity entity : entitySet.getEntities()) {
+      assertNotNull(entity.getId());
+    }
+    entitySet.setCount(entitySet.getEntities().size());
+
+    final ClientEntitySet written =
+        getClient().getBinder().getODataEntitySet(new ResWrap<EntityCollection>((URI) null, null,
+            getClient().getBinder().getEntitySet(entitySet)));
+    assertEquals(entitySet, written);
+  }
+
+  @Test
+  public void atomRef() throws Exception {
+    ref(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void jsonRef() throws Exception {
+    ref(ContentType.JSON);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/752bfad3/lib/client-core/src/test/java/org/apache/olingo/client/core/EntityTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/EntityTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/EntityTest.java
new file mode 100644
index 0000000..77a9c39
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/EntityTest.java
@@ -0,0 +1,390 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.util.Iterator;
+
+import org.apache.olingo.client.api.EdmEnabledODataClient;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.domain.ClientAnnotation;
+import org.apache.olingo.client.api.domain.ClientComplexValue;
+import org.apache.olingo.client.api.domain.ClientEntity;
+import org.apache.olingo.client.api.domain.ClientInlineEntitySet;
+import org.apache.olingo.client.api.domain.ClientLink;
+import org.apache.olingo.client.api.domain.ClientLinkType;
+import org.apache.olingo.client.api.domain.ClientProperty;
+import org.apache.olingo.client.api.domain.ClientValuable;
+import org.apache.olingo.client.api.domain.ClientValue;
+import org.apache.olingo.client.core.EdmEnabledODataClientImpl;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmDateTimeOffset;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmDuration;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class EntityTest extends AbstractTest {
+
+  @Override
+  protected ODataClient getClient() {
+    return v4Client;
+  }
+
+  private EdmEnabledODataClient getEdmEnabledClient() {
+    return new EdmEnabledODataClientImpl(null, null, null) {
+
+      private Edm edm;
+
+      @Override
+      public Edm getEdm(final String metadataETag) {
+        return getCachedEdm();
+      }
+
+      @Override
+      public Edm getCachedEdm() {
+        if (edm == null) {
+          edm = getReader().readMetadata(getClass().getResourceAsStream("staticservice-metadata.xml"));
+        }
+        return edm;
+      }
+
+    };
+  }
+
+  private void singleton(final ContentType contentType) throws Exception {
+    final InputStream input = getClass().getResourceAsStream("VipCustomer." + getSuffix(contentType));
+    final ClientEntity entity = getClient().getBinder().getODataEntity(
+        getClient().getDeserializer(contentType).toEntity(input));
+    assertNotNull(entity);
+
+    assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
+
+    final ClientProperty birthday = entity.getProperty("Birthday");
+    assertTrue(birthday.hasPrimitiveValue());
+    assertEquals(EdmDateTimeOffset.getInstance(), birthday.getPrimitiveValue().getType());
+
+    final ClientProperty timeBetweenLastTwoOrders = entity.getProperty("TimeBetweenLastTwoOrders");
+    assertTrue(timeBetweenLastTwoOrders.hasPrimitiveValue());
+    assertEquals(EdmDuration.getInstance(), timeBetweenLastTwoOrders.getPrimitiveValue().getType());
+
+    int checked = 0;
+    for (ClientLink link : entity.getNavigationLinks()) {
+      if ("Parent".equals(link.getName())) {
+        checked++;
+        assertEquals(ClientLinkType.ENTITY_NAVIGATION, link.getType());
+      }
+      if ("Orders".equals(link.getName())) {
+        checked++;
+        if (contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC)
+            || contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)) {
+          assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, link.getType());
+        }
+      }
+      if ("Company".equals(link.getName())) {
+        checked++;
+        assertEquals(ClientLinkType.ENTITY_NAVIGATION, link.getType());
+      }
+    }
+    assertEquals(3, checked);
+
+    assertEquals(2, entity.getOperations().size());
+    assertEquals("#Microsoft.Test.OData.Services.ODataWCFService.ResetAddress",
+        entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.ResetAddress").getMetadataAnchor());
+    assertEquals("#Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress",
+        entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress").getMetadataAnchor());
+
+    // operations won't get serialized
+    entity.getOperations().clear();
+    final ClientEntity written = getClient().getBinder().getODataEntity(
+        new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
+    assertEquals(entity, written);
+    input.close();
+  }
+
+  @Test
+  public void atomSingleton() throws Exception {
+    singleton(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void jsonSingleton() throws Exception {
+    singleton(ContentType.JSON_FULL_METADATA);
+  }
+
+  private void withEnums(final ContentType contentType) throws Exception {
+    final InputStream input = getClass().getResourceAsStream("Products_5." + getSuffix(contentType));
+    final ClientEntity entity = getClient().getBinder().getODataEntity(
+        getClient().getDeserializer(contentType).toEntity(input));
+    assertNotNull(entity);
+
+    final ClientProperty skinColor = entity.getProperty("SkinColor");
+    assertTrue(skinColor.hasEnumValue());
+    assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Color", skinColor.getEnumValue().getTypeName());
+    assertEquals("Red", skinColor.getEnumValue().getValue());
+
+    final ClientProperty coverColors = entity.getProperty("CoverColors");
+    assertTrue(coverColors.hasCollectionValue());
+    for (final Iterator<ClientValue> itor = coverColors.getCollectionValue().iterator(); itor.hasNext();) {
+      final ClientValue item = itor.next();
+      assertTrue(item.isEnum());
+    }
+
+    // operations won't get serialized
+    entity.getOperations().clear();
+    final ClientEntity written = getClient().getBinder().getODataEntity(
+        new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
+    assertEquals(entity, written);
+    input.close();
+  }
+
+  @Test
+  public void atomWithEnums() throws Exception {
+    withEnums(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void jsonWithEnums() throws Exception {
+    withEnums(ContentType.JSON_FULL_METADATA);
+  }
+
+  private void withInlineEntitySet(final ContentType contentType) throws Exception {
+    final InputStream input = getClass().getResourceAsStream(
+        "Accounts_101_expand_MyPaymentInstruments." + getSuffix(contentType));
+    final ClientEntity entity = getClient().getBinder().getODataEntity(
+        getClient().getDeserializer(contentType).toEntity(input));
+    assertNotNull(entity);
+
+    final ClientLink instruments = entity.getNavigationLink("MyPaymentInstruments");
+    assertNotNull(instruments);
+    assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, instruments.getType());
+
+    final ClientInlineEntitySet inline = instruments.asInlineEntitySet();
+    assertNotNull(inline);
+    assertEquals(3, inline.getEntitySet().getEntities().size());
+
+    // count shouldn't be serialized
+    inline.getEntitySet().setCount(3);
+    // operations won't get serialized
+    entity.getOperations().clear();
+    final ClientEntity written = getClient().getBinder().getODataEntity(
+        new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
+    assertEquals(entity, written);
+    input.close();
+  }
+
+  @Test
+  public void atomWithInlineEntitySet() throws Exception {
+    withInlineEntitySet(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void jsonWithInlineEntitySet() throws Exception {
+    withInlineEntitySet(ContentType.JSON_FULL_METADATA);
+  }
+
+  private void mediaEntity(final ContentType contentType) throws Exception {
+    final InputStream input = getClass().getResourceAsStream(
+        "Advertisements_f89dee73-af9f-4cd4-b330-db93c25ff3c7." + getSuffix(contentType));
+    final ClientEntity entity = getClient().getBinder().getODataEntity(
+        getClient().getDeserializer(contentType).toEntity(input));
+    assertNotNull(entity);
+
+    assertTrue(entity.isMediaEntity());
+    assertNotNull(entity.getMediaContentSource());
+    assertEquals("\"8zOOKKvgOtptr4gt8IrnapX3jds=\"", entity.getMediaETag());
+
+    final ClientEntity written = getClient().getBinder().getODataEntity(
+        new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
+    assertEquals(entity, written);
+    input.close();
+  }
+
+  @Test
+  public void atomMediaEntity() throws Exception {
+    mediaEntity(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void jsonMediaEntity() throws Exception {
+    mediaEntity(ContentType.JSON_FULL_METADATA);
+  }
+
+  private void withStream(final ContentType contentType) throws Exception {
+    final InputStream input = getClass().getResourceAsStream("PersonDetails_1." + getSuffix(contentType));
+    final ClientEntity entity = getClient().getBinder().getODataEntity(
+        getClient().getDeserializer(contentType).toEntity(input));
+    assertNotNull(entity);
+
+    assertFalse(entity.isMediaEntity());
+
+    final ClientLink editMedia = entity.getMediaEditLink("Photo");
+    assertNotNull(editMedia);
+
+    final ClientEntity written = getClient().getBinder().getODataEntity(
+        new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
+    assertEquals(entity, written);
+    input.close();
+  }
+
+  @Test
+  public void atomWithStream() throws Exception {
+    withStream(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void jsonWithStream() throws Exception {
+    withStream(ContentType.JSON_FULL_METADATA);
+  }
+
+  private void ref(final ContentType contentType) throws Exception {
+    final InputStream input = getClass().getResourceAsStream("entityReference." + getSuffix(contentType));
+    final ClientEntity entity = getClient().getBinder().getODataEntity(
+        getClient().getDeserializer(contentType).toEntity(input));
+    assertNotNull(entity);
+
+    assertNotNull(entity.getId());
+
+    final ClientEntity written = getClient().getBinder().getODataEntity(
+        new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
+    assertEquals(entity, written);
+    input.close();
+  }
+
+  @Test
+  public void atomRef() throws Exception {
+    ref(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void jsonRef() throws Exception {
+    ref(ContentType.JSON);
+  }
+
+  private void complexNavigationProperties(final ContentType contentType) throws Exception {
+    final InputStream input = getClass().getResourceAsStream("entity.withcomplexnavigation." + getSuffix(contentType));
+    final ClientEntity entity = getClient().getBinder().getODataEntity(
+        getClient().getDeserializer(contentType).toEntity(input));
+    assertNotNull(entity);
+
+    final ClientComplexValue addressValue = entity.getProperty("Address").getComplexValue();
+    assertNotNull(addressValue);
+    assertNotNull(addressValue.getNavigationLink("Country"));
+
+    // ETag is not serialized
+    entity.setETag(null);
+    final ClientEntity written = getClient().getBinder().getODataEntity(
+        new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
+    assertEquals(entity, written);
+    input.close();
+  }
+
+  @Test
+  public void atomComplexNavigationProperties() throws Exception {
+    complexNavigationProperties(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void jsonComplexNavigationProperties() throws Exception {
+    complexNavigationProperties(ContentType.JSON);
+  }
+
+  private void annotated(final ContentType contentType) throws EdmPrimitiveTypeException, Exception {
+    final InputStream input = getClass().getResourceAsStream("annotated." + getSuffix(contentType));
+    final ClientEntity entity = getClient().getBinder().getODataEntity(
+        getClient().getDeserializer(contentType).toEntity(input));
+    assertNotNull(entity);
+
+    assertFalse(entity.getAnnotations().isEmpty());
+
+    ClientAnnotation annotation = entity.getAnnotations().get(0);
+    assertEquals("com.contoso.display.highlight", annotation.getTerm());
+    assertEquals(true, annotation.getPrimitiveValue().toCastValue(Boolean.class));
+
+    annotation = entity.getAnnotations().get(1);
+    assertEquals("com.contoso.PersonalInfo.PhoneNumbers", annotation.getTerm());
+    assertTrue(annotation.hasCollectionValue());
+
+    annotation = entity.getProperty("LastName").getAnnotations().get(0);
+    assertEquals("com.contoso.display.style", annotation.getTerm());
+    assertTrue(annotation.hasComplexValue());
+
+    final ClientLink orders = entity.getNavigationLink("Orders");
+    assertFalse(orders.getAnnotations().isEmpty());
+
+    annotation = orders.getAnnotations().get(0);
+    assertEquals("com.contoso.display.style", annotation.getTerm());
+    assertEquals("com.contoso.display.styleType", annotation.getValue().getTypeName());
+    assertTrue(annotation.hasComplexValue());
+    assertEquals(2,
+        annotation.getValue().asComplex().get("order").getPrimitiveValue().toCastValue(Integer.class), 0);
+
+    final ClientEntity written = getClient().getBinder().getODataEntity(
+        new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
+    assertEquals(entity, written);
+    input.close();
+  }
+
+  @Test
+  @Ignore
+  public void atomAnnotated() throws Exception {
+    annotated(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  @Ignore
+  public void jsonAnnotated() throws Exception {
+    annotated(ContentType.JSON);
+  }
+
+  private void derived(final ODataClient client, final ContentType contentType) throws Exception {
+    final InputStream input = getClass().getResourceAsStream("Customer." + getSuffix(contentType));
+    final ClientEntity entity = client.getBinder().getODataEntity(client.getDeserializer(contentType).toEntity(input));
+    assertNotNull(entity);
+
+    assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
+    assertEquals("Microsoft.Test.OData.Services.ODataWCFService.CompanyAddress",
+        ((ClientValuable) entity.getProperty("HomeAddress")).getValue().getTypeName());
+    input.close();
+  }
+
+  @Test
+  public void derivedFromAtom() throws Exception {
+    derived(getClient(), ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void derivedFromJSON() throws Exception {
+    derived(getEdmEnabledClient(), ContentType.JSON);
+  }
+
+  @Test
+  public void derivedFromFullJSON() throws Exception {
+    derived(getClient(), ContentType.JSON_FULL_METADATA);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/752bfad3/lib/client-core/src/test/java/org/apache/olingo/client/core/ErrorTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/ErrorTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/ErrorTest.java
new file mode 100644
index 0000000..8ced6a3
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/ErrorTest.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.api.ex.ODataError;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.junit.Test;
+
+public class ErrorTest extends AbstractTest {
+
+  @Override
+  protected ODataClient getClient() {
+    return v4Client;
+  }
+
+  private ODataError error(final String name, final ContentType contentType) throws ODataDeserializerException {
+    final ODataError error = getClient().getDeserializer(contentType).toError(
+            getClass().getResourceAsStream(name + "." + getSuffix(contentType)));
+    assertNotNull(error);
+    return error;
+  }
+
+  private void simple(final ContentType contentType) throws ODataDeserializerException {
+    final ODataError error = error("error", contentType);
+    assertEquals("501", error.getCode());
+    assertEquals("Unsupported functionality", error.getMessage());
+    assertEquals("query", error.getTarget());
+  }
+
+  @Test
+  public void jsonSimple() throws Exception {
+    simple(ContentType.JSON);
+  }
+
+  @Test
+  public void atomSimple() throws Exception {
+    simple(ContentType.APPLICATION_ATOM_XML);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/752bfad3/lib/client-core/src/test/java/org/apache/olingo/client/core/JSONTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/JSONTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/JSONTest.java
new file mode 100644
index 0000000..11a99ed
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/JSONTest.java
@@ -0,0 +1,257 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.domain.ClientCollectionValue;
+import org.apache.olingo.client.api.domain.ClientComplexValue;
+import org.apache.olingo.client.api.domain.ClientEntity;
+import org.apache.olingo.client.api.domain.ClientValue;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.Delta;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.junit.Test;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+public class JSONTest extends AbstractTest {
+
+  private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+  @Override
+  protected ODataClient getClient() {
+    return v4Client;
+  }
+
+  protected ContentType getODataPubFormat() {
+    return ContentType.JSON;
+  }
+
+  protected ContentType getODataFormat() {
+    return ContentType.JSON;
+  }
+
+  private void cleanup(final ObjectNode node) {
+    if (node.has(Constants.JSON_CONTEXT)) {
+      node.remove(Constants.JSON_CONTEXT);
+    }
+    if (node.has(Constants.JSON_ETAG)) {
+      node.remove(Constants.JSON_ETAG);
+    }
+    if (node.has(Constants.JSON_TYPE)) {
+      node.remove(Constants.JSON_TYPE);
+    }
+    if (node.has(Constants.JSON_EDIT_LINK)) {
+      node.remove(Constants.JSON_EDIT_LINK);
+    }
+    if (node.has(Constants.JSON_READ_LINK)) {
+      node.remove(Constants.JSON_READ_LINK);
+    }
+    if (node.has(Constants.JSON_MEDIA_EDIT_LINK)) {
+      node.remove(Constants.JSON_MEDIA_EDIT_LINK);
+    }
+    if (node.has(Constants.JSON_MEDIA_READ_LINK)) {
+      node.remove(Constants.JSON_MEDIA_READ_LINK);
+    }
+    if (node.has(Constants.JSON_MEDIA_CONTENT_TYPE)) {
+      node.remove(Constants.JSON_MEDIA_CONTENT_TYPE);
+    }
+    if (node.has(Constants.JSON_COUNT)) {
+      node.remove(Constants.JSON_COUNT);
+    }
+    final List<String> toRemove = new ArrayList<String>();
+    for (final Iterator<Map.Entry<String, JsonNode>> itor = node.fields(); itor.hasNext();) {
+      final Map.Entry<String, JsonNode> field = itor.next();
+
+      final String key = field.getKey();
+      if (key.charAt(0) == '#'
+          || key.endsWith(Constants.JSON_TYPE)
+          || key.endsWith(Constants.JSON_MEDIA_EDIT_LINK)
+          || key.endsWith(Constants.JSON_MEDIA_CONTENT_TYPE)
+          || key.endsWith(Constants.JSON_ASSOCIATION_LINK)
+          || key.endsWith(Constants.JSON_MEDIA_ETAG)) {
+
+        toRemove.add(key);
+      } else if (field.getValue().isObject()) {
+        cleanup((ObjectNode) field.getValue());
+      } else if (field.getValue().isArray()) {
+        for (final Iterator<JsonNode> arrayItems = field.getValue().elements(); arrayItems.hasNext();) {
+          final JsonNode arrayItem = arrayItems.next();
+          if (arrayItem.isObject()) {
+            cleanup((ObjectNode) arrayItem);
+          }
+        }
+      }
+    }
+    node.remove(toRemove);
+  }
+
+  protected void assertSimilar(final String filename, final String actual) throws Exception {
+    final JsonNode expected = OBJECT_MAPPER.readTree(IOUtils.toString(getClass().getResourceAsStream(filename)).
+        replace(Constants.JSON_NAVIGATION_LINK, Constants.JSON_BIND_LINK_SUFFIX));
+    cleanup((ObjectNode) expected);
+    final ObjectNode actualNode = (ObjectNode) OBJECT_MAPPER.readTree(new ByteArrayInputStream(actual.getBytes()));
+    cleanup(actualNode);
+    assertEquals(expected, actualNode);
+  }
+
+  protected void entitySet(final String filename, final ContentType contentType) throws Exception {
+    final StringWriter writer = new StringWriter();
+    getClient().getSerializer(contentType).write(writer, getClient().getDeserializer(contentType).toEntitySet(
+        getClass().getResourceAsStream(filename + "." + getSuffix(contentType))).getPayload());
+
+    assertSimilar(filename + "." + getSuffix(contentType), writer.toString());
+  }
+
+  @Test
+  public void entitySets() throws Exception {
+    entitySet("Customers", getODataPubFormat());
+    entitySet("collectionOfEntityReferences", getODataPubFormat());
+  }
+
+  protected void entity(final String filename, final ContentType contentType) throws Exception {
+    final StringWriter writer = new StringWriter();
+    getClient().getSerializer(contentType).write(writer, getClient().getDeserializer(contentType).toEntity(
+        getClass().getResourceAsStream(filename + "." + getSuffix(contentType))).getPayload());
+    System.out.println(writer.toString());
+    assertSimilar(filename + "." + getSuffix(contentType), writer.toString());
+  }
+
+  @Test
+  public void additionalEntities() throws Exception {
+    entity("entity.minimal", getODataPubFormat());
+    entity("entity.primitive", getODataPubFormat());
+    entity("entity.complex", getODataPubFormat());
+    entity("entity.collection.primitive", getODataPubFormat());
+    entity("entity.collection.complex", getODataPubFormat());
+  }
+
+  @Test
+  public void entities() throws Exception {
+    entity("Products_5", getODataPubFormat());
+    entity("VipCustomer", getODataPubFormat());
+    entity("Advertisements_f89dee73-af9f-4cd4-b330-db93c25ff3c7", getODataPubFormat());
+    entity("entityReference", getODataPubFormat());
+    entity("entity.withcomplexnavigation", getODataPubFormat());
+    entity("annotated", getODataPubFormat());
+  }
+
+  protected void property(final String filename, final ContentType contentType) throws Exception {
+    final StringWriter writer = new StringWriter();
+    getClient().getSerializer(contentType).write(writer, getClient().getDeserializer(contentType).
+        toProperty(getClass().getResourceAsStream(filename + "." + getSuffix(contentType))).getPayload());
+
+    assertSimilar(filename + "." + getSuffix(contentType), writer.toString());
+  }
+
+  @Test
+  public void properties() throws Exception {
+    property("Products_5_SkinColor", getODataFormat());
+    property("Products_5_CoverColors", getODataFormat());
+    property("Employees_3_HomeAddress", getODataFormat());
+    property("Employees_3_HomeAddress", getODataFormat());
+  }
+
+  @Test
+  public void crossjoin() throws Exception {
+    assertNotNull(getClient().getDeserializer(ContentType.JSON_FULL_METADATA).toEntitySet(
+        getClass().getResourceAsStream("crossjoin.json")));
+  }
+
+  protected void delta(final String filename, final ContentType contentType) throws Exception {
+    final Delta delta = getClient().getDeserializer(contentType).toDelta(
+        getClass().getResourceAsStream(filename + "." + getSuffix(contentType))).getPayload();
+    assertNotNull(delta);
+    assertNotNull(delta.getDeltaLink());
+    assertEquals(5, delta.getCount(), 0);
+
+    assertEquals(1, delta.getDeletedEntities().size());
+    assertTrue(delta.getDeletedEntities().get(0).getId().toASCIIString().endsWith("Customers('ANTON')"));
+
+    assertEquals(1, delta.getAddedLinks().size());
+    assertTrue(delta.getAddedLinks().get(0).getSource().toASCIIString().endsWith("Customers('BOTTM')"));
+    assertEquals("Orders", delta.getAddedLinks().get(0).getRelationship());
+
+    assertEquals(1, delta.getDeletedLinks().size());
+    assertTrue(delta.getDeletedLinks().get(0).getSource().toASCIIString().endsWith("Customers('ALFKI')"));
+    assertEquals("Orders", delta.getDeletedLinks().get(0).getRelationship());
+
+    assertEquals(2, delta.getEntities().size());
+    Property property = delta.getEntities().get(0).getProperty("ContactName");
+    assertNotNull(property);
+    assertTrue(property.isPrimitive());
+    property = delta.getEntities().get(1).getProperty("ShippingAddress");
+    assertNotNull(property);
+    assertTrue(property.isComplex());
+  }
+
+  @Test
+  public void deltas() throws Exception {
+    delta("delta", getODataPubFormat());
+  }
+
+  @Test
+  public void issueOLINGO390() throws Exception {
+    final ClientEntity message = getClient().getObjectFactory().
+        newEntity(new FullQualifiedName("Microsoft.Exchange.Services.OData.Model.Message"));
+
+    final ClientComplexValue toRecipient = getClient().getObjectFactory().
+        newComplexValue("Microsoft.Exchange.Services.OData.Model.Recipient");
+    toRecipient.add(getClient().getObjectFactory().newPrimitiveProperty("Name",
+        getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("challen_olingo_client")));
+    toRecipient.add(getClient().getObjectFactory().newPrimitiveProperty("Address",
+        getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("challenh@microsoft.com")));
+    final ClientCollectionValue<ClientValue> toRecipients = getClient().getObjectFactory().
+        newCollectionValue("Microsoft.Exchange.Services.OData.Model.Recipient");
+    toRecipients.add(toRecipient);
+    message.getProperties().add(getClient().getObjectFactory().newCollectionProperty("ToRecipients", toRecipients));
+
+    final ClientComplexValue body =
+        getClient().getObjectFactory().newComplexValue("Microsoft.Exchange.Services.OData.Model.ItemBody");
+    body.add(getClient().getObjectFactory().newPrimitiveProperty("Content",
+        getClient().getObjectFactory().newPrimitiveValueBuilder().
+            buildString("this is a simple email body content")));
+    body.add(getClient().getObjectFactory().newEnumProperty("ContentType",
+        getClient().getObjectFactory().newEnumValue("Microsoft.Exchange.Services.OData.Model.BodyType", "text")));
+    message.getProperties().add(getClient().getObjectFactory().newComplexProperty("Body", body));
+
+    final String actual = IOUtils.toString(getClient().getWriter().writeEntity(message, ContentType.JSON));
+    final JsonNode expected =
+        OBJECT_MAPPER.readTree(IOUtils.toString(getClass().getResourceAsStream("olingo390.json")).
+            replace(Constants.JSON_NAVIGATION_LINK, Constants.JSON_BIND_LINK_SUFFIX));
+    final ObjectNode actualNode = (ObjectNode) OBJECT_MAPPER.readTree(new ByteArrayInputStream(actual.getBytes()));
+    assertEquals(expected, actualNode);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/752bfad3/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java
new file mode 100644
index 0000000..2ee68d7
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/MetadataTest.java
@@ -0,0 +1,412 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.InputStream;
+import java.util.List;
+
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.edm.xml.XMLMetadata;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmAction;
+import org.apache.olingo.commons.api.edm.EdmAnnotation;
+import org.apache.olingo.commons.api.edm.EdmAnnotations;
+import org.apache.olingo.commons.api.edm.EdmAnnotationsTarget;
+import org.apache.olingo.commons.api.edm.EdmComplexType;
+import org.apache.olingo.commons.api.edm.EdmEntityContainer;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.edm.EdmEnumType;
+import org.apache.olingo.commons.api.edm.EdmFunction;
+import org.apache.olingo.commons.api.edm.EdmFunctionImport;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.EdmSchema;
+import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.annotation.EdmUrlRef;
+import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
+import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation;
+import org.apache.olingo.commons.api.edm.provider.CsdlAnnotations;
+import org.apache.olingo.commons.api.edm.provider.CsdlComplexType;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityType;
+import org.apache.olingo.commons.api.edm.provider.CsdlFunction;
+import org.apache.olingo.commons.api.edm.provider.CsdlFunctionImport;
+import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
+import org.apache.olingo.commons.api.edm.provider.CsdlSingleton;
+import org.apache.olingo.commons.api.edm.provider.CsdlTerm;
+import org.apache.olingo.commons.api.edm.provider.annotation.Apply;
+import org.apache.olingo.commons.api.edm.provider.annotation.Collection;
+import org.apache.olingo.commons.api.edm.provider.annotation.ConstantAnnotationExpression;
+import org.apache.olingo.commons.api.edm.provider.annotation.Path;
+import org.apache.olingo.commons.api.edm.provider.annotation.TwoParamsOpDynamicAnnotationExpression;
+import org.apache.olingo.commons.api.edm.provider.annotation.UrlRef;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmDecimal;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmInt32;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
+import org.junit.Test;
+
+public class MetadataTest extends AbstractTest {
+
+  @Override
+  protected ODataClient getClient() {
+    return v4Client;
+  }
+
+  @Test
+  public void parse() {
+    final Edm edm = getClient().getReader().readMetadata(getClass().getResourceAsStream("metadata.xml"));
+    assertNotNull(edm);
+
+    // 1. Enum
+    final EdmEnumType responseEnumType = edm.getEnumType(
+        new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "ResponseType"));
+    assertNotNull(responseEnumType);
+    assertEquals(6, responseEnumType.getMemberNames().size());
+    assertEquals("3", responseEnumType.getMember("Accepted").getValue());
+    assertEquals(EdmTypeKind.ENUM, responseEnumType.getKind());
+
+    // 2. Complex
+    final EdmComplexType responseStatus = edm.getComplexType(
+        new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "ResponseStatus"));
+    assertNotNull(responseStatus);
+    assertTrue(responseStatus.getNavigationPropertyNames().isEmpty());
+    assertEquals("Recipient", responseStatus.getBaseType().getName());
+    assertEquals(EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.DateTimeOffset),
+        responseStatus.getProperty("Time").getType());
+
+    // 3. Entity
+    final EdmEntityType user = edm.getEntityType(
+        new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "User"));
+    assertNotNull(user);
+    assertFalse(user.getPropertyNames().isEmpty());
+    assertFalse(user.getNavigationPropertyNames().isEmpty());
+
+    final EdmEntityType entity = edm.getEntityType(
+        new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "Entity"));
+    assertEquals(entity, user.getBaseType());
+    assertFalse(entity.getPropertyNames().isEmpty());
+    assertTrue(entity.getNavigationPropertyNames().isEmpty());
+
+    final EdmEntityType folder = edm.getEntityType(
+        new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "Folder"));
+    assertEquals(folder, user.getNavigationProperty("Inbox").getType());
+
+    // 4. Action
+    final EdmAction move = edm.getBoundAction(
+        new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "Move"),
+        new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "Folder"),
+        false);
+    assertNotNull(move);
+    assertTrue(move.isBound());
+    assertEquals(2, move.getParameterNames().size());
+    assertEquals(EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.String),
+        move.getParameter("DestinationId").getType());
+
+    // 5. EntityContainer
+    final EdmEntityContainer container = edm.getEntityContainer(
+        new FullQualifiedName("Microsoft.Exchange.Services.OData.Model", "EntityContainer"));
+    assertNotNull(container);
+    final EdmEntitySet users = container.getEntitySet("Users");
+    assertNotNull(users);
+    assertEquals(edm.getEntityType(new FullQualifiedName(container.getNamespace(), "User")),
+        users.getEntityType());
+    assertEquals(container.getEntitySet("Folders"), users.getRelatedBindingTarget("Folders"));
+  }
+
+  @Test
+  public void demo() {
+    final XMLMetadata metadata = getClient().getDeserializer(ContentType.APPLICATION_XML).
+        toMetadata(getClass().getResourceAsStream("demo-metadata.xml"));
+    assertNotNull(metadata);
+
+    assertFalse(metadata.getSchema(0).getAnnotationGroups().isEmpty());
+    final CsdlAnnotations annots = metadata.getSchema(0).getAnnotationGroup("ODataDemo.DemoService/Suppliers");
+    assertNotNull(annots);
+    assertFalse(annots.getAnnotations().isEmpty());
+    assertEquals(ConstantAnnotationExpression.Type.String,
+        annots.getAnnotation("Org.OData.Publication.V1.PrivacyPolicyUrl").getExpression().asConstant().getType());
+    assertEquals("http://www.odata.org/",
+        annots.getAnnotation("Org.OData.Publication.V1.PrivacyPolicyUrl").getExpression().asConstant().getValue());
+
+    // Now let's test some edm:Annotations
+    final Edm edm = getClient().getReader().
+        readMetadata(getClass().getResourceAsStream("demo-metadata.xml"));
+    assertNotNull(edm);
+
+    final EdmSchema schema = edm.getSchema("ODataDemo");
+    assertNotNull(schema);
+    assertTrue(schema.getAnnotations().isEmpty());
+    assertFalse(schema.getAnnotationGroups().isEmpty());
+
+    final EdmAnnotations annotationGroup = schema.getAnnotationGroups().get(2);
+    assertNotNull(annotationGroup);
+    final EdmAnnotationsTarget annotationsTarget = annotationGroup.getTarget();
+    assertNotNull(annotationsTarget);
+    assertTrue(EdmAnnotationsTarget.TargetType.Property == annotationsTarget.getAnnotationsTargetType());
+    assertEquals(new FullQualifiedName("ODataDemo.Product"), annotationsTarget.getAnnotationsTargetFQN());
+    assertEquals("Name", annotationsTarget.getAnnotationsTargetPath());
+
+    final EdmAnnotation annotation = annotationGroup.getAnnotations().get(0);
+    assertNotNull(annotation);
+    assertTrue(annotation.getExpression().isConstant());
+    assertEquals("Edm.String", annotation.getExpression().asConstant().getValue().getType());
+
+    assertEquals(10, schema.getAnnotationGroups().get(3).getAnnotations().size());
+  }
+
+  @Test
+  public void multipleSchemas() {
+    final XMLMetadata metadata = getClient().getDeserializer(ContentType.APPLICATION_XML).
+        toMetadata(getClass().getResourceAsStream("northwind-metadata.xml"));
+    assertNotNull(metadata);
+
+    final CsdlSchema first = metadata.getSchema("NorthwindModel");
+    assertNotNull(first);
+
+    final CsdlSchema second = metadata.getSchema("ODataWebExperimental.Northwind.Model");
+    assertNotNull(second);
+
+    final CsdlEntityContainer entityContainer = second.getEntityContainer();
+    assertNotNull(entityContainer);
+    assertEquals("NorthwindEntities", entityContainer.getName());
+  }
+
+  /**
+   * Tests Example 85 from CSDL specification.
+   */
+  @Test
+  public void fromdoc1() {
+    final XMLMetadata metadata = getClient().getDeserializer(ContentType.APPLICATION_XML).
+        toMetadata(getClass().getResourceAsStream("fromdoc1-metadata.xml"));
+    assertNotNull(metadata);
+
+    assertFalse(metadata.getReferences().isEmpty());
+    assertEquals("Org.OData.Measures.V1", metadata.getReferences().get(1).getIncludes().get(0).getNamespace());
+
+    final CsdlEntityType product = metadata.getSchema(0).getEntityType("Product");
+    assertTrue(product.hasStream());
+    assertEquals("UoM.ISOCurrency", product.getProperty("Price").getAnnotations().get(0).getTerm());
+    assertEquals("Products", product.getNavigationProperty("Supplier").getPartner());
+
+    final CsdlEntityType category = metadata.getSchema(0).getEntityType("Category");
+    assertNotNull(category);
+
+    final CsdlComplexType address = metadata.getSchema(0).getComplexType("Address");
+    assertFalse(address.getNavigationProperty("Country").getReferentialConstraints().isEmpty());
+    assertEquals("Name",
+        address.getNavigationProperty("Country").getReferentialConstraints().get(0).getReferencedProperty());
+
+    final CsdlFunction productsByRating = metadata.getSchema(0).getFunctions("ProductsByRating").get(0);
+    assertNotNull(productsByRating.getParameter("Rating"));
+    assertEquals("Edm.Int32", productsByRating.getParameter("Rating").getType());
+    assertEquals("ODataDemo.Product", productsByRating.getReturnType().getType());
+    assertTrue(productsByRating.getReturnType().isCollection());
+
+    final CsdlSingleton contoso = metadata.getSchema(0).getEntityContainer().getSingleton("Contoso");
+    assertNotNull(contoso);
+    assertFalse(contoso.getNavigationPropertyBindings().isEmpty());
+    assertEquals("Products", contoso.getNavigationPropertyBindings().get(0).getPath());
+
+    final CsdlFunctionImport functionImport = metadata.getSchema(0).getEntityContainer().
+        getFunctionImport("ProductsByRating");
+    assertNotNull(functionImport);
+    assertEquals(metadata.getSchema(0).getNamespace() + "." + productsByRating.getName(),
+        functionImport.getFunction());
+
+    // Now let's go high-level
+    final Edm edm = getClient().getReader().readMetadata(getClass().getResourceAsStream("fromdoc1-metadata.xml"));
+    assertNotNull(edm);
+
+    List<EdmSchema> schemaList = edm.getSchemas();
+    assertNotNull(schemaList);
+    assertEquals(1, schemaList.size());
+    EdmSchema schema = schemaList.get(0);
+
+    EdmEntityContainer demoService = schema.getEntityContainer();
+    assertNotNull(demoService);
+    for (EdmFunction function : schema.getFunctions()) {
+      final EdmFunctionImport fi = demoService.getFunctionImport(function.getName());
+      assertNotNull(fi);
+      assertEquals(demoService.getEntitySet("Products"), fi.getReturnedEntitySet());
+
+      final EdmFunction edmFunction =
+          edm.getUnboundFunction(
+              new FullQualifiedName(metadata.getSchema(0).getNamespace(), "ProductsByRating"), function
+                  .getParameterNames());
+      assertNotNull(edmFunction);
+      assertEquals(edmFunction.getName(), fi.getUnboundFunction(function.getParameterNames()).getName());
+      assertEquals(edmFunction.getNamespace(), fi.getUnboundFunction(function.getParameterNames()).getNamespace());
+      assertEquals(edmFunction.getParameterNames(), fi.getUnboundFunction(function.getParameterNames())
+          .getParameterNames());
+      assertEquals(edmFunction.getReturnType().getType().getName(),
+          fi.getUnboundFunction(function.getParameterNames()).getReturnType().getType().getName());
+      assertEquals(edmFunction.getReturnType().getType().getNamespace(),
+          fi.getUnboundFunction(function.getParameterNames()).getReturnType().getType().getNamespace());
+    }
+
+    final EdmTypeDefinition weight = edm.getTypeDefinition(new FullQualifiedName("ODataDemo", "Weight"));
+    assertNotNull(weight);
+    assertEquals(EdmInt32.getInstance(), weight.getUnderlyingType());
+    assertFalse(weight.getAnnotations().isEmpty());
+    assertEquals("Kilograms", weight.getAnnotations().get(0).getExpression().asConstant().getValueAsString());
+  }
+
+  /**
+   * Tests Example 86 from CSDL specification.
+   */
+  @Test
+  public void fromdoc2() {
+    final XMLMetadata metadata = getClient().getDeserializer(ContentType.APPLICATION_XML)
+        .toMetadata(getClass().getResourceAsStream("fromdoc2-metadata.xml"));
+    assertNotNull(metadata);
+
+    // Check displayName
+    final CsdlAnnotation displayName = metadata.getSchema(0).getAnnotationGroup("ODataDemo.Supplier").
+        getAnnotation("Vocabulary1.DisplayName");
+    assertNotNull(displayName);
+    assertTrue(displayName.getExpression().isDynamic());
+
+    assertTrue(displayName.getExpression().asDynamic().isApply());
+    final Apply apply = displayName.getExpression().asDynamic().asApply();
+    assertEquals(Constants.CANONICAL_FUNCTION_CONCAT, apply.getFunction());
+    assertEquals(3, apply.getParameters().size());
+
+    Path path = (Path) apply.getParameters().get(0);
+    assertEquals("Name", path.getValue());
+
+    ConstantAnnotationExpression expression =
+        (ConstantAnnotationExpression) apply.getParameters().get(1);
+    assertEquals(" in ", expression.getValue());
+    assertEquals(ConstantAnnotationExpression.Type.String, expression.getType());
+
+    Path thirdArg = (Path) apply.getParameters().get(2);
+    assertEquals("Address/CountryName", thirdArg.getValue());
+
+    // Check Tags
+    final CsdlAnnotation tags = metadata.getSchema(0).getAnnotationGroup("ODataDemo.Product").
+        getAnnotation("Vocabulary1.Tags");
+    assertNotNull(tags);
+    assertTrue(tags.getExpression().isDynamic());
+
+    assertTrue(tags.getExpression().asDynamic().isCollection());
+    final Collection collection = tags.getExpression().asDynamic().asCollection();
+    assertEquals(1, collection.getItems().size());
+    assertEquals(ConstantAnnotationExpression.Type.String, collection.getItems().get(0).asConstant().getType());
+    assertEquals("MasterData", collection.getItems().get(0).asConstant().getValue());
+  }
+
+  /**
+   * Various annotation examples taken from CSDL specification.
+   */
+  @Test
+  public void fromdoc3() {
+    final Edm edm = getClient().getReader().readMetadata(getClass().getResourceAsStream("fromdoc3-metadata.xml"));
+    assertNotNull(edm);
+
+    final EdmAnnotations group = edm.getSchema("Annotations").getAnnotationGroups().get(0);
+    assertNotNull(group);
+
+    final EdmAnnotation time1 = group.getAnnotations().get(0);
+    assertEquals("Edm.TimeOfDay", time1.getExpression().asConstant().getValue().getType());
+
+    final EdmAnnotation time2 = group.getAnnotations().get(1);
+    assertEquals("Edm.TimeOfDay", time2.getExpression().asConstant().getValue().getType());
+  }
+
+  /**
+   * Various annotation examples taken from CSDL specification.
+   */
+  @Test
+  public void fromdoc4() {
+    final XMLMetadata metadata = getClient().getDeserializer(ContentType.APPLICATION_XML).
+        toMetadata(getClass().getResourceAsStream("fromdoc4-metadata.xml"));
+    assertNotNull(metadata);
+
+    final CsdlAnnotations group = metadata.getSchema(0).getAnnotationGroups().get(0);
+    assertNotNull(group);
+
+    CsdlAnnotation annotation = group.getAnnotations().get(0);
+    assertTrue(annotation.getExpression().isDynamic());
+    assertTrue(annotation.getExpression().asDynamic().isCast());
+    assertEquals("Edm.Decimal", annotation.getExpression().asDynamic().asCast().getType());
+
+    annotation = group.getAnnotation("And");
+    assertTrue(annotation.getExpression().isDynamic());
+    assertTrue(annotation.getExpression().asDynamic().isTwoParamsOp());
+    assertEquals(TwoParamsOpDynamicAnnotationExpression.Type.And,
+        annotation.getExpression().asDynamic().asTwoParamsOp().getType());
+    assertTrue(annotation.getExpression().asDynamic().asTwoParamsOp().getLeftExpression().isPath());
+
+    annotation = group.getAnnotation("Vocab.Supplier");
+    assertNotNull(annotation);
+    assertTrue(annotation.getExpression().isDynamic());
+    assertTrue(annotation.getExpression().asDynamic().isUrlRef());
+    final UrlRef urlRef = annotation.getExpression().asDynamic().asUrlRef();
+    assertTrue(urlRef.getValue().isDynamic());
+    assertTrue(urlRef.getValue().asDynamic().isApply());
+
+    // Now let's go high-level
+    final Edm edm = getClient().getReader().readMetadata(getClass().getResourceAsStream("fromdoc4-metadata.xml"));
+    assertNotNull(edm);
+
+    final EdmAnnotations edmGroup = edm.getSchemas().get(0).getAnnotationGroups().get(0);
+    assertNotNull(edmGroup);
+
+    EdmAnnotation edmAnnotation = edmGroup.getAnnotations().get(0);
+    assertTrue(edmAnnotation.getExpression().isDynamic());
+    assertTrue(edmAnnotation.getExpression().asDynamic().isCast());
+    assertEquals(EdmDecimal.getInstance(), edmAnnotation.getExpression().asDynamic().asCast().getType());
+
+    edmAnnotation = edmGroup.getAnnotations().get(1);
+    assertTrue(edmAnnotation.getExpression().isDynamic());
+    assertTrue(edmAnnotation.getExpression().asDynamic().isAnd());
+    assertTrue(edmAnnotation.getExpression().asDynamic().asAnd().getLeftExpression().isPath());
+
+    edmAnnotation = edmGroup.getAnnotations().get(edmGroup.getAnnotations().size() - 2);
+    assertNotNull(edmAnnotation);
+    assertTrue(edmAnnotation.getExpression().isDynamic());
+    assertTrue(edmAnnotation.getExpression().asDynamic().isUrlRef());
+    final EdmUrlRef edmUrlRef = edmAnnotation.getExpression().asDynamic().asUrlRef();
+    assertTrue(edmUrlRef.getValue().isDynamic());
+    assertTrue(edmUrlRef.getValue().asDynamic().isApply());
+  }
+
+  @Test
+  public void metadataWithCapabilities() throws Exception {
+    InputStream input = getClass().getResourceAsStream("Metadata-With-Capabilities.xml");
+    final XMLMetadata metadata = getClient().getDeserializer(ContentType.APPLICATION_XML).
+            toMetadata(input);
+
+    CsdlSchema schema = metadata.getSchema("Capabilities");
+    assertNotNull(schema);
+    assertEquals(23, schema.getTerms().size());
+
+    final CsdlTerm deleteRestrictions = schema.getTerm("DeleteRestrictions");
+    assertNotNull(deleteRestrictions);
+    assertEquals("Capabilities.DeleteRestrictionsType", deleteRestrictions.getType());
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/752bfad3/lib/client-core/src/test/java/org/apache/olingo/client/core/PrimitiveValueTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/PrimitiveValueTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/PrimitiveValueTest.java
new file mode 100644
index 0000000..f46f272
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/PrimitiveValueTest.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core;
+
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.domain.ClientValue;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.junit.Test;
+
+import java.util.Calendar;
+
+import static org.junit.Assert.assertEquals;
+
+public class PrimitiveValueTest extends AbstractTest {
+
+  @Override
+  protected ODataClient getClient() {
+    return v4Client;
+  }
+
+  @Test
+  public void timeOfDay() throws EdmPrimitiveTypeException {
+    final Calendar expected = Calendar.getInstance();
+    expected.clear();
+    expected.set(2013, 0, 10, 21, 45, 17);
+
+    final ClientValue value = getClient().getObjectFactory().newPrimitiveValueBuilder().
+            setType(EdmPrimitiveTypeKind.TimeOfDay).setValue(expected).build();
+    assertEquals(EdmPrimitiveTypeKind.TimeOfDay, value.asPrimitive().getTypeKind());
+
+    final Calendar actual = value.asPrimitive().toCastValue(Calendar.class);
+    assertEquals(expected.get(Calendar.HOUR), actual.get(Calendar.HOUR));
+    assertEquals(expected.get(Calendar.MINUTE), actual.get(Calendar.MINUTE));
+    assertEquals(expected.get(Calendar.SECOND), actual.get(Calendar.SECOND));
+
+    assertEquals("21:45:17", value.asPrimitive().toString());
+  }
+
+  @Test
+  public void Date() throws EdmPrimitiveTypeException {
+    final Calendar expected = Calendar.getInstance();
+    expected.clear();
+    expected.set(2013, 0, 10);
+
+    final ClientValue value = getClient().getObjectFactory().newPrimitiveValueBuilder().
+            setType(EdmPrimitiveTypeKind.Date).setValue(expected).build();
+    assertEquals(EdmPrimitiveTypeKind.Date, value.asPrimitive().getTypeKind());
+
+    final Calendar actual = value.asPrimitive().toCastValue(Calendar.class);
+    assertEquals(expected.get(Calendar.YEAR), actual.get(Calendar.YEAR));
+    assertEquals(expected.get(Calendar.MONTH), actual.get(Calendar.MONTH));
+    assertEquals(expected.get(Calendar.DATE), actual.get(Calendar.DATE));
+
+    assertEquals("2013-01-10", value.asPrimitive().toString());
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/752bfad3/lib/client-core/src/test/java/org/apache/olingo/client/core/PropertyTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/PropertyTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/PropertyTest.java
new file mode 100644
index 0000000..a545dc2
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/PropertyTest.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.InputStream;
+import java.util.Iterator;
+
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.domain.ClientCollectionValue;
+import org.apache.olingo.client.api.domain.ClientComplexValue;
+import org.apache.olingo.client.api.domain.ClientProperty;
+import org.apache.olingo.client.api.domain.ClientValue;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
+import org.apache.olingo.client.api.serialization.ODataSerializerException;
+import org.junit.Test;
+
+public class PropertyTest extends AbstractTest {
+
+  @Override
+  protected ODataClient getClient() {
+    return v4Client;
+  }
+
+  private void _enum(final ContentType contentType) throws ODataDeserializerException, ODataSerializerException {
+    final InputStream input = getClass().getResourceAsStream("Products_5_SkinColor." + getSuffix(contentType));
+    final ClientProperty property = getClient().getReader().readProperty(input, contentType);
+    assertNotNull(property);
+    assertTrue(property.hasEnumValue());
+
+    final ClientProperty written = getClient().getReader().readProperty(
+            getClient().getWriter().writeProperty(property, contentType), contentType);
+    // This is needed because type information gets lost with serialization
+    if (contentType.isCompatible(ContentType.APPLICATION_XML)) {
+      final ClientProperty comparable = getClient().getObjectFactory().newEnumProperty(property.getName(),
+              getClient().getObjectFactory().
+              newEnumValue(property.getEnumValue().getTypeName(), written.getEnumValue().getValue()));
+
+      assertEquals(property, comparable);
+    }
+  }
+
+  @Test
+  public void xmlEnum() throws Exception {
+    _enum(ContentType.APPLICATION_XML);
+  }
+
+  @Test
+  public void jsonEnum() throws Exception {
+    _enum(ContentType.JSON);
+  }
+
+  private void complex(final ContentType contentType) throws ODataDeserializerException, ODataSerializerException {
+    final InputStream input = getClass().getResourceAsStream("Employees_3_HomeAddress." + getSuffix(contentType));
+    final ClientProperty property = getClient().getReader().readProperty(input, contentType);
+    assertNotNull(property);
+    assertTrue(property.hasComplexValue());
+    assertEquals(3, property.getComplexValue().size());
+
+    final ClientProperty written = getClient().getReader().readProperty(
+            getClient().getWriter().writeProperty(property, contentType), contentType);
+    // This is needed because type information gets lost with JSON serialization
+    final ClientComplexValue typedValue = getClient().getObjectFactory().
+            newComplexValue(property.getComplexValue().getTypeName());
+    for (final Iterator<ClientProperty> itor = written.getComplexValue().iterator(); itor.hasNext();) {
+      final ClientProperty prop = itor.next();
+      typedValue.add(prop);
+    }
+    final ClientProperty comparable = getClient().getObjectFactory().
+            newComplexProperty(property.getName(), typedValue);
+
+    assertEquals(property, comparable);
+  }
+
+  @Test
+  public void xmlComplex() throws Exception {
+    complex(ContentType.APPLICATION_XML);
+  }
+
+  @Test
+  public void jsonComplex() throws Exception {
+    complex(ContentType.JSON);
+  }
+
+  private void collection(final ContentType contentType) throws ODataDeserializerException, ODataSerializerException {
+    final InputStream input = getClass().getResourceAsStream("Products_5_CoverColors." + getSuffix(contentType));
+    final ClientProperty property = getClient().getReader().readProperty(input, contentType);
+    assertNotNull(property);
+    assertTrue(property.hasCollectionValue());
+    assertEquals(3, property.getCollectionValue().size());
+
+    final ClientProperty written = getClient().getReader().readProperty(
+            getClient().getWriter().writeProperty(property, contentType), contentType);
+    // This is needed because type information gets lost with JSON serialization
+    if(contentType.isCompatible(ContentType.APPLICATION_XML)) {
+      final ClientCollectionValue<ClientValue> typedValue = getClient().getObjectFactory().
+              newCollectionValue(property.getCollectionValue().getTypeName());
+      for (final Iterator<ClientValue> itor = written.getCollectionValue().iterator(); itor.hasNext();) {
+        final ClientValue value = itor.next();
+        typedValue.add(value);
+      }
+      final ClientProperty comparable = getClient().getObjectFactory().
+              newCollectionProperty(property.getName(), typedValue);
+
+      assertEquals(property, comparable);
+    }
+  }
+
+  @Test
+  public void xmlCollection() throws Exception {
+    collection(ContentType.APPLICATION_XML);
+  }
+
+  @Test
+  public void jsonCollection() throws Exception {
+    collection(ContentType.JSON);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/752bfad3/lib/client-core/src/test/java/org/apache/olingo/client/core/ServiceDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/ServiceDocumentTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/ServiceDocumentTest.java
new file mode 100644
index 0000000..5b7c246
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/ServiceDocumentTest.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URI;
+
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.data.ServiceDocument;
+import org.apache.olingo.client.api.domain.ClientServiceDocument;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.client.api.serialization.ODataDeserializerException;
+import org.junit.Test;
+
+public class ServiceDocumentTest extends AbstractTest {
+
+  @Override
+  protected ODataClient getClient() {
+    return v4Client;
+  }
+
+  private String getFileExtension(final ContentType contentType) {
+    return contentType.isCompatible(ContentType.APPLICATION_XML) ? "xml" : "json";
+  }
+
+  private ClientServiceDocument parse(final ContentType contentType) throws ODataDeserializerException {
+    ResWrap<ServiceDocument> service = getClient().getDeserializer(contentType).toServiceDocument(
+        getClass().getResourceAsStream("serviceDocument." + getFileExtension(contentType)));
+
+    assertEquals(URI.create("http://host/service/$metadata"), service.getContextURL());
+    assertEquals("W/\"MjAxMy0wNS0xM1QxNDo1NFo=\"", service.getMetadataETag());
+
+    final ClientServiceDocument serviceDocument = getClient().getBinder().getODataServiceDocument(service.getPayload());
+    assertNotNull(serviceDocument);
+
+    assertTrue(serviceDocument.getEntitySetNames().contains("Order Details"));
+    assertEquals(URI.create("http://host/service/TopProducts"),
+        serviceDocument.getFunctionImportURI("TopProducts"));
+    assertEquals(URI.create("http://host/HR/"),
+        serviceDocument.getRelatedServiceDocumentsURIs().iterator().next());
+
+    return serviceDocument;
+  }
+
+  @Test
+  public void json() throws Exception {
+    parse(ContentType.JSON);
+  }
+
+  @Test
+  public void xml() throws Exception {
+    parse(ContentType.APPLICATION_XML);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/752bfad3/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/FilterFactoryTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/FilterFactoryTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/FilterFactoryTest.java
new file mode 100644
index 0000000..1d26f81
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/FilterFactoryTest.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core.uri;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.Calendar;
+import java.util.TimeZone;
+
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.uri.FilterArgFactory;
+import org.apache.olingo.client.api.uri.FilterFactory;
+import org.apache.olingo.client.api.uri.URIFilter;
+import org.apache.olingo.client.core.AbstractTest;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.edm.EdmEnumType;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.provider.CsdlEnumType;
+import org.apache.olingo.commons.core.edm.EdmEnumTypeImpl;
+import org.junit.Test;
+
+public class FilterFactoryTest extends AbstractTest {
+
+  @Override
+  protected ODataClient getClient() {
+    return v4Client;
+  }
+
+  private FilterFactory getFilterFactory() {
+    return getClient().getFilterFactory();
+  }
+
+  private FilterArgFactory getFilterArgFactory() {
+    return getFilterFactory().getArgFactory();
+  }
+
+  @Test
+  public void has() {
+    final EdmEnumType pattern =
+        new EdmEnumTypeImpl(null, new FullQualifiedName("Sales", "Pattern"), new CsdlEnumType());
+    final URIFilter filter = getFilterFactory().has(getFilterArgFactory().property("style"), pattern, "Yellow");
+
+    assertEquals("(style has Sales.Pattern'Yellow')", filter.build());
+  }
+
+  @Test
+  public void contains() {
+    final URIFilter filter = getFilterFactory().match(getFilterArgFactory().contains(
+        getFilterArgFactory().property("CompanyName"), getFilterArgFactory().literal("Alfreds")));
+
+    assertEquals("contains(CompanyName,'Alfreds')", filter.build());
+  }
+
+  @Test
+  public void maxdatetime() {
+    final URIFilter filter = getFilterFactory().eq(
+        getFilterArgFactory().property("EndTime"),
+        getFilterArgFactory().maxdatetime());
+
+    assertEquals("(EndTime eq maxdatetime())", filter.build());
+  }
+
+  @Test
+  public void any() {
+    final URIFilter filter = getFilterFactory().match(
+        getFilterArgFactory().any(getFilterArgFactory().property("Items"),
+            getFilterFactory().gt("d:d/Quantity", 100)));
+
+    assertEquals("Items/any(d:d/Quantity gt 100)", filter.build());
+  }
+
+  @Test
+  public void issueOLINGO357() throws UnsupportedEncodingException {
+    final Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT-8"));
+    calendar.clear();
+    calendar.set(2011, 2, 8, 14, 21, 12);
+
+    final URIFilter filter = getFilterFactory().ge("OrderDate", calendar);
+    assertEquals("(OrderDate ge " + URLEncoder.encode("2011-03-08T14:21:12-08:00", Constants.UTF8) + ")",
+        filter.build());
+  }
+
+}