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:34 UTC

[02/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/LinkTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/LinkTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/LinkTestITCase.java
new file mode 100644
index 0000000..6e08f74
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/LinkTestITCase.java
@@ -0,0 +1,177 @@
+/*
+ * 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.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotNull;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Collections;
+import java.util.List;
+import org.apache.olingo.client.api.communication.request.UpdateType;
+import org.apache.olingo.client.api.communication.request.cud.ODataLinkCreateRequest;
+import org.apache.olingo.client.api.communication.request.cud.ODataLinkUpdateRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataLinkCollectionRequest;
+import org.apache.olingo.client.api.communication.response.ODataLinkOperationResponse;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.domain.ODataLink;
+import org.apache.olingo.client.api.domain.ODataLinkCollection;
+import org.apache.olingo.client.api.format.ODataFormat;
+import org.apache.olingo.client.api.uri.URIBuilder;
+import org.apache.olingo.client.api.uri.V3URIBuilder;
+import org.junit.Test;
+
+/**
+ * This is the unit test class to check basic link operations.
+ */
+public class LinkTestITCase extends AbstractV3TestITCase {
+
+  protected String getServiceRoot() {
+    return testStaticServiceRootURL;
+  }
+
+  private ODataLinkCollection doRetrieveLinkURIs(final ODataFormat format, final String linkname) throws IOException {
+    final URIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()).
+            appendEntitySetSegment("Customer").appendKeySegment(-10);
+
+    final ODataLinkCollectionRequest req =
+            client.getRetrieveRequestFactory().getLinkCollectionRequest(uriBuilder.build(), linkname);
+    req.setFormat(format);
+
+    final ODataRetrieveResponse<ODataLinkCollection> res = req.execute();
+    assertEquals(200, res.getStatusCode());
+
+    return res.getBody();
+  }
+
+  private void retrieveLinkURIs(final ODataFormat format) throws IOException {
+    final List<URI> links = doRetrieveLinkURIs(format, "Logins").getLinks();
+    assertEquals(2, links.size());
+    assertTrue(links.contains(URI.create(getServiceRoot() + "/Login('1')")));
+    assertTrue(links.contains(URI.create(getServiceRoot() + "/Login('4')")));
+  }
+
+  @Test
+  public void retrieveXMLLinkURIsWithNext() throws IOException {
+    final ODataLinkCollection uris = doRetrieveLinkURIs(ODataFormat.XML, "Orders");
+    assertEquals(2, uris.getLinks().size());
+    assertNotNull(uris.getNext());
+  }
+
+  @Test
+  public void retrieveXMLLinkURIs() throws IOException {
+    retrieveLinkURIs(ODataFormat.XML);
+  }
+
+  @Test
+  public void retrieveJSONLinkURIs() throws IOException {
+    retrieveLinkURIs(ODataFormat.JSON);
+  }
+
+  private void createLink(final ODataFormat format) throws IOException {
+    // 1. read current Logins $links (for later usage)
+    final List<URI> before = doRetrieveLinkURIs(format, "Logins").getLinks();
+    assertEquals(2, before.size());
+
+    // 2. create new link
+    final ODataLink newLink = client.getObjectFactory().
+            newAssociationLink(null, URI.create(getServiceRoot() + "/Login('3')"));
+
+    final URIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()).
+            appendEntitySetSegment("Customer").appendKeySegment(-10).appendLinksSegment("Logins");
+
+    final ODataLinkCreateRequest req =
+            client.getCUDRequestFactory().getLinkCreateRequest(uriBuilder.build(), newLink);
+    req.setFormat(format);
+
+    final ODataLinkOperationResponse res = req.execute();
+    assertEquals(204, res.getStatusCode());
+
+    final List<URI> after = doRetrieveLinkURIs(format, "Logins").getLinks();
+    assertEquals(before.size() + 1, after.size());
+
+    // 3. reset Logins $links as before this test was run
+    after.removeAll(before);
+    assertEquals(Collections.singletonList(newLink.getLink()), after);
+
+    assertEquals(204, client.getCUDRequestFactory().getDeleteRequest(
+            client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer").
+            appendKeySegment(-10).appendLinksSegment("Logins('3')").build()).execute().getStatusCode());
+  }
+
+  @Test
+  public void createXMLLink() throws IOException {
+    createLink(ODataFormat.XML);
+  }
+
+  @Test
+  public void createJSONLink() throws IOException {
+    createLink(ODataFormat.JSON);
+  }
+
+  private void updateLink(final ODataFormat format, final UpdateType updateType) throws IOException {
+    // 1. read what is the link before the test runs
+    final URI before = doRetrieveLinkURIs(format, "Info").getLinks().get(0);
+
+    // 2. update the link
+    ODataLink newLink =
+            client.getObjectFactory().newAssociationLink(null, URI.create(getServiceRoot() + "/CustomerInfo(12)"));
+
+    final V3URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot());
+    uriBuilder.appendEntitySetSegment("Customer").appendKeySegment(-10).appendLinksSegment("Info");
+
+    ODataLinkUpdateRequest req =
+            client.getCUDRequestFactory().getLinkUpdateRequest(uriBuilder.build(), updateType, newLink);
+    req.setFormat(format);
+
+    ODataLinkOperationResponse res = req.execute();
+    assertEquals(204, res.getStatusCode());
+
+    URI after = doRetrieveLinkURIs(format, "Info").getLinks().get(0);
+    assertNotEquals(before, after);
+    assertEquals(newLink.getLink(), after);
+
+    // 3. reset back the link value
+    newLink = client.getObjectFactory().newAssociationLink(null, before);
+    req = client.getCUDRequestFactory().getLinkUpdateRequest(uriBuilder.build(), updateType, newLink);
+    req.setFormat(format);
+
+    res = req.execute();
+    assertEquals(204, res.getStatusCode());
+
+    after = doRetrieveLinkURIs(format, "Info").getLinks().get(0);
+    assertEquals(before, after);
+  }
+
+  @Test
+  public void updateXMLLink() throws IOException {
+    updateLink(ODataFormat.XML, UpdateType.MERGE);
+    updateLink(ODataFormat.XML, UpdateType.PATCH);
+    updateLink(ODataFormat.XML, UpdateType.REPLACE);
+  }
+
+  @Test
+  public void updateJSONLink() throws IOException {
+    updateLink(ODataFormat.JSON, UpdateType.MERGE);
+    updateLink(ODataFormat.JSON, UpdateType.PATCH);
+    updateLink(ODataFormat.JSON, UpdateType.REPLACE);
+  }
+}

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/MediaEntityTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/MediaEntityTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/MediaEntityTestITCase.java
new file mode 100644
index 0000000..004378c
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/MediaEntityTestITCase.java
@@ -0,0 +1,221 @@
+/*
+ * 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 java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import org.apache.commons.io.IOUtils;
+import org.apache.olingo.client.api.communication.ODataClientErrorException;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataMediaRequest;
+import org.apache.olingo.client.api.communication.request.streamed.MediaEntityCreateStreamManager;
+import org.apache.olingo.client.api.communication.request.streamed.MediaEntityUpdateStreamManager;
+import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityCreateRequest;
+import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityUpdateRequest;
+import org.apache.olingo.client.api.communication.request.streamed.ODataStreamUpdateRequest;
+import org.apache.olingo.client.api.communication.request.streamed.StreamUpdateStreamManager;
+import org.apache.olingo.client.api.communication.response.ODataMediaEntityCreateResponse;
+import org.apache.olingo.client.api.communication.response.ODataMediaEntityUpdateResponse;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.communication.response.ODataStreamUpdateResponse;
+import org.apache.olingo.client.api.domain.ODataEntity;
+import org.apache.olingo.client.api.domain.ODataProperty;
+import org.apache.olingo.client.api.format.ODataMediaFormat;
+import org.apache.olingo.client.api.format.ODataPubFormat;
+import org.apache.olingo.client.api.http.HttpClientException;
+import org.apache.olingo.client.api.uri.URIBuilder;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class MediaEntityTestITCase extends AbstractV3TestITCase {
+
+  @Test
+  @Ignore
+  public void read() throws Exception {
+    final URIBuilder<?> builder = client.getURIBuilder(testStaticServiceRootURL).
+            appendEntitySetSegment("Car").appendKeySegment(12).appendValueSegment();
+
+    final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build());
+    retrieveReq.setFormat(ODataMediaFormat.WILDCARD);
+
+    final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute();
+    assertEquals(200, retrieveRes.getStatusCode());
+
+    final byte[] actual = new byte[Integer.parseInt(retrieveRes.getHeader("Content-Length").iterator().next())];
+    IOUtils.read(retrieveRes.getBody(), actual, 0, actual.length);
+  }
+
+  @Test(expected = ODataClientErrorException.class)
+  @Ignore
+  public void readWithXmlError() throws Exception {
+    final URIBuilder<?> builder = client.getURIBuilder(testStaticServiceRootURL).
+            appendEntitySetSegment("Car").appendKeySegment(12).appendValueSegment();
+
+    final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build());
+    retrieveReq.setFormat(ODataMediaFormat.APPLICATION_XML);
+
+    retrieveReq.execute();
+  }
+
+  @Test(expected = ODataClientErrorException.class)
+  @Ignore
+  public void readWithJsonError() throws Exception {
+    final URIBuilder<?> builder = client.getURIBuilder(testStaticServiceRootURL).
+            appendEntitySetSegment("Car").appendKeySegment(12).appendValueSegment();
+
+    final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build());
+    retrieveReq.setFormat(ODataMediaFormat.APPLICATION_JSON);
+
+    retrieveReq.execute();
+  }
+
+  @Test
+  @Ignore
+  public void updateMediaEntityAsAtom() throws Exception {
+    updateMediaEntity(ODataPubFormat.ATOM, 14);
+  }
+
+  @Test
+  @Ignore
+  public void updateMediaEntityAsJson() throws Exception {
+    updateMediaEntity(ODataPubFormat.JSON, 15);
+  }
+
+  @Test
+  @Ignore
+  public void createMediaEntityAsAtom() throws Exception {
+    createMediaEntity(ODataPubFormat.ATOM, IOUtils.toInputStream("buffered stream sample"));
+  }
+
+  @Test
+  @Ignore
+  public void createMediaEntityAsJson() throws Exception {
+    createMediaEntity(ODataPubFormat.JSON, IOUtils.toInputStream("buffered stream sample"));
+  }
+
+  @Test
+  @Ignore
+  public void issue137() throws Exception {
+    createMediaEntity(ODataPubFormat.JSON, this.getClass().getResourceAsStream("/sample.png"));
+  }
+
+  @Test
+  @Ignore
+  public void issue136() throws Exception {
+    byte[] input = new byte[65000];
+    for (int i = 0; i < 65000; i++) {
+      input[i] = (byte) i;
+    }
+    createMediaEntity(ODataPubFormat.ATOM, new ByteArrayInputStream(input));
+  }
+
+  @Test(expected = HttpClientException.class)
+  @Ignore
+  public void issue136FailsWithException() throws Exception {
+    byte[] input = new byte[68000];
+    for (int i = 0; i < 68000; i++) {
+      input[i] = (byte) i;
+    }
+    createMediaEntity(ODataPubFormat.ATOM, new ByteArrayInputStream(input));
+  }
+
+  @Test
+  @Ignore
+  public void updateNamedStream() throws Exception {
+    URIBuilder<?> builder = client.getURIBuilder(testStaticServiceRootURL).
+            appendEntitySetSegment("Car").appendKeySegment(16).appendNavigationSegment("Photo");
+
+    final String TO_BE_UPDATED = "buffered stream sample";
+    final InputStream input = new ByteArrayInputStream(TO_BE_UPDATED.getBytes());
+
+    final ODataStreamUpdateRequest updateReq =
+            client.getStreamedRequestFactory().getStreamUpdateRequest(builder.build(), input);
+
+    final StreamUpdateStreamManager streamManager = updateReq.execute();
+    final ODataStreamUpdateResponse updateRes = streamManager.getResponse();
+    updateRes.close();
+    assertEquals(204, updateRes.getStatusCode());
+
+    final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build());
+
+    final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute();
+    assertEquals(200, retrieveRes.getStatusCode());
+    assertEquals(TO_BE_UPDATED, IOUtils.toString(retrieveRes.getBody()));
+  }
+
+  private void updateMediaEntity(final ODataPubFormat format, final int id) throws Exception {
+    URIBuilder<?> builder = client.getURIBuilder(testStaticServiceRootURL).
+            appendEntitySetSegment("Car").appendKeySegment(id).appendValueSegment();
+
+    final String TO_BE_UPDATED = "new buffered stream sample";
+    final InputStream input = IOUtils.toInputStream(TO_BE_UPDATED);
+
+    final ODataMediaEntityUpdateRequest updateReq =
+            client.getStreamedRequestFactory().getMediaEntityUpdateRequest(builder.build(), input);
+    updateReq.setFormat(format);
+
+    final MediaEntityUpdateStreamManager streamManager = updateReq.execute();
+    final ODataMediaEntityUpdateResponse updateRes = streamManager.getResponse();
+    assertEquals(204, updateRes.getStatusCode());
+
+    builder = client.getURIBuilder(testStaticServiceRootURL).
+            appendEntitySetSegment("Car").appendKeySegment(id).appendValueSegment();
+
+    final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build());
+
+    final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute();
+    assertEquals(200, retrieveRes.getStatusCode());
+    assertEquals(TO_BE_UPDATED, IOUtils.toString(retrieveRes.getBody()));
+  }
+
+  private void createMediaEntity(final ODataPubFormat format, final InputStream input) throws Exception {
+    final URIBuilder<?> builder = client.getURIBuilder(testStaticServiceRootURL).
+            appendEntitySetSegment("Car");
+
+    final ODataMediaEntityCreateRequest createReq =
+            client.getStreamedRequestFactory().getMediaEntityCreateRequest(builder.build(), input);
+    createReq.setFormat(format);
+
+    final MediaEntityCreateStreamManager streamManager = createReq.execute();
+    final ODataMediaEntityCreateResponse createRes = streamManager.getResponse();
+    assertEquals(201, createRes.getStatusCode());
+
+    final ODataEntity created = createRes.getBody();
+    assertNotNull(created);
+    assertEquals(2, created.getProperties().size());
+
+    Integer id = null;
+    for (ODataProperty prop : created.getProperties()) {
+      if ("VIN".equals(prop.getName())) {
+        id = prop.getPrimitiveValue().<Integer>toCastValue();
+      }
+    }
+    assertNotNull(id);
+
+    builder.appendKeySegment(id).appendValueSegment();
+
+    final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build());
+
+    final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute();
+    assertEquals(200, retrieveRes.getStatusCode());
+    assertNotNull(retrieveRes.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/NavigationLinkCreateTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/NavigationLinkCreateTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/NavigationLinkCreateTestITCase.java
new file mode 100644
index 0000000..b1aa071
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/NavigationLinkCreateTestITCase.java
@@ -0,0 +1,520 @@
+/*
+ * 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.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+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.ODataCollectionValue;
+import org.apache.olingo.client.api.domain.ODataComplexValue;
+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.ODataJClientEdmPrimitiveType;
+import org.apache.olingo.client.api.domain.ODataLink;
+import org.apache.olingo.client.api.domain.ODataProperty;
+import org.apache.olingo.client.api.domain.ODataValue;
+import org.apache.olingo.client.api.format.ODataPubFormat;
+import org.apache.olingo.client.api.http.HttpClientException;
+import org.apache.olingo.client.api.uri.URIBuilder;
+import org.apache.olingo.client.api.utils.URIUtils;
+
+import org.junit.Test;
+
+import org.junit.Ignore;
+
+public class NavigationLinkCreateTestITCase extends AbstractV3TestITCase {
+
+  // create navigation link with ATOM
+  @Test
+  public void createNavWithAtom() {
+    final ODataPubFormat format = ODataPubFormat.ATOM;
+    final String contentType = "application/atom+xml";
+    final String prefer = "return-content";
+    final ODataEntity actual = createNavigation(format, 20, contentType, prefer);
+    delete(format, actual, false, testStaticServiceRootURL);
+  }
+  // create navigation link with JSON full metadata
+
+  @Test
+  public void createNavWithJSONFullMetadata() {
+    final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+    final String contentType = "application/json;odata=fullmetadata";
+    final String prefer = "return-content";
+    final ODataEntity actual = createNavigation(format, 21, contentType, prefer);
+    delete(format, actual, false, testStaticServiceRootURL);
+  }
+  // throws Null pointer exception when the format is JSON No metadata
+
+  @Test(expected = HttpClientException.class)
+  public void createNavWithJSONNoMetadata() {
+    final ODataPubFormat format = ODataPubFormat.JSON_NO_METADATA;
+    final String contentType = "application/json;odata=nometadata";
+    final String prefer = "return-content";
+    final ODataEntity actual = createNavigation(format, 22, contentType, prefer);
+    delete(format, actual, false, testStaticServiceRootURL);
+  }
+  // test with JSON accept and atom content type
+
+  @Test
+  @Ignore
+  public void createNavWithJSONAndATOM() {
+    final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+    final String contentType = "application/atom+xml";
+    final String prefer = "return-content";
+    final ODataEntity actual = createNavigation(format, 23, contentType, prefer);
+    delete(format, actual, false, testStaticServiceRootURL);
+  }
+  // test with JSON full metadata in format and json no metadata in content type
+
+  @Test
+  public void createNavWithDiffJSON() {
+    final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+    final String contentType = "application/json;odata=nometadata";
+    final String prefer = "return-content";
+    final ODataEntity actual = createNavigation(format, 24, contentType, prefer);
+    delete(format, actual, false, testStaticServiceRootURL);
+  }
+  // test with JSON no metadata format and json no metadata in content type
+
+  @Test(expected = HttpClientException.class)
+  public void createNavWithNoMetadata() {
+    final ODataPubFormat format = ODataPubFormat.JSON_NO_METADATA;
+    final String contentType = "application/json;odata=fullmetadata";
+    final String prefer = "return-content";
+    final ODataEntity actual = createNavigation(format, 25, contentType, prefer);
+    delete(format, actual, false, testStaticServiceRootURL);
+  }
+  // create collection navigation link with ATOM
+
+  @Test
+  public void createCollectionNavWithAtom() {
+    final ODataPubFormat format = ODataPubFormat.ATOM;
+    final String contentType = "application/atom+xml";
+    final String prefer = "return-content";
+    final ODataEntity actual = createCollectionNavigation(format, 55, contentType, prefer);
+    delete(format, actual, false, testStaticServiceRootURL);
+  }
+  // create collection navigation link with JSON
+
+  @Test
+  public void createCollectionNavWithJSON() {
+    final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
+    final String contentType = "application/json;odata=fullmetadata";
+    final String prefer = "return-content";
+    final ODataEntity actual = createCollectionNavigation(format, 77, contentType, prefer);
+    delete(format, actual, false, testStaticServiceRootURL);
+  }
+
+  // create a navigation link
+  public ODataEntity createNavigation(final ODataPubFormat format, final int id, final String contenttype,
+          final String prefer) {
+    final String name = "Customer Navigation test";
+
+    final ODataEntity original = getNewCustomer(id, name, false);
+    original.addLink(client.getObjectFactory().newEntityNavigationLink(
+            "Info", URI.create(testStaticServiceRootURL + "/CustomerInfo(11)")));
+    final ODataEntity created = createNav(testStaticServiceRootURL, format, original, "Customer", contenttype,
+            prefer);
+
+    final ODataEntity actual = validateEntities(testStaticServiceRootURL, format, created, id, null, "Customer");
+
+    final URIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL);
+    uriBuilder.appendEntitySetSegment("Customer").appendKeySegment(id).appendEntitySetSegment("Info");
+
+    final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
+    req.setFormat(format);
+    req.setContentType(contenttype);
+    req.setPrefer(prefer);
+    final ODataRetrieveResponse<ODataEntity> res = req.execute();
+    assertEquals(200, res.getStatusCode());
+    assertTrue(res.getHeader("DataServiceVersion").contains("3.0;"));
+    final ODataEntity entity = res.getBody();
+    assertNotNull(entity);
+    for (ODataProperty prop : entity.getProperties()) {
+      if ("CustomerInfoId".equals(prop.getName())) {
+        assertEquals("11", prop.getValue().toString());
+      }
+    }
+    return actual;
+  }
+
+  // create a navigation link
+  public ODataEntity createNav(final String url, final ODataPubFormat format, final ODataEntity original,
+          final String entitySetName, final String contentType, final String prefer) {
+    final URIBuilder<?> uriBuilder = client.getURIBuilder(url);
+    uriBuilder.appendEntitySetSegment(entitySetName);
+    final ODataEntityCreateRequest createReq =
+            client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), original);
+    createReq.setFormat(format);
+    createReq.setContentType(contentType);
+    createReq.setPrefer(prefer);
+    final ODataEntityCreateResponse createRes = createReq.execute();
+    assertEquals(201, createRes.getStatusCode());
+
+    assertEquals("Created", createRes.getStatusMessage());
+
+    final ODataEntity created = createRes.getBody();
+    assertNotNull(created);
+    return created;
+  }
+  // create collection navigation link
+
+  public ODataEntity createCollectionNavigation(final ODataPubFormat format, final int id,
+          final String contentType, final String prefer) {
+    {
+      final String name = "Collection Navigation Key Customer";
+      final ODataEntity original = getNewCustomer(id, name, false);
+
+      final Set<Integer> navigationKeys = new HashSet<Integer>();
+      navigationKeys.add(-118);
+      navigationKeys.add(-119);
+
+      for (Integer key : navigationKeys) {
+        final ODataEntity orderEntity =
+                client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Order");
+
+        orderEntity.getProperties().add(client.getObjectFactory().newPrimitiveProperty("OrderId",
+                client.getPrimitiveValueBuilder().setValue(key).setType(ODataJClientEdmPrimitiveType.Int32).build()));
+        orderEntity.getProperties().add(client.getObjectFactory().newPrimitiveProperty("CustomerId",
+                client.getPrimitiveValueBuilder().setValue(id).setType(ODataJClientEdmPrimitiveType.Int32).build()));
+
+        final ODataEntityCreateRequest createReq = client.getCUDRequestFactory().getEntityCreateRequest(
+                client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Order").build(),
+                orderEntity);
+        createReq.setFormat(format);
+        createReq.setContentType(contentType);
+        original.addLink(client.getObjectFactory().newFeedNavigationLink(
+                "Orders",
+                createReq.execute().getBody().getEditLink()));
+      }
+      final ODataEntity createdEntity = createNav(testStaticServiceRootURL, format, original, "Customer",
+              contentType, prefer);
+      final ODataEntity actualEntity =
+              validateEntities(testStaticServiceRootURL, format, createdEntity, id, null, "Customer");
+
+      final URIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL);
+      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(navigationKeys.contains(key));
+        assertEquals(Integer.valueOf(id), customerId);
+        navigationKeys.remove(key);
+        final ODataDeleteRequest deleteReq = client.getCUDRequestFactory().getDeleteRequest(
+                URIUtils.getURI(testStaticServiceRootURL, entity.getEditLink().toASCIIString()));
+
+        deleteReq.setFormat(format);
+        assertEquals(204, deleteReq.execute().getStatusCode());
+      }
+
+      return actualEntity;
+    }
+  }
+  // get a Customer entity to be created
+
+  public ODataEntity getNewCustomer(
+          final int id, final String name, final boolean withInlineInfo) {
+
+    final ODataEntity entity =
+            client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Customer");
+
+    // add name attribute
+    entity.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Name",
+            client.getPrimitiveValueBuilder().setText(name).setType(ODataJClientEdmPrimitiveType.String).build()));
+
+    // add key attribute
+    if (id != 0) {
+      entity.getProperties().add(client.getObjectFactory().newPrimitiveProperty("CustomerId",
+              client.getPrimitiveValueBuilder().setText(String.valueOf(id)).
+              setType(ODataJClientEdmPrimitiveType.Int32).build()));
+    }
+    final ODataCollectionValue backupContactInfoValue = new ODataCollectionValue(
+            "Collection(Microsoft.Test.OData.Services.AstoriaDefaultService.ContactDetails)");
+
+
+    final ODataComplexValue contactDetails = new ODataComplexValue(
+            "Microsoft.Test.OData.Services.AstoriaDefaultService.ContactDetails");
+
+
+    final ODataCollectionValue altNamesValue = new ODataCollectionValue("Collection(Edm.String)");
+    altNamesValue.add(client.getPrimitiveValueBuilder().
+            setText("My Alternative name").setType(ODataJClientEdmPrimitiveType.String).build());
+    contactDetails.add(client.getObjectFactory().newCollectionProperty("AlternativeNames", altNamesValue));
+
+    final ODataCollectionValue emailBagValue = new ODataCollectionValue("Collection(Edm.String)");
+    emailBagValue.add(client.getPrimitiveValueBuilder().
+            setText("altname@mydomain.com").setType(ODataJClientEdmPrimitiveType.String).build());
+    contactDetails.add(client.getObjectFactory().newCollectionProperty("EmailBag", emailBagValue));
+
+    final ODataComplexValue contactAliasValue = new ODataComplexValue(
+            "Microsoft.Test.OData.Services.AstoriaDefaultService.Aliases");
+    contactDetails.add(client.getObjectFactory().newComplexProperty("ContactAlias", contactAliasValue));
+
+    final ODataCollectionValue aliasAltNamesValue = new ODataCollectionValue("Collection(Edm.String)");
+    aliasAltNamesValue.add(client.getPrimitiveValueBuilder().
+            setText("myAlternativeName").setType(ODataJClientEdmPrimitiveType.String).build());
+    contactAliasValue.add(client.getObjectFactory().newCollectionProperty("AlternativeNames", aliasAltNamesValue));
+
+    final ODataComplexValue homePhone = new ODataComplexValue(
+            "Microsoft.Test.OData.Services.AstoriaDefaultService.Phone");
+    homePhone.add(client.getObjectFactory().newPrimitiveProperty("PhoneNumber",
+            client.getPrimitiveValueBuilder().setText("8437568356834568").
+            setType(ODataJClientEdmPrimitiveType.String).build()));
+    homePhone.add(client.getObjectFactory().newPrimitiveProperty("Extension",
+            client.getPrimitiveValueBuilder().setText("124365426534621534423ttrf").
+            setType(ODataJClientEdmPrimitiveType.String).
+            build()));
+    contactDetails.add(client.getObjectFactory().newComplexProperty("HomePhone", homePhone));
+
+    backupContactInfoValue.add(contactDetails);
+    entity.getProperties().add(client.getObjectFactory().newCollectionProperty("BackupContactInfo",
+            backupContactInfoValue));
+    if (withInlineInfo) {
+      final ODataInlineEntity inlineInfo = client.getObjectFactory().newInlineEntity("Info", URI.create(
+              "Customer(" + id
+              + ")/Info"), getInfo(id, name + "_Info"));
+      inlineInfo.getEntity().setMediaEntity(true);
+      entity.addLink(inlineInfo);
+    }
+
+    return entity;
+  }
+  //delete an entity and associated links after creation
+
+  public void delete(final ODataPubFormat format, final ODataEntity created, final boolean includeInline,
+          final String baseUri) {
+    final Set<URI> toBeDeleted = new HashSet<URI>();
+    toBeDeleted.add(created.getEditLink());
+
+    if (includeInline) {
+      for (ODataLink link : created.getNavigationLinks()) {
+        if (link instanceof ODataInlineEntity) {
+          final ODataEntity inline = ((ODataInlineEntity) link).getEntity();
+          if (inline.getEditLink() != null) {
+            toBeDeleted.add(URIUtils.getURI(baseUri, inline.getEditLink().toASCIIString()));
+          }
+        }
+
+        if (link instanceof ODataInlineEntitySet) {
+          final ODataEntitySet inline = ((ODataInlineEntitySet) link).getEntitySet();
+          for (ODataEntity entity : inline.getEntities()) {
+            if (entity.getEditLink() != null) {
+              toBeDeleted.add(URIUtils.getURI(baseUri, entity.getEditLink().toASCIIString()));
+            }
+          }
+        }
+      }
+    }
+    assertFalse(toBeDeleted.isEmpty());
+
+    for (URI link : toBeDeleted) {
+      final ODataDeleteRequest deleteReq = client.getCUDRequestFactory().getDeleteRequest(link);
+      final ODataDeleteResponse deleteRes = deleteReq.execute();
+
+      assertEquals(204, deleteRes.getStatusCode());
+      assertEquals("No Content", deleteRes.getStatusMessage());
+
+      deleteRes.close();
+    }
+  }
+  // add Information property
+
+  public ODataEntity getInfo(final int id, final String info) {
+    final ODataEntity entity =
+            client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.CustomerInfo");
+    entity.setMediaEntity(true);
+
+    entity.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Information",
+            client.getPrimitiveValueBuilder().setText(info).setType(ODataJClientEdmPrimitiveType.String).build()));
+    return entity;
+  }
+  // validate newly created entities
+
+  public ODataEntity validateEntities(final String serviceRootURL,
+          final ODataPubFormat format,
+          final ODataEntity original,
+          final int actualObjectId,
+          final Collection<String> expands, final String entitySetName) {
+
+    final URIBuilder<?> uriBuilder = client.getURIBuilder(serviceRootURL).
+            appendEntitySetSegment(entitySetName).appendKeySegment(actualObjectId);
+
+    if (expands != null) {
+      for (String expand : expands) {
+        uriBuilder.expand(expand);
+      }
+    }
+    final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
+    req.setFormat(format);
+
+    final ODataRetrieveResponse<ODataEntity> res = req.execute();
+    assertEquals(200, res.getStatusCode());
+
+    final ODataEntity actual = res.getBody();
+    assertNotNull(actual);
+
+    validateLinks(original.getAssociationLinks(), actual.getAssociationLinks());
+    validateLinks(original.getEditMediaLinks(), actual.getEditMediaLinks());
+    validateLinks(original.getNavigationLinks(), actual.getNavigationLinks());
+
+    checkProperties(original.getProperties(), actual.getProperties());
+    return actual;
+  }
+  // compares links of the newly created entity with the previous 
+
+  public void validateLinks(final Collection<ODataLink> original, final Collection<ODataLink> actual) {
+    assertTrue(original.size() <= actual.size());
+
+    for (ODataLink originalLink : original) {
+      ODataLink foundOriginal = null;
+      ODataLink foundActual = null;
+
+      for (ODataLink actualLink : actual) {
+
+        if (actualLink.getType() == originalLink.getType()
+                && (originalLink.getLink() == null
+                || actualLink.getLink().toASCIIString().endsWith(originalLink.getLink().toASCIIString()))
+                && actualLink.getName().equals(originalLink.getName())) {
+
+          foundOriginal = originalLink;
+          foundActual = actualLink;
+        }
+      }
+
+      assertNotNull(foundOriginal);
+      assertNotNull(foundActual);
+
+      if (foundOriginal instanceof ODataInlineEntity && foundActual instanceof ODataInlineEntity) {
+        final ODataEntity originalInline = ((ODataInlineEntity) foundOriginal).getEntity();
+        assertNotNull(originalInline);
+
+        final ODataEntity actualInline = ((ODataInlineEntity) foundActual).getEntity();
+        assertNotNull(actualInline);
+
+        checkProperties(originalInline.getProperties(), actualInline.getProperties());
+      }
+    }
+  }
+  // compares properties of the newly created entity with the properties that were originally provided
+
+  @Override
+  public void checkProperties(final Collection<ODataProperty> original, final Collection<ODataProperty> actual) {
+    assertTrue(original.size() <= actual.size());
+
+    final Map<String, ODataProperty> actualProperties = new HashMap<String, ODataProperty>(actual.size());
+
+    for (ODataProperty prop : actual) {
+      assertFalse(actualProperties.containsKey(prop.getName()));
+      actualProperties.put(prop.getName(), prop);
+    }
+
+    assertTrue(actual.size() <= actualProperties.size());
+
+    for (ODataProperty prop : original) {
+      assertNotNull(prop);
+      if (actualProperties.containsKey(prop.getName())) {
+        final ODataProperty actualProp = actualProperties.get(prop.getName());
+        assertNotNull(actualProp);
+
+        if (prop.getValue() != null && actualProp.getValue() != null) {
+          checkPropertyValue(prop.getName(), prop.getValue(), actualProp.getValue());
+        }
+      }
+    }
+  }
+  // compares property value of the newly created entity with the property value that were originally provided
+
+  @Override
+  public void checkPropertyValue(final String propertyName,
+          final ODataValue original, final ODataValue actual) {
+
+    assertNotNull("Null original value for " + propertyName, original);
+    assertNotNull("Null actual value for " + propertyName, actual);
+
+    assertEquals("Type mismatch for '" + propertyName + "'",
+            original.getClass().getSimpleName(), actual.getClass().getSimpleName());
+
+    if (original.isComplex()) {
+      final List<ODataProperty> originalPropertyValue = new ArrayList<ODataProperty>();
+      for (ODataProperty prop : original.asComplex()) {
+        originalPropertyValue.add(prop);
+      }
+
+      final List<ODataProperty> actualPropertyValue = new ArrayList<ODataProperty>();
+      for (ODataProperty prop : (ODataComplexValue) actual) {
+        actualPropertyValue.add(prop);
+      }
+
+      checkProperties(originalPropertyValue, actualPropertyValue);
+    } else if (original.isCollection()) {
+      assertTrue(original.asCollection().size() <= actual.asCollection().size());
+
+      boolean found = original.asCollection().isEmpty();
+
+      for (ODataValue originalValue : original.asCollection()) {
+        for (ODataValue actualValue : actual.asCollection()) {
+          try {
+            checkPropertyValue(propertyName, originalValue, actualValue);
+            found = true;
+          } catch (AssertionError error) {
+          }
+        }
+      }
+
+      assertTrue("Found " + actual + " and expected " + original, found);
+    } else {
+      assertTrue("Primitive value for '" + propertyName + "' type mismatch",
+              original.asPrimitive().getTypeName().equals(actual.asPrimitive().getTypeName()));
+
+      assertEquals("Primitive value for '" + propertyName + "' mismatch",
+              original.asPrimitive().toString(), actual.asPrimitive().toString());
+    }
+  }
+}

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/OpenTypeTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/OpenTypeTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/OpenTypeTestITCase.java
new file mode 100644
index 0000000..074228a
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/OpenTypeTestITCase.java
@@ -0,0 +1,273 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+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.ODataComplexValue;
+import org.apache.olingo.client.api.domain.ODataEntity;
+import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
+import org.apache.olingo.client.api.domain.geospatial.Geospatial;
+import org.apache.olingo.client.api.domain.geospatial.GeospatialCollection;
+import org.apache.olingo.client.api.domain.geospatial.LineString;
+import org.apache.olingo.client.api.domain.geospatial.MultiLineString;
+import org.apache.olingo.client.api.domain.geospatial.MultiPoint;
+import org.apache.olingo.client.api.domain.geospatial.MultiPolygon;
+import org.apache.olingo.client.api.domain.geospatial.Point;
+import org.apache.olingo.client.api.domain.geospatial.Polygon;
+import org.apache.olingo.client.api.format.ODataPubFormat;
+import org.apache.olingo.client.api.uri.URIBuilder;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmSchema;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class OpenTypeTestITCase extends AbstractV3TestITCase {
+
+  @Test
+  public void checkOpenTypeEntityTypesExist() {
+    final Edm metadata = client.getRetrieveRequestFactory().
+            getMetadataRequest(testStaticServiceRootURL).execute().getBody();
+
+    final EdmSchema schema = metadata.getSchemas().get(0);
+
+    // TODO: https://issues.apache.org/jira/browse/OLINGO-209
+//        assertTrue(metadata.getEntityType(new FullQualifiedName(schema.getNamespace(), "Row")).isOpenType());
+//        assertTrue(metadata.getEntityType(new FullQualifiedName(schema.getNamespace(), "IndexedRow")).isOpenType());
+//        assertTrue(metadata.getEntityType(new FullQualifiedName(schema.getNamespace(), "RowIndex")).isOpenType());
+  }
+
+  private ODataEntity readRow(final ODataPubFormat format, final String uuid) {
+    final URIBuilder<?> builder = client.getURIBuilder(testStaticServiceRootURL).
+            appendEntitySetSegment("Row").appendKeySegment(UUID.fromString(uuid));
+    return read(format, builder.build());
+  }
+
+  private void read(final ODataPubFormat format) {
+    ODataEntity row = readRow(format, "71f7d0dc-ede4-45eb-b421-555a2aa1e58f");
+    assertEquals(
+            ODataJClientEdmPrimitiveType.Double.toString(),
+            row.getProperty("Double").getPrimitiveValue().getTypeName());
+    assertEquals(
+            ODataJClientEdmPrimitiveType.Guid.toString(),
+            row.getProperty("Id").getPrimitiveValue().getTypeName());
+
+    row = readRow(format, "672b8250-1e6e-4785-80cf-b94b572e42b3");
+    assertEquals(
+            ODataJClientEdmPrimitiveType.Decimal.toString(),
+            row.getProperty("Decimal").getPrimitiveValue().getTypeName());
+  }
+
+  @Test
+  @Ignore
+  public void readAsAtom() {
+    read(ODataPubFormat.ATOM);
+  }
+
+  @Test
+  @Ignore
+  public void readAsJSON() {
+    read(ODataPubFormat.JSON_FULL_METADATA);
+  }
+
+  private void cud(final ODataPubFormat format) {
+    final UUID guid = UUID.randomUUID();
+
+    ODataEntity row = client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.OpenTypesService.Row");
+    row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Id",
+            client.getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Guid).setValue(guid).
+            build()));
+    row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aString",
+            client.getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.String).setValue("string").
+            build()));
+    row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aBoolean",
+            client.getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Boolean).setValue(true).
+            build()));
+    row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aLong",
+            client.getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Int64).setValue(15L).
+            build()));
+    row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aDouble",
+            client.getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Double).setValue(1.5D).
+            build()));
+    row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aByte",
+            client.getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.SByte).setValue(Byte.MAX_VALUE).
+            build()));
+    row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aDate",
+            client.getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.DateTime).setValue(new Date()).
+            build()));
+
+    final Point point = new Point(Geospatial.Dimension.GEOGRAPHY);
+    point.setX(1.2);
+    point.setY(2.1);
+    row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aPoint",
+            client.getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeographyPoint).
+            setValue(point).build()));
+    final List<Point> points = new ArrayList<Point>();
+    points.add(point);
+    points.add(point);
+    final MultiPoint multipoint = new MultiPoint(Geospatial.Dimension.GEOMETRY, points);
+    row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aMultiPoint",
+            client.getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeometryMultiPoint).
+            setValue(multipoint).build()));
+    final LineString lineString = new LineString(Geospatial.Dimension.GEOMETRY, points);
+    row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aLineString",
+            client.getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeometryLineString).
+            setValue(lineString).build()));
+    final List<LineString> lineStrings = new ArrayList<LineString>();
+    lineStrings.add(lineString);
+    lineStrings.add(lineString);
+    final MultiLineString multiLineString = new MultiLineString(Geospatial.Dimension.GEOGRAPHY, lineStrings);
+    row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aMultiLineString",
+            client.getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeometryMultiLineString).
+            setValue(multiLineString).build()));
+    final Point otherPoint = new Point(Geospatial.Dimension.GEOGRAPHY);
+    otherPoint.setX(3.4);
+    otherPoint.setY(4.3);
+    points.set(1, otherPoint);
+    points.add(otherPoint);
+    points.add(point);
+    final Polygon polygon =
+            new Polygon(Geospatial.Dimension.GEOGRAPHY, points, points);
+    row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aPolygon",
+            client.getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeographyPolygon).
+            setValue(polygon).build()));
+    final List<Polygon> polygons = new ArrayList<Polygon>();
+    polygons.add(polygon);
+    polygons.add(polygon);
+    final MultiPolygon multiPolygon = new MultiPolygon(Geospatial.Dimension.GEOGRAPHY, polygons);
+    row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aMultiPolygon",
+            client.getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeographyMultiPolygon).
+            setValue(multiPolygon).build()));
+    final List<Geospatial> geospatials = new ArrayList<Geospatial>();
+    geospatials.add(otherPoint);
+    geospatials.add(polygon);
+    geospatials.add(multiLineString);
+    geospatials.add(multiPolygon);
+    final GeospatialCollection geoColl = new GeospatialCollection(Geospatial.Dimension.GEOGRAPHY, geospatials);
+    row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aCollection",
+            client.getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeographyCollection).
+            setValue(geoColl).build()));
+
+    final ODataComplexValue contactDetails =
+            new ODataComplexValue("Microsoft.Test.OData.Services.OpenTypesService.ContactDetails");
+    contactDetails.add(client.getObjectFactory().newPrimitiveProperty("FirstContacted",
+            client.getPrimitiveValueBuilder().
+            setType(ODataJClientEdmPrimitiveType.Binary).setValue("text".getBytes()).build()));
+    contactDetails.add(client.getObjectFactory().newPrimitiveProperty("LastContacted",
+            client.getPrimitiveValueBuilder().
+            setType(ODataJClientEdmPrimitiveType.DateTimeOffset).setText("2001-04-05T05:05:05.001+00:01").build()));
+    contactDetails.add(client.getObjectFactory().newPrimitiveProperty("Contacted",
+            client.getPrimitiveValueBuilder().
+            setType(ODataJClientEdmPrimitiveType.DateTime).setText("2001-04-05T05:05:04.001").build()));
+    contactDetails.add(client.getObjectFactory().newPrimitiveProperty("GUID",
+            client.getPrimitiveValueBuilder().
+            setType(ODataJClientEdmPrimitiveType.Guid).setValue(UUID.randomUUID()).build()));
+    contactDetails.add(client.getObjectFactory().newPrimitiveProperty("PreferedContactTime",
+            client.getPrimitiveValueBuilder().
+            setType(ODataJClientEdmPrimitiveType.Time).setText("-P9DT51M10.5063807S").build()));
+    contactDetails.add(client.getObjectFactory().newPrimitiveProperty("Byte",
+            client.getPrimitiveValueBuilder().
+            setType(ODataJClientEdmPrimitiveType.Byte).setValue(Integer.valueOf(241)).build()));
+    contactDetails.add(client.getObjectFactory().newPrimitiveProperty("SignedByte",
+            client.getPrimitiveValueBuilder().
+            setType(ODataJClientEdmPrimitiveType.SByte).setValue(Byte.MAX_VALUE).build()));
+    contactDetails.add(client.getObjectFactory().newPrimitiveProperty("Double",
+            client.getPrimitiveValueBuilder().
+            setType(ODataJClientEdmPrimitiveType.Double).setValue(Double.MAX_VALUE).build()));
+    contactDetails.add(client.getObjectFactory().newPrimitiveProperty("Single",
+            client.getPrimitiveValueBuilder().
+            setType(ODataJClientEdmPrimitiveType.Single).setValue(Float.MAX_VALUE).build()));
+    contactDetails.add(client.getObjectFactory().newPrimitiveProperty("Short",
+            client.getPrimitiveValueBuilder().
+            setType(ODataJClientEdmPrimitiveType.Int16).setValue(Short.MAX_VALUE).build()));
+    contactDetails.add(client.getObjectFactory().newPrimitiveProperty("Int",
+            client.getPrimitiveValueBuilder().
+            setType(ODataJClientEdmPrimitiveType.Int32).setValue(Integer.MAX_VALUE).build()));
+    contactDetails.add(client.getObjectFactory().newPrimitiveProperty("Long",
+            client.getPrimitiveValueBuilder().
+            setType(ODataJClientEdmPrimitiveType.Int64).setValue(Long.MAX_VALUE).build()));
+    row.getProperties().add(client.getObjectFactory().newComplexProperty("aContact", contactDetails));
+
+    final ODataEntityCreateRequest createReq = client.getCUDRequestFactory().
+            getEntityCreateRequest(client.getURIBuilder(testStaticServiceRootURL).
+            appendEntitySetSegment("Row").build(), row);
+    createReq.setFormat(format);
+    final ODataEntityCreateResponse createRes = createReq.execute();
+    assertEquals(201, createRes.getStatusCode());
+
+    row = readRow(format, guid.toString());
+    assertNotNull(row);
+    assertEquals(ODataJClientEdmPrimitiveType.Guid.toString(),
+            row.getProperty("Id").getPrimitiveValue().getTypeName());
+    assertEquals(ODataJClientEdmPrimitiveType.String.toString(),
+            row.getProperty("aString").getPrimitiveValue().getTypeName());
+    assertEquals(ODataJClientEdmPrimitiveType.Boolean.toString(),
+            row.getProperty("aBoolean").getPrimitiveValue().getTypeName());
+    assertEquals(ODataJClientEdmPrimitiveType.Int64.toString(),
+            row.getProperty("aLong").getPrimitiveValue().getTypeName());
+    assertEquals(ODataJClientEdmPrimitiveType.Double.toString(),
+            row.getProperty("aDouble").getPrimitiveValue().getTypeName());
+    assertEquals(ODataJClientEdmPrimitiveType.SByte.toString(),
+            row.getProperty("aByte").getPrimitiveValue().getTypeName());
+    assertEquals(ODataJClientEdmPrimitiveType.DateTime.toString(),
+            row.getProperty("aDate").getPrimitiveValue().getTypeName());
+    assertEquals(ODataJClientEdmPrimitiveType.GeographyPoint.toString(),
+            row.getProperty("aPoint").getPrimitiveValue().getTypeName());
+    assertEquals(ODataJClientEdmPrimitiveType.GeometryMultiPoint.toString(),
+            row.getProperty("aMultiPoint").getPrimitiveValue().getTypeName());
+    assertEquals(ODataJClientEdmPrimitiveType.GeometryLineString.toString(),
+            row.getProperty("aLineString").getPrimitiveValue().getTypeName());
+    assertEquals(ODataJClientEdmPrimitiveType.GeometryMultiLineString.toString(),
+            row.getProperty("aMultiLineString").getPrimitiveValue().getTypeName());
+    assertEquals(ODataJClientEdmPrimitiveType.GeographyPolygon.toString(),
+            row.getProperty("aPolygon").getPrimitiveValue().getTypeName());
+    assertEquals(ODataJClientEdmPrimitiveType.GeographyMultiPolygon.toString(),
+            row.getProperty("aMultiPolygon").getPrimitiveValue().getTypeName());
+    assertEquals(ODataJClientEdmPrimitiveType.GeographyCollection.toString(),
+            row.getProperty("aCollection").getPrimitiveValue().getTypeName());
+    assertEquals("Microsoft.Test.OData.Services.OpenTypesService.ContactDetails",
+            row.getProperty("aContact").getComplexValue().getTypeName());
+    assertEquals(ODataJClientEdmPrimitiveType.SByte.toString(),
+            row.getProperty("aContact").getComplexValue().get("SignedByte").getPrimitiveValue().getTypeName());
+
+    final ODataDeleteResponse deleteRes = client.getCUDRequestFactory().getDeleteRequest(row.getEditLink()).
+            execute();
+    assertEquals(204, deleteRes.getStatusCode());
+  }
+
+  @Test
+  @Ignore
+  public void cudAsAtom() {
+    cud(ODataPubFormat.ATOM);
+  }
+
+  @Test
+  @Ignore
+  public void cudAsJSON() {
+    cud(ODataPubFormat.JSON_FULL_METADATA);
+  }
+}

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/PrimitiveKeysTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PrimitiveKeysTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PrimitiveKeysTestITCase.java
new file mode 100644
index 0000000..4b3f916
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PrimitiveKeysTestITCase.java
@@ -0,0 +1,80 @@
+/*
+ * 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 java.math.BigDecimal;
+import java.util.UUID;
+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.ODataDuration;
+import org.apache.olingo.client.api.domain.ODataEntity;
+import org.apache.olingo.client.api.format.ODataPubFormat;
+import org.junit.Test;
+
+public class PrimitiveKeysTestITCase extends AbstractV3TestITCase {
+
+  private void readEntity(final String entityType, final Object key, final ODataPubFormat format) {
+    final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(
+            client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment(entityType).
+            appendKeySegment(key).
+            build());
+    req.setFormat(format);
+    final ODataRetrieveResponse<ODataEntity> res = req.execute();
+    assertEquals(200, res.getStatusCode());
+    final ODataEntity entity = res.getBody();
+    assertNotNull(entity);
+    assertNotNull(entity.getProperty("Id"));
+  }
+
+  private void readPrimitiveKeys(final ODataPubFormat format) {
+    // commented as per #115
+    //readEntity("EdmBinarySet", new byte[] {Byte.valueOf("2"), Byte.valueOf("3"), Byte.valueOf("4")}, format);
+    readEntity("EdmBooleanSet", Boolean.TRUE, format);
+    readEntity("EdmByteSet", 255, format);
+    readEntity("EdmDecimalSet", new BigDecimal("79228162514264337593543950335"), format);
+    readEntity("EdmDoubleSet", 1.7976931348623157E+308D, format);
+    readEntity("EdmSingleSet", 3.40282347E+38F, format);
+    readEntity("EdmGuidSet", UUID.fromString("00000000-0000-0000-0000-000000000000"), format);
+    readEntity("EdmInt16Set", 32767, format);
+    readEntity("EdmInt32Set", -2147483648, format);
+    readEntity("EdmInt64Set", 9223372036854775807L, format);
+    readEntity("EdmStringSet", "$", format);
+    readEntity("EdmTimeSet", new ODataDuration("-P10675199DT2H48M5.4775808S"), format);
+    // commented as per #115
+    //readEntity("EdmDateTimeSet",
+    //        ODataTimestamp.parse(EdmSimpleType.DATE_TIME.pattern(), "0001-01-01T00:00:00"),
+    //        format);
+    //readEntity("EdmDateTimeOffsetSet",
+    //        ODataTimestamp.parse(EdmSimpleType.DATE_TIME_OFFSET.pattern(), "2013-08-14T13:33:46.1045905+02:00"),
+    //        format);
+  }
+
+  @Test
+  public void readEntityAsAtom() {
+    readPrimitiveKeys(ODataPubFormat.ATOM);
+  }
+
+  @Test
+  public void readEntityAsJSON() {
+    readPrimitiveKeys(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/PropertyRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PropertyRetrieveTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PropertyRetrieveTestITCase.java
new file mode 100644
index 0000000..f106a6a
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/PropertyRetrieveTestITCase.java
@@ -0,0 +1,277 @@
+/*
+ * 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.assertTrue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.List;
+import org.apache.olingo.client.api.communication.ODataClientErrorException;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.domain.ODataCollectionValue;
+import org.apache.olingo.client.api.domain.ODataComplexValue;
+import org.apache.olingo.client.api.domain.ODataEntity;
+import org.apache.olingo.client.api.domain.ODataEntitySet;
+import org.apache.olingo.client.api.domain.ODataPrimitiveValue;
+import org.apache.olingo.client.api.domain.ODataProperty;
+import org.apache.olingo.client.api.format.ODataFormat;
+import org.apache.olingo.client.api.uri.URIBuilder;
+import org.junit.Test;
+
+public class PropertyRetrieveTestITCase extends AbstractV3TestITCase {
+
+  private void retreivePropertyTest(final ODataFormat format, String entitySegment, String structuralSegment) {
+    final URIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
+            appendEntitySetSegment(entitySegment).appendPropertySegment(structuralSegment);
+    final ODataPropertyRequest req = client.getRetrieveRequestFactory().getPropertyRequest(uriBuilder.build());
+    req.setFormat(format);
+    try {
+      final ODataProperty property = req.execute().getBody();
+      assertNotNull(property);
+      if (property.hasNullValue()) {
+        assertNull(property.getValue());
+      } else if (property.hasPrimitiveValue()) {
+        final ODataPrimitiveValue value = property.getPrimitiveValue();
+        assertTrue(value.isPrimitive());
+      } else if (property.hasComplexValue()) {
+        final ODataComplexValue value = property.getComplexValue();
+        assertTrue(value.isComplex());
+      } else if (property.hasCollectionValue()) {
+        final ODataCollectionValue value = property.getCollectionValue();
+        assertTrue(value.isCollection());
+      }
+    } catch (ODataClientErrorException e) {
+      if (e.getStatusLine().getStatusCode() != 404
+              && e.getStatusLine().getStatusCode() != 400) {
+        fail(e.getMessage());
+      }
+    }
+  }
+  //test with json header
+
+  @Test
+  public void jsonRetrieveProperty() {
+    //Primitive types
+    retreivePropertyTest(ODataFormat.JSON, "Customer(-10)", "Name");
+    retreivePropertyTest(ODataFormat.JSON, "Customer(-10)", "CustomerId");
+    retreivePropertyTest(ODataFormat.JSON, "Message(FromUsername='1',MessageId=-10)", "Sent");
+    retreivePropertyTest(ODataFormat.JSON, "Message(FromUsername='1',MessageId=-10)", "IsRead");
+    //Collection of Complex types
+    retreivePropertyTest(ODataFormat.JSON, "Customer(-10)", "BackupContactInfo");
+    //Collection of primitives
+    retreivePropertyTest(ODataFormat.JSON, "Customer(-10)/PrimaryContactInfo", "EmailBag");
+    //complex types
+    retreivePropertyTest(ODataFormat.JSON, "Order(-9)", "Concurrency");
+  }
+  //test with json full metadata
+
+  @Test
+  public void jsonFullMetadataRetrieveProperty() {
+    //primitive types
+    retreivePropertyTest(ODataFormat.JSON_FULL_METADATA, "Customer(-10)", "Name");
+    retreivePropertyTest(ODataFormat.JSON_FULL_METADATA, "Customer(-10)", "CustomerId");
+    retreivePropertyTest(ODataFormat.JSON_FULL_METADATA, "Message(FromUsername='1',MessageId=-10)", "Sent");
+    retreivePropertyTest(ODataFormat.JSON_FULL_METADATA, "Message(FromUsername='1',MessageId=-10)", "IsRead");
+    //Collection of Complex types
+    retreivePropertyTest(ODataFormat.JSON_FULL_METADATA, "Customer(-10)", "BackupContactInfo");
+    //Collection of primitives		
+    retreivePropertyTest(ODataFormat.JSON_FULL_METADATA, "Customer(-10)/PrimaryContactInfo", "EmailBag");
+    //Complex types
+    retreivePropertyTest(ODataFormat.JSON_FULL_METADATA, "Order(-9)", "Concurrency");
+  }
+  // json with no metadata
+
+  @Test
+  public void jsonNoMetadataRetrieveProperty() {
+    //primitive types
+    retreivePropertyTest(ODataFormat.JSON_NO_METADATA, "Customer(-10)", "Name");
+    retreivePropertyTest(ODataFormat.JSON_NO_METADATA, "Customer(-10)", "CustomerId");
+    retreivePropertyTest(ODataFormat.JSON_NO_METADATA, "Message(FromUsername='1',MessageId=-10)", "Sent");
+    retreivePropertyTest(ODataFormat.JSON_NO_METADATA, "Message(FromUsername='1',MessageId=-10)", "IsRead");
+    //Collection of Complex types
+    retreivePropertyTest(ODataFormat.JSON_NO_METADATA, "Customer(-10)", "BackupContactInfo");
+    //Collection of Primitives
+    retreivePropertyTest(ODataFormat.JSON_NO_METADATA, "Customer(-10)/PrimaryContactInfo", "EmailBag");
+    //Complex types
+    retreivePropertyTest(ODataFormat.JSON_NO_METADATA, "Order(-9)", "Concurrency");
+
+  }
+  // json with minimla metadata
+
+  @Test
+  public void jsonmininalRetrieveProperty() {
+    //primitive types
+    retreivePropertyTest(ODataFormat.JSON_NO_METADATA, "Customer(-10)", "Name");
+    retreivePropertyTest(ODataFormat.JSON_NO_METADATA, "Customer(-10)", "CustomerId");
+    retreivePropertyTest(ODataFormat.JSON_NO_METADATA, "Message(FromUsername='1',MessageId=-10)", "Sent");
+    retreivePropertyTest(ODataFormat.JSON_NO_METADATA, "Message(FromUsername='1',MessageId=-10)", "IsRead");
+    //Collection of complex types
+    retreivePropertyTest(ODataFormat.JSON_NO_METADATA, "Customer(-10)", "BackupContactInfo");
+    //Collection of primitives
+    retreivePropertyTest(ODataFormat.JSON_NO_METADATA, "Customer(-10)/PrimaryContactInfo", "EmailBag");
+    //Complex types
+    retreivePropertyTest(ODataFormat.JSON_NO_METADATA, "Order(-9)", "Concurrency");
+  }
+  // with xml header
+
+  @Test
+  public void xmlRetrieveProperty() {
+    //primitive types
+    retreivePropertyTest(ODataFormat.XML, "Customer(-10)", "Name");
+    retreivePropertyTest(ODataFormat.XML, "Customer(-10)", "CustomerId");
+    retreivePropertyTest(ODataFormat.XML, "Message(FromUsername='1',MessageId=-10)", "Sent");
+    retreivePropertyTest(ODataFormat.XML, "Message(FromUsername='1',MessageId=-10)", "IsRead");
+    //Collection of Complex types
+    retreivePropertyTest(ODataFormat.XML, "Customer(-10)", "BackupContactInfo");
+    //Collection of primitives
+    retreivePropertyTest(ODataFormat.XML, "Customer(-10)/PrimaryContactInfo", "EmailBag");
+    //Complex types
+    retreivePropertyTest(ODataFormat.XML, "Order(-9)", "Concurrency");
+  }
+  // with atom header
+
+  @Test
+  public void atomRetrieveProperty() {
+    //primitive types
+    retreivePropertyTest(ODataFormat.XML, "Customer(-10)", "Name");
+    retreivePropertyTest(ODataFormat.XML, "Customer(-10)", "CustomerId");
+    retreivePropertyTest(ODataFormat.XML, "Message(FromUsername='1',MessageId=-10)", "Sent");
+    retreivePropertyTest(ODataFormat.XML, "Message(FromUsername='1',MessageId=-10)", "IsRead");
+    //Collection of Complex types 
+    retreivePropertyTest(ODataFormat.XML, "Customer(-10)", "BackupContactInfo");
+    //Collection of primitives
+    retreivePropertyTest(ODataFormat.XML, "Customer(-10)/PrimaryContactInfo", "EmailBag");
+    //complex types
+    retreivePropertyTest(ODataFormat.XML, "Order(-9)", "Concurrency");
+  }
+  // with invalid structural segment
+
+  @Test
+  public void invalidSegmentRetrieveProperty() {
+    //primitive types
+    retreivePropertyTest(ODataFormat.XML, "Customers(-10)", "Name");
+
+  }
+  // with null pub format
+
+  @Test
+  public void nullSegmentRetrieveProperty() {
+    //primitive types
+    retreivePropertyTest(null, "Customers(-10)", "Name");
+
+  }
+  // with null accept header format
+
+  @Test
+  public void nullAcceptRetrieveProperty() {
+    //primitive types
+    retreivePropertyTest(ODataFormat.XML, "Customers(-10)", "Name");
+
+  }
+  // with json pub format and atom accept format
+
+  @Test
+  public void differentFormatAndAcceptRetrieveProperty() {
+    //
+    retreivePropertyTest(ODataFormat.JSON_FULL_METADATA, "Customers(-10)", "Name");
+
+  }
+  //bad request 400 error. Message takes two keys
+
+  @Test
+  public void badRequestTest() {
+    //primitive types
+    retreivePropertyTest(ODataFormat.JSON_FULL_METADATA, "Message(FromUsername='1')", "Sent");
+  }
+  //navigation link of stream
+
+  @Test
+  public void navigationMediaLink() {
+    URIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
+            appendNavigationSegment("Product").appendKeySegment(-7).appendLinksSegment("Photos");
+    ODataEntitySetRequest req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
+    req.setAccept("application/json");
+    ODataRetrieveResponse<ODataEntitySet> res = req.execute();
+    assertEquals(200, res.getStatusCode());
+    ODataEntitySet entitySet = res.getBody();
+    assertNotNull(entitySet);
+    List<ODataEntity> entity = entitySet.getEntities();
+    assertNotNull(entity);
+    assertEquals(entity.size(), 2);
+    assertEquals(testStaticServiceRootURL + "/ProductPhoto(PhotoId=-3,ProductId=-3)",
+            entity.get(0).getProperties().get(0).getValue().toString());
+    assertEquals(testStaticServiceRootURL + "/ProductPhoto(PhotoId=-2,ProductId=-2)",
+            entity.get(1).getProperties().get(0).getValue().toString());
+    for (int i = 0; i < entity.size(); i++) {
+      assertNotNull(entity.get(0).getProperties().get(0).getValue());
+    }
+  }
+  //navigation link of stream, Bad Request(404 error). 'Photo' is not a valid navigation link
+
+  @Test
+  public void navigationMediaLinkInvalidQuery() {
+    URIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
+            appendNavigationSegment("Product").appendKeySegment(-7).appendLinksSegment("Photo");
+    ODataEntitySetRequest req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
+    req.setAccept("application/json");
+    try {
+      ODataRetrieveResponse<ODataEntitySet> res = req.execute();
+      assertEquals(200, res.getStatusCode());
+      ODataEntitySet entitySet = res.getBody();
+      assertNotNull(entitySet);
+      List<ODataEntity> entity = entitySet.getEntities();
+      assertNotNull(entity);
+      assertEquals(entity.size(), 2);
+      assertEquals(testStaticServiceRootURL + "/ProductPhoto(PhotoId=-3,ProductId=-3)", entity.get(0).
+              getProperties().get(0).getValue().toString());
+      assertEquals(testStaticServiceRootURL + "/ProductPhoto(PhotoId=-2,ProductId=-2)", entity.get(1).
+              getProperties().get(0).getValue().toString());
+    } catch (ODataClientErrorException e) {
+      assertEquals(404, e.getStatusLine().getStatusCode());
+    }
+  }
+
+  @Test
+  public void navigationMediaLinkInvalidFormat() {
+    URIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
+            appendNavigationSegment("Product").appendKeySegment(-7).appendLinksSegment("Photos");
+    ODataEntitySetRequest req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
+    req.setAccept("application/atom+xml");
+    try {
+      ODataRetrieveResponse<ODataEntitySet> res = req.execute();
+      assertEquals(200, res.getStatusCode());
+      ODataEntitySet entitySet = res.getBody();
+      assertNotNull(entitySet);
+      List<ODataEntity> entity = entitySet.getEntities();
+      assertNotNull(entity);
+      assertEquals(entity.size(), 2);
+      assertEquals(testStaticServiceRootURL + "/ProductPhoto(PhotoId=-3,ProductId=-3)", entity.get(0).
+              getProperties().get(0).getValue().toString());
+      assertEquals(testStaticServiceRootURL + "/ProductPhoto(PhotoId=-2,ProductId=-2)", entity.get(1).
+              getProperties().get(0).getValue().toString());
+    } catch (ODataClientErrorException e) {
+      assertEquals(415, e.getStatusLine().getStatusCode());
+    }
+  }
+}