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 2015/09/01 14:45:29 UTC

[27/31] olingo-odata4 git commit: [OLINGO-659] Removed v4 from package and class names

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/base/DerivedTypeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/base/DerivedTypeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/base/DerivedTypeTestITCase.java
new file mode 100644
index 0000000..2f470c3
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/base/DerivedTypeTestITCase.java
@@ -0,0 +1,150 @@
+/*
+ * 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.fit.base;
+
+import static org.junit.Assert.assertEquals;
+
+import java.math.BigDecimal;
+import java.util.Calendar;
+import java.util.TimeZone;
+
+import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
+import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
+import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
+import org.apache.olingo.client.api.domain.ClientComplexValue;
+import org.apache.olingo.client.api.domain.ClientEntity;
+import org.apache.olingo.client.api.domain.ClientEntitySet;
+import org.apache.olingo.client.api.domain.ClientValuable;
+import org.apache.olingo.client.api.uri.URIBuilder;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.junit.Test;
+
+public class DerivedTypeTestITCase extends AbstractTestITCase {
+
+  private void read(final ContentType contentType) {
+    // 1. entity set
+    URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
+        appendEntitySetSegment("People").
+        appendDerivedEntityTypeSegment("Microsoft.Test.OData.Services.ODataWCFService.Customer");
+    ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().
+        getEntitySetRequest(uriBuilder.build());
+    req.setFormat(contentType);
+
+    for (ClientEntity customer : req.execute().getBody().getEntities()) {
+      assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", customer.getTypeName().toString());
+    }
+
+    // 2. contained entity set
+    uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
+        appendEntitySetSegment("Accounts").appendKeySegment(101).
+        appendNavigationSegment("MyPaymentInstruments").
+        appendDerivedEntityTypeSegment("Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI");
+    req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
+    req.setFormat(contentType);
+
+    for (ClientEntity customer : req.execute().getBody().getEntities()) {
+      assertEquals("Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI", customer.getTypeName().toString());
+    }
+  }
+
+  @Test
+  public void readfromAtom() {
+    read(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void readfromJSON() {
+    read(ContentType.JSON_FULL_METADATA);
+  }
+
+  private void createDelete(final ContentType conentType) {
+    final ClientEntity customer = client.getObjectFactory().
+        newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
+
+    customer.getProperties().add(client.getObjectFactory().newPrimitiveProperty("PersonID",
+        client.getObjectFactory().newPrimitiveValueBuilder().buildInt32(976)));
+    customer.getProperties().add(client.getObjectFactory().newPrimitiveProperty("FirstName",
+        client.getObjectFactory().newPrimitiveValueBuilder().buildString("Test")));
+    customer.getProperties().add(client.getObjectFactory().newPrimitiveProperty("LastName",
+        client.getObjectFactory().newPrimitiveValueBuilder().buildString("Test")));
+
+    final ClientComplexValue homeAddress =
+        client.getObjectFactory().newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.CompanyAddress");
+    homeAddress.add(client.getObjectFactory().newPrimitiveProperty("Street",
+        client.getObjectFactory().newPrimitiveValueBuilder().buildString("V.le Gabriele D'Annunzio")));
+    homeAddress.add(client.getObjectFactory().newPrimitiveProperty("City",
+        client.getObjectFactory().newPrimitiveValueBuilder().buildString("Pescara")));
+    homeAddress.add(client.getObjectFactory().newPrimitiveProperty("PostalCode",
+        client.getObjectFactory().newPrimitiveValueBuilder().buildString("65127")));
+    homeAddress.add(client.getObjectFactory().newPrimitiveProperty("CompanyName",
+        client.getObjectFactory().newPrimitiveValueBuilder().buildString("Tirasa")));
+    customer.getProperties().add(client.getObjectFactory().newComplexProperty("HomeAddress", homeAddress));
+
+    customer.getProperties().add(client.getObjectFactory().newCollectionProperty("Numbers",
+        client.getObjectFactory().newCollectionValue("Edm.String")));
+    customer.getProperties().add(client.getObjectFactory().newCollectionProperty("Emails",
+        client.getObjectFactory().newCollectionValue("Edm.String")));
+    customer.getProperties().add(client.getObjectFactory().newPrimitiveProperty("City",
+        client.getObjectFactory().newPrimitiveValueBuilder().buildString("Pescara")));
+    final Calendar dateTime = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+    dateTime.set(1977, 8, 8, 0, 0, 0);
+    customer.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Birthday",
+        client.getObjectFactory().newPrimitiveValueBuilder().
+        setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(dateTime).build()));
+    customer.getProperties().add(client.getObjectFactory().newPrimitiveProperty("TimeBetweenLastTwoOrders",
+        client.getObjectFactory().newPrimitiveValueBuilder().
+        setType(EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal("0.0000002")).build()));
+
+    final ODataEntityCreateRequest<ClientEntity> createReq = client.getCUDRequestFactory().
+        getEntityCreateRequest(
+            client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People").build(),
+            customer);
+    createReq.setFormat(conentType);
+
+    final ODataEntityCreateResponse<ClientEntity> createRes = createReq.execute();
+    assertEquals(201, createRes.getStatusCode());
+
+    final ODataEntityRequest<ClientEntity> fetchReq = client.getRetrieveRequestFactory().
+        getEntityRequest(client.newURIBuilder(testStaticServiceRootURL).
+            appendEntitySetSegment("People").appendKeySegment(976).build());
+    fetchReq.setFormat(conentType);
+
+    final ClientEntity actual = fetchReq.execute().getBody();
+    assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", actual.getTypeName().toString());
+    assertEquals("Microsoft.Test.OData.Services.ODataWCFService.CompanyAddress",
+        ((ClientValuable) actual.getProperty("HomeAddress")).getValue().getTypeName());
+
+    final ODataDeleteRequest deleteReq = client.getCUDRequestFactory().getDeleteRequest(actual.getEditLink());
+    assertEquals(204, deleteReq.execute().getStatusCode());
+  }
+
+  @Test
+  public void createDeleteAsAtom() {
+    createDelete(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void createDeleteAsJSON() {
+    createDelete(ContentType.JSON_FULL_METADATA);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/base/EntityCreateTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/base/EntityCreateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/base/EntityCreateTestITCase.java
new file mode 100644
index 0000000..868c154
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/base/EntityCreateTestITCase.java
@@ -0,0 +1,191 @@
+/*
+ * 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.fit.base;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.net.URI;
+import java.util.Calendar;
+
+import org.apache.commons.lang3.RandomUtils;
+import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
+import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
+import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
+import org.apache.olingo.client.api.domain.ClientEntity;
+import org.apache.olingo.client.api.domain.ClientEntitySet;
+import org.apache.olingo.client.api.domain.ClientInlineEntitySet;
+import org.apache.olingo.client.api.domain.ClientLink;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.junit.Test;
+
+public class EntityCreateTestITCase extends AbstractTestITCase {
+
+  @Test
+  public void atomCreateAndDelete() {
+    createAndDeleteOrder(testStaticServiceRootURL, ContentType.APPLICATION_ATOM_XML, 1000);
+  }
+
+  @Test
+  public void jsonCreateAndDelete() {
+    createAndDeleteOrder(testStaticServiceRootURL, ContentType.JSON, 1001);
+    createAndDeleteOrder(testStaticServiceRootURL, ContentType.JSON_NO_METADATA, 1001);
+    createAndDeleteOrder(testStaticServiceRootURL, ContentType.JSON_FULL_METADATA, 1001);
+  }
+
+  private void onContained(final ContentType contentType) {
+    final URI uri = getClient().newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Accounts").
+        appendKeySegment(101).appendNavigationSegment("MyPaymentInstruments").build();
+
+    // 1. read contained collection before any operation
+    ClientEntitySet instruments = getClient().getRetrieveRequestFactory().getEntitySetRequest(uri).execute().getBody();
+    assertNotNull(instruments);
+    final int sizeBefore = instruments.getCount();
+
+    // 2. instantiate an ODataEntity of the same type as the collection above
+    final ClientEntity instrument = getClient().getObjectFactory().
+        newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument"));
+
+    int id = RandomUtils.nextInt(101999, 105000);
+    instrument.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("PaymentInstrumentID",
+        getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(id)));
+    instrument.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("FriendlyName",
+        getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("New one")));
+    instrument.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("CreatedDate",
+        getClient().getObjectFactory().newPrimitiveValueBuilder().
+        setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(Calendar.getInstance()).build()));
+
+    // 3. create it as contained entity
+    final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
+        getEntityCreateRequest(uri, instrument);
+    req.setFormat(contentType);
+
+    final ODataEntityCreateResponse<ClientEntity> res = req.execute();
+    assertEquals(201, res.getStatusCode());
+
+    // 4. verify that the contained collection effectively grew
+    instruments = getClient().getRetrieveRequestFactory().getEntitySetRequest(uri).execute().getBody();
+    assertNotNull(instruments);
+    final int sizeAfter = instruments.getCount();
+    assertEquals(sizeBefore + 1, sizeAfter);
+
+    // 5. remove the contained entity created above
+    final ODataDeleteResponse deleteRes = getClient().getCUDRequestFactory().
+        getDeleteRequest(getClient().newURIBuilder(uri.toASCIIString()).appendKeySegment(id).build()).execute();
+    assertEquals(204, deleteRes.getStatusCode());
+
+    // 6. verify that the contained collection effectively reduced
+    instruments = getClient().getRetrieveRequestFactory().getEntitySetRequest(uri).execute().getBody();
+    assertNotNull(instruments);
+    final int sizeEnd = instruments.getCount();
+    assertEquals(sizeBefore, sizeEnd);
+  }
+
+  @Test
+  public void atomOnContained() {
+    onContained(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void jsonOnContained() {
+    onContained(ContentType.JSON);
+  }
+
+  private void deepInsert(final ContentType contentType, final int productId, final int productDetailId)
+      throws EdmPrimitiveTypeException {
+
+    final ClientEntity product = getClient().getObjectFactory().
+        newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Product"));
+    product.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("ProductID",
+        getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(productId)));
+    product.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("Name",
+        getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("Latte")));
+    product.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("QuantityPerUnit",
+        getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("100g Bag")));
+    product.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("UnitPrice",
+        getClient().getObjectFactory().newPrimitiveValueBuilder().buildSingle(3.24f)));
+    product.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("QuantityInStock",
+        getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(100)));
+    product.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("Discontinued",
+        getClient().getObjectFactory().newPrimitiveValueBuilder().buildBoolean(false)));
+    product.getProperties().add(getClient().getObjectFactory().newEnumProperty("UserAccess",
+        getClient().getObjectFactory().
+        newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.AccessLevel", "Execute")));
+    product.getProperties().add(getClient().getObjectFactory().newEnumProperty("SkinColor",
+        getClient().getObjectFactory().
+        newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.Color", "Blue")));
+    product.getProperties().add(getClient().getObjectFactory().newCollectionProperty("CoverColors",
+        getClient().getObjectFactory().
+        newCollectionValue("Microsoft.Test.OData.Services.ODataWCFService.Color")));
+    product.getProperty("CoverColors").getCollectionValue().add(getClient().getObjectFactory().
+        newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.Color", "Green"));
+    product.getProperty("CoverColors").getCollectionValue().add(getClient().getObjectFactory().
+        newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.Color", "Red"));
+
+    final ClientEntity detail = getClient().getObjectFactory().
+        newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.ProductDetail"));
+    detail.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("ProductID",
+        getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(productId)));
+    detail.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("ProductDetailID",
+        getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(productDetailId)));
+    detail.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("ProductName",
+        getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("LatteHQ")));
+    detail.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("Description",
+        getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("High-Quality Milk")));
+
+    final ClientEntitySet details = getClient().getObjectFactory().newEntitySet();
+    details.getEntities().add(detail);
+
+    final ClientInlineEntitySet inlineDetails = getClient().getObjectFactory().
+        newDeepInsertEntitySet("Details", details);
+    product.addLink(inlineDetails);
+
+    final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest(
+        getClient().newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Products").build(), product);
+    req.setFormat(contentType);
+    final ODataEntityCreateResponse<ClientEntity> res = req.execute();
+    assertEquals(201, res.getStatusCode());
+
+    final ClientEntity createdProduct = res.getBody();
+    assertEquals(productId,
+        createdProduct.getProperty("ProductID").getPrimitiveValue().toCastValue(Integer.class), 0);
+
+    final ClientLink createdLink = createdProduct.getNavigationLink("Details");
+    assertNotNull(createdLink);
+
+    final ClientEntitySet createdProductDetails =
+        getClient().getRetrieveRequestFactory().getEntitySetRequest(createdLink.getLink()).execute().getBody();
+    assertNotNull(createdProductDetails);
+    assertEquals(productDetailId, createdProductDetails.getEntities().iterator().next().
+        getProperty("ProductDetailID").getPrimitiveValue().toCastValue(Integer.class), 0);
+  }
+
+  @Test
+  public void atomDeepInsert() throws EdmPrimitiveTypeException {
+    deepInsert(ContentType.APPLICATION_ATOM_XML, 10, 10);
+  }
+
+  @Test
+  public void jsonDeepInsert() throws EdmPrimitiveTypeException {
+    deepInsert(ContentType.JSON_FULL_METADATA, 11, 11);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/base/EntityRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/base/EntityRetrieveTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/base/EntityRetrieveTestITCase.java
new file mode 100644
index 0000000..2137dfb
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/base/EntityRetrieveTestITCase.java
@@ -0,0 +1,378 @@
+/*
+ * 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.fit.base;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URI;
+import java.sql.Timestamp;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.client.api.EdmEnabledODataClient;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataRawRequest;
+import org.apache.olingo.client.api.communication.response.ODataRawResponse;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.domain.ClientEntity;
+import org.apache.olingo.client.api.domain.ClientEntitySet;
+import org.apache.olingo.client.api.domain.ClientInlineEntity;
+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.uri.URIBuilder;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * This is the unit test class to check entity retrieve operations.
+ */
+public class EntityRetrieveTestITCase extends AbstractTestITCase {
+
+  private void withInlineEntity(final ODataClient client, final ContentType contentType) {
+    final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
+        appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");
+
+    final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().
+        getEntityRequest(uriBuilder.build());
+    req.setFormat(contentType);
+
+    final ODataRetrieveResponse<ClientEntity> res = req.execute();
+    final ClientEntity entity = res.getBody();
+
+    assertNotNull(entity);
+    assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
+    assertTrue(entity.getProperty("Home").hasPrimitiveValue());
+    assertEquals("Edm.GeographyPoint", entity.getProperty("Home").getPrimitiveValue().getTypeName());
+
+    // In JSON with minimal metadata, links are not provided
+    if (contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC)
+        || contentType.isCompatible(ContentType.APPLICATION_ATOM_XML) 
+        || (contentType.isCompatible(ContentType.JSON) 
+              && ContentType.VALUE_ODATA_METADATA_FULL
+              .equals(contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA)))) {
+      assertEquals(testStaticServiceRootURL + "/Customers(1)", entity.getEditLink().toASCIIString());
+      assertEquals(3, entity.getNavigationLinks().size());
+
+      if (ContentType.APPLICATION_ATOM_XML == contentType) {
+        assertTrue(entity.getAssociationLinks().isEmpty());
+        // In JSON, association links for each $ref link will exist.
+      }
+
+      boolean found = false;
+
+      for (ClientLink link : entity.getNavigationLinks()) {
+        if (link instanceof ClientInlineEntity) {
+          final ClientEntity inline = ((ClientInlineEntity) link).getEntity();
+          assertNotNull(inline);
+
+          final List<? extends ClientProperty> properties = inline.getProperties();
+          assertEquals(5, properties.size());
+
+          assertTrue(properties.get(0).getName().equals("CompanyID")
+              || properties.get(1).getName().equals("CompanyID")
+              || properties.get(2).getName().equals("CompanyID")
+              || properties.get(3).getName().equals("CompanyID")
+              || properties.get(4).getName().equals("CompanyID"));
+          assertTrue(properties.get(0).getValue().toString().equals("0")
+              || properties.get(1).getValue().toString().equals("0")
+              || properties.get(2).getValue().toString().equals("0")
+              || properties.get(3).getValue().toString().equals("0")
+              || properties.get(4).getValue().toString().equals("0"));
+
+          found = true;
+        }
+      }
+
+      assertTrue(found);
+    }
+  }
+
+  @Ignore
+  @Test
+  public void withInlineEntityFromAtom() {
+    withInlineEntity(client, ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void withInlineEntityFromFullJSON() {
+    withInlineEntity(client, ContentType.JSON_FULL_METADATA);
+  }
+
+  @Test
+  public void withInlineEntityFromJSON() {
+    withInlineEntity(edmClient, ContentType.JSON);
+  }
+
+  private void withInlineEntitySet(final ODataClient client, final ContentType contentType) {
+    final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
+        appendEntitySetSegment("Customers").appendKeySegment(1).expand("Orders");
+
+    final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().
+        getEntityRequest(uriBuilder.build());
+    req.setFormat(contentType);
+
+    final ODataRetrieveResponse<ClientEntity> res = req.execute();
+    final ClientEntity entity = res.getBody();
+    assertNotNull(entity);
+    assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
+
+    // In JSON with minimal metadata, links are not provided
+    if (contentType.equals(ContentType.APPLICATION_ATOM_XML) || contentType.equals(ContentType.JSON_FULL_METADATA)) {
+      boolean found = false;
+      for (ClientLink link : entity.getNavigationLinks()) {
+        if (link instanceof ClientInlineEntitySet) {
+          final ClientEntitySet inline = ((ClientInlineEntitySet) link).getEntitySet();
+          assertNotNull(inline);
+
+          found = true;
+        }
+      }
+      assertTrue(found);
+    }
+  }
+
+  @Ignore
+  @Test
+  public void withInlineEntitySetFromAtom() {
+    withInlineEntitySet(client, ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void withInlineEntitySetFromFullJSON() {
+    withInlineEntitySet(client, ContentType.JSON_FULL_METADATA);
+  }
+
+  @Test
+  public void withInlineEntitySetFromJSON() {
+    withInlineEntitySet(edmClient, ContentType.JSON);
+  }
+
+  private void rawRequest(final ContentType contentType) {
+    final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
+        appendEntitySetSegment("People").appendKeySegment(5);
+
+    final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
+    req.setFormat(contentType.toContentTypeString());
+
+    final ODataRawResponse res = req.execute();
+    assertNotNull(res);
+
+    final ResWrap<ClientEntitySet> entitySet = res.getBodyAs(ClientEntitySet.class);
+    assertNull(entitySet);
+
+    final ResWrap<ClientEntity> entity = res.getBodyAs(ClientEntity.class);
+    assertTrue(entity.getPayload().getId().toASCIIString().endsWith("/StaticService/V40/Static.svc/People(5)"));
+  }
+
+  @Test
+  public void rawRequestAsAtom() {
+    rawRequest(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void rawRequestAsJSON() {
+    // this needs to be full, otherwise reference will not be provided
+    rawRequest(ContentType.JSON_FULL_METADATA);
+  }
+
+  private void multiKey(final ContentType contentType) throws EdmPrimitiveTypeException {
+    final LinkedHashMap<String, Object> multiKey = new LinkedHashMap<String, Object>();
+    multiKey.put("ProductID", "6");
+    multiKey.put("ProductDetailID", 1);
+
+    final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
+        appendEntitySetSegment("ProductDetails").appendKeySegment(multiKey);
+
+    final ODataEntityRequest<ClientEntity> req =
+        client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
+    req.setFormat(contentType);
+
+    final ODataRetrieveResponse<ClientEntity> res = req.execute();
+    final ClientEntity entity = res.getBody();
+    assertNotNull(entity);
+    assertEquals(Integer.valueOf(1),
+        entity.getProperty("ProductDetailID").getPrimitiveValue().toCastValue(Integer.class));
+  }
+
+  @Test
+  public void multiKeyAsAtom() throws EdmPrimitiveTypeException {
+    multiKey(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void multiKeyAsJSON() throws EdmPrimitiveTypeException {
+    multiKey(ContentType.JSON_FULL_METADATA);
+  }
+
+  private void checkForETag(final ODataClient client, final ContentType contentType) {
+    final URIBuilder uriBuilder =
+        client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders").appendKeySegment(8);
+
+    final ODataEntityRequest<ClientEntity> req =
+        client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
+    req.setFormat(contentType);
+
+    final ODataRetrieveResponse<ClientEntity> res = req.execute();
+    assertEquals(200, res.getStatusCode());
+
+    final String etag = res.getETag();
+    assertTrue(StringUtils.isNotBlank(etag));
+
+    final ClientEntity order = res.getBody();
+    assertEquals(etag, order.getETag());
+    assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Order", order.getTypeName().toString());
+    assertEquals("Edm.Int32", order.getProperty("OrderID").getPrimitiveValue().getTypeName());
+    assertEquals("Edm.DateTimeOffset", order.getProperty("OrderDate").getPrimitiveValue().getTypeName());
+    assertEquals("Edm.Duration", order.getProperty("ShelfLife").getPrimitiveValue().getTypeName());
+    assertEquals("Collection(Edm.Duration)", order.getProperty("OrderShelfLifes").getCollectionValue().getTypeName());
+  }
+
+  @Test
+  public void checkForETagAsAtom() {
+    checkForETag(client, ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void checkForETagAsFullJSON() {
+    checkForETag(client, ContentType.JSON_FULL_METADATA);
+  }
+
+  @Test
+  public void checkForETagAsJSON() {
+    checkForETag(edmClient, ContentType.JSON);
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void issue99() {
+    final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders");
+
+    final ODataEntityRequest<ClientEntity> req =
+        client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
+    req.setFormat(ContentType.JSON);
+
+    // this statement should cause an IllegalArgumentException bearing JsonParseException
+    // since we are attempting to parse an EntitySet as if it was an Entity
+    req.execute().getBody();
+  }
+
+  private void reference(final ContentType contentType) {
+    final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
+        appendEntitySetSegment("Orders").appendKeySegment(8).appendNavigationSegment("CustomerForOrder").
+        appendRefSegment();
+
+    ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
+    req.setFormat(contentType);
+
+    ODataRetrieveResponse<ClientEntity> res = req.execute();
+    assertNotNull(res);
+
+    final ClientEntity entity = res.getBody();
+    assertNotNull(entity);
+    assertTrue(entity.getId().toASCIIString().endsWith("/StaticService/V40/Static.svc/Customers(PersonID=1)"));
+
+    final URI referenceURI = client.newURIBuilder(testStaticServiceRootURL).
+        appendEntityIdSegment(entity.getId().toASCIIString()).build();
+
+    req = client.getRetrieveRequestFactory().getEntityRequest(referenceURI);
+    req.setFormat(contentType);
+
+    res = req.execute();
+    assertNotNull(res);
+    assertNotNull(res.getBody());
+  }
+
+  @Test
+  public void atomReference() {
+    reference(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void jsonReference() {
+    reference(ContentType.JSON_FULL_METADATA);
+  }
+
+  private void contained(final ODataClient client, final ContentType contentType) throws EdmPrimitiveTypeException {
+    final URI uri = client.newURIBuilder(testStaticServiceRootURL).
+        appendEntitySetSegment("Accounts").appendKeySegment(101).
+        appendNavigationSegment("MyPaymentInstruments").appendKeySegment(101902).build();
+    final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uri);
+    req.setFormat(contentType);
+
+    final ClientEntity contained = req.execute().getBody();
+    assertNotNull(contained);
+    assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument", contained.getTypeName().toString());
+    assertEquals(101902,
+        contained.getProperty("PaymentInstrumentID").getPrimitiveValue().toCastValue(Integer.class), 0);
+    assertEquals("Edm.DateTimeOffset", contained.getProperty("CreatedDate").getPrimitiveValue().getTypeName());
+    assertNotNull(contained.getProperty("CreatedDate").getPrimitiveValue().toCastValue(Timestamp.class));
+  }
+
+  @Test
+  public void containedFromAtom() throws EdmPrimitiveTypeException {
+    contained(client, ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void containedFromFullJSON() throws EdmPrimitiveTypeException {
+    contained(client, ContentType.JSON_FULL_METADATA);
+  }
+
+  @Test
+  public void containedFromJSON() throws EdmPrimitiveTypeException {
+    contained(edmClient, ContentType.JSON);
+  }
+
+  private void entitySetNavigationLink(final ODataClient client, final ContentType contentType) {
+    final URI uri = client.newURIBuilder(testStaticServiceRootURL).
+        appendEntitySetSegment("Accounts").appendKeySegment(101).build();
+    final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uri);
+    req.setFormat(contentType);
+
+    final ClientEntity entity = req.execute().getBody();
+    assertNotNull(entity);
+
+    // With JSON, entity set navigation links are only recognizable via Edm
+    if (contentType.equals(ContentType.APPLICATION_ATOM_XML) || client instanceof EdmEnabledODataClient) {
+      assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("MyPaymentInstruments").getType());
+      assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("ActiveSubscriptions").getType());
+    }
+  }
+
+  @Test
+  public void entitySetNavigationLinkFromAtom() {
+    entitySetNavigationLink(client, ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void entitySetNavigationLinkFromJSON() {
+    // only JSON_FULL_METADATA has links, only Edm can recognize entity set navigation
+    entitySetNavigationLink(edmClient, ContentType.JSON_FULL_METADATA);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/base/EntitySetTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/base/EntitySetTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/base/EntitySetTestITCase.java
new file mode 100644
index 0000000..f3e784a
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/base/EntitySetTestITCase.java
@@ -0,0 +1,178 @@
+/*
+ * 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.fit.base;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetIteratorRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataRawRequest;
+import org.apache.olingo.client.api.communication.response.ODataRawResponse;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.domain.ClientEntity;
+import org.apache.olingo.client.api.domain.ClientEntitySet;
+import org.apache.olingo.client.api.domain.ClientEntitySetIterator;
+import org.apache.olingo.client.api.uri.URIBuilder;
+import org.apache.olingo.client.core.uri.URIUtils;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.junit.Test;
+
+/**
+ * This is the unit test class to check basic feed operations.
+ */
+public class EntitySetTestITCase extends AbstractTestITCase {
+
+  private void rawRequest(final ContentType contentType) {
+    final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
+
+    final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
+    req.setFormat(contentType.toContentTypeString());
+
+    final ODataRawResponse res = req.execute();
+    assertNotNull(res);
+
+    final ResWrap<ClientEntitySet> entitySet = res.getBodyAs(ClientEntitySet.class);
+    assertNotNull(entitySet.getPayload());
+    assertTrue(entitySet.getContextURL().toASCIIString().endsWith("$metadata#People"));
+  }
+
+  @Test
+  public void rawRequestAsAtom() throws IOException {
+    rawRequest(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void rawRequestAsJSON() throws IOException {
+    rawRequest(ContentType.JSON);
+  }
+
+  private void readWithInlineCount(final ODataClient client, final ContentType contentType) {
+    final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
+        appendEntitySetSegment("People").count(true);
+
+    final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
+    req.setFormat(contentType.toContentTypeString());
+
+    final ODataRawResponse res = req.execute();
+    assertNotNull(res);
+
+    final ResWrap<ClientEntitySet> entitySet = res.getBodyAs(ClientEntitySet.class);
+    assertEquals(5, entitySet.getPayload().getEntities().size());
+
+    assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Address",
+        entitySet.getPayload().getEntities().get(2).getProperty("HomeAddress").getComplexValue().getTypeName());
+  }
+
+  @Test
+  public void readWithInlineCountAsJSON() throws IOException {
+    readWithInlineCount(edmClient, ContentType.JSON);
+  }
+
+  @Test
+  public void readWithInlineCountAsFullJSON() throws IOException {
+    readWithInlineCount(client, ContentType.JSON_FULL_METADATA);
+  }
+
+  @Test
+  public void readWithInlineCountAsAtom() throws IOException {
+    readWithInlineCount(client, ContentType.APPLICATION_ATOM_XML);
+  }
+
+  private void readODataEntitySetIterator(final ContentType contentType) {
+    final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
+
+    final ODataEntitySetIteratorRequest<ClientEntitySet, ClientEntity> req =
+        client.getRetrieveRequestFactory().getEntitySetIteratorRequest(uriBuilder.build());
+    req.setFormat(contentType);
+
+    final ODataRetrieveResponse<ClientEntitySetIterator<ClientEntitySet, ClientEntity>> res = req.execute();
+    final ClientEntitySetIterator<ClientEntitySet, ClientEntity> feedIterator = res.getBody();
+
+    assertNotNull(feedIterator);
+
+    int count = 0;
+
+    while (feedIterator.hasNext()) {
+      assertNotNull(feedIterator.next());
+      count++;
+    }
+    assertEquals(5, count);
+    assertTrue(feedIterator.getNext().toASCIIString().endsWith("People?$skiptoken=5"));
+  }
+
+  @Test
+  public void readODataEntitySetIteratorFromAtom() {
+    readODataEntitySetIterator(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void readODataEntitySetIteratorFromJSON() {
+    readODataEntitySetIterator(ContentType.JSON);
+  }
+
+  @Test
+  public void readODataEntitySetIteratorFromJSONFull() {
+    readODataEntitySetIterator(ContentType.JSON_FULL_METADATA);
+  }
+
+  @Test
+  public void readODataEntitySetIteratorFromJSONNo() {
+    readODataEntitySetIterator(ContentType.JSON_NO_METADATA);
+  }
+
+  private void readWithNext(final ContentType format) {
+    final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
+
+    final ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().
+        getEntitySetRequest(uriBuilder.build());
+    req.setFormat(format);
+    req.setPrefer(client.newPreferences().maxPageSize(5));
+
+    final ODataRetrieveResponse<ClientEntitySet> res = req.execute();
+    final ClientEntitySet feed = res.getBody();
+
+    assertNotNull(feed);
+
+    assertEquals(5, feed.getEntities().size());
+    assertNotNull(feed.getNext());
+
+    final URI expected = URI.create(testStaticServiceRootURL + "/People?$skiptoken=5");
+    final URI found = URIUtils.getURI(testStaticServiceRootURL, feed.getNext().toASCIIString());
+
+    assertEquals(expected, found);
+  }
+
+  @Test
+  public void readWithNextFromAtom() {
+    readWithNext(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void readWithNextFromJSON() {
+    readWithNext(ContentType.JSON_FULL_METADATA);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/base/EntityUpdateTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/base/EntityUpdateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/base/EntityUpdateTestITCase.java
new file mode 100644
index 0000000..aa2bc06
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/base/EntityUpdateTestITCase.java
@@ -0,0 +1,185 @@
+/*
+ * 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.fit.base;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.math.BigDecimal;
+import java.net.URI;
+import java.util.Calendar;
+import java.util.TimeZone;
+import java.util.UUID;
+
+import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
+import org.apache.olingo.client.api.communication.request.cud.ODataReferenceAddingRequest;
+import org.apache.olingo.client.api.communication.request.cud.UpdateType;
+import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
+import org.apache.olingo.client.api.communication.response.ODataReferenceAddingResponse;
+import org.apache.olingo.client.api.domain.ClientEntity;
+import org.apache.olingo.client.api.domain.ClientLink;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class EntityUpdateTestITCase extends AbstractTestITCase {
+
+  private void upsert(final UpdateType updateType, final ContentType contentType) {
+    final ClientEntity order = getClient().getObjectFactory().
+        newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order"));
+
+    order.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("OrderID",
+        getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(9)));
+    order.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("OrderDate",
+        getClient().getObjectFactory().newPrimitiveValueBuilder()
+        .setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(
+            Calendar.getInstance(TimeZone.getTimeZone("GMT"))).build()));
+    order.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("ShelfLife",
+        getClient().getObjectFactory().newPrimitiveValueBuilder().
+        setType(EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal("0.0000002")).build()));
+
+    final URI upsertURI = getClient().newURIBuilder(testStaticServiceRootURL).
+        appendEntitySetSegment("Orders").appendKeySegment(9).build();
+    final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
+        getEntityUpdateRequest(upsertURI, updateType, order);
+    req.setFormat(contentType);
+
+    req.execute();
+    try {
+      final ClientEntity read = read(contentType, upsertURI);
+      assertNotNull(read);
+      assertEquals(order.getProperty("OrderID"), read.getProperty("OrderID"));
+      assertEquals(order.getProperty("OrderDate").getPrimitiveValue().toString(),
+          read.getProperty("OrderDate").getPrimitiveValue().toString());
+      assertEquals(order.getProperty("ShelfLife").getPrimitiveValue().toString(),
+          read.getProperty("ShelfLife").getPrimitiveValue().toString());
+    } finally {
+      getClient().getCUDRequestFactory().getDeleteRequest(upsertURI).execute();
+    }
+  }
+
+  @Test
+  @Ignore
+  public void testUpateSingleValuedNavtiogationReference() throws Exception {
+    URI targetURI =
+        getClient().newURIBuilder(testStaticServiceRootURL)
+        .appendEntitySetSegment("People")
+        .appendKeySegment(1)
+        .appendNavigationSegment("Parent")
+        .build();
+
+    URI reference = getClient().newURIBuilder(testStaticServiceRootURL)
+        .appendEntitySetSegment("People")
+        .appendKeySegment(0)
+        .build();
+
+    final ODataReferenceAddingRequest request =
+        getClient().getCUDRequestFactory().getReferenceSingleChangeRequest(new URI(testStaticServiceRootURL),
+            targetURI, reference);
+
+    final ODataReferenceAddingResponse response = request.execute();
+
+    assertEquals(204, response.getStatusCode());
+  }
+
+  @Test
+  public void atomUpsert() {
+    upsert(UpdateType.PATCH, ContentType.APPLICATION_ATOM_XML);
+    upsert(UpdateType.REPLACE, ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void jsonUpsert() {
+    upsert(UpdateType.PATCH, ContentType.JSON);
+    upsert(UpdateType.REPLACE, ContentType.JSON);
+  }
+
+  private void onContained(final ContentType contentType) {
+    final String newName = UUID.randomUUID().toString();
+    final ClientEntity changes = getClient().getObjectFactory().newEntity(
+        new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument"));
+    changes.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("FriendlyName",
+        getClient().getObjectFactory().newPrimitiveValueBuilder().buildString(newName)));
+
+    final URI uri = getClient().newURIBuilder(testStaticServiceRootURL).
+        appendEntitySetSegment("Accounts").appendKeySegment(101).
+        appendNavigationSegment("MyPaymentInstruments").appendKeySegment(101901).build();
+    final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
+        getEntityUpdateRequest(uri, UpdateType.PATCH, changes);
+    req.setFormat(contentType);
+
+    final ODataEntityUpdateResponse<ClientEntity> res = req.execute();
+    assertEquals(204, res.getStatusCode());
+
+    final ClientEntity actual = getClient().getRetrieveRequestFactory().getEntityRequest(uri).execute().getBody();
+    assertNotNull(actual);
+    assertEquals(newName, actual.getProperty("FriendlyName").getPrimitiveValue().toString());
+  }
+
+  @Test
+  public void atomOnContained() {
+    onContained(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void jsonOnContained() {
+    onContained(ContentType.JSON);
+  }
+
+  private void bindOperation(final ContentType contentType) throws EdmPrimitiveTypeException {
+    final ClientEntity changes = getClient().getObjectFactory().newEntity(
+        new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
+    final ClientLink parent = getClient().getObjectFactory().newEntityNavigationLink("Parent",
+        getClient().newURIBuilder(testStaticServiceRootURL).
+        appendEntitySetSegment("People").appendKeySegment(1).build());
+    changes.getNavigationLinks().add(parent);
+
+    final URI uri = getClient().newURIBuilder(testStaticServiceRootURL).
+        appendEntitySetSegment("People").appendKeySegment(5).build();
+    final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
+        getEntityUpdateRequest(uri, UpdateType.PATCH, changes);
+    req.setFormat(contentType);
+
+    final ODataEntityUpdateResponse<ClientEntity> res = req.execute();
+    assertEquals(204, res.getStatusCode());
+
+    final ClientEntity updated = getClient().getRetrieveRequestFactory().getEntityRequest(uri).execute().getBody();
+    assertNotNull(updated);
+    final ClientLink updatedLink = updated.getNavigationLink("Parent");
+    assertNotNull(updatedLink);
+
+    final ClientEntity updatedEntity = getClient().getRetrieveRequestFactory().getEntityRequest(updatedLink.getLink()).
+        execute().getBody();
+    assertNotNull(updatedEntity);
+    assertEquals(1, updatedEntity.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0);
+  }
+
+  @Test
+  public void atomBindOperation() throws EdmPrimitiveTypeException {
+    bindOperation(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void jsonBindOperation() throws EdmPrimitiveTypeException {
+    bindOperation(ContentType.JSON);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/base/ErrorResponseTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/base/ErrorResponseTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/base/ErrorResponseTestITCase.java
new file mode 100644
index 0000000..d386bbe
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/base/ErrorResponseTestITCase.java
@@ -0,0 +1,62 @@
+/*
+ * 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.fit.base;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.net.URI;
+import java.util.Map;
+
+import org.apache.olingo.client.api.communication.ODataClientErrorException;
+import org.apache.olingo.commons.api.ex.ODataError;
+import org.apache.olingo.commons.api.ex.ODataErrorDetail;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.junit.Test;
+
+public class ErrorResponseTestITCase extends AbstractTestITCase {
+
+  @Test
+  public void jsonError() {
+    final URI readURI = getClient().newURIBuilder(testStaticServiceRootURL).
+        appendEntitySetSegment("Customers").appendKeySegment(32).
+        build();
+
+    try {
+      read(ContentType.JSON, readURI);
+      fail("should have got exception");
+    } catch (Exception ex) {
+      final ODataError err = ((ODataClientErrorException) ex).getODataError();
+
+      // verify details
+      final ODataErrorDetail detail = err.getDetails().get(0);
+      assertEquals("Code should be correct", "301", detail.getCode());
+      assertEquals("Target should be correct", "$search", detail.getTarget());
+      assertEquals("Message should be correct", "$search query option not supported", detail.getMessage());
+
+      // verify inner error dictionary
+      final Map<String, String> innerErr = err.getInnerError();
+      assertEquals("innerError dictionary size should be correct", 2, innerErr.size());
+      assertEquals("innerError['context'] should be correct",
+          "{\"key1\":\"for debug deployment only\"}", innerErr.get("context"));
+      assertEquals("innerError['trace'] should be correct",
+          "[\"callmethod1 etc\",\"callmethod2 etc\"]", innerErr.get("trace"));
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/base/FilterFactoryTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/base/FilterFactoryTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/base/FilterFactoryTestITCase.java
new file mode 100644
index 0000000..ccf97a0
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/base/FilterFactoryTestITCase.java
@@ -0,0 +1,62 @@
+/*
+ * 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.fit.base;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
+import org.apache.olingo.client.api.domain.ClientEntity;
+import org.apache.olingo.client.api.domain.ClientEntitySet;
+import org.apache.olingo.client.api.uri.FilterArgFactory;
+import org.apache.olingo.client.api.uri.FilterFactory;
+import org.apache.olingo.client.api.uri.URIBuilder;
+import org.apache.olingo.client.api.uri.URIFilter;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.junit.Test;
+
+public class FilterFactoryTestITCase extends AbstractTestITCase {
+
+  private FilterFactory getFilterFactory() {
+    return getClient().getFilterFactory();
+  }
+
+  private FilterArgFactory getFilterArgFactory() {
+    return getFilterFactory().getArgFactory();
+  }
+
+  @Test
+  public void crossjoin() {
+    final URIFilter filter = getFilterFactory().eq(
+        getFilterArgFactory().property("Orders/OrderID"), getFilterArgFactory().property("Customers/Order"));
+
+    final URIBuilder uriBuilder =
+        client.newURIBuilder(testStaticServiceRootURL).appendCrossjoinSegment("Customers", "Orders").filter(filter);
+
+    final ODataEntitySetRequest<ClientEntitySet> req =
+        client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
+    req.setFormat(ContentType.JSON_FULL_METADATA);
+
+    final ClientEntitySet feed = req.execute().getBody();
+    assertEquals(3, feed.getEntities().size());
+
+    for (ClientEntity entity : feed.getEntities()) {
+      assertEquals(2, entity.getNavigationLinks().size());
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/base/JSONFormatConformanceTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/base/JSONFormatConformanceTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/base/JSONFormatConformanceTestITCase.java
new file mode 100644
index 0000000..4f8a779
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/base/JSONFormatConformanceTestITCase.java
@@ -0,0 +1,333 @@
+/*
+ * 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.fit.base;
+
+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.math.BigDecimal;
+import java.net.URI;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.domain.ClientAnnotation;
+import org.apache.olingo.client.api.domain.ClientEntity;
+import org.apache.olingo.client.api.domain.ClientEntitySet;
+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.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.junit.Test;
+
+/**
+ * The test cases in this class are inspired by client conformance criteria defined in the <a
+ * href="http://docs.oasis-open.org/odata/odata-json-format/v4.0/os/odata-json-format-v4.0-os.html#_Toc372793094">specs
+ * </a>.
+ */
+public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
+
+  /**
+   * MUST either:
+   * <ol>
+   * <li>understand <tt>odata.metadata=minimal</tt> (section 3.1.1) or</li>
+   * <li>explicitly specify <tt>odata.metadata=none</tt>(section 3.1.3) or <tt>odata.metadata=full</tt> (section 3.1.2)
+   * in the request (client)</li>
+   * </ol>
+   * .
+   */
+  @Test
+  public void item1() throws EdmPrimitiveTypeException {
+    final URI uri = edmClient.newURIBuilder().
+        appendEntitySetSegment("Accounts").appendKeySegment(102).
+        appendNavigationSegment("MyPaymentInstruments").appendKeySegment(102902).build();
+    final ODataEntityRequest<ClientEntity> req = edmClient.getRetrieveRequestFactory().getEntityRequest(uri);
+
+    // request format (via Accept header) is set to minimal by default
+    assertEquals("application/json;odata.metadata=minimal", req.getAccept());
+
+    final ODataRetrieveResponse<ClientEntity> res = req.execute();
+
+    // response is odata.metadata=minimal
+    assertFalse(res.getContentType().contains("odata.metadata=none"));
+    assertFalse(res.getContentType().contains("odata.metadata=full"));
+
+    // response payload is understood
+    final ClientEntity entity = res.getBody();
+    assertNotNull(entity);
+    assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument", entity.getTypeName().toString());
+    assertEquals(102902, entity.getProperty("PaymentInstrumentID").getPrimitiveValue().toCastValue(Integer.class), 0);
+    assertEquals("Edm.DateTimeOffset", entity.getProperty("CreatedDate").getPrimitiveValue().getTypeName());
+  }
+
+  /**
+   * MUST be prepared to consume a response with full metadata.
+   */
+  @Test
+  public void item2() {
+    final URI uri = edmClient.newURIBuilder(testStaticServiceRootURL).
+        appendEntitySetSegment("Accounts").appendKeySegment(102).build();
+    final ODataEntityRequest<ClientEntity> req = edmClient.getRetrieveRequestFactory().getEntityRequest(uri);
+    req.setFormat(ContentType.JSON_FULL_METADATA);
+
+    // request format (via Accept header) is set to full metadata
+    assertEquals("application/json;odata.metadata=full", req.getAccept());
+
+    final ODataRetrieveResponse<ClientEntity> res = req.execute();
+
+    // response is odata.metadata=full
+    assertTrue(res.getContentType().contains("odata.metadata=full"));
+
+    // response payload is understood (including links, only returned with full metadata)
+    final ClientEntity entity = res.getBody();
+    assertNotNull(entity);
+    assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("MyPaymentInstruments").getType());
+    assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("ActiveSubscriptions").getType());
+  }
+
+  /**
+   * MUST be prepared to receive all data types (section 7.1)
+   * <ol>
+   * <li>defined in this specification (client)</li>
+   * <li>exposed by the service (service)</li>
+   * </ol>
+   * .
+   */
+  @Test
+  public void item3() throws Exception {
+    final String fromSection71 = "{"
+        + "\"NullValue\": null,"
+        + "\"TrueValue\": true,"
+        + "\"FalseValue\": false,"
+        + "\"BinaryValue@odata.type\": \"Binary\","
+        + "\"BinaryValue\": \"T0RhdGE\","
+        + "\"IntegerValue\": -128,"
+        + "\"DoubleValue\": 3.1415926535897931,"
+        + "\"SingleValue@odata.type\": \"Single\","
+        + "\"SingleValue\": \"INF\","
+        + "\"DecimalValue@odata.type\": \"Decimal\","
+        + "\"DecimalValue\": 34.95,"
+        + "\"StringValue\": \"Say \\\"Hello\\\",\\nthen go\","
+        + "\"DateValue@odata.type\": \"Date\","
+        + "\"DateValue\": \"2012-12-03\","
+        + "\"DateTimeOffsetValue@odata.type\": \"DateTimeOffset\","
+        + "\"DateTimeOffsetValue\": \"2012-12-03T07:16:23Z\","
+        + "\"DurationValue@odata.type\": \"Duration\","
+        + "\"DurationValue\": \"P12DT23H59M59.999999999999S\","
+        + "\"TimeOfDayValue@odata.type\": \"TimeOfDay\","
+        + "\"TimeOfDayValue\": \"07:59:59.999\","
+        + "\"GuidValue@odata.type\": \"Guid\","
+        + "\"GuidValue\": \"01234567-89ab-cdef-0123-456789abcdef\","
+        + "\"Int64Value@odata.type\": \"Int64\","
+        + "\"Int64Value\": 0,"
+        + "\"ColorEnumValue@odata.type\": \"Test.Color\","
+        + "\"ColorEnumValue\": \"Yellow\","
+        + "\"GeographyPoint\": {\"type\": \"Point\",\"coordinates\":[142.1,64.1]}"
+        + "}";
+
+    final ClientEntity entity = client.getReader().readEntity(IOUtils.toInputStream(fromSection71), ContentType.JSON);
+
+    assertTrue(entity.getProperty("NullValue").hasNullValue());
+
+    assertEquals(EdmPrimitiveTypeKind.Boolean, entity.getProperty("TrueValue").getPrimitiveValue().getTypeKind());
+    assertEquals(Boolean.TRUE, entity.getProperty("TrueValue").getPrimitiveValue().toCastValue(Boolean.class));
+
+    assertEquals(EdmPrimitiveTypeKind.Boolean, entity.getProperty("FalseValue").getPrimitiveValue().getTypeKind());
+    assertEquals(Boolean.FALSE, entity.getProperty("FalseValue").getPrimitiveValue().toCastValue(Boolean.class));
+
+    assertEquals(EdmPrimitiveTypeKind.Binary, entity.getProperty("BinaryValue").getPrimitiveValue().getTypeKind());
+
+    assertEquals(EdmPrimitiveTypeKind.Int32, entity.getProperty("IntegerValue").getPrimitiveValue().getTypeKind());
+    assertEquals(-128, entity.getProperty("IntegerValue").getPrimitiveValue().toCastValue(Integer.class), 0);
+
+    assertEquals(EdmPrimitiveTypeKind.Double, entity.getProperty("DoubleValue").getPrimitiveValue().getTypeKind());
+    assertEquals(3.1415926535897931,
+        entity.getProperty("DoubleValue").getPrimitiveValue().toCastValue(Double.class), 0);
+
+    assertEquals(EdmPrimitiveTypeKind.Single, entity.getProperty("SingleValue").getPrimitiveValue().getTypeKind());
+    assertEquals(Float.POSITIVE_INFINITY,
+        entity.getProperty("SingleValue").getPrimitiveValue().toCastValue(Float.class), 0);
+
+    assertEquals(EdmPrimitiveTypeKind.Decimal, entity.getProperty("DecimalValue").getPrimitiveValue().getTypeKind());
+    assertEquals(BigDecimal.valueOf(34.95),
+        entity.getProperty("DecimalValue").getPrimitiveValue().toCastValue(BigDecimal.class));
+
+    assertEquals(EdmPrimitiveTypeKind.String, entity.getProperty("StringValue").getPrimitiveValue().getTypeKind());
+    assertEquals("Say \"Hello\",\nthen go",
+        entity.getProperty("StringValue").getPrimitiveValue().toCastValue(String.class));
+
+    assertEquals(EdmPrimitiveTypeKind.Date, entity.getProperty("DateValue").getPrimitiveValue().getTypeKind());
+
+    assertEquals(EdmPrimitiveTypeKind.DateTimeOffset,
+        entity.getProperty("DateTimeOffsetValue").getPrimitiveValue().getTypeKind());
+
+    assertEquals(EdmPrimitiveTypeKind.Duration, entity.getProperty("DurationValue").getPrimitiveValue().getTypeKind());
+
+    assertEquals(EdmPrimitiveTypeKind.TimeOfDay,
+        entity.getProperty("TimeOfDayValue").getPrimitiveValue().getTypeKind());
+
+    assertEquals(EdmPrimitiveTypeKind.Guid, entity.getProperty("GuidValue").getPrimitiveValue().getTypeKind());
+
+    assertEquals(EdmPrimitiveTypeKind.Int64, entity.getProperty("Int64Value").getPrimitiveValue().getTypeKind());
+
+    assertTrue(entity.getProperty("ColorEnumValue").hasEnumValue());
+
+    assertEquals(EdmPrimitiveTypeKind.GeographyPoint,
+        entity.getProperty("GeographyPoint").getPrimitiveValue().getTypeKind());
+  }
+
+  /**
+   * MUST interpret all odata annotations defined according to the OData-Version header of the payload (section 4.5).
+   */
+  @Test
+  public void item4() throws Exception {
+    final String fromSection45_1 = "{"
+        + "\"@odata.context\": \"http://host/service/$metadata#Customers/$entity\","
+        + "\"@odata.metadataEtag\": \"W/\\\"A1FF3E230954908F\\\"\","
+        + "\"@odata.etag\": \"W/\\\"A1FF3E230954908G\\\"\","
+        + "\"@odata.type\": \"#Model.VipCustomer\","
+        + "\"@odata.id\": \"http://host/service/Employees(PersonID=3)\","
+        + "\"@odata.editLink\": \"People(976)\","
+        + "\"@odata.mediaEditLink\": \"Employees(1)/$value\","
+        + "\"@odata.mediaContentType\": \"image/jpeg\","
+        + "\"@odata.mediaEtag\": \"W/\\\"A1FF3E230954908H\\\"\","
+        + "\"Parent@odata.navigationLink\": \"People(976)/Parent\","
+        + "\"Parent@odata.associationLink\": \"People(976)/Parent\""
+        + "}";
+
+    final ResWrap<Entity> entity =
+        client.getDeserializer(ContentType.JSON).toEntity(IOUtils.toInputStream(fromSection45_1));
+
+    assertEquals("http://host/service/$metadata#Customers/$entity", entity.getContextURL().toASCIIString());
+    assertEquals("W/\"A1FF3E230954908F\"", entity.getMetadataETag());
+    assertEquals("W/\"A1FF3E230954908G\"", entity.getPayload().getETag());
+    assertEquals("Model.VipCustomer", entity.getPayload().getType());
+    assertEquals("http://host/service/Employees(PersonID=3)", entity.getPayload().getId().toASCIIString());
+    assertEquals("People(976)", entity.getPayload().getEditLink().getHref());
+    assertEquals("Employees(1)/$value", entity.getPayload().getMediaContentSource().toASCIIString());
+    assertEquals("image/jpeg", entity.getPayload().getMediaContentType());
+    assertEquals("W/\"A1FF3E230954908H\"", entity.getPayload().getMediaETag());
+    assertEquals("People(976)/Parent", entity.getPayload().getNavigationLink("Parent").getHref());
+    assertEquals("People(976)/Parent", entity.getPayload().getAssociationLink("Parent").getHref());
+
+    final String fromSection45_2 = "{"
+        + "  \"@odata.count\": 5,"
+        + "  \"value\": [],"
+        + "  \"@odata.nextLink\": \"Customers?$expand=Orders&$skipToken=5\","
+        + "  \"@odata.deltaLink\": \"Customers?$expand=Orders&$deltatoken=8015\""
+        + "}";
+
+    final ResWrap<EntityCollection> entitySet =
+        client.getDeserializer(ContentType.JSON).toEntitySet(IOUtils.toInputStream(fromSection45_2));
+
+    assertEquals(5, entitySet.getPayload().getCount(), 0);
+    assertEquals("Customers?$expand=Orders&$skipToken=5", entitySet.getPayload().getNext().toASCIIString());
+    assertEquals("Customers?$expand=Orders&$deltatoken=8015", entitySet.getPayload().getDeltaLink().toASCIIString());
+  }
+
+  /**
+   * MUST be prepared to receive any annotations, including custom annotations and <tt>odata</tt> annotations not
+   * defined in the <tt>OData-Version</tt> header of the payload (section 20).
+   */
+  @Test
+  public void item5() throws Exception {
+    final String sample = "{"
+        + "  \"@odata.context\": \"http://host/service/$metadata#Customers\","
+        + "  \"@odata.notdefined\": 11,"
+        + "  \"@com.contoso.customer.setkind\": \"VIPs\","
+        + "  \"value\": ["
+        + "    {"
+        + "      \"@com.contoso.display.highlight\": true,"
+        + "      \"ID\": \"ALFKI\","
+        + "      \"CompanyName@com.contoso.display.style\": { \"title\": true, \"order\": 1 },"
+        + "      \"CompanyName\": \"Alfreds Futterkiste\","
+        + "      \"Orders@com.contoso.display.style\": { \"order\": 2 },"
+        + "      \"Orders@odata.navigationLink\": \"People(976)/Orders\""
+        + "    }"
+        + "  ]"
+        + "}";
+
+    final ClientEntitySet entitySet = client.getReader().
+        readEntitySet(IOUtils.toInputStream(sample), ContentType.JSON);
+
+    assertEquals(2, entitySet.getAnnotations().size());
+
+    final ClientAnnotation notdefined = entitySet.getAnnotations().get(0);
+    assertEquals("odata.notdefined", notdefined.getTerm());
+    assertEquals(11, notdefined.getPrimitiveValue().toCastValue(Integer.class), 0);
+
+    final ClientAnnotation setkind = entitySet.getAnnotations().get(1);
+    assertEquals("com.contoso.customer.setkind", setkind.getTerm());
+    assertEquals("VIPs", setkind.getPrimitiveValue().toCastValue(String.class));
+
+    final ClientEntity entity = entitySet.getEntities().get(0);
+    assertEquals(1, entity.getAnnotations().size());
+
+    final ClientAnnotation highlight = entity.getAnnotations().get(0);
+    assertEquals("com.contoso.display.highlight", highlight.getTerm());
+    assertEquals(Boolean.TRUE, highlight.getPrimitiveValue().toCastValue(Boolean.class));
+
+    final ClientProperty property = entity.getProperty("CompanyName");
+    assertEquals(1, property.getAnnotations().size());
+
+    final ClientAnnotation style = property.getAnnotations().get(0);
+    assertEquals("com.contoso.display.style", style.getTerm());
+    assertTrue(style.hasComplexValue());
+    assertEquals(Boolean.TRUE, style.getComplexValue().get("title").getPrimitiveValue().toCastValue(Boolean.class));
+    assertEquals(1, style.getComplexValue().get("order").getPrimitiveValue().toCastValue(Integer.class), 0);
+
+    final ClientLink orders = entity.getNavigationLink("Orders");
+    assertEquals(1, orders.getAnnotations().size());
+
+    final ClientAnnotation style2 = orders.getAnnotations().get(0);
+    assertEquals("com.contoso.display.style", style2.getTerm());
+    assertTrue(style2.hasComplexValue());
+    assertEquals(2, style2.getComplexValue().get("order").getPrimitiveValue().toCastValue(Integer.class), 0);
+  }
+
+  /**
+   * MUST NOT require <tt>odata.streaming=true</tt> in the <tt>Content-Type</tt> header (section 4.4).
+   */
+  @Test
+  public void item6() throws EdmPrimitiveTypeException {
+    final URI uri = edmClient.newURIBuilder().
+        appendEntitySetSegment("Accounts").appendKeySegment(102).
+        appendNavigationSegment("MyPaymentInstruments").appendKeySegment(102902).build();
+    final ODataEntityRequest<ClientEntity> req = edmClient.getRetrieveRequestFactory().getEntityRequest(uri);
+
+    // request format (via Accept header) does not contain odata.streaming=true
+    assertEquals("application/json;odata.metadata=minimal", req.getAccept());
+
+    final ODataRetrieveResponse<ClientEntity> res = req.execute();
+
+    // response payload is understood
+    final ClientEntity entity = res.getBody();
+    assertNotNull(entity);
+    assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument", entity.getTypeName().toString());
+    assertEquals(102902, entity.getProperty("PaymentInstrumentID").getPrimitiveValue().toCastValue(Integer.class), 0);
+    assertEquals("Edm.DateTimeOffset", entity.getProperty("CreatedDate").getPrimitiveValue().getTypeName());
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/base/KeyAsSegmentTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/base/KeyAsSegmentTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/base/KeyAsSegmentTestITCase.java
new file mode 100644
index 0000000..3670292
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/base/KeyAsSegmentTestITCase.java
@@ -0,0 +1,127 @@
+/*
+ * 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.fit.base;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
+import java.net.URI;
+
+import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
+import org.apache.olingo.client.api.communication.request.cud.UpdateType;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
+import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.domain.ClientEntity;
+import org.apache.olingo.client.api.domain.ClientProperty;
+import org.apache.olingo.client.api.uri.URIBuilder;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class KeyAsSegmentTestITCase extends AbstractTestITCase {
+
+  @BeforeClass
+  public static void enableKeyAsSegment() {
+    client.getConfiguration().setKeyAsSegment(true);
+  }
+
+  @AfterClass
+  public static void disableKeyAsSegment() {
+    client.getConfiguration().setKeyAsSegment(false);
+  }
+
+  private void read(final ContentType contentType) {
+    final URIBuilder uriBuilder = client.newURIBuilder(testKeyAsSegmentServiceRootURL).
+        appendEntitySetSegment("Accounts").appendKeySegment(101);
+
+    final ODataEntityRequest<ClientEntity> req =
+        client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
+    req.setFormat(contentType);
+
+    final ODataRetrieveResponse<ClientEntity> res = req.execute();
+    final ClientEntity entity = res.getBody();
+    assertNotNull(entity);
+
+    // In JSON with minimal metadata, links are not provided
+    if (contentType.equals(ContentType.APPLICATION_ATOM_XML) || contentType.equals(ContentType.JSON_FULL_METADATA)) {
+      assertFalse(entity.getEditLink().toASCIIString().contains("("));
+      assertFalse(entity.getEditLink().toASCIIString().contains(")"));
+    }
+  }
+
+  @Test
+  public void atomRead() {
+    read(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void jsonRead() {
+    read(ContentType.JSON);
+  }
+
+  @Test
+  public void atomCreateAndDelete() {
+    createAndDeleteOrder(testKeyAsSegmentServiceRootURL, ContentType.APPLICATION_ATOM_XML, 1000);
+  }
+
+  @Test
+  public void jsonCreateAndDelete() {
+    createAndDeleteOrder(testKeyAsSegmentServiceRootURL, ContentType.JSON_FULL_METADATA, 1001);
+  }
+
+  private void update(final ContentType contentType) {
+    final ClientEntity changes = getClient().getObjectFactory().newEntity(
+        new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
+    final ClientProperty middleName = getClient().getObjectFactory().newPrimitiveProperty("MiddleName",
+        getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("middle"));
+    changes.getProperties().add(middleName);
+
+    final URI uri = getClient().newURIBuilder(testKeyAsSegmentServiceRootURL).
+        appendEntitySetSegment("People").appendKeySegment(5).build();
+    final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
+        getEntityUpdateRequest(uri, UpdateType.PATCH, changes);
+    req.setFormat(contentType);
+
+    final ODataEntityUpdateResponse<ClientEntity> res = req.execute();
+    assertEquals(204, res.getStatusCode());
+
+    final ClientEntity updated = getClient().getRetrieveRequestFactory().getEntityRequest(uri).execute().getBody();
+    assertNotNull(updated);
+    assertFalse(updated.getEditLink().toASCIIString().contains("("));
+    assertFalse(updated.getEditLink().toASCIIString().contains(")"));
+
+    final ClientProperty updatedMiddleName = updated.getProperty("MiddleName");
+    assertNotNull(updatedMiddleName);
+    assertEquals("middle", updatedMiddleName.getPrimitiveValue().toString());
+  }
+
+  @Test
+  public void atomUpdate() {
+    update(ContentType.APPLICATION_ATOM_XML);
+  }
+
+  @Test
+  public void jsonUpdate() {
+    update(ContentType.JSON);
+  }
+}