olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chall...@apache.org
Subject [07/50] [abbrv] git commit: MetadataTestITCase for V4
Date Mon, 12 May 2014 08:38:42 GMT
MetadataTestITCase for V4


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

Branch: refs/heads/olingo274
Commit: 58ecb3f5d9567ec38f0fd11e6d4865402032d229
Parents: 6b7be9d
Author: Francesco Chicchiricc├▓ <ilgrosso@apache.org>
Authored: Wed May 7 17:44:22 2014 +0200
Committer: Francesco Chicchiricc├▓ <ilgrosso@apache.org>
Committed: Wed May 7 17:44:22 2014 +0200

----------------------------------------------------------------------
 .../commons/EntityTypeInvocationHandler.java    |  16 +-
 .../olingo/ext/proxy/utils/EngineUtils.java     |   5 +-
 .../org/apache/olingo/fit/AbstractServices.java |   2 +-
 .../main/java/org/apache/olingo/fit/V4Demo.java | 157 +++++++++++++++++
 .../$value.bin                                  |   0
 .../entity.full.json                            |  16 ++
 .../entity.xml                                  |  40 +++++
 .../resources/V40/Advertisements/feed.full.json |  31 ++++
 .../main/resources/V40/Advertisements/feed.xml  |  65 +++++++
 fit/src/main/resources/V40/demoMetadata.xml     | 172 +++++++++++++++++++
 .../main/webapp/WEB-INF/applicationContext.xml  |   1 +
 .../olingo/fit/v3/AbstractTestITCase.java       |   2 +-
 .../apache/olingo/fit/v3/AsyncTestITCase.java   |   2 +-
 .../olingo/fit/v3/MediaEntityTestITCase.java    | 109 ++++++------
 .../olingo/fit/v4/AbstractTestITCase.java       |   3 +
 .../olingo/fit/v4/MediaEntityTestITCase.java    | 122 +++++++++++++
 .../olingo/fit/v4/PropertyTestITCase.java       |  29 ++--
 .../olingo/client/api/CommonODataClient.java    |   4 +-
 .../streamed/CommonStreamedRequestFactory.java  |  67 --------
 .../streamed/StreamedRequestFactory.java        |  67 ++++++++
 .../streamed/v3/StreamedRequestFactory.java     |  24 ---
 .../streamed/v4/StreamedRequestFactory.java     |  24 ---
 .../olingo/client/api/v3/ODataClient.java       |   4 -
 .../olingo/client/api/v4/ODataClient.java       |   4 -
 .../request/retrieve/ODataMediaRequestImpl.java |   3 +-
 .../AbstractStreamedRequestFactory.java         |  77 ---------
 .../streamed/StreamedRequestFactoryImpl.java    |  77 +++++++++
 .../streamed/v3/StreamedRequestFactoryImpl.java |  33 ----
 .../streamed/v4/StreamedRequestFactoryImpl.java |  33 ----
 .../client/core/op/AbstractODataBinder.java     |   9 +-
 .../olingo/client/core/v3/ODataClientImpl.java  |   4 +-
 .../olingo/client/core/v4/ODataClientImpl.java  |   4 +-
 .../olingo/client/core/v3/EntityTest.java       |   2 +-
 .../olingo/client/core/v4/EntityTest.java       |   2 +-
 .../apache/olingo/commons/api/data/Entity.java  |   4 +-
 .../commons/api/domain/CommonODataEntity.java   |  10 +-
 .../commons/core/data/AbstractEntity.java       |  10 +-
 .../commons/core/data/AtomDeserializer.java     |   2 +-
 .../commons/core/data/AtomSerializer.java       |   4 +-
 .../core/data/JSONEntityDeserializer.java       |   4 +-
 .../commons/core/data/JSONEntitySerializer.java |  20 ++-
 .../core/domain/AbstractODataEntity.java        |  22 +--
 42 files changed, 888 insertions(+), 398 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityTypeInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityTypeInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityTypeInvocationHandler.java
index 389f791..d738b5b 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityTypeInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityTypeInvocationHandler.java
@@ -342,9 +342,9 @@ public class EntityTypeInvocationHandler<C extends CommonEdmEnabledODataClient<?
 
         res = type == null
                 ? EngineUtils.getValueFromProperty(
-                client.getCachedEdm(), entity.getProperty(name))
+                        client.getCachedEdm(), entity.getProperty(name))
                 : EngineUtils.getValueFromProperty(
-                client.getCachedEdm(), entity.getProperty(name), type);
+                        client.getCachedEdm(), entity.getProperty(name), type);
 
         if (res != null) {
           int checkpoint = propertyChanges.hashCode();
@@ -475,19 +475,17 @@ public class EntityTypeInvocationHandler<C extends CommonEdmEnabledODataClient<?
 
   public InputStream getStream() {
 
-    final String contentSource = entity.getMediaContentSource();
+    final URI contentSource = entity.getMediaContentSource();
 
     if (this.stream == null
             && typeRef.getAnnotation(EntityType.class).hasStream()
-            && StringUtils.isNotBlank(contentSource)) {
+            && contentSource != null) {
 
-      final String comntentType =
+      final String contentType = 
               StringUtils.isBlank(entity.getMediaContentType()) ? "*/*" : entity.getMediaContentType();
 
-      final URI contentSourceURI = URIUtils.getURI(containerHandler.getFactory().getServiceRoot(), contentSource);
-
-      final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(contentSourceURI);
-      retrieveReq.setFormat(ODataMediaFormat.fromFormat(comntentType));
+      final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(contentSource);
+      retrieveReq.setFormat(ODataMediaFormat.fromFormat(contentType));
 
       this.stream = retrieveReq.execute().getBody();
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/EngineUtils.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/EngineUtils.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/EngineUtils.java
index d625c80..f3e2c62 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/EngineUtils.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/EngineUtils.java
@@ -181,7 +181,8 @@ public final class EngineUtils {
         } else {
           oprop = ((org.apache.olingo.commons.api.domain.v4.ODataObjectFactory) client.getObjectFactory()).
                   newEnumProperty(name,
-                  ((org.apache.olingo.commons.api.domain.v4.ODataValue) getODataValue(client, type, obj)).asEnum());
+                          ((org.apache.olingo.commons.api.domain.v4.ODataValue) getODataValue(client, type, obj)).
+                          asEnum());
         }
       } else {
         throw new UnsupportedOperationException("Usupported object type " + type.getFullQualifiedName());
@@ -412,7 +413,7 @@ public final class EngineUtils {
   }
 
   public static URI getEditMediaLink(final String name, final CommonODataEntity entity) {
-    for (ODataLink editMediaLink : entity.getEditMediaLinks()) {
+    for (ODataLink editMediaLink : entity.getMediaEditLinks()) {
       if (name.equalsIgnoreCase(editMediaLink.getName())) {
         return editMediaLink.getLink();
       }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
index f3be7ce..a7e37f9 100644
--- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
+++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
@@ -582,7 +582,7 @@ public abstract class AbstractServices {
         editLink.setTitle(entitySetName);
         entry.setEditLink(editLink);
 
-        entry.setMediaContentSource(editLink.getHref() + "/$value");
+        entry.setMediaContentSource(URI.create(editLink.getHref() + "/$value"));
 
         container = new ResWrap<AtomEntityImpl>((URI) null, null, entry);
       } else {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/fit/src/main/java/org/apache/olingo/fit/V4Demo.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/V4Demo.java b/fit/src/main/java/org/apache/olingo/fit/V4Demo.java
new file mode 100644
index 0000000..c00d14a
--- /dev/null
+++ b/fit/src/main/java/org/apache/olingo/fit/V4Demo.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.fit;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.fit.metadata.Metadata;
+import org.apache.olingo.fit.utils.Accept;
+import org.apache.olingo.fit.utils.ConstantKey;
+import org.apache.olingo.fit.utils.Constants;
+import org.apache.olingo.fit.utils.FSManager;
+import org.springframework.stereotype.Service;
+
+@Service
+@Path("/V40/Demo.svc")
+public class V4Demo {
+
+  private final Metadata demoMetadata;
+
+  private final V4Services services;
+
+  public V4Demo() throws Exception {
+    this.demoMetadata = new Metadata(FSManager.instance(ODataServiceVersion.V40).
+            readFile("demo" + StringUtils.capitalize(Constants.get(ODataServiceVersion.V40, ConstantKey.METADATA)),
+                    Accept.XML), ODataServiceVersion.V40);
+    this.services = new V4Services() {
+      @Override
+      protected Metadata getMetadataObj() {
+        return demoMetadata;
+      }
+    };
+  }
+
+  private Response replaceServiceName(final Response response) {
+    try {
+      final String content = IOUtils.toString((InputStream) response.getEntity(), Constants.ENCODING).
+              replaceAll("Static\\.svc", "Demo.svc");
+
+      final Response.ResponseBuilder builder = Response.status(response.getStatus());
+      for (String headerName : response.getHeaders().keySet()) {
+        for (Object headerValue : response.getHeaders().get(headerName)) {
+          builder.header(headerName, headerValue);
+        }
+      }
+
+      final InputStream toBeStreamedBack = IOUtils.toInputStream(content, Constants.ENCODING);
+      final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+      IOUtils.copy(toBeStreamedBack, baos);
+      IOUtils.closeQuietly(toBeStreamedBack);
+
+      builder.header("Content-Length", baos.size());
+      builder.entity(new ByteArrayInputStream(baos.toByteArray()));
+
+      return builder.build();
+    } catch (Exception e) {
+      return response;
+    }
+  }
+
+  @GET
+  @Path("/$metadata")
+  @Produces(MediaType.APPLICATION_XML)
+  public Response getMetadata() {
+    return services.getMetadata(
+            "demo" + StringUtils.capitalize(Constants.get(ODataServiceVersion.V40, ConstantKey.METADATA)));
+  }
+
+  @GET
+  @Path("/{entitySetName}({entityId})")
+  public Response getEntity(
+          @Context UriInfo uriInfo,
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+          @PathParam("entitySetName") String entitySetName,
+          @PathParam("entityId") String entityId,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
+          @QueryParam("$expand") @DefaultValue(StringUtils.EMPTY) String expand,
+          @QueryParam("$select") @DefaultValue(StringUtils.EMPTY) String select) {
+
+    return replaceServiceName(services.getEntityInternal(uriInfo.getRequestUri().toASCIIString(),
+            accept, entitySetName, entityId, format, expand, select, false));
+  }
+
+  @GET
+  @Path("/{entitySetName}({entityId})/$value")
+  public Response getMediaEntity(
+          @Context UriInfo uriInfo,
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+          @PathParam("entitySetName") String entitySetName,
+          @PathParam("entityId") String entityId) {
+
+    return services.getMediaEntity(uriInfo, accept, entitySetName, entityId);
+  }
+
+  @POST
+  @Path("/{entitySetName}")
+  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
+  @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM})
+  public Response postNewEntity(
+          @Context UriInfo uriInfo,
+          @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
+          @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType,
+          @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) String prefer,
+          @PathParam("entitySetName") String entitySetName,
+          final String entity) {
+
+    return replaceServiceName(services.postNewEntity(uriInfo, accept, contentType, prefer, entitySetName, entity));
+  }
+
+  @PUT
+  @Produces({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
+  @Consumes({MediaType.WILDCARD, MediaType.APPLICATION_OCTET_STREAM})
+  @Path("/{entitySetName}({entityId})/$value")
+  public Response replaceMediaEntity(
+          @Context UriInfo uriInfo,
+          @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) String prefer,
+          @PathParam("entitySetName") String entitySetName,
+          @PathParam("entityId") String entityId,
+          @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format,
+          String value) {
+
+    return services.replaceMediaEntity(uriInfo, prefer, entitySetName, entityId, format, value);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/fit/src/main/resources/V40/Advertisements/f89dee73-af9f-4cd4-b330-db93c25ff3c7/$value.bin
----------------------------------------------------------------------
diff --git a/fit/src/main/resources/V40/Advertisements/f89dee73-af9f-4cd4-b330-db93c25ff3c7/$value.bin b/fit/src/main/resources/V40/Advertisements/f89dee73-af9f-4cd4-b330-db93c25ff3c7/$value.bin
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/fit/src/main/resources/V40/Advertisements/f89dee73-af9f-4cd4-b330-db93c25ff3c7/entity.full.json
----------------------------------------------------------------------
diff --git a/fit/src/main/resources/V40/Advertisements/f89dee73-af9f-4cd4-b330-db93c25ff3c7/entity.full.json b/fit/src/main/resources/V40/Advertisements/f89dee73-af9f-4cd4-b330-db93c25ff3c7/entity.full.json
new file mode 100644
index 0000000..4730781
--- /dev/null
+++ b/fit/src/main/resources/V40/Advertisements/f89dee73-af9f-4cd4-b330-db93c25ff3c7/entity.full.json
@@ -0,0 +1,16 @@
+{
+  "@odata.context": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Demo.svc/$metadata#Advertisements/$entity",
+  "@odata.type": "#ODataDemo.Advertisement",
+  "@odata.id": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Demo.svc/Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)",
+  "@odata.editLink": "Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)",
+  "@odata.mediaEditLink": "Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/$value",
+  "@odata.mediaContentType": "*/*",
+  "@odata.mediaEtag": "\"8zOOKKvgOtptr4gt8IrnapX3jds=\"",
+  "ID@odata.type": "#Guid",
+  "ID": "f89dee73-af9f-4cd4-b330-db93c25ff3c7",
+  "Name": "Old School Lemonade Store, Retro Style",
+  "AirDate@odata.type": "#DateTimeOffset",
+  "AirDate": "2012-11-07T00:00:00Z",
+  "FeaturedProduct@odata.associationLink": "Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/FeaturedProduct/$ref",
+  "FeaturedProduct@odata.navigationLink": "Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/FeaturedProduct"
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/fit/src/main/resources/V40/Advertisements/f89dee73-af9f-4cd4-b330-db93c25ff3c7/entity.xml
----------------------------------------------------------------------
diff --git a/fit/src/main/resources/V40/Advertisements/f89dee73-af9f-4cd4-b330-db93c25ff3c7/entity.xml b/fit/src/main/resources/V40/Advertisements/f89dee73-af9f-4cd4-b330-db93c25ff3c7/entity.xml
new file mode 100644
index 0000000..72a8cc6
--- /dev/null
+++ b/fit/src/main/resources/V40/Advertisements/f89dee73-af9f-4cd4-b330-db93c25ff3c7/entity.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+    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.
+
+-->
+<entry xml:base="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Demo.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://docs.oasis-open.org/odata/ns/data" xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" m:context="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Demo.svc/$metadata#Advertisements/$entity">
+  <id>http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Demo.svc/Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)</id>
+  <category term="#ODataDemo.Advertisement" scheme="http://docs.oasis-open.org/odata/ns/scheme"/>
+  <link rel="edit" title="Advertisement" href="Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)"/>
+  <link rel="http://docs.oasis-open.org/odata/ns/relatedlinks/FeaturedProduct" type="application/xml" title="FeaturedProduct" href="Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/FeaturedProduct/$ref"/>
+  <link rel="http://docs.oasis-open.org/odata/ns/related/FeaturedProduct" type="application/atom+xml;type=entry" title="FeaturedProduct" href="Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/FeaturedProduct"/>
+  <title/>
+  <updated>2014-05-07T13:42:01Z</updated>
+  <author>
+    <name/>
+  </author>
+  <link rel="edit-media" title="Advertisement" href="Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/$value" m:etag="&quot;8zOOKKvgOtptr4gt8IrnapX3jds=&quot;"/>
+  <content type="*/*" src="Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/$value"/>
+  <m:properties>
+    <d:ID m:type="Guid">f89dee73-af9f-4cd4-b330-db93c25ff3c7</d:ID>
+    <d:Name>Old School Lemonade Store, Retro Style</d:Name>
+    <d:AirDate m:type="DateTimeOffset">2012-11-07T00:00:00Z</d:AirDate>
+  </m:properties>
+</entry>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/fit/src/main/resources/V40/Advertisements/feed.full.json
----------------------------------------------------------------------
diff --git a/fit/src/main/resources/V40/Advertisements/feed.full.json b/fit/src/main/resources/V40/Advertisements/feed.full.json
new file mode 100644
index 0000000..3d0a90e
--- /dev/null
+++ b/fit/src/main/resources/V40/Advertisements/feed.full.json
@@ -0,0 +1,31 @@
+{
+  "@odata.context": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Demo.svc/$metadata#Advertisements",
+  "value": [{
+      "@odata.type": "#ODataDemo.Advertisement",
+      "@odata.id": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Demo.svc/Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)",
+      "@odata.editLink": "Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)",
+      "@odata.mediaEditLink": "Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/$value",
+      "@odata.mediaContentType": "*/*",
+      "@odata.mediaEtag": "\"8zOOKKvgOtptr4gt8IrnapX3jds=\"",
+      "ID@odata.type": "#Guid",
+      "ID": "f89dee73-af9f-4cd4-b330-db93c25ff3c7",
+      "Name": "Old School Lemonade Store, Retro Style",
+      "AirDate@odata.type": "#DateTimeOffset",
+      "AirDate": "2012-11-07T00:00:00Z",
+      "FeaturedProduct@odata.associationLink": "Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/FeaturedProduct/$ref",
+      "FeaturedProduct@odata.navigationLink": "Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/FeaturedProduct"
+    }, {
+      "@odata.type": "#ODataDemo.Advertisement",
+      "@odata.id": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Demo.svc/Advertisements(db2d2186-1c29-4d1e-88ef-a127f521b9c6)",
+      "@odata.editLink": "Advertisements(db2d2186-1c29-4d1e-88ef-a127f521b9c6)",
+      "@odata.mediaEditLink": "Advertisements(db2d2186-1c29-4d1e-88ef-a127f521b9c6)/$value",
+      "@odata.mediaContentType": "*/*",
+      "ID@odata.type": "#Guid",
+      "ID": "db2d2186-1c29-4d1e-88ef-a127f521b9c6",
+      "Name": "Early morning start, need coffee",
+      "AirDate@odata.type": "#DateTimeOffset",
+      "AirDate": "2000-02-29T00:00:00Z",
+      "FeaturedProduct@odata.associationLink": "Advertisements(db2d2186-1c29-4d1e-88ef-a127f521b9c6)/FeaturedProduct/$ref",
+      "FeaturedProduct@odata.navigationLink": "Advertisements(db2d2186-1c29-4d1e-88ef-a127f521b9c6)/FeaturedProduct"
+    }]
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/fit/src/main/resources/V40/Advertisements/feed.xml
----------------------------------------------------------------------
diff --git a/fit/src/main/resources/V40/Advertisements/feed.xml b/fit/src/main/resources/V40/Advertisements/feed.xml
new file mode 100644
index 0000000..874ffe9
--- /dev/null
+++ b/fit/src/main/resources/V40/Advertisements/feed.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+    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.
+
+-->
+<feed xml:base="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Demo.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://docs.oasis-open.org/odata/ns/data" xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" m:context="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Demo.svc/$metadata#Advertisements">
+  <id>http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Demo.svc/Advertisements</id>
+  <title type="text">Advertisements</title>
+  <updated>2014-05-07T13:39:27Z</updated>
+  <link rel="self" title="Advertisements" href="Advertisements"/>
+  <entry>
+    <id>http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Demo.svc/Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)</id>
+    <category term="#ODataDemo.Advertisement" scheme="http://docs.oasis-open.org/odata/ns/scheme"/>
+    <link rel="edit" title="Advertisement" href="Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)"/>
+    <link rel="http://docs.oasis-open.org/odata/ns/relatedlinks/FeaturedProduct" type="application/xml" title="FeaturedProduct" href="Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/FeaturedProduct/$ref"/>
+    <link rel="http://docs.oasis-open.org/odata/ns/related/FeaturedProduct" type="application/atom+xml;type=entry" title="FeaturedProduct" href="Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/FeaturedProduct"/>
+    <title/>
+    <updated>2014-05-07T13:39:27Z</updated>
+    <author>
+      <name/>
+    </author>
+    <link rel="edit-media" title="Advertisement" href="Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/$value" m:etag="&quot;8zOOKKvgOtptr4gt8IrnapX3jds=&quot;"/>
+    <content type="*/*" src="Advertisements(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/$value"/>
+    <m:properties>
+      <d:ID m:type="Guid">f89dee73-af9f-4cd4-b330-db93c25ff3c7</d:ID>
+      <d:Name>Old School Lemonade Store, Retro Style</d:Name>
+      <d:AirDate m:type="DateTimeOffset">2012-11-07T00:00:00Z</d:AirDate>
+    </m:properties>
+  </entry>
+  <entry>
+    <id>http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Demo.svc/Advertisements(db2d2186-1c29-4d1e-88ef-a127f521b9c6)</id>
+    <category term="#ODataDemo.Advertisement" scheme="http://docs.oasis-open.org/odata/ns/scheme"/>
+    <link rel="edit" title="Advertisement" href="Advertisements(db2d2186-1c29-4d1e-88ef-a127f521b9c6)"/>
+    <link rel="http://docs.oasis-open.org/odata/ns/relatedlinks/FeaturedProduct" type="application/xml" title="FeaturedProduct" href="Advertisements(db2d2186-1c29-4d1e-88ef-a127f521b9c6)/FeaturedProduct/$ref"/>
+    <link rel="http://docs.oasis-open.org/odata/ns/related/FeaturedProduct" type="application/atom+xml;type=entry" title="FeaturedProduct" href="Advertisements(db2d2186-1c29-4d1e-88ef-a127f521b9c6)/FeaturedProduct"/>
+    <title/>
+    <updated>2014-05-07T13:39:27Z</updated>
+    <author>
+      <name/>
+    </author>
+    <link rel="edit-media" title="Advertisement" href="Advertisements(db2d2186-1c29-4d1e-88ef-a127f521b9c6)/$value"/>
+    <content type="*/*" src="Advertisements(db2d2186-1c29-4d1e-88ef-a127f521b9c6)/$value"/>
+    <m:properties>
+      <d:ID m:type="Guid">db2d2186-1c29-4d1e-88ef-a127f521b9c6</d:ID>
+      <d:Name>Early morning start, need coffee</d:Name>
+      <d:AirDate m:type="DateTimeOffset">2000-02-29T00:00:00Z</d:AirDate>
+    </m:properties>
+  </entry>
+</feed>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/fit/src/main/resources/V40/demoMetadata.xml
----------------------------------------------------------------------
diff --git a/fit/src/main/resources/V40/demoMetadata.xml b/fit/src/main/resources/V40/demoMetadata.xml
new file mode 100644
index 0000000..22ecfe1
--- /dev/null
+++ b/fit/src/main/resources/V40/demoMetadata.xml
@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+    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.
+
+-->
+<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
+  <edmx:DataServices>
+    <Schema Namespace="ODataDemo" xmlns="http://docs.oasis-open.org/odata/ns/edm">
+      <EntityType Name="Product">
+        <Key>
+          <PropertyRef Name="ID" />
+        </Key>
+        <Property Name="ID" Type="Edm.Int32" Nullable="false" />
+        <Property Name="Name" Type="Edm.String" />
+        <Property Name="Description" Type="Edm.String" />
+        <Property Name="ReleaseDate" Type="Edm.DateTimeOffset" Nullable="false" />
+        <Property Name="DiscontinuedDate" Type="Edm.DateTimeOffset" />
+        <Property Name="Rating" Type="Edm.Int16" Nullable="false" />
+        <Property Name="Price" Type="Edm.Double" Nullable="false" />
+        <NavigationProperty Name="Categories" Type="Collection(ODataDemo.Category)" Partner="Products" />
+        <NavigationProperty Name="Supplier" Type="ODataDemo.Supplier" Partner="Products" />
+        <NavigationProperty Name="ProductDetail" Type="ODataDemo.ProductDetail" Partner="Product" />
+      </EntityType>
+      <EntityType Name="FeaturedProduct" BaseType="ODataDemo.Product">
+        <NavigationProperty Name="Advertisement" Type="ODataDemo.Advertisement" Partner="FeaturedProduct" />
+      </EntityType>
+      <EntityType Name="ProductDetail">
+        <Key>
+          <PropertyRef Name="ProductID" />
+        </Key>
+        <Property Name="ProductID" Type="Edm.Int32" Nullable="false" />
+        <Property Name="Details" Type="Edm.String" />
+        <NavigationProperty Name="Product" Type="ODataDemo.Product" Partner="ProductDetail" />
+      </EntityType>
+      <EntityType Name="Category" OpenType="true">
+        <Key>
+          <PropertyRef Name="ID" />
+        </Key>
+        <Property Name="ID" Type="Edm.Int32" Nullable="false" />
+        <Property Name="Name" Type="Edm.String" />
+        <NavigationProperty Name="Products" Type="Collection(ODataDemo.Product)" Partner="Categories" />
+      </EntityType>
+      <EntityType Name="Supplier">
+        <Key>
+          <PropertyRef Name="ID" />
+        </Key>
+        <Property Name="ID" Type="Edm.Int32" Nullable="false" />
+        <Property Name="Name" Type="Edm.String" />
+        <Property Name="Address" Type="ODataDemo.Address" />
+        <Property Name="Location" Type="Edm.GeographyPoint" SRID="Variable" />
+        <Property Name="Concurrency" Type="Edm.Int32" ConcurrencyMode="Fixed" Nullable="false" />
+        <NavigationProperty Name="Products" Type="Collection(ODataDemo.Product)" Partner="Supplier" />
+      </EntityType>
+      <ComplexType Name="Address">
+        <Property Name="Street" Type="Edm.String" />
+        <Property Name="City" Type="Edm.String" />
+        <Property Name="State" Type="Edm.String" />
+        <Property Name="ZipCode" Type="Edm.String" />
+        <Property Name="Country" Type="Edm.String" />
+      </ComplexType>
+      <EntityType Name="Person">
+        <Key>
+          <PropertyRef Name="ID" />
+        </Key>
+        <Property Name="ID" Type="Edm.Int32" Nullable="false" />
+        <Property Name="Name" Type="Edm.String" />
+        <NavigationProperty Name="PersonDetail" Type="ODataDemo.PersonDetail" Partner="Person" />
+      </EntityType>
+      <EntityType Name="Customer" BaseType="ODataDemo.Person">
+        <Property Name="TotalExpense" Type="Edm.Decimal" Nullable="false" />
+      </EntityType>
+      <EntityType Name="Employee" BaseType="ODataDemo.Person">
+        <Property Name="EmployeeID" Type="Edm.Int64" Nullable="false" />
+        <Property Name="HireDate" Type="Edm.DateTimeOffset" Nullable="false" />
+        <Property Name="Salary" Type="Edm.Single" Nullable="false" />
+      </EntityType>
+      <EntityType Name="PersonDetail">
+        <Key>
+          <PropertyRef Name="PersonID" />
+        </Key>
+        <Property Name="PersonID" Type="Edm.Int32" Nullable="false" />
+        <Property Name="Age" Type="Edm.Byte" Nullable="false" />
+        <Property Name="Gender" Type="Edm.Boolean" Nullable="false" />
+        <Property Name="Phone" Type="Edm.String" />
+        <Property Name="Address" Type="ODataDemo.Address" />
+        <Property Name="Photo" Type="Edm.Stream" Nullable="false" />
+        <NavigationProperty Name="Person" Type="ODataDemo.Person" Partner="PersonDetail" />
+      </EntityType>
+      <EntityType Name="Advertisement" HasStream="true">
+        <Key>
+          <PropertyRef Name="ID" />
+        </Key>
+        <Property Name="ID" Type="Edm.Guid" Nullable="false" />
+        <Property Name="Name" Type="Edm.String" />
+        <Property Name="AirDate" Type="Edm.DateTimeOffset" Nullable="false" />
+        <NavigationProperty Name="FeaturedProduct" Type="ODataDemo.FeaturedProduct" Partner="Advertisement" />
+      </EntityType>
+      <Action Name="Discount" IsBound="true">
+        <Parameter Name="product" Type="ODataDemo.Product" />
+        <Parameter Name="discountPercentage" Type="Edm.Int32" Nullable="false" />
+        <ReturnType Type="Edm.Double" Nullable="false" />
+      </Action>
+      <Action Name="IncreaseSalaries">
+        <Parameter Name="percentage" Type="Edm.Int32" Nullable="false" />
+      </Action>
+      <EntityContainer Name="DemoService">
+        <EntitySet Name="Products" EntityType="ODataDemo.Product">
+          <NavigationPropertyBinding Path="ODataDemo.FeaturedProduct/Advertisement" Target="Advertisements" />
+          <NavigationPropertyBinding Path="Categories" Target="Categories" />
+          <NavigationPropertyBinding Path="Supplier" Target="Suppliers" />
+          <NavigationPropertyBinding Path="ProductDetail" Target="ProductDetails" />
+        </EntitySet>
+        <EntitySet Name="ProductDetails" EntityType="ODataDemo.ProductDetail">
+          <NavigationPropertyBinding Path="Product" Target="Products" />
+        </EntitySet>
+        <EntitySet Name="Categories" EntityType="ODataDemo.Category">
+          <NavigationPropertyBinding Path="Products" Target="Products" />
+        </EntitySet>
+        <EntitySet Name="Suppliers" EntityType="ODataDemo.Supplier">
+          <NavigationPropertyBinding Path="Products" Target="Products" />
+        </EntitySet>
+        <EntitySet Name="Persons" EntityType="ODataDemo.Person">
+          <NavigationPropertyBinding Path="PersonDetail" Target="PersonDetails" />
+        </EntitySet>
+        <EntitySet Name="PersonDetails" EntityType="ODataDemo.PersonDetail">
+          <NavigationPropertyBinding Path="Person" Target="Persons" />
+        </EntitySet>
+        <EntitySet Name="Advertisements" EntityType="ODataDemo.Advertisement">
+          <NavigationPropertyBinding Path="FeaturedProduct" Target="Products" />
+        </EntitySet>
+        <ActionImport Name="IncreaseSalaries" Action="ODataDemo.IncreaseSalaries" />
+      </EntityContainer>
+      <Annotations Target="ODataDemo.DemoService">
+        <Annotation Term="Org.OData.Display.V1.Description" String="This is a sample OData service with vocabularies" />
+      </Annotations>
+      <Annotations Target="ODataDemo.Product">
+        <Annotation Term="Org.OData.Display.V1.Description" String="All Products available in the online store" />
+      </Annotations>
+      <Annotations Target="ODataDemo.Product/Name">
+        <Annotation Term="Org.OData.Display.V1.DisplayName" String="Product Name" />
+      </Annotations>
+      <Annotations Target="ODataDemo.DemoService/Suppliers">
+        <Annotation Term="Org.OData.Publication.V1.PublisherName" String="Microsoft Corp." />
+        <Annotation Term="Org.OData.Publication.V1.PublisherId" String="MSFT" />
+        <Annotation Term="Org.OData.Publication.V1.Keywords" String="Inventory, Supplier, Advertisers, Sales, Finance" />
+        <Annotation Term="Org.OData.Publication.V1.AttributionUrl" String="http://www.odata.org/" />
+        <Annotation Term="Org.OData.Publication.V1.AttributionDescription" String="All rights reserved" />
+        <Annotation Term="Org.OData.Publication.V1.DocumentationUrl " String="http://www.odata.org/" />
+        <Annotation Term="Org.OData.Publication.V1.TermsOfUseUrl" String="All rights reserved" />
+        <Annotation Term="Org.OData.Publication.V1.PrivacyPolicyUrl" String="http://www.odata.org/" />
+        <Annotation Term="Org.OData.Publication.V1.LastModified" String="4/2/2013" />
+        <Annotation Term="Org.OData.Publication.V1.ImageUrl " String="http://www.odata.org/" />
+      </Annotations>
+    </Schema>
+  </edmx:DataServices>
+</edmx:Edmx>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/fit/src/main/webapp/WEB-INF/applicationContext.xml
----------------------------------------------------------------------
diff --git a/fit/src/main/webapp/WEB-INF/applicationContext.xml b/fit/src/main/webapp/WEB-INF/applicationContext.xml
index c37b8d0..f228583 100644
--- a/fit/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/fit/src/main/webapp/WEB-INF/applicationContext.xml
@@ -49,6 +49,7 @@
       <bean class="org.apache.olingo.fit.V4NorthWindExt"/>
       <bean class="org.apache.olingo.fit.V4OpenType"/>
       <bean class="org.apache.olingo.fit.V4Vocabularies"/>
+      <bean class="org.apache.olingo.fit.V4Demo"/>
     </jaxrs:serviceBeans>
     <jaxrs:providers>
       <bean class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider"/>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/fit/src/test/java/org/apache/olingo/fit/v3/AbstractTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/AbstractTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/AbstractTestITCase.java
index ab81e7c..6ecc4f3 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/AbstractTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/AbstractTestITCase.java
@@ -375,7 +375,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
 
     // check defined links
     checkLinks(original.getAssociationLinks(), actual.getAssociationLinks());
-    checkLinks(original.getEditMediaLinks(), actual.getEditMediaLinks());
+    checkLinks(original.getMediaEditLinks(), actual.getMediaEditLinks());
     checkLinks(original.getNavigationLinks(), actual.getNavigationLinks());
 
     // check defined properties equality

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/fit/src/test/java/org/apache/olingo/fit/v3/AsyncTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/AsyncTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/AsyncTestITCase.java
index 68d8524..aa6f5e2 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/AsyncTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/AsyncTestITCase.java
@@ -70,7 +70,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
     final ODataEntity entity = entityRes.getBody();
     entity.getAssociationLinks().clear();
     entity.getNavigationLinks().clear();
-    entity.getEditMediaLinks().clear();
+    entity.getMediaEditLinks().clear();
 
     entity.getProperties().remove(entity.getProperty("Description"));
     getClient().getBinder().add(entity,

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java
index e0bf0f2..4907378 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java
@@ -18,6 +18,9 @@
  */
 package org.apache.olingo.fit.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;
@@ -38,11 +41,6 @@ import org.apache.olingo.commons.api.domain.v3.ODataEntity;
 import org.apache.olingo.commons.api.domain.v3.ODataProperty;
 import org.apache.olingo.commons.api.format.ODataMediaFormat;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotNull;
-
 import org.junit.Test;
 
 public class MediaEntityTestITCase extends AbstractTestITCase {
@@ -84,56 +82,8 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
     retrieveReq.execute();
   }
 
-  @Test
-  public void updateMediaEntityAsAtom() throws Exception {
-    updateMediaEntity(ODataPubFormat.ATOM, 14);
-  }
-
-  @Test
-  public void updateMediaEntityAsJson() throws Exception {
-    updateMediaEntity(ODataPubFormat.JSON, 15);
-  }
-
-  @Test
-  public void createMediaEntityAsAtom() throws Exception {
-    createMediaEntity(ODataPubFormat.ATOM, IOUtils.toInputStream("buffered stream sample"));
-  }
-
-  @Test
-  public void createMediaEntityAsJson() throws Exception {
-    createMediaEntity(ODataPubFormat.JSON, IOUtils.toInputStream("buffered stream sample"));
-  }
-
-  @Test
-  public void issue137() throws Exception {
-    createMediaEntity(ODataPubFormat.JSON, this.getClass().getResourceAsStream("/sample.png"));
-  }
-
-  @Test
-  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).
+    final URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL).
             appendEntitySetSegment("Car").appendKeySegment(id).appendValueSegment();
 
     final String TO_BE_UPDATED = "new buffered stream sample";
@@ -154,9 +104,18 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
     assertEquals(TO_BE_UPDATED, IOUtils.toString(retrieveRes.getBody()));
   }
 
+  @Test
+  public void updateMediaEntityAsAtom() throws Exception {
+    updateMediaEntity(ODataPubFormat.ATOM, 14);
+  }
+
+  @Test
+  public void updateMediaEntityAsJson() throws Exception {
+    updateMediaEntity(ODataPubFormat.JSON, 15);
+  }
+
   private void createMediaEntity(final ODataPubFormat format, final InputStream input) throws Exception {
-    final URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL).
-            appendEntitySetSegment("Car");
+    final URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car");
 
     final ODataMediaEntityCreateRequest<ODataEntity> createReq =
             client.getStreamedRequestFactory().getMediaEntityCreateRequest(builder.build(), input);
@@ -186,4 +145,42 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
     assertEquals(200, retrieveRes.getStatusCode());
     assertNotNull(retrieveRes.getBody());
   }
+
+  @Test
+  public void createMediaEntityAsAtom() throws Exception {
+    createMediaEntity(ODataPubFormat.ATOM, IOUtils.toInputStream("buffered stream sample"));
+  }
+
+  @Test
+  public void createMediaEntityAsJson() throws Exception {
+    createMediaEntity(ODataPubFormat.JSON, IOUtils.toInputStream("buffered stream sample"));
+  }
+
+  @Test
+  public void issue137() throws Exception {
+    createMediaEntity(ODataPubFormat.JSON, this.getClass().getResourceAsStream("/sample.png"));
+  }
+
+  @Test
+  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()));
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/fit/src/test/java/org/apache/olingo/fit/v4/AbstractTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/AbstractTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/AbstractTestITCase.java
index 4916126..7fe0837 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/AbstractTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/AbstractTestITCase.java
@@ -49,6 +49,8 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
 
   protected static String testStaticServiceRootURL;
 
+  protected static String testDemoServiceRootURL;
+
   protected static String testVocabulariesServiceRootURL;
 
   protected static String testNorthwindRootURL;
@@ -64,6 +66,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
   @BeforeClass
   public static void setUpODataServiceRoot() throws IOException {
     testStaticServiceRootURL = "http://localhost:9080/stub/StaticService/V40/Static.svc";
+    testDemoServiceRootURL = "http://localhost:9080/stub/StaticService/V40/Demo.svc";
     testVocabulariesServiceRootURL = "http://localhost:9080/stub/StaticService/V40/Vocabularies.svc";
     testNorthwindRootURL = "http://localhost:9080/stub/StaticService/V40/NorthWind.svc";
     testKeyAsSegmentServiceRootURL = "http://localhost:9080/stub/StaticService/V40/KeyAsSegment.svc";

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java
new file mode 100644
index 0000000..459b246
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.fit.v4;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.UUID;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataMediaRequest;
+import org.apache.olingo.client.api.communication.request.streamed.MediaEntityUpdateStreamManager;
+import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityUpdateRequest;
+import org.apache.olingo.client.api.communication.response.ODataMediaEntityUpdateResponse;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.uri.v4.URIBuilder;
+import org.apache.olingo.client.api.v4.ODataClient;
+import org.apache.olingo.client.core.ODataClientFactory;
+import org.apache.olingo.commons.api.domain.v4.ODataEntity;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.junit.Test;
+
+public class MediaEntityTestITCase extends AbstractTestITCase {
+
+  private void read(final ODataClient client, final ODataPubFormat format) throws IOException {
+    final URIBuilder builder = client.getURIBuilder(testDemoServiceRootURL).
+            appendEntitySetSegment("Advertisements").
+            appendKeySegment(UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7"));
+    final ODataEntityRequest<ODataEntity> entityReq =
+            client.getRetrieveRequestFactory().getEntityRequest(builder.build());
+
+    final ODataEntity entity = entityReq.execute().getBody();
+    assertNotNull(entity);
+    assertTrue(entity.isMediaEntity());
+    assertEquals(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName().toString(),
+            entity.getProperty("AirDate").getValue().getTypeName());
+
+    final ODataMediaRequest streamReq = client.getRetrieveRequestFactory().
+            getMediaRequest(entity.getMediaContentSource());
+    final ODataRetrieveResponse<InputStream> streamRes = streamReq.execute();
+    assertEquals(200, streamRes.getStatusCode());
+
+    final byte[] actual = new byte[Integer.parseInt(streamRes.getHeader("Content-Length").iterator().next())];
+    IOUtils.read(streamRes.getBody(), actual, 0, actual.length);
+  }
+
+  @Test
+  public void readAsAtom() throws IOException {
+    read(client, ODataPubFormat.ATOM);
+  }
+
+  @Test
+  public void readAsJSON() throws IOException {
+    read(ODataClientFactory.getEdmEnabledV4(testDemoServiceRootURL), ODataPubFormat.JSON);
+  }
+
+  @Test
+  public void readAsJSONFull() throws IOException {
+    read(client, ODataPubFormat.JSON_FULL_METADATA);
+  }
+
+  private void update(final ODataClient client, final ODataPubFormat format)
+          throws IOException, EdmPrimitiveTypeException {
+
+    final URI uri = client.getURIBuilder(testDemoServiceRootURL).
+            appendEntitySetSegment("Advertisements").
+            appendKeySegment(UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7")).appendValueSegment().build();
+
+    final String random = RandomStringUtils.random(124);
+
+    // 1. update providing media content
+    final ODataMediaEntityUpdateRequest<ODataEntity> updateReq = client.getStreamedRequestFactory().
+            getMediaEntityUpdateRequest(uri, IOUtils.toInputStream(random));
+    updateReq.setFormat(format);
+
+    final MediaEntityUpdateStreamManager<ODataEntity> streamManager = updateReq.execute();
+    final ODataMediaEntityUpdateResponse<ODataEntity> createRes = streamManager.getResponse();
+    assertEquals(204, createRes.getStatusCode());
+
+    // 2. check that media content was effectively uploaded
+    final ODataMediaRequest streamReq = client.getRetrieveRequestFactory().getMediaRequest(uri);
+    final ODataRetrieveResponse<InputStream> streamRes = streamReq.execute();
+    assertEquals(200, streamRes.getStatusCode());
+
+    final byte[] actual = new byte[Integer.parseInt(streamRes.getHeader("Content-Length").iterator().next())];
+    IOUtils.read(streamRes.getBody(), actual, 0, actual.length);
+    assertEquals(random, new String(actual));
+  }
+
+  @Test
+  public void updateAsAtom() throws IOException, EdmPrimitiveTypeException {
+    update(client, ODataPubFormat.ATOM);
+  }
+
+  @Test
+  public void updateAsJSON() throws IOException, EdmPrimitiveTypeException {
+    update(client, ODataPubFormat.JSON);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/fit/src/test/java/org/apache/olingo/fit/v4/PropertyTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/PropertyTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/PropertyTestITCase.java
index de7ea50..2c8046b 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/PropertyTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/PropertyTestITCase.java
@@ -18,12 +18,12 @@
  */
 package org.apache.olingo.fit.v4;
 
-import java.io.IOException;
-import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
-import org.apache.olingo.client.api.communication.request.cud.v4.UpdateType;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
+import java.io.IOException;
+import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
+import org.apache.olingo.client.api.communication.request.cud.v4.UpdateType;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
 import org.apache.olingo.client.api.communication.response.ODataPropertyUpdateResponse;
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
@@ -112,16 +112,6 @@ public class PropertyTestITCase extends AbstractTestITCase {
     complex(edmClient, ODataFormat.JSON);
   }
 
-  @Test
-  public void complexFromFullJSON() {
-    complex(client, ODataFormat.JSON_FULL_METADATA);
-  }
-
-  @Test
-  public void patchComplexPropertyAsJSON() throws IOException {
-    updateComplexProperty(ODataFormat.JSON_FULL_METADATA, UpdateType.PATCH);
-  }
-
   private void updateComplexProperty(final ODataFormat format, final UpdateType type) throws IOException {
     final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
             appendEntitySetSegment("Customers").appendKeySegment(1).appendPropertySegment("HomeAddress");
@@ -135,7 +125,7 @@ public class PropertyTestITCase extends AbstractTestITCase {
 
     ODataProperty homeAddress =
             client.getObjectFactory().newComplexProperty("HomeAddress",
-            client.getObjectFactory().newComplexValue(retrieveRes.getBody().getComplexValue().getTypeName()));
+                    client.getObjectFactory().newComplexValue(retrieveRes.getBody().getComplexValue().getTypeName()));
 
     homeAddress.getComplexValue().add(client.getObjectFactory().
             newPrimitiveProperty("City", client.getObjectFactory().newPrimitiveValueBuilder().buildString("Pescara")));
@@ -161,4 +151,15 @@ public class PropertyTestITCase extends AbstractTestITCase {
     homeAddress = retrieveRes.getBody();
     assertEquals("Pescara", homeAddress.getComplexValue().get("City").getPrimitiveValue().toString());
   }
+
+  @Test
+  public void complexFromFullJSON() {
+    complex(client, ODataFormat.JSON_FULL_METADATA);
+  }
+
+  @Test
+  public void patchComplexPropertyAsJSON() throws IOException {
+    updateComplexProperty(ODataFormat.JSON_FULL_METADATA, UpdateType.PATCH);
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java
index 759636d..1d9cdd3 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java
@@ -25,7 +25,7 @@ import org.apache.olingo.client.api.communication.request.cud.CommonCUDRequestFa
 import org.apache.olingo.client.api.communication.request.cud.CommonUpdateType;
 import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory;
 import org.apache.olingo.client.api.communication.request.retrieve.CommonRetrieveRequestFactory;
-import org.apache.olingo.client.api.communication.request.streamed.CommonStreamedRequestFactory;
+import org.apache.olingo.client.api.communication.request.streamed.StreamedRequestFactory;
 import org.apache.olingo.client.api.op.ClientODataDeserializer;
 import org.apache.olingo.commons.api.domain.CommonODataObjectFactory;
 import org.apache.olingo.client.api.op.CommonODataBinder;
@@ -71,7 +71,7 @@ public interface CommonODataClient<UT extends CommonUpdateType> {
 
   CommonCUDRequestFactory<UT> getCUDRequestFactory();
 
-  CommonStreamedRequestFactory getStreamedRequestFactory();
+  StreamedRequestFactory getStreamedRequestFactory();
 
   InvokeRequestFactory getInvokeRequestFactory();
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/CommonStreamedRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/CommonStreamedRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/CommonStreamedRequestFactory.java
deleted file mode 100644
index ec91b9b..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/CommonStreamedRequestFactory.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.api.communication.request.streamed;
-
-import java.io.InputStream;
-import java.io.Serializable;
-import java.net.URI;
-import org.apache.olingo.commons.api.domain.CommonODataEntity;
-
-/**
- * OData request factory class.
- */
-public interface CommonStreamedRequestFactory extends Serializable {
-
-  /**
-   * Gets a media entity create request object instance.
-   * <br/>
-   * Use this kind of request to create a new media entity.
-   *
-   * @param <E> concrete ODataEntity implementation
-   * @param targetURI entity set URI.
-   * @param media entity blob to be created.
-   * @return new ODataMediaEntityCreateRequest instance.
-   */
-  <E extends CommonODataEntity> ODataMediaEntityCreateRequest<E> getMediaEntityCreateRequest(
-          URI targetURI, InputStream media);
-
-  /**
-   * Gets a stream update request object instance.
-   * <br/>
-   * Use this kind of request to update a named stream property.
-   *
-   * @param targetURI target URI.
-   * @param stream stream to be updated.
-   * @return new ODataStreamUpdateRequest instance.
-   */
-  ODataStreamUpdateRequest getStreamUpdateRequest(URI targetURI, InputStream stream);
-
-  /**
-   * Gets a media entity update request object instance.
-   * <br/>
-   * Use this kind of request to update a media entity.
-   *
-   * @param <E> concrete ODataEntity implementation
-   * @param editURI media entity edit link URI.
-   * @param media entity blob to be updated.
-   * @return new ODataMediaEntityUpdateRequest instance.
-   */
-  <E extends CommonODataEntity> ODataMediaEntityUpdateRequest<E> getMediaEntityUpdateRequest(
-          URI editURI, InputStream media);
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/StreamedRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/StreamedRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/StreamedRequestFactory.java
new file mode 100644
index 0000000..b70642f
--- /dev/null
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/StreamedRequestFactory.java
@@ -0,0 +1,67 @@
+/*
+ * 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.api.communication.request.streamed;
+
+import java.io.InputStream;
+import java.io.Serializable;
+import java.net.URI;
+import org.apache.olingo.commons.api.domain.CommonODataEntity;
+
+/**
+ * OData request factory class.
+ */
+public interface StreamedRequestFactory extends Serializable {
+
+  /**
+   * Gets a media entity create request object instance.
+   * <br/>
+   * Use this kind of request to create a new media entity.
+   *
+   * @param <E> concrete ODataEntity implementation
+   * @param targetURI entity set URI.
+   * @param media entity blob to be created.
+   * @return new ODataMediaEntityCreateRequest instance.
+   */
+  <E extends CommonODataEntity> ODataMediaEntityCreateRequest<E> getMediaEntityCreateRequest(
+          URI targetURI, InputStream media);
+
+  /**
+   * Gets a stream update request object instance.
+   * <br/>
+   * Use this kind of request to update a named stream property.
+   *
+   * @param targetURI target URI.
+   * @param stream stream to be updated.
+   * @return new ODataStreamUpdateRequest instance.
+   */
+  ODataStreamUpdateRequest getStreamUpdateRequest(URI targetURI, InputStream stream);
+
+  /**
+   * Gets a media entity update request object instance.
+   * <br/>
+   * Use this kind of request to update a media entity.
+   *
+   * @param <E> concrete ODataEntity implementation
+   * @param editURI media entity edit link URI.
+   * @param media entity blob to be updated.
+   * @return new ODataMediaEntityUpdateRequest instance.
+   */
+  <E extends CommonODataEntity> ODataMediaEntityUpdateRequest<E> getMediaEntityUpdateRequest(
+          URI editURI, InputStream media);
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/v3/StreamedRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/v3/StreamedRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/v3/StreamedRequestFactory.java
deleted file mode 100644
index db3ff84..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/v3/StreamedRequestFactory.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * 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.api.communication.request.streamed.v3;
-
-import org.apache.olingo.client.api.communication.request.streamed.CommonStreamedRequestFactory;
-
-public interface StreamedRequestFactory extends CommonStreamedRequestFactory {
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/v4/StreamedRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/v4/StreamedRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/v4/StreamedRequestFactory.java
deleted file mode 100644
index 7319e33..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/v4/StreamedRequestFactory.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * 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.api.communication.request.streamed.v4;
-
-import org.apache.olingo.client.api.communication.request.streamed.CommonStreamedRequestFactory;
-
-public interface StreamedRequestFactory extends CommonStreamedRequestFactory {
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java
index 576d648..bca42cc 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java
@@ -23,7 +23,6 @@ import org.apache.olingo.client.api.communication.request.batch.v3.BatchRequestF
 import org.apache.olingo.client.api.communication.request.cud.v3.CUDRequestFactory;
 import org.apache.olingo.client.api.communication.request.cud.v3.UpdateType;
 import org.apache.olingo.client.api.communication.request.retrieve.v3.RetrieveRequestFactory;
-import org.apache.olingo.client.api.communication.request.streamed.v3.StreamedRequestFactory;
 import org.apache.olingo.client.api.op.v3.ODataBinder;
 import org.apache.olingo.client.api.op.v3.ODataDeserializer;
 import org.apache.olingo.client.api.op.v3.ODataReader;
@@ -61,8 +60,5 @@ public interface ODataClient extends CommonODataClient<UpdateType> {
   CUDRequestFactory getCUDRequestFactory();
 
   @Override
-  StreamedRequestFactory getStreamedRequestFactory();
-
-  @Override
   BatchRequestFactory getBatchRequestFactory();
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java
index 171f51f..411e1fc 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java
@@ -23,7 +23,6 @@ import org.apache.olingo.client.api.communication.request.batch.v4.BatchRequestF
 import org.apache.olingo.client.api.communication.request.cud.v4.CUDRequestFactory;
 import org.apache.olingo.client.api.communication.request.cud.v4.UpdateType;
 import org.apache.olingo.client.api.communication.request.retrieve.v4.RetrieveRequestFactory;
-import org.apache.olingo.client.api.communication.request.streamed.v4.StreamedRequestFactory;
 import org.apache.olingo.client.api.communication.request.v4.AsyncRequestFactory;
 import org.apache.olingo.client.api.op.v4.ODataBinder;
 import org.apache.olingo.client.api.op.v4.ODataDeserializer;
@@ -64,8 +63,5 @@ public interface ODataClient extends CommonODataClient<UpdateType> {
   CUDRequestFactory getCUDRequestFactory();
 
   @Override
-  StreamedRequestFactory getStreamedRequestFactory();
-
-  @Override
   BatchRequestFactory getBatchRequestFactory();
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java
index 8159281..527ab2f 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMediaRequestImpl.java
@@ -42,7 +42,7 @@ public class ODataMediaRequestImpl extends AbstractODataRetrieveRequest<InputStr
    * @param odataClient client instance getting this request
    * @param query query to be executed.
    */
-  ODataMediaRequestImpl(final CommonODataClient odataClient, final URI query) {
+  ODataMediaRequestImpl(final CommonODataClient<?> odataClient, final URI query) {
     super(odataClient, ODataMediaFormat.class, query);
 
     setAccept(ODataMediaFormat.APPLICATION_OCTET_STREAM.toString());
@@ -75,6 +75,7 @@ public class ODataMediaRequestImpl extends AbstractODataRetrieveRequest<InputStr
      * Just to create response templates to be initialized from batch.
      */
     private ODataMediaResponseImpl() {
+      super();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractStreamedRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractStreamedRequestFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractStreamedRequestFactory.java
deleted file mode 100644
index cf15fcb..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractStreamedRequestFactory.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.communication.request.streamed;
-
-import java.io.InputStream;
-import java.net.URI;
-import org.apache.olingo.client.api.CommonODataClient;
-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.CommonStreamedRequestFactory;
-import org.apache.olingo.client.api.http.HttpMethod;
-import org.apache.olingo.commons.api.domain.CommonODataEntity;
-
-public abstract class AbstractStreamedRequestFactory implements CommonStreamedRequestFactory {
-
-  private static final long serialVersionUID = -2438839640443961168L;
-
-  protected final CommonODataClient<?> client;
-
-  protected AbstractStreamedRequestFactory(final CommonODataClient<?> client) {
-    this.client = client;
-  }
-
-  @Override
-  public <E extends CommonODataEntity> ODataMediaEntityCreateRequest<E> getMediaEntityCreateRequest(
-          final URI targetURI, final InputStream media) {
-
-    return new ODataMediaEntityCreateRequestImpl<E>(client, targetURI, media);
-  }
-
-  @Override
-  public ODataStreamUpdateRequest getStreamUpdateRequest(final URI targetURI, final InputStream stream) {
-    final ODataStreamUpdateRequest req;
-
-    if (client.getConfiguration().isUseXHTTPMethod()) {
-      req = new ODataStreamUpdateRequestImpl(client, HttpMethod.POST, targetURI, stream);
-      req.setXHTTPMethod(HttpMethod.PUT.name());
-    } else {
-      req = new ODataStreamUpdateRequestImpl(client, HttpMethod.PUT, targetURI, stream);
-    }
-
-    return req;
-  }
-
-  @Override
-  public <E extends CommonODataEntity> ODataMediaEntityUpdateRequest<E> getMediaEntityUpdateRequest(
-          final URI editURI, final InputStream media) {
-
-    final ODataMediaEntityUpdateRequest<E> req;
-
-    if (client.getConfiguration().isUseXHTTPMethod()) {
-      req = new ODataMediaEntityUpdateRequestImpl<E>(client, HttpMethod.POST, editURI, media);
-      req.setXHTTPMethod(HttpMethod.PUT.name());
-    } else {
-      req = new ODataMediaEntityUpdateRequestImpl<E>(client, HttpMethod.PUT, editURI, media);
-    }
-
-    return req;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/StreamedRequestFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/StreamedRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/StreamedRequestFactoryImpl.java
new file mode 100644
index 0000000..a7f1b56
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/StreamedRequestFactoryImpl.java
@@ -0,0 +1,77 @@
+/*
+ * 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.communication.request.streamed;
+
+import java.io.InputStream;
+import java.net.URI;
+import org.apache.olingo.client.api.CommonODataClient;
+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.StreamedRequestFactory;
+import org.apache.olingo.client.api.http.HttpMethod;
+import org.apache.olingo.commons.api.domain.CommonODataEntity;
+
+public class StreamedRequestFactoryImpl implements StreamedRequestFactory {
+
+  private static final long serialVersionUID = -2438839640443961168L;
+
+  protected final CommonODataClient<?> client;
+
+  public StreamedRequestFactoryImpl(final CommonODataClient<?> client) {
+    this.client = client;
+  }
+
+  @Override
+  public <E extends CommonODataEntity> ODataMediaEntityCreateRequest<E> getMediaEntityCreateRequest(
+          final URI targetURI, final InputStream media) {
+
+    return new ODataMediaEntityCreateRequestImpl<E>(client, targetURI, media);
+  }
+
+  @Override
+  public ODataStreamUpdateRequest getStreamUpdateRequest(final URI targetURI, final InputStream stream) {
+    final ODataStreamUpdateRequest req;
+
+    if (client.getConfiguration().isUseXHTTPMethod()) {
+      req = new ODataStreamUpdateRequestImpl(client, HttpMethod.POST, targetURI, stream);
+      req.setXHTTPMethod(HttpMethod.PUT.name());
+    } else {
+      req = new ODataStreamUpdateRequestImpl(client, HttpMethod.PUT, targetURI, stream);
+    }
+
+    return req;
+  }
+
+  @Override
+  public <E extends CommonODataEntity> ODataMediaEntityUpdateRequest<E> getMediaEntityUpdateRequest(
+          final URI editURI, final InputStream media) {
+
+    final ODataMediaEntityUpdateRequest<E> req;
+
+    if (client.getConfiguration().isUseXHTTPMethod()) {
+      req = new ODataMediaEntityUpdateRequestImpl<E>(client, HttpMethod.POST, editURI, media);
+      req.setXHTTPMethod(HttpMethod.PUT.name());
+    } else {
+      req = new ODataMediaEntityUpdateRequestImpl<E>(client, HttpMethod.PUT, editURI, media);
+    }
+
+    return req;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/v3/StreamedRequestFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/v3/StreamedRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/v3/StreamedRequestFactoryImpl.java
deleted file mode 100644
index 77446ce..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/v3/StreamedRequestFactoryImpl.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.communication.request.streamed.v3;
-
-import org.apache.olingo.client.api.v3.ODataClient;
-import org.apache.olingo.client.api.communication.request.streamed.v3.StreamedRequestFactory;
-import org.apache.olingo.client.core.communication.request.streamed.AbstractStreamedRequestFactory;
-
-public class StreamedRequestFactoryImpl extends AbstractStreamedRequestFactory
-        implements StreamedRequestFactory {
-
-  private static final long serialVersionUID = 2255688283995758441L;
-
-  public StreamedRequestFactoryImpl(final ODataClient client) {
-    super(client);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/v4/StreamedRequestFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/v4/StreamedRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/v4/StreamedRequestFactoryImpl.java
deleted file mode 100644
index 608c0ef..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/v4/StreamedRequestFactoryImpl.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.communication.request.streamed.v4;
-
-import org.apache.olingo.client.api.v4.ODataClient;
-import org.apache.olingo.client.api.communication.request.streamed.v4.StreamedRequestFactory;
-import org.apache.olingo.client.core.communication.request.streamed.AbstractStreamedRequestFactory;
-
-public class StreamedRequestFactoryImpl extends AbstractStreamedRequestFactory
-        implements StreamedRequestFactory {
-
-  private static final long serialVersionUID = 960862845654673053L;
-
-  public StreamedRequestFactoryImpl(final ODataClient client) {
-    super(client);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/58ecb3f5/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
index 397ae95..4566eb6 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
@@ -179,7 +179,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
     // -------------------------------------------------------------
     // Append edit-media links
     // -------------------------------------------------------------
-    for (ODataLink link : odataEntity.getEditMediaLinks()) {
+    for (ODataLink link : odataEntity.getMediaEditLinks()) {
       LOG.debug("Append edit-media link\n{}", link);
       entity.getMediaEditLinks().add(getLink(link,
               ResourceFactory.formatForEntityClass(reference) == ODataPubFormat.ATOM));
@@ -417,9 +417,8 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
     odataNavigationLinks(edmType, resource.getPayload(), entity, resource.getMetadataETag(), base);
 
     for (Link link : resource.getPayload().getMediaEditLinks()) {
-      entity.addLink(new ODataLink.Builder().setVersion(client.getServiceVersion()).
-              setURI(URIUtils.getURI(base, link.getHref())).
-              setType(ODataLinkType.MEDIA_EDIT).setTitle(link.getTitle()).build());
+      entity.addLink(client.getObjectFactory().
+              newMediaEditLink(link.getTitle(), URIUtils.getURI(base, link.getHref())));
     }
 
     for (ODataOperation operation : resource.getPayload().getOperations()) {
@@ -429,7 +428,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
 
     if (resource.getPayload().isMediaEntity()) {
       entity.setMediaEntity(true);
-      entity.setMediaContentSource(resource.getPayload().getMediaContentSource());
+      entity.setMediaContentSource(URIUtils.getURI(base, resource.getPayload().getMediaContentSource()));
       entity.setMediaContentType(resource.getPayload().getMediaContentType());
       entity.setMediaETag(resource.getPayload().getMediaETag());
     }


Mime
View raw message