You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by fm...@apache.org on 2014/03/14 18:33:35 UTC

[03/19] [OLINGO-175, OLINGO-205] imported all V3 test. Missing: invoke request (requires refactoring) + not yet supported functionalities by the static server (action overloading, media entity CRUD, property CUD)

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/a835edd1/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java
new file mode 100644
index 0000000..32ee8eb
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java
@@ -0,0 +1,480 @@
+/*
+ * 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.it.v3;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.net.URI;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Set;
+import org.apache.http.entity.ContentType;
+import org.apache.olingo.client.api.communication.header.HeaderName;
+import org.apache.olingo.client.api.communication.header.ODataHeaderValues;
+import org.apache.olingo.client.api.communication.request.UpdateType;
+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.ODataDeleteResponse;
+import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.domain.ODataEntity;
+import org.apache.olingo.client.api.domain.ODataEntitySet;
+import org.apache.olingo.client.api.domain.ODataInlineEntitySet;
+import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
+import org.apache.olingo.client.api.domain.ODataLink;
+import org.apache.olingo.client.api.domain.ODataProperty;
+import org.apache.olingo.client.api.format.ODataPubFormat;
+import org.apache.olingo.client.api.http.NoContentException;
+import org.apache.olingo.client.api.uri.URIBuilder;
+import org.apache.olingo.client.api.utils.URIUtils;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * This is the unit test class to check create entity operations.
+ */
+public class EntityCreateTestITCase extends AbstractV3TestITCase {
+
+  protected String getServiceRoot() {
+    return testStaticServiceRootURL;
+  }
+
+  @Test
+  public void createAsAtom() {
+    final ODataPubFormat format = ODataPubFormat.ATOM;
+    final int id = 1;
+    final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
+
+    createEntity(getServiceRoot(), format, original, "Customer");
+    final ODataEntity actual = compareEntities(getServiceRoot(), format, original, id, null);
+
+    cleanAfterCreate(format, actual, false, getServiceRoot());
+  }
+
+  @Test
+  public void createAsJSON() {
+    final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+    final int id = 2;
+    final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
+
+    createEntity(getServiceRoot(), format, original, "Customer");
+    final ODataEntity actual = compareEntities(getServiceRoot(), format, original, id, null);
+
+    cleanAfterCreate(format, actual, false, getServiceRoot());
+  }
+
+  @Test
+  public void createWithInlineAsAtom() {
+    final ODataPubFormat format = ODataPubFormat.ATOM;
+    final int id = 3;
+    final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", true);
+
+    createEntity(getServiceRoot(), format, original, "Customer");
+    final ODataEntity actual =
+            compareEntities(getServiceRoot(), format, original, id, Collections.<String>singleton("Info"));
+
+    cleanAfterCreate(format, actual, true, getServiceRoot());
+  }
+
+  @Test
+  public void createWithInlineAsJSON() {
+    // this needs to be full, otherwise there is no mean to recognize links
+    final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+    final int id = 4;
+    final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", true);
+
+    createEntity(getServiceRoot(), format, original, "Customer");
+    final ODataEntity actual =
+            compareEntities(getServiceRoot(), format, original, id, Collections.<String>singleton("Info"));
+
+    cleanAfterCreate(format, actual, true, getServiceRoot());
+  }
+
+  @Test
+  public void createInlineWithoutLinkAsAtom() {
+    final ODataPubFormat format = ODataPubFormat.ATOM;
+    final int id = 5;
+    final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
+
+    original.addLink(client.getObjectFactory().newInlineEntity(
+            "Info", null, getSampleCustomerInfo(id, "Sample Customer_Info")));
+
+    createEntity(getServiceRoot(), format, original, "Customer");
+    final ODataEntity actual =
+            compareEntities(getServiceRoot(), format, original, id, Collections.<String>singleton("Info"));
+
+    boolean found = false;
+
+    for (ODataLink link : actual.getNavigationLinks()) {
+      assertNotNull(link.getLink());
+      if (link.getLink().toASCIIString().endsWith("Customer(" + id + ")/Info")) {
+        found = true;
+      }
+    }
+
+    assertTrue(found);
+
+    cleanAfterCreate(format, actual, true, getServiceRoot());
+  }
+
+  @Test
+  public void createInlineWithoutLinkAsJSON() {
+    final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+    final int id = 6;
+    final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
+
+    original.addLink(client.getObjectFactory().newInlineEntity(
+            "Info", null, getSampleCustomerInfo(id, "Sample Customer_Info")));
+
+    createEntity(getServiceRoot(), format, original, "Customer");
+    final ODataEntity actual =
+            compareEntities(getServiceRoot(), format, original, id, Collections.<String>singleton("Info"));
+
+    boolean found = false;
+
+    for (ODataLink link : actual.getNavigationLinks()) {
+      assertNotNull(link.getLink());
+      if (link.getLink().toASCIIString().endsWith("Customer(" + id + ")/Info")) {
+        found = true;
+      }
+    }
+
+    assertTrue(found);
+
+    cleanAfterCreate(format, actual, true, getServiceRoot());
+  }
+
+  @Test
+  public void createWithNavigationAsAtom() {
+    final ODataPubFormat format = ODataPubFormat.ATOM;
+    final ODataEntity actual = createWithNavigationLink(format, 5);
+    cleanAfterCreate(format, actual, false, getServiceRoot());
+  }
+
+  @Test
+  public void createWithNavigationAsJSON() {
+    // this needs to be full, otherwise there is no mean to recognize links
+    final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+    final ODataEntity actual = createWithNavigationLink(format, 6);
+    cleanAfterCreate(format, actual, false, getServiceRoot());
+  }
+
+  @Test
+  public void createWithFeedNavigationAsAtom() {
+    final ODataPubFormat format = ODataPubFormat.ATOM;
+    final ODataEntity actual = createWithFeedNavigationLink(format, 7);
+    cleanAfterCreate(format, actual, false, getServiceRoot());
+  }
+
+  @Test
+  public void createWithFeedNavigationAsJSON() {
+    // this needs to be full, otherwise there is no mean to recognize links
+    final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+    final ODataEntity actual = createWithFeedNavigationLink(format, 8);
+    cleanAfterCreate(format, actual, false, getServiceRoot());
+  }
+
+  @Test
+  public void createWithBackNavigationAsAtom() {
+    final ODataPubFormat format = ODataPubFormat.ATOM;
+    final ODataEntity actual = createWithBackNavigationLink(format, 9);
+    cleanAfterCreate(format, actual, true, getServiceRoot());
+  }
+
+  @Test
+  public void createWithBackNavigationAsJSON() {
+    // this needs to be full, otherwise there is no mean to recognize links
+    final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+    final ODataEntity actual = createWithBackNavigationLink(format, 10);
+    cleanAfterCreate(format, actual, true, getServiceRoot());
+  }
+
+  @Test
+  public void multiKeyAsAtom() {
+    multiKey(ODataPubFormat.ATOM);
+  }
+
+  @Test
+  public void multiKeyAsJSON() {
+    multiKey(ODataPubFormat.JSON);
+  }
+
+  @Test
+  public void createReturnNoContent() {
+    final int id = 1;
+    final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
+
+    final ODataEntityCreateRequest createReq = client.getCUDRequestFactory().getEntityCreateRequest(
+            client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer").build(), original);
+    createReq.setPrefer(ODataHeaderValues.preferReturnNoContent);
+
+    final ODataEntityCreateResponse createRes = createReq.execute();
+    assertEquals(204, createRes.getStatusCode());
+    assertEquals(ODataHeaderValues.preferReturnNoContent,
+            createRes.getHeader(HeaderName.preferenceApplied).iterator().next());
+
+    try {
+      createRes.getBody();
+      fail();
+    } catch (NoContentException e) {
+      assertNotNull(e);
+    }
+
+    final ODataDeleteResponse deleteRes = client.getCUDRequestFactory().getDeleteRequest(
+            client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer").appendKeySegment(id).build()).
+            execute();
+    assertEquals(204, deleteRes.getStatusCode());
+  }
+
+  @Test
+  @Ignore
+  public void issue135() {
+    final int id = 2;
+    final ODataEntity original = getSampleCustomerProfile(id, "Sample customer for issue 135", false);
+
+    final URIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer");
+    final ODataEntityCreateRequest createReq =
+            client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), original);
+    createReq.setFormat(ODataPubFormat.JSON_FULL_METADATA);
+    createReq.setContentType(ContentType.APPLICATION_ATOM_XML.getMimeType());
+    createReq.setPrefer(ODataHeaderValues.preferReturnContent);
+
+    try {
+      final ODataEntityCreateResponse createRes = createReq.execute();
+      assertEquals(201, createRes.getStatusCode());
+    } catch (Exception e) {
+      fail(e.getMessage());
+    } finally {
+      final ODataDeleteResponse deleteRes = client.getCUDRequestFactory().getDeleteRequest(
+              client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer").appendKeySegment(id).
+              build()).
+              execute();
+      assertEquals(204, deleteRes.getStatusCode());
+    }
+  }
+
+  private ODataEntity createWithFeedNavigationLink(final ODataPubFormat format, final int id) {
+    final String sampleName = "Sample customer";
+    final ODataEntity original = getSampleCustomerProfile(id, sampleName, false);
+
+    final Set<Integer> keys = new HashSet<Integer>();
+    keys.add(-100);
+    keys.add(-101);
+
+    for (Integer key : keys) {
+      final ODataEntity order =
+              client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Order");
+
+      order.getProperties().add(client.getObjectFactory().newPrimitiveProperty("OrderId",
+              client.getPrimitiveValueBuilder().setValue(key).setType(ODataJClientEdmPrimitiveType.Int32)
+              .build()));
+      order.getProperties().add(client.getObjectFactory().newPrimitiveProperty("CustomerId",
+              client.getPrimitiveValueBuilder().setValue(id).setType(ODataJClientEdmPrimitiveType.Int32)
+              .build()));
+
+      final ODataEntityCreateRequest createReq = client.getCUDRequestFactory().getEntityCreateRequest(
+              client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Order").build(), order);
+      createReq.setFormat(format);
+
+      original.addLink(client.getObjectFactory().newFeedNavigationLink(
+              "Orders",
+              createReq.execute().getBody().getEditLink()));
+    }
+
+    final ODataEntity created = createEntity(getServiceRoot(), format, original, "Customer");
+    // now, compare the created one with the actual one and go deeply into the associated customer info.....
+    final ODataEntity actual = compareEntities(getServiceRoot(), format, created, id, null);
+
+    final URIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot());
+    uriBuilder.appendEntitySetSegment("Customer").appendKeySegment(id).appendEntitySetSegment("Orders");
+
+    final ODataEntitySetRequest req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
+    req.setFormat(format);
+
+    final ODataRetrieveResponse<ODataEntitySet> res = req.execute();
+    assertEquals(200, res.getStatusCode());
+
+    final ODataEntitySet entitySet = res.getBody();
+    assertNotNull(entitySet);
+    assertEquals(2, entitySet.getCount());
+
+    for (ODataEntity entity : entitySet.getEntities()) {
+      final Integer key = entity.getProperty("OrderId").getPrimitiveValue().<Integer>toCastValue();
+      final Integer customerId = entity.getProperty("CustomerId").getPrimitiveValue().<Integer>toCastValue();
+      assertTrue(keys.contains(key));
+      assertEquals(Integer.valueOf(id), customerId);
+      keys.remove(key);
+
+      final ODataDeleteRequest deleteReq = client.getCUDRequestFactory().getDeleteRequest(
+              URIUtils.getURI(getServiceRoot(), entity.getEditLink().toASCIIString()));
+
+      deleteReq.setFormat(format);
+      assertEquals(204, deleteReq.execute().getStatusCode());
+    }
+
+    return actual;
+  }
+
+  private ODataEntity createWithNavigationLink(final ODataPubFormat format, final int id) {
+    final String sampleName = "Sample customer";
+
+    final ODataEntity original = getSampleCustomerProfile(id, sampleName, false);
+    original.addLink(client.getObjectFactory().newEntityNavigationLink(
+            "Info", URI.create(getServiceRoot() + "/CustomerInfo(12)")));
+
+    final ODataEntity created = createEntity(getServiceRoot(), format, original, "Customer");
+    // now, compare the created one with the actual one and go deeply into the associated customer info.....
+    final ODataEntity actual = compareEntities(getServiceRoot(), format, created, id, null);
+
+    final URIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot());
+    uriBuilder.appendEntitySetSegment("Customer").appendKeySegment(id).appendEntitySetSegment("Info");
+
+    final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
+    req.setFormat(format);
+
+    final ODataRetrieveResponse<ODataEntity> res = req.execute();
+    assertEquals(200, res.getStatusCode());
+
+    final ODataEntity info = res.getBody();
+    assertNotNull(info);
+
+    boolean found = false;
+
+    for (ODataProperty prop : info.getProperties()) {
+      if ("CustomerInfoId".equals(prop.getName())) {
+        assertEquals("12", prop.getValue().toString());
+        found = true;
+      }
+    }
+
+    assertTrue(found);
+
+    return actual;
+  }
+
+  private ODataEntity createWithBackNavigationLink(final ODataPubFormat format, final int id) {
+    final String sampleName = "Sample customer";
+
+    ODataEntity customer = getSampleCustomerProfile(id, sampleName, false);
+    customer = createEntity(getServiceRoot(), format, customer, "Customer");
+
+    ODataEntity order = client.getObjectFactory().newEntity(
+            "Microsoft.Test.OData.Services.AstoriaDefaultService.Order");
+    order.getProperties().add(client.getObjectFactory().newPrimitiveProperty("CustomerId",
+            client.getPrimitiveValueBuilder().setValue(id).setType(ODataJClientEdmPrimitiveType.Int32).build()));
+    order.getProperties().add(client.getObjectFactory().newPrimitiveProperty("OrderId",
+            client.getPrimitiveValueBuilder().setValue(id).setType(ODataJClientEdmPrimitiveType.Int32).build()));
+
+    order.addLink(client.getObjectFactory().newEntityNavigationLink(
+            "Customer", URIUtils.getURI(getServiceRoot(), customer.getEditLink().toASCIIString())));
+
+    order = createEntity(getServiceRoot(), format, order, "Order");
+
+    ODataEntity changes = client.getObjectFactory().newEntity(
+            "Microsoft.Test.OData.Services.AstoriaDefaultService.Customer");
+    changes.setEditLink(customer.getEditLink());
+    changes.addLink(client.getObjectFactory().newFeedNavigationLink(
+            "Orders", URIUtils.getURI(getServiceRoot(), order.getEditLink().toASCIIString())));
+    update(UpdateType.PATCH, changes, format, null);
+
+    final ODataEntityRequest customerreq = client.getRetrieveRequestFactory().getEntityRequest(
+            URIUtils.getURI(getServiceRoot(), order.getEditLink().toASCIIString() + "/Customer"));
+    customerreq.setFormat(format);
+
+    customer = customerreq.execute().getBody();
+
+    assertEquals(
+            Integer.valueOf(id), customer.getProperty("CustomerId").getPrimitiveValue().<Integer>toCastValue());
+
+    final ODataEntitySetRequest orderreq = client.getRetrieveRequestFactory().getEntitySetRequest(
+            URIUtils.getURI(getServiceRoot(), customer.getEditLink().toASCIIString() + "/Orders"));
+    orderreq.setFormat(format);
+
+    final ODataRetrieveResponse<ODataEntitySet> orderres = orderreq.execute();
+    assertEquals(200, orderres.getStatusCode());
+
+    assertEquals(Integer.valueOf(id),
+            orderres.getBody().getEntities().get(0).getProperty("OrderId").getPrimitiveValue().
+            <Integer>toCastValue());
+
+    final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(
+            URIUtils.getURI(getServiceRoot(), customer.getEditLink().toASCIIString() + "?$expand=Orders"));
+    req.setFormat(format);
+
+    customer = req.execute().getBody();
+
+    boolean found = false;
+    for (ODataLink link : customer.getNavigationLinks()) {
+      if (link instanceof ODataInlineEntitySet && "Orders".equals(link.getName())) {
+        found = true;
+      }
+    }
+    assertTrue(found);
+
+    return customer;
+  }
+
+  private void multiKey(final ODataPubFormat format) {
+    final ODataEntity message = client.getObjectFactory().newEntity(
+            "Microsoft.Test.OData.Services.AstoriaDefaultService.Message");
+
+    message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("MessageId",
+            client.getPrimitiveValueBuilder().setValue(1000).
+            setType(ODataJClientEdmPrimitiveType.Int32).build()));
+    message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("FromUsername",
+            client.getPrimitiveValueBuilder().setValue("1").
+            setType(ODataJClientEdmPrimitiveType.String).build()));
+    message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("ToUsername",
+            client.getPrimitiveValueBuilder().setValue("xlodhxzzusxecbzptxlfxprneoxkn").
+            setType(ODataJClientEdmPrimitiveType.String).build()));
+    message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Subject",
+            client.getPrimitiveValueBuilder().setValue("Test subject").
+            setType(ODataJClientEdmPrimitiveType.String).build()));
+    message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Body",
+            client.getPrimitiveValueBuilder().setValue("Test body").
+            setType(ODataJClientEdmPrimitiveType.String).build()));
+    message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("IsRead",
+            client.getPrimitiveValueBuilder().setValue(false).
+            setType(ODataJClientEdmPrimitiveType.Boolean).build()));
+
+    final URIBuilder<?> builder =
+            client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Message");
+    final ODataEntityCreateRequest req = client.getCUDRequestFactory().getEntityCreateRequest(builder.build(),
+            message);
+    req.setFormat(format);
+
+    final ODataEntityCreateResponse res = req.execute();
+    assertNotNull(res);
+    assertEquals(201, res.getStatusCode());
+
+    final LinkedHashMap<String, Object> multiKey = new LinkedHashMap<String, Object>();
+    multiKey.put("FromUsername", "1");
+    multiKey.put("MessageId", 1000);
+
+    final ODataDeleteResponse deleteRes = client.getCUDRequestFactory().
+            getDeleteRequest(builder.appendKeySegment(multiKey).build()).execute();
+    assertEquals(204, deleteRes.getStatusCode());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/a835edd1/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityRetrieveTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityRetrieveTestITCase.java
new file mode 100644
index 0000000..e955772
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityRetrieveTestITCase.java
@@ -0,0 +1,240 @@
+/*
+ * 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.it.v3;
+
+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.util.LinkedHashMap;
+import java.util.List;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataGenericRetrieveRequest;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.data.ObjectWrapper;
+import org.apache.olingo.client.api.domain.ODataEntity;
+import org.apache.olingo.client.api.domain.ODataEntitySet;
+import org.apache.olingo.client.api.domain.ODataInlineEntity;
+import org.apache.olingo.client.api.domain.ODataInlineEntitySet;
+import org.apache.olingo.client.api.domain.ODataLink;
+import org.apache.olingo.client.api.domain.ODataProperty;
+import org.apache.olingo.client.api.format.ODataPubFormat;
+import org.apache.olingo.client.api.uri.URIBuilder;
+import org.apache.olingo.client.core.op.impl.ResourceFactory;
+import org.junit.Test;
+
+/**
+ * This is the unit test class to check entity retrieve operations.
+ */
+public class EntityRetrieveTestITCase extends AbstractV3TestITCase {
+
+  protected String getServiceRoot() {
+    return testStaticServiceRootURL;
+  }
+
+  private void withInlineEntry(final ODataPubFormat format) {
+    final URIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()).
+            appendEntitySetSegment("Customer").appendKeySegment(-10).expand("Info");
+
+    final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
+    req.setFormat(format);
+
+    final ODataRetrieveResponse<ODataEntity> res = req.execute();
+    final ODataEntity entity = res.getBody();
+
+    assertNotNull(entity);
+    assertEquals("Microsoft.Test.OData.Services.AstoriaDefaultService.Customer", entity.getName());
+    assertEquals(getServiceRoot() + "/Customer(-10)", entity.getEditLink().toASCIIString());
+
+    assertEquals(5, entity.getNavigationLinks().size());
+    assertTrue(entity.getAssociationLinks().isEmpty());
+
+    boolean found = false;
+
+    for (ODataLink link : entity.getNavigationLinks()) {
+      if (link instanceof ODataInlineEntity) {
+        final ODataEntity inline = ((ODataInlineEntity) link).getEntity();
+        assertNotNull(inline);
+
+        debugEntry(client.getBinder().getEntry(
+                inline, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM)), "Just read");
+
+        final List<ODataProperty> properties = inline.getProperties();
+        assertEquals(2, properties.size());
+
+        assertTrue(properties.get(0).getName().equals("CustomerInfoId")
+                || properties.get(1).getName().equals("CustomerInfoId"));
+        assertTrue(properties.get(0).getValue().toString().equals("11")
+                || properties.get(1).getValue().toString().equals("11"));
+
+        found = true;
+      }
+    }
+
+    assertTrue(found);
+  }
+
+  @Test
+  public void withInlineEntryFromAtom() {
+    withInlineEntry(ODataPubFormat.ATOM);
+  }
+
+  @Test
+  public void withInlineEntryFromJSON() {
+    // this needs to be full, otherwise there is no mean to recognize links
+    withInlineEntry(ODataPubFormat.JSON_FULL_METADATA);
+  }
+
+  private void withInlineFeed(final ODataPubFormat format) {
+    final URIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()).
+            appendEntitySetSegment("Customer").appendKeySegment(-10).expand("Orders");
+
+    final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
+    req.setFormat(format);
+
+    final ODataRetrieveResponse<ODataEntity> res = req.execute();
+    final ODataEntity entity = res.getBody();
+    assertNotNull(entity);
+
+    boolean found = false;
+
+    for (ODataLink link : entity.getNavigationLinks()) {
+      if (link instanceof ODataInlineEntitySet) {
+        final ODataEntitySet inline = ((ODataInlineEntitySet) link).getEntitySet();
+        assertNotNull(inline);
+
+        debugFeed(client.getBinder().getFeed(inline, ResourceFactory.feedClassForFormat(
+                format == ODataPubFormat.ATOM)), "Just read");
+
+        found = true;
+      }
+    }
+
+    assertTrue(found);
+  }
+
+  @Test
+  public void withInlineFeedFromAtom() {
+    withInlineFeed(ODataPubFormat.ATOM);
+  }
+
+  @Test
+  public void withInlineFeedFromJSON() {
+    // this needs to be full, otherwise there is no mean to recognize links
+    withInlineFeed(ODataPubFormat.JSON_FULL_METADATA);
+  }
+
+  private void genericRequest(final ODataPubFormat format) {
+    final URIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()).
+            appendEntitySetSegment("Car").appendKeySegment(16);
+
+    final ODataGenericRetrieveRequest req =
+            client.getRetrieveRequestFactory().getGenericRetrieveRequest(uriBuilder.build());
+    req.setFormat(format.toString());
+
+    final ODataRetrieveResponse<ObjectWrapper> res = req.execute();
+
+    final ObjectWrapper wrapper = res.getBody();
+
+    final ODataEntitySet entitySet = wrapper.getODataEntitySet();
+    assertNull(entitySet);
+
+    final ODataEntity entity = wrapper.getODataEntity();
+    assertNotNull(entity);
+  }
+
+  @Test
+  public void genericRequestAsAtom() {
+    genericRequest(ODataPubFormat.ATOM);
+  }
+
+  @Test
+  public void genericRequestAsJSON() {
+    // this needs to be full, otherwise actions will not be provided
+    genericRequest(ODataPubFormat.JSON_FULL_METADATA);
+  }
+
+  private void multiKey(final ODataPubFormat format) {
+    final LinkedHashMap<String, Object> multiKey = new LinkedHashMap<String, Object>();
+    multiKey.put("FromUsername", "1");
+    multiKey.put("MessageId", -10);
+
+    final URIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()).
+            appendEntitySetSegment("Message").appendKeySegment(multiKey);
+
+    final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
+    req.setFormat(format);
+
+    final ODataRetrieveResponse<ODataEntity> res = req.execute();
+    final ODataEntity entity = res.getBody();
+    assertNotNull(entity);
+    assertEquals("1", entity.getProperty("FromUsername").getPrimitiveValue().<String>toCastValue());
+  }
+
+  @Test
+  public void multiKeyAsAtom() {
+    multiKey(ODataPubFormat.ATOM);
+  }
+
+  @Test
+  public void multiKeyAsJSON() {
+    multiKey(ODataPubFormat.JSON_FULL_METADATA);
+  }
+
+  @Test
+  public void checkForETagAsATOM() {
+    checkForETag(ODataPubFormat.ATOM);
+  }
+
+  @Test
+  public void checkForETagAsJSON() {
+    checkForETag(ODataPubFormat.JSON_FULL_METADATA);
+  }
+
+  private void checkForETag(final ODataPubFormat format) {
+    final URIBuilder<?> uriBuilder =
+            client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Product").appendKeySegment(-10);
+
+    final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
+    req.setFormat(format);
+
+    final ODataRetrieveResponse<ODataEntity> res = req.execute();
+    assertEquals(200, res.getStatusCode());
+
+    final String etag = res.getEtag();
+    assertTrue(StringUtils.isNotBlank(etag));
+
+    final ODataEntity product = res.getBody();
+    assertEquals(etag, product.getETag());
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void issue99() {
+    final URIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Car");
+
+    final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
+    req.setFormat(ODataPubFormat.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();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/a835edd1/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntitySetTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntitySetTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntitySetTestITCase.java
new file mode 100644
index 0000000..b26ce7e
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntitySetTestITCase.java
@@ -0,0 +1,151 @@
+/*
+ * 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.it.v3;
+
+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.communication.request.retrieve.ODataEntitySetIteratorRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataGenericRetrieveRequest;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.data.ObjectWrapper;
+import org.apache.olingo.client.api.domain.ODataEntitySet;
+import org.apache.olingo.client.api.domain.ODataEntitySetIterator;
+import org.apache.olingo.client.api.format.ODataPubFormat;
+import org.apache.olingo.client.api.uri.URIBuilder;
+import org.apache.olingo.client.api.utils.URIUtils;
+import org.apache.olingo.client.core.op.impl.ResourceFactory;
+import org.junit.Test;
+
+/**
+ * This is the unit test class to check basic feed operations.
+ */
+public class EntitySetTestITCase extends AbstractV3TestITCase {
+
+  protected String getServiceRoot() {
+    return testStaticServiceRootURL;
+  }
+
+  @Test
+  public void genericRequestAsAtom() throws IOException {
+    genericRequest(ODataPubFormat.ATOM);
+  }
+
+  @Test
+  public void genericRequestAsJSON() throws IOException {
+    genericRequest(ODataPubFormat.JSON);
+  }
+
+  @Test
+  public void readODataEntitySetIteratorFromAtom() {
+    readODataEntitySetIterator(ODataPubFormat.ATOM);
+  }
+
+  @Test
+  public void readODataEntitySetIteratorFromJSON() {
+    readODataEntitySetIterator(ODataPubFormat.JSON);
+  }
+
+  @Test
+  public void readODataEntitySetIteratorFromJSONFullMeta() {
+    readODataEntitySetIterator(ODataPubFormat.JSON_FULL_METADATA);
+  }
+
+  @Test
+  public void readODataEntitySetIteratorFromJSONNoMeta() {
+    readODataEntitySetIterator(ODataPubFormat.JSON_NO_METADATA);
+  }
+
+  @Test
+  public void readODataEntitySetWithNextFromAtom() {
+    readEntitySetWithNextLink(ODataPubFormat.ATOM);
+  }
+
+  @Test
+  public void readODataEntitySetWithNextFromJSON() {
+    readEntitySetWithNextLink(ODataPubFormat.JSON_FULL_METADATA);
+  }
+
+  private void readEntitySetWithNextLink(final ODataPubFormat format) {
+    final URIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot());
+    uriBuilder.appendEntitySetSegment("Customer");
+
+    final ODataEntitySetRequest req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
+    req.setFormat(format);
+
+    final ODataRetrieveResponse<ODataEntitySet> res = req.execute();
+    final ODataEntitySet feed = res.getBody();
+
+    assertNotNull(feed);
+
+    debugFeed(client.getBinder().getFeed(feed, ResourceFactory.feedClassForFormat(
+            ODataPubFormat.ATOM == format)), "Just retrieved feed");
+
+    assertEquals(2, feed.getEntities().size());
+    assertNotNull(feed.getNext());
+
+    final URI expected = URI.create(getServiceRoot() + "/Customer?$skiptoken=-9");
+    final URI found = URIUtils.getURI(getServiceRoot(), feed.getNext().toASCIIString());
+
+    assertEquals(expected, found);
+  }
+
+  private void readODataEntitySetIterator(final ODataPubFormat format) {
+    final URIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot());
+    uriBuilder.appendEntitySetSegment("Customer");
+
+    final ODataEntitySetIteratorRequest req =
+            client.getRetrieveRequestFactory().getEntitySetIteratorRequest(uriBuilder.build());
+    req.setFormat(format);
+
+    final ODataRetrieveResponse<ODataEntitySetIterator> res = req.execute();
+    final ODataEntitySetIterator feedIterator = res.getBody();
+
+    assertNotNull(feedIterator);
+
+    int count = 0;
+
+    while (feedIterator.hasNext()) {
+      assertNotNull(feedIterator.next());
+      count++;
+    }
+    assertEquals(2, count);
+    assertTrue(feedIterator.getNext().toASCIIString().endsWith("Customer?$skiptoken=-9"));
+  }
+
+  private void genericRequest(final ODataPubFormat format) {
+    final URIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot());
+    uriBuilder.appendEntitySetSegment("Car");
+
+    final ODataGenericRetrieveRequest req =
+            client.getRetrieveRequestFactory().getGenericRetrieveRequest(uriBuilder.build());
+    req.setFormat(format.toString());
+
+    final ODataRetrieveResponse<ObjectWrapper> res = req.execute();
+
+    ObjectWrapper wrapper = res.getBody();
+
+    final ODataEntitySet entitySet = wrapper.getODataEntitySet();
+    assertNotNull(entitySet);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/a835edd1/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityUpdateTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityUpdateTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityUpdateTestITCase.java
new file mode 100644
index 0000000..c224319
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityUpdateTestITCase.java
@@ -0,0 +1,238 @@
+/*
+ * 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.it.v3;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.net.URI;
+import java.util.LinkedHashMap;
+import org.apache.olingo.client.api.communication.ODataClientErrorException;
+import org.apache.olingo.client.api.communication.header.HeaderName;
+import org.apache.olingo.client.api.communication.header.ODataHeaderValues;
+import org.apache.olingo.client.api.communication.request.UpdateType;
+import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
+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.domain.ODataEntity;
+import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
+import org.apache.olingo.client.api.format.ODataPubFormat;
+import org.junit.Test;
+
+/**
+ * This is the unit test class to check entity update operations.
+ */
+public class EntityUpdateTestITCase extends AbstractV3TestITCase {
+
+  protected String getServiceRoot() {
+    return testStaticServiceRootURL;
+  }
+
+  @Test
+  public void mergeAsAtom() {
+    final ODataPubFormat format = ODataPubFormat.ATOM;
+    final URI uri = client.getURIBuilder(getServiceRoot()).
+            appendEntitySetSegment("Product").appendKeySegment(-10).build();
+    final String etag = getETag(uri);
+    final ODataEntity merge = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
+    merge.setEditLink(uri);
+    updateEntityDescription(format, merge, UpdateType.MERGE, etag);
+  }
+
+  @Test
+  public void mergeAsJSON() {
+    final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+    final URI uri = client.getURIBuilder(getServiceRoot()).
+            appendEntitySetSegment("Product").appendKeySegment(-10).build();
+    final String etag = getETag(uri);
+    final ODataEntity merge = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
+    merge.setEditLink(uri);
+    updateEntityDescription(format, merge, UpdateType.MERGE, etag);
+  }
+
+  @Test
+  public void patchAsAtom() {
+    final ODataPubFormat format = ODataPubFormat.ATOM;
+    final URI uri = client.getURIBuilder(getServiceRoot()).
+            appendEntitySetSegment("Product").appendKeySegment(-10).build();
+    final String etag = getETag(uri);
+    final ODataEntity patch = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
+    patch.setEditLink(uri);
+    updateEntityDescription(format, patch, UpdateType.PATCH, etag);
+  }
+
+  @Test
+  public void patchAsJSON() {
+    final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+    final URI uri = client.getURIBuilder(getServiceRoot()).
+            appendEntitySetSegment("Product").appendKeySegment(-10).build();
+    final String etag = getETag(uri);
+    final ODataEntity patch = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
+    patch.setEditLink(uri);
+    updateEntityDescription(format, patch, UpdateType.PATCH, etag);
+  }
+
+  @Test
+  public void replaceAsAtom() {
+    final ODataPubFormat format = ODataPubFormat.ATOM;
+    final ODataEntity changes = read(format, client.getURIBuilder(getServiceRoot()).
+            appendEntitySetSegment("Car").appendKeySegment(14).build());
+    updateEntityDescription(format, changes, UpdateType.REPLACE);
+  }
+
+  @Test
+  public void replaceAsJSON() {
+    final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+    final ODataEntity changes = read(format, client.getURIBuilder(getServiceRoot()).
+            appendEntitySetSegment("Car").appendKeySegment(14).build());
+    updateEntityDescription(format, changes, UpdateType.REPLACE);
+  }
+
+  @Test
+  public void patchLinkAsAtom() {
+    patchLink(ODataPubFormat.ATOM);
+  }
+
+  @Test
+  public void patchLinkAsJSON() {
+    patchLink(ODataPubFormat.JSON_FULL_METADATA);
+  }
+
+  public void patchLink(final ODataPubFormat format) {
+    final URI uri = client.getURIBuilder(getServiceRoot()).
+            appendEntitySetSegment("Customer").appendKeySegment(-10).build();
+
+    final ODataEntity patch =
+            client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Customer");
+    patch.setEditLink(uri);
+
+    // ---------------------------------------
+    // Update to CustomerInfo(12)
+    // ---------------------------------------
+    URI customerInfoURI = client.getURIBuilder(getServiceRoot()).
+            appendEntitySetSegment("CustomerInfo").appendKeySegment(12).build();
+
+    patch.addLink(client.getObjectFactory().newEntityNavigationLink("Info", customerInfoURI));
+
+    update(UpdateType.PATCH, patch, format, null);
+
+    customerInfoURI = client.getURIBuilder(getServiceRoot()).
+            appendEntitySetSegment("Customer").appendKeySegment(-10).appendNavigationSegment("Info").build();
+
+    ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(customerInfoURI);
+    req.setFormat(format);
+
+    ODataEntity newInfo = req.execute().getBody();
+
+    assertEquals(Integer.valueOf(12),
+            newInfo.getProperty("CustomerInfoId").getPrimitiveValue().<Integer>toCastValue());
+    // ---------------------------------------
+
+    // ---------------------------------------
+    // Restore to CustomerInfo(11)
+    // ---------------------------------------
+    patch.getNavigationLinks().clear();
+
+    customerInfoURI = client.getURIBuilder(getServiceRoot()).
+            appendEntitySetSegment("CustomerInfo").appendKeySegment(11).build();
+    read(format, customerInfoURI);
+
+    patch.addLink(client.getObjectFactory().newEntityNavigationLink("Info", customerInfoURI));
+
+    update(UpdateType.PATCH, patch, format, null);
+
+    customerInfoURI = client.getURIBuilder(getServiceRoot()).
+            appendEntitySetSegment("Customer").appendKeySegment(-10).appendNavigationSegment("Info").build();
+
+    req = client.getRetrieveRequestFactory().getEntityRequest(customerInfoURI);
+    req.setFormat(format);
+
+    newInfo = req.execute().getBody();
+
+    assertEquals(Integer.valueOf(11),
+            newInfo.getProperty("CustomerInfoId").getPrimitiveValue().<Integer>toCastValue());
+    // ---------------------------------------
+  }
+
+  private ODataEntityUpdateRequest buildMultiKeyUpdateReq(final ODataPubFormat format) {
+    final LinkedHashMap<String, Object> multiKey = new LinkedHashMap<String, Object>();
+    multiKey.put("FromUsername", "1");
+    multiKey.put("MessageId", -10);
+    final ODataEntity message = read(format, client.getURIBuilder(getServiceRoot()).
+            appendEntitySetSegment("Message").appendKeySegment(multiKey).build());
+    message.getAssociationLinks().clear();
+    message.getNavigationLinks().clear();
+
+    final boolean before = message.getProperty("IsRead").getPrimitiveValue().<Boolean>toCastValue();
+    message.getProperties().remove(message.getProperty("IsRead"));
+    message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("IsRead",
+            client.getPrimitiveValueBuilder().setValue(!before).
+            setType(ODataJClientEdmPrimitiveType.Boolean).build()));
+
+    return client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.MERGE, message);
+  }
+
+  private void mergeMultiKey(final ODataPubFormat format) {
+    final ODataEntityUpdateResponse res = buildMultiKeyUpdateReq(format).execute();
+    assertEquals(204, res.getStatusCode());
+  }
+
+  @Test
+  public void mergeMultiKeyAsAtom() {
+    mergeMultiKey(ODataPubFormat.ATOM);
+  }
+
+  @Test
+  public void mergeMultiKeyAsJSON() {
+    mergeMultiKey(ODataPubFormat.JSON_FULL_METADATA);
+  }
+
+  @Test
+  public void updateReturnContent() {
+    final ODataEntityUpdateRequest req = buildMultiKeyUpdateReq(client.getConfiguration().getDefaultPubFormat());
+    req.setPrefer(ODataHeaderValues.preferReturnContent);
+
+    final ODataEntityUpdateResponse res = req.execute();
+    assertEquals(200, res.getStatusCode());
+    assertEquals(ODataHeaderValues.preferReturnContent,
+            res.getHeader(HeaderName.preferenceApplied).iterator().next());
+    assertNotNull(res.getBody());
+  }
+
+  @Test
+  public void concurrentModification() {
+    final URI uri = client.getURIBuilder(getServiceRoot()).
+            appendEntitySetSegment("Product").appendKeySegment(-10).build();
+    String etag = getETag(uri);
+    final ODataEntity product = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
+    product.setEditLink(uri);
+    updateEntityStringProperty("BaseConcurrency",
+            client.getConfiguration().getDefaultPubFormat(), product, UpdateType.MERGE, etag);
+
+    try {
+      etag += "-invalidone";
+      updateEntityStringProperty("BaseConcurrency",
+              client.getConfiguration().getDefaultPubFormat(), product, UpdateType.MERGE, etag);
+      fail();
+    } catch (ODataClientErrorException e) {
+      assertEquals(412, e.getStatusLine().getStatusCode());
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/a835edd1/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/ErrorTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/ErrorTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/ErrorTestITCase.java
new file mode 100644
index 0000000..5dbebe5
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/ErrorTestITCase.java
@@ -0,0 +1,172 @@
+/*
+ * 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.it.v3;
+
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.net.URI;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.communication.ODataClientErrorException;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
+import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
+import org.apache.olingo.client.api.domain.ODataEntity;
+import org.apache.olingo.client.api.format.ODataPubFormat;
+import org.apache.olingo.client.api.http.HttpMethod;
+import org.apache.olingo.client.api.uri.URIBuilder;
+import org.apache.olingo.client.api.utils.URIUtils;
+import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
+import org.apache.olingo.client.core.communication.response.ODataResponseImpl;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmEntityContainer;
+import org.apache.olingo.commons.api.edm.EdmFunctionImport;
+import org.junit.Test;
+
+/**
+ * This is the unit test class to check basic entity operations.
+ */
+public class ErrorTestITCase extends AbstractV3TestITCase {
+
+  private class ErrorGeneratingRequest
+          extends AbstractODataBasicRequest<ODataEntityCreateResponse, ODataPubFormat> {
+
+    public ErrorGeneratingRequest(final HttpMethod method, final URI uri) {
+      super(client, ODataPubFormat.class, method, uri);
+    }
+
+    @Override
+    protected InputStream getPayload() {
+      return new ByteArrayInputStream(new byte[0]);
+    }
+
+    @Override
+    public ODataEntityCreateResponse execute() {
+      final HttpResponse res = doExecute();
+      return new ErrorResponseImpl(client, httpClient, res);
+    }
+
+    private class ErrorResponseImpl extends ODataResponseImpl implements ODataEntityCreateResponse {
+
+      private final ODataClient odataClient;
+
+      public ErrorResponseImpl(
+              final ODataClient odataClient, final HttpClient client, final HttpResponse res) {
+
+        super(client, res);
+        this.odataClient = odataClient;
+      }
+
+      @Override
+      public ODataEntity getBody() {
+        return odataClient.getObjectFactory().newEntity("Invalid");
+      }
+    }
+  }
+
+  private void stacktraceError(final ODataPubFormat format) {
+    final URIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL);
+    uriBuilder.appendEntitySetSegment("Customer");
+
+    final ErrorGeneratingRequest errorReq = new ErrorGeneratingRequest(HttpMethod.POST, uriBuilder.build());
+    errorReq.setFormat(format);
+
+    try {
+      errorReq.execute();
+      fail();
+    } catch (ODataClientErrorException e) {
+      LOG.error("ODataClientErrorException found", e);
+      assertEquals(400, e.getStatusLine().getStatusCode());
+      assertNotNull(e.getCause());
+      assertNotNull(e.getODataError());
+    }
+  }
+
+  @Test
+  public void xmlStacktraceError() {
+    stacktraceError(ODataPubFormat.ATOM);
+  }
+
+  @Test
+  public void jsonStacktraceError() {
+    stacktraceError(ODataPubFormat.JSON);
+  }
+
+  private void notfoundError(final ODataPubFormat format) {
+    final URIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL);
+    uriBuilder.appendEntitySetSegment("Customer(154)");
+
+    final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
+    req.setFormat(format);
+
+    try {
+      req.execute();
+      fail();
+    } catch (ODataClientErrorException e) {
+      LOG.error("ODataClientErrorException found", e);
+      assertEquals(404, e.getStatusLine().getStatusCode());
+      assertNull(e.getCause());
+      assertNotNull(e.getODataError());
+    }
+  }
+
+  @Test
+  public void xmlNotfoundError() {
+    notfoundError(ODataPubFormat.ATOM);
+  }
+
+  @Test
+  public void jsonNotfoundError() {
+    notfoundError(ODataPubFormat.JSON);
+  }
+
+  private void instreamError(final ODataPubFormat format) {
+    final Edm metadata =
+            client.getRetrieveRequestFactory().getMetadataRequest(testStaticServiceRootURL).execute().getBody();
+    assertNotNull(metadata);
+
+    final EdmEntityContainer container = metadata.getSchemas().get(0).getEntityContainer();
+    final EdmFunctionImport funcImp = container.getFunctionImport("InStreamErrorGetCustomer");
+    final URIBuilder<?> builder = client.getURIBuilder(testStaticServiceRootURL).
+            appendOperationCallSegment(URIUtils.rootFunctionImportURISegment(container, funcImp), null);
+    // TODO: review invoke
+//        final ODataInvokeRequest<ODataEntitySet> req =
+//                client.getInvokeRequestFactory().getInvokeRequest(builder.build(), metadata, funcImp);
+//        req.setFormat(format);
+//
+//        final ODataInvokeResponse<ODataEntitySet> res = req.execute();
+//        res.getBody();
+    throw new IllegalArgumentException();
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void atomInstreamError() {
+    instreamError(ODataPubFormat.ATOM);
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void jsonInstreamError() {
+    instreamError(ODataPubFormat.JSON);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/a835edd1/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/FilterFactoryTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/FilterFactoryTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/FilterFactoryTestITCase.java
new file mode 100644
index 0000000..c5910f4
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/FilterFactoryTestITCase.java
@@ -0,0 +1,167 @@
+/*
+ * 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.it.v3;
+
+import org.apache.olingo.client.api.domain.ODataEntitySet;
+import org.apache.olingo.client.api.uri.URIBuilder;
+import org.apache.olingo.client.api.uri.filter.URIFilter;
+import org.apache.olingo.client.api.uri.filter.V3FilterArgFactory;
+import org.apache.olingo.client.api.uri.filter.V3FilterFactory;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+
+public class FilterFactoryTestITCase extends AbstractV3TestITCase {
+
+  private V3FilterFactory getFilterFactory() {
+    return getClient().getFilterFactory();
+  }
+
+  private V3FilterArgFactory getFilterArgFactory() {
+    return getFilterFactory().getArgFactory();
+  }
+
+  private void match(final String entitySet, final URIFilter filter, final int expected) {
+    final URIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
+            appendEntitySetSegment(entitySet).filter(filter);
+
+    final ODataEntitySet feed = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build()).
+            execute().getBody();
+    assertNotNull(feed);
+    assertEquals(expected, feed.getEntities().size());
+  }
+
+  @Test
+  public void simple() {
+    match("Car", getFilterFactory().lt("VIN", 16), 5);
+  }
+
+  @Test
+  public void and() {
+    final URIFilter filter =
+            getFilterFactory().and(
+            getFilterFactory().lt("VIN", 16),
+            getFilterFactory().gt("VIN", 12));
+
+    match("Car", filter, 3);
+  }
+
+  @Test
+  public void not() {
+    final URIFilter filter =
+            getFilterFactory().not(
+            getFilterFactory().or(
+            getFilterFactory().ge("VIN", 16),
+            getFilterFactory().le("VIN", 12)));
+
+    match("Car", filter, 3);
+  }
+
+  @Test
+  public void operator() {
+    URIFilter filter =
+            getFilterFactory().eq(
+            getFilterArgFactory().add(getFilterArgFactory().property("VIN"), getFilterArgFactory().
+            literal(1)),
+            getFilterArgFactory().literal(16));
+
+    match("Car", filter, 1);
+
+    filter =
+            getFilterFactory().eq(
+            getFilterArgFactory().add(getFilterArgFactory().literal(1), getFilterArgFactory().
+            property("VIN")),
+            getFilterArgFactory().literal(16));
+
+    match("Car", filter, 1);
+
+    filter =
+            getFilterFactory().eq(
+            getFilterArgFactory().literal(16),
+            getFilterArgFactory().add(getFilterArgFactory().literal(1), getFilterArgFactory().
+            property("VIN")));
+
+    match("Car", filter, 1);
+  }
+
+  @Test
+  public void function() {
+    final URIFilter filter =
+            getFilterFactory().match(
+            getFilterArgFactory().startswith(
+            getFilterArgFactory().property("Description"), getFilterArgFactory().literal("cen")));
+
+    match("Car", filter, 1);
+  }
+
+  @Test
+  public void composed() {
+    final URIFilter filter =
+            getFilterFactory().gt(
+            getFilterArgFactory().length(getFilterArgFactory().property("Description")),
+            getFilterArgFactory().add(getFilterArgFactory().property("VIN"), getFilterArgFactory().literal(
+            10)));
+
+    match("Car", filter, 5);
+  }
+
+  @Test
+  public void propertyPath() {
+    URIFilter filter =
+            getFilterFactory().eq(
+            getFilterArgFactory().indexof(
+            getFilterArgFactory().property("PrimaryContactInfo/HomePhone/PhoneNumber"),
+            getFilterArgFactory().literal("ODataJClient")),
+            getFilterArgFactory().literal(1));
+
+    match("Customer", filter, 0);
+
+    filter =
+            getFilterFactory().ne(
+            getFilterArgFactory().indexof(
+            getFilterArgFactory().property("PrimaryContactInfo/HomePhone/PhoneNumber"),
+            getFilterArgFactory().literal("lccvussrv")),
+            getFilterArgFactory().literal(-1));
+
+    match("Customer", filter, 2);
+  }
+
+  @Test
+  public void datetime() {
+    final URIFilter filter =
+            getFilterFactory().eq(
+            getFilterArgFactory().month(
+            getFilterArgFactory().property("PurchaseDate")),
+            getFilterArgFactory().literal(12));
+
+    match("ComputerDetail", filter, 1);
+  }
+
+  @Test
+  public void isof() {
+    final URIFilter filter =
+            getFilterFactory().match(
+            getFilterArgFactory().isof(
+            getFilterArgFactory().literal(
+            "Microsoft.Test.OData.Services.AstoriaDefaultService.SpecialEmployee")));
+
+    match("Person", filter, 4);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/a835edd1/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/FilterTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/FilterTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/FilterTestITCase.java
new file mode 100644
index 0000000..6cc217f
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/FilterTestITCase.java
@@ -0,0 +1,94 @@
+/*
+ * 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.it.v3;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+
+import org.apache.olingo.client.api.domain.ODataEntitySet;
+import org.apache.olingo.client.api.uri.URIBuilder;
+import org.junit.Test;
+
+public class FilterTestITCase extends AbstractV3TestITCase {
+
+  private void filterQueryTest(final String entity, final String filter, final int expected) {
+    final URIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
+            appendEntitySetSegment(entity).filter(filter);
+    final ODataEntitySet entitySet = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build()).
+            execute().getBody();
+    assertNotNull(entitySet);
+    assertEquals(expected, entitySet.getEntities().size());
+  }
+
+  @Test
+  public void withId() {
+    filterQueryTest("Customer", "CustomerId eq -10", 1);
+  }
+
+  @Test
+  public void logical() {
+    filterQueryTest("Customer", "CustomerId gt -10", 2);
+    filterQueryTest("Customer", "CustomerId lt -10", 0);
+    filterQueryTest("Customer", "not endswith(Name,'Chandan')", 2);
+    filterQueryTest("Car", "VIN le 18 and VIN gt 12", 6);
+  }
+
+  @Test
+  public void arithmetic() {
+    filterQueryTest("Car", "VIN add 5 lt 11", 0);
+    filterQueryTest("Car", "VIN div 2 le 8", 7);
+    filterQueryTest("Car", "VIN mul 2 le 30", 5);
+    filterQueryTest("Person", "PersonId sub 2 lt -10", 2);
+  }
+
+  @Test
+  public void stringOperations() {
+    filterQueryTest("Product", "length(Description) eq 7", 1);
+    filterQueryTest("Product", "length(Description) eq 7", 1);
+    filterQueryTest("Product", "substringof('kdcuklu', Description) eq true", 1);
+    filterQueryTest("Product", "startswith(Description, 'k') eq true", 2);
+    filterQueryTest("Product", "startswith(Description, 'k') eq true", 2);
+    filterQueryTest("Product", "indexof(Description, 'k') eq 0", 2);
+    filterQueryTest("Product", "toupper(Description) eq 'KDCUKLU'", 1);
+    filterQueryTest("Product", "concat(Description, ', newname') eq 'kdcuklu, newname'", 1);
+  }
+
+  @Test
+  public void math() {
+    filterQueryTest("Product", "round(Dimensions/Width) eq 7338", 1);
+    filterQueryTest("Product", "round(Dimensions/Width) eq 7338", 1);
+    filterQueryTest("Product", "floor(Dimensions/Width) eq 7337", 1);
+    filterQueryTest("Product", "ceiling(Dimensions/Width) eq 7338", 1);
+  }
+
+  @Test
+  public void date() {
+    filterQueryTest("ComputerDetail", "day(PurchaseDate) eq 15", 1);
+    filterQueryTest("ComputerDetail", "month(PurchaseDate) eq 12", 2);
+    filterQueryTest("ComputerDetail", "hour(PurchaseDate) eq 1", 1);
+    filterQueryTest("ComputerDetail", "minute(PurchaseDate) eq 33", 1);
+    filterQueryTest("ComputerDetail", "second(PurchaseDate) eq 35", 1);
+    filterQueryTest("ComputerDetail", "year(PurchaseDate) eq 2020", 1);
+  }
+
+  @Test
+  public void isOfTest() {
+    filterQueryTest("Customer", "isof(Name,'Edm.String') eq true", 2);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/a835edd1/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/InvokeTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/InvokeTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/InvokeTestITCase.java
new file mode 100644
index 0000000..a296650
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/InvokeTestITCase.java
@@ -0,0 +1,275 @@
+/*
+ * 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.it.v3;
+
+public class InvokeTestITCase extends AbstractV3TestITCase {
+
+//    private void getWithNoParams(final ODataPubFormat format) {
+//        final Edm metadata =
+//                client.getRetrieveRequestFactory().getMetadataRequest(testStaticServiceRootURL).execute().getBody();
+//        assertNotNull(metadata);
+//
+//        final EdmEdmEntityContainer container = metadata.getSchemas().get(0).getEntityContainer();
+//
+//        // 1. get primitive value property
+//        EdmFunctionImport funcImp = container.getFunctionImport("GetPrimitiveString");
+//
+//        URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL).
+//                appendEdmFunctionImportSegment(URIUtils.rootEdmFunctionImportURISegment(container, funcImp));
+//
+//        ODataInvokeRequest<ODataProperty> req =
+//                client.getInvokeRequestFactory().getInvokeRequest(builder.build(), metadata, funcImp);
+//        req.setFormat(format);
+//        ODataInvokeResponse<ODataProperty> res = req.execute();
+//        assertNotNull(res);
+//
+//        ODataProperty property = res.getBody();
+//        assertNotNull(property);
+//        assertEquals("Foo", property.getPrimitiveValue().<String>toCastValue());
+//
+//        // 2. get collection of complex type property
+//        funcImp = container.getFunctionImport("EntityProjectionReturnsCollectionOfComplexTypes");
+//
+//        builder = client.getURIBuilder(testStaticServiceRootURL).
+//                appendEdmFunctionImportSegment(URIUtils.rootEdmFunctionImportURISegment(container, funcImp));
+//
+//        req = client.getInvokeRequestFactory().getInvokeRequest(builder.build(), metadata, funcImp);
+//        req.setFormat(format);
+//        res = req.execute();
+//        assertNotNull(res);
+//
+//        property = res.getBody();
+//        assertNotNull(property);
+//        assertTrue(property.hasCollectionValue());
+//        assertFalse(property.getCollectionValue().isEmpty());
+//    }
+//
+//    @Test
+//    public void getWithNoParamsAsAtom() {
+//        getWithNoParams(ODataPubFormat.ATOM);
+//    }
+//
+//    @Test
+//    public void getWithNoParamsAsJSON() {
+//        getWithNoParams(ODataPubFormat.JSON);
+//    }
+//
+//    private void getWithParams(final ODataPubFormat format) {
+//        // 1. primitive result
+//        Edm metadata =
+//                client.getRetrieveRequestFactory().getMetadataRequest(testStaticServiceRootURL).execute().getBody();
+//        assertNotNull(metadata);
+//
+//        EdmEntityContainer container = metadata.getSchemas().get(0).getEntityContainer();
+//        EdmFunctionImport funcImp = container.getFunctionImport("GetArgumentPlusOne");
+//
+//        URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL).
+//                appendEdmFunctionImportSegment(URIUtils.rootEdmFunctionImportURISegment(container, funcImp));
+//
+//        EdmType type = new EdmV3Type(funcImp.getParameters().get(0).getType());
+//        ODataPrimitiveValue argument = client.getPrimitiveValueBuilder().
+//                setType(type.getSimpleType()).
+//                setValue(154).
+//                build();
+//        Map<String, ODataValue> parameters = new HashMap<String, ODataValue>();
+//        parameters.put(funcImp.getParameters().get(0).getName(), argument);
+//
+//        final ODataInvokeRequest<ODataProperty> primitiveReq =
+//                client.getInvokeRequestFactory().getInvokeRequest(builder.build(), metadata, funcImp,
+//                        parameters);
+//        primitiveReq.setFormat(format);
+//
+//        final ODataInvokeResponse<ODataProperty> primitiveRes = primitiveReq.execute();
+//        assertNotNull(primitiveRes);
+//
+//        final ODataProperty property = primitiveRes.getBody();
+//        assertNotNull(property);
+//        assertEquals(Integer.valueOf(155), property.getPrimitiveValue().<Integer>toCastValue());
+//
+//        // 2. feed result
+//        metadata = 
+//  client.getRetrieveRequestFactory().getMetadataRequest(testStaticServiceRootURL).execute().getBody();
+//        assertNotNull(metadata);
+//
+//        container = metadata.getSchemas().get(0).getEntityContainer();
+//        funcImp = container.getFunctionImport("GetSpecificCustomer");
+//
+//        builder = client.getURIBuilder(testStaticServiceRootURL).
+//                appendEdmFunctionImportSegment(URIUtils.rootEdmFunctionImportURISegment(container, funcImp));
+//
+//        type = new EdmV3Type(funcImp.getParameters().get(0).getType());
+//        argument = client.getPrimitiveValueBuilder().
+//                setType(type.getSimpleType()).
+//                setText(StringUtils.EMPTY).
+//                build();
+//        parameters = new LinkedHashMap<String, ODataValue>();
+//        parameters.put(funcImp.getParameters().get(0).getName(), argument);
+//
+//        final ODataInvokeRequest<ODataEntitySet> feedReq =
+//                client.getInvokeRequestFactory().getInvokeRequest(builder.build(), metadata, funcImp, parameters);
+//        feedReq.setFormat(format);
+//
+//        final ODataInvokeResponse<ODataEntitySet> feedRes = feedReq.execute();
+//        assertNotNull(feedRes);
+//
+//        final ODataEntitySet feed = feedRes.getBody();
+//        assertNotNull(feed);
+//
+//        final Set<Integer> customerIds = new HashSet<Integer>(feed.getEntities().size());
+//        for (ODataEntity entity : feed.getEntities()) {
+//            customerIds.add(entity.getProperty("CustomerId").getPrimitiveValue().<Integer>toCastValue());
+//        }
+//        assertTrue(customerIds.contains(-8));
+//    }
+//
+//    @Test
+//    public void getWithParamsAsAtom() {
+//        getWithParams(ODataPubFormat.ATOM);
+//    }
+//
+//    @Test
+//    public void getWithParamsAsJSON() {
+//        getWithParams(ODataPubFormat.JSON);
+//    }
+//
+//    private ODataEntity createEmployee(final ODataPubFormat format) {
+//        final ODataEntity employee = client.getObjectFactory().newEntity(
+//                "Microsoft.Test.OData.Services.AstoriaDefaultService.Employee");
+//
+//        employee.getProperties().add(client.getObjectFactory().newPrimitiveProperty("PersonId", client.
+//                getPrimitiveValueBuilder().
+//                setText("1244").setType(ODataJClientEdmPrimitiveType.Int32).build()));
+//        employee.getProperties().add(client.getObjectFactory().newPrimitiveProperty(
+//                "Name", client.getPrimitiveValueBuilder().
+//                setText("Test employee").build()));
+//        employee.getProperties().add(client.getObjectFactory().newPrimitiveProperty("ManagersPersonId", client.
+//                getPrimitiveValueBuilder().
+//                setText("3777").setType(ODataJClientEdmPrimitiveType.Int32).build()));
+//        employee.getProperties().add(client.getObjectFactory().newPrimitiveProperty(
+//                "Salary", client.getPrimitiveValueBuilder().
+//                setText("1000").setType(ODataJClientEdmPrimitiveType.Int32).build()));
+//        employee.getProperties().add(client.getObjectFactory().newPrimitiveProperty(
+//                "Title", client.getPrimitiveValueBuilder().
+//                setText("CEO").build()));
+//
+//        final URIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
+//                appendEntitySetSegment("Person");
+//
+//        final ODataEntityCreateRequest createReq =
+//                client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), employee);
+//        createReq.setFormat(format);
+//        final ODataEntityCreateResponse createRes = createReq.execute();
+//        assertEquals(201, createRes.getStatusCode());
+//
+//        return createRes.getBody();
+//    }
+//
+//    private void deleteEmployee(final ODataPubFormat format, final Integer id) {
+//        final URIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
+//                appendEntitySetSegment("Person").appendKeySegment(id);
+//
+//        final ODataDeleteRequest deleteReq = client.getCUDRequestFactory().getDeleteRequest(uriBuilder.build());
+//        deleteReq.setFormat(format);
+//        final ODataDeleteResponse deleteRes = deleteReq.execute();
+//        assertEquals(204, deleteRes.getStatusCode());
+//    }
+//
+//    @Test
+//    public void boundPost() {
+//        // 0. create an employee
+//        final ODataEntity created = createEmployee(ODataPubFormat.JSON_FULL_METADATA);
+//        assertNotNull(created);
+//        final Integer createdId = created.getProperty("PersonId").getPrimitiveValue().<Integer>toCastValue();
+//        assertNotNull(createdId);
+//
+//        // 1. invoke action bound with the employee just created
+//        final ODataOperation action = created.getOperations().get(0);
+//
+//        final Edm metadata =
+//                client.getRetrieveRequestFactory().getMetadataRequest(testStaticServiceRootURL).execute().getBody();
+//        assertNotNull(metadata);
+//
+//        final EdmEntityContainer container = metadata.getSchemas().get(0).getEntityContainer();
+//        final EdmFunctionImport funcImp = container.getFunctionImport(action.getTitle());
+//
+//        final ODataInvokeRequest<ODataNoContent> req = client.getInvokeRequestFactory().getInvokeRequest(
+//                action.getTarget(), metadata, funcImp);
+//        req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
+//        final ODataInvokeResponse<ODataNoContent> res = req.execute();
+//        assertNotNull(res);
+//        assertEquals(204, res.getStatusCode());
+//
+//        // 2. check that invoked action has effectively run
+//        final URIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
+//                appendEntitySetSegment("Person").appendKeySegment(createdId);
+//        final ODataEntityRequest retrieveRes = 
+//  client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
+//        retrieveRes.setFormat(ODataPubFormat.JSON_FULL_METADATA);
+//        final ODataEntity read = retrieveRes.execute().getBody();
+//        assertEquals("0", read.getProperty("Salary").getPrimitiveValue().toString());
+//        assertTrue(read.getProperty("Title").getPrimitiveValue().toString().endsWith("[Sacked]"));
+//
+//        // 3. remove the test employee
+//        deleteEmployee(ODataPubFormat.JSON_FULL_METADATA, createdId);
+//    }
+//
+//    @Test
+//    public void boundPostWithParams() {
+//        // 1. read employees and store their current salary
+//        final URIBuilder<?> builder = client.getURIBuilder(testStaticServiceRootURL).
+//                appendEntitySetSegment("Person").
+//                appendEntitySetSegment("Microsoft.Test.OData.Services.AstoriaDefaultService.Employee");
+//        final URI employeesURI = builder.build();
+//        ODataEntitySet employees = client.getRetrieveRequestFactory().getEntitySetRequest(employeesURI).execute().
+//                getBody();
+//        assertFalse(employees.getEntities().isEmpty());
+//        final Map<Integer, Integer> preSalaries = new HashMap<Integer, Integer>(employees.getCount());
+//        for (ODataEntity employee : employees.getEntities()) {
+//            preSalaries.put(employee.getProperty("PersonId").getPrimitiveValue().<Integer>toCastValue(),
+//                    employee.getProperty("Salary").getPrimitiveValue().<Integer>toCastValue());
+//        }
+//        assertFalse(preSalaries.isEmpty());
+//
+//        // 2. invoke action bound, with additional parameter
+//        final Edm metadata =
+//                client.getRetrieveRequestFactory().getMetadataRequest(testStaticServiceRootURL).execute().getBody();
+//        assertNotNull(metadata);
+//
+//        final EdmEntityContainer container = metadata.getSchemas().get(0).getEntityContainer();
+//        final EdmFunctionImport funcImp = container.getFunctionImport("IncreaseSalaries");
+//
+//        final ODataInvokeRequest<ODataNoContent> req = client.getInvokeRequestFactory().getInvokeRequest(
+//                builder.appendOperationCallSegment(funcImp.getName()).build(), metadata, funcImp,
+//                Collections.<String, ODataValue>singletonMap(
+//                        "n", client.getPrimitiveValueBuilder().setValue(1).
+//  setType(ODataJClientEdmPrimitiveType.Int32).build()));
+//        final ODataInvokeResponse<ODataNoContent> res = req.execute();
+//        assertNotNull(res);
+//        assertEquals(204, res.getStatusCode());
+//
+//        // 3. check whether salaries were incremented
+//        employees = client.getRetrieveRequestFactory().getEntitySetRequest(employeesURI).execute().getBody();
+//        assertFalse(employees.getEntities().isEmpty());
+//        for (ODataEntity employee : employees.getEntities()) {
+//            assertTrue(
+//                    preSalaries.get(employee.getProperty("PersonId").getPrimitiveValue().<Integer>toCastValue())
+//                    < employee.getProperty("Salary").getPrimitiveValue().<Integer>toCastValue());
+//        }
+//    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/a835edd1/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/KeyAsSegmentTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/KeyAsSegmentTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/KeyAsSegmentTestITCase.java
new file mode 100644
index 0000000..0706408
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/KeyAsSegmentTestITCase.java
@@ -0,0 +1,110 @@
+/*
+ * 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.it.v3;
+
+import org.apache.olingo.client.api.communication.request.UpdateType;
+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.ODataEntity;
+import org.apache.olingo.client.api.format.ODataPubFormat;
+import org.apache.olingo.client.api.uri.URIBuilder;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class KeyAsSegmentTestITCase extends AbstractV3TestITCase {
+
+  @BeforeClass
+  public static void enableKeyAsSegment() {
+    client.getConfiguration().setKeyAsSegment(true);
+  }
+
+  private void read(final ODataPubFormat format) {
+    final URIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
+            appendEntitySetSegment("Customer").appendKeySegment(-10);
+
+    final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
+    req.setFormat(format);
+
+    final ODataRetrieveResponse<ODataEntity> res = req.execute();
+    final ODataEntity entity = res.getBody();
+    assertNotNull(entity);
+
+    assertFalse(entity.getEditLink().toASCIIString().contains("("));
+    assertFalse(entity.getEditLink().toASCIIString().contains(")"));
+  }
+
+  @Test
+  public void fromAtom() {
+    read(ODataPubFormat.ATOM);
+  }
+
+  @Test
+  public void fromJSON() {
+    read(ODataPubFormat.JSON_FULL_METADATA);
+  }
+
+  @Test
+  public void createODataEntityAsAtom() {
+    final ODataPubFormat format = ODataPubFormat.ATOM;
+    final int id = 1;
+    final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
+
+    createEntity(testStaticServiceRootURL, format, original, "Customer");
+    final ODataEntity actual = compareEntities(testStaticServiceRootURL, format, original, id, null);
+
+    cleanAfterCreate(format, actual, false, testStaticServiceRootURL);
+  }
+
+  @Test
+  public void createODataEntityAsJSON() {
+    final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+    final int id = 2;
+    final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
+
+    createEntity(testStaticServiceRootURL, format, original, "Customer");
+    final ODataEntity actual = compareEntities(testStaticServiceRootURL, format, original, id, null);
+
+    cleanAfterCreate(format, actual, false, testStaticServiceRootURL);
+  }
+
+  @Test
+  public void replaceODataEntityAsAtom() {
+    final ODataPubFormat format = ODataPubFormat.ATOM;
+    final ODataEntity changes = read(format, client.getURIBuilder(testStaticServiceRootURL).
+            appendEntitySetSegment("Car").appendKeySegment(14).build());
+    updateEntityDescription(format, changes, UpdateType.REPLACE);
+  }
+
+  @Test
+  public void replaceODataEntityAsJSON() {
+    final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+    final ODataEntity changes = read(format, client.getURIBuilder(testStaticServiceRootURL).
+            appendEntitySetSegment("Car").appendKeySegment(14).build());
+    updateEntityDescription(format, changes, UpdateType.REPLACE);
+  }
+
+  @AfterClass
+  public static void disableKeyAsSegment() {
+    client.getConfiguration().setKeyAsSegment(false);
+  }
+}