You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2013/09/11 14:36:53 UTC

git commit: Moved complete content type handling into ContentNegotiator

Updated Branches:
  refs/heads/master 31c3d8fca -> 99e549dde


Moved complete content type handling into ContentNegotiator


Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/commit/99e549dd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/tree/99e549dd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/diff/99e549dd

Branch: refs/heads/master
Commit: 99e549dde8f5c80f1c451ea6a9a13e16adc16053
Parents: 31c3d8f
Author: Michael Bolz <mi...@apache.org>
Authored: Wed Sep 11 13:47:52 2013 +0200
Committer: Michael Bolz <mi...@apache.org>
Committed: Wed Sep 11 14:27:55 2013 +0200

----------------------------------------------------------------------
 .../core/jpa/ODataJPAProcessorDefaultTest.java  | 16 +++++---
 .../api/processor/ODataSingleProcessor.java     | 21 +---------
 .../olingo/odata2/core/ContentNegotiator.java   | 41 +++++++++++---------
 .../odata2/core/ep/AtomEntityProvider.java      |  8 +---
 .../odata2/core/ep/BasicEntityProvider.java     |  5 +--
 .../odata2/core/ep/BasicProviderTest.java       |  9 +++--
 .../odata2/core/ep/ProviderFacadeImplTest.java  |  5 ++-
 .../AtomServiceDocumentProducerTest.java        |  4 +-
 .../producer/ServiceDocumentProducerTest.java   |  5 +--
 9 files changed, 50 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/99e549dd/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefaultTest.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefaultTest.java b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefaultTest.java
index e0e7590..baa2570 100644
--- a/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefaultTest.java
+++ b/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefaultTest.java
@@ -25,6 +25,7 @@ import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -52,6 +53,7 @@ import org.apache.olingo.odata2.api.edm.EdmTypeKind;
 import org.apache.olingo.odata2.api.edm.EdmTyped;
 import org.apache.olingo.odata2.api.exception.ODataException;
 import org.apache.olingo.odata2.api.processor.ODataContext;
+import org.apache.olingo.odata2.api.processor.ODataResponse;
 import org.apache.olingo.odata2.api.uri.KeyPredicate;
 import org.apache.olingo.odata2.api.uri.NavigationSegment;
 import org.apache.olingo.odata2.api.uri.PathInfo;
@@ -84,7 +86,6 @@ public class ODataJPAProcessorDefaultTest extends JPAEdmTestModelView {
   private static final String SO_ID = "SoId";
   private static final String SALES_ORDER = "SalesOrder";
   private static final String SALES_ORDER_HEADERS = "SalesOrderHeaders";
-  private static final String TEXT_PLAIN_CHARSET_UTF_8 = "text/plain;charset=utf-8";
   private static final String STR_CONTENT_TYPE = "Content-Type";
 
   @Before
@@ -111,8 +112,14 @@ public class ODataJPAProcessorDefaultTest extends JPAEdmTestModelView {
   @Test
   public void testcountEntitySet() {
     try {
-      Assert.assertNotNull(objODataJPAProcessorDefault.countEntitySet(getEntitySetCountUriInfo(), HttpContentType.APPLICATION_XML));
-      Assert.assertEquals(TEXT_PLAIN_CHARSET_UTF_8, objODataJPAProcessorDefault.countEntitySet(getEntitySetCountUriInfo(), HttpContentType.APPLICATION_XML).getHeader(STR_CONTENT_TYPE));
+      ODataResponse countEntitySet = objODataJPAProcessorDefault.countEntitySet(getEntitySetCountUriInfo(), HttpContentType.APPLICATION_XML);
+      Assert.assertNotNull(countEntitySet);
+      Object entity = countEntitySet.getEntity();
+      Assert.assertNotNull(entity);
+      
+      byte[] b = new byte[2];
+      ((ByteArrayInputStream)entity).read(b);
+      Assert.assertEquals("11", new String(b, Charset.forName("utf-8")));
     } catch (ODataException e) {
       fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
     } catch (Exception e) {
@@ -124,7 +131,7 @@ public class ODataJPAProcessorDefaultTest extends JPAEdmTestModelView {
   public void testExistsEntity() {
     try {
       Assert.assertNotNull(objODataJPAProcessorDefault.existsEntity(getEntityCountCountUriInfo(), HttpContentType.APPLICATION_XML));
-      Assert.assertEquals(TEXT_PLAIN_CHARSET_UTF_8, objODataJPAProcessorDefault.existsEntity(getEntityCountCountUriInfo(), HttpContentType.APPLICATION_XML).getHeader(STR_CONTENT_TYPE));
+      Assert.assertNull("ContentType MUST NOT set by entity provider", objODataJPAProcessorDefault.existsEntity(getEntityCountCountUriInfo(), HttpContentType.APPLICATION_XML).getHeader(STR_CONTENT_TYPE));
     } catch (ODataException e) {
       fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
     } catch (Exception e) {
@@ -136,7 +143,6 @@ public class ODataJPAProcessorDefaultTest extends JPAEdmTestModelView {
   public void testDeleteEntity() {
     try {
       Assert.assertNotNull(objODataJPAProcessorDefault.deleteEntity(getDeletetUriInfo(), HttpContentType.APPLICATION_XML));
-      Assert.assertEquals(TEXT_PLAIN_CHARSET_UTF_8, objODataJPAProcessorDefault.countEntitySet(getEntitySetCountUriInfo(), HttpContentType.APPLICATION_XML).getHeader(STR_CONTENT_TYPE));
     } catch (ODataException e) {
       fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
     }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/99e549dd/odata-api/src/main/java/org/apache/olingo/odata2/api/processor/ODataSingleProcessor.java
----------------------------------------------------------------------
diff --git a/odata-api/src/main/java/org/apache/olingo/odata2/api/processor/ODataSingleProcessor.java b/odata-api/src/main/java/org/apache/olingo/odata2/api/processor/ODataSingleProcessor.java
index 7e033c6..87ed4c3 100644
--- a/odata-api/src/main/java/org/apache/olingo/odata2/api/processor/ODataSingleProcessor.java
+++ b/odata-api/src/main/java/org/apache/olingo/odata2/api/processor/ODataSingleProcessor.java
@@ -25,7 +25,6 @@ import java.util.List;
 import org.apache.olingo.odata2.api.ODataServiceVersion;
 import org.apache.olingo.odata2.api.batch.BatchHandler;
 import org.apache.olingo.odata2.api.batch.BatchResponsePart;
-import org.apache.olingo.odata2.api.commons.HttpHeaders;
 import org.apache.olingo.odata2.api.commons.HttpStatusCodes;
 import org.apache.olingo.odata2.api.commons.ODataHttpHeaders;
 import org.apache.olingo.odata2.api.edm.Edm;
@@ -335,24 +334,8 @@ public abstract class ODataSingleProcessor implements MetadataProcessor, Service
 
     final ODataResponse response = EntityProvider.writeServiceDocument(contentType, entityDataModel, serviceRoot);
     final ODataResponseBuilder odataResponseBuilder = ODataResponse.fromResponse(response).header(ODataHttpHeaders.DATASERVICEVERSION, ODataServiceVersion.V10);
-    if (isContentTypeUpdateNecessary(contentType, response)) {
-      odataResponseBuilder.contentHeader(contentType);
-    }
-    return odataResponseBuilder.build();
-  }
-
-  /**
-   * Simple check whether the content type for the {@link ODataResponse} needs adapted or not (based on requested content type).
-   * 
-   * @param contentType
-   * @param response
-   * @return true if an update is necessary
-   */
-  private boolean isContentTypeUpdateNecessary(final String contentType, final ODataResponse response) {
-    boolean contentTypeAlreadySet = contentType.equals(response.getContentHeader());
-    boolean requestedAtomAndRespondAtomSvc = contentType.contains("atom") && response.getContentHeader().contains("atomsvc");
 
-    return !(contentTypeAlreadySet || requestedAtomAndRespondAtomSvc);
+    return odataResponseBuilder.build();
   }
 
   /**
@@ -362,7 +345,7 @@ public abstract class ODataSingleProcessor implements MetadataProcessor, Service
   public ODataResponse readMetadata(final GetMetadataUriInfo uriInfo, final String contentType) throws ODataException {
     final EdmServiceMetadata edmServiceMetadata = getContext().getService().getEntityDataModel().getServiceMetadata();
 
-    return ODataResponse.status(HttpStatusCodes.OK).header(HttpHeaders.CONTENT_TYPE, contentType).header(ODataHttpHeaders.DATASERVICEVERSION, edmServiceMetadata.getDataServiceVersion()).entity(edmServiceMetadata.getMetadata()).build();
+    return ODataResponse.status(HttpStatusCodes.OK).header(ODataHttpHeaders.DATASERVICEVERSION, edmServiceMetadata.getDataServiceVersion()).entity(edmServiceMetadata.getMetadata()).build();
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/99e549dd/odata-core/src/main/java/org/apache/olingo/odata2/core/ContentNegotiator.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/ContentNegotiator.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/ContentNegotiator.java
index bb63801..d9fe2fe 100644
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/ContentNegotiator.java
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/ContentNegotiator.java
@@ -24,6 +24,7 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
 
+import org.apache.olingo.odata2.api.commons.HttpContentType;
 import org.apache.olingo.odata2.api.commons.ODataHttpMethod;
 import org.apache.olingo.odata2.api.exception.ODataBadRequestException;
 import org.apache.olingo.odata2.api.exception.ODataException;
@@ -44,8 +45,8 @@ public class ContentNegotiator {
   private static final String URI_INFO_FORMAT_XML = "xml";
   static final String DEFAULT_CHARSET = "utf-8";
   
-  private UriInfoImpl uriInfo;
-  private ODataRequest odataRequest;
+  private final UriInfoImpl uriInfo;
+  private final ODataRequest odataRequest;
 
   /**
    * Creates a {@link ContentNegotiator} for given {@link ODataRequest} and {@link UriInfoImpl}
@@ -93,10 +94,10 @@ public class ContentNegotiator {
         (uriInfo.getUriType() == UriType.URI1 || uriInfo.getUriType() == UriType.URI6B)) {
 
       usedContentTypes = new LinkedList<String>(supportedContentTypes);
-      usedContentTypes.add(0, ContentType.APPLICATION_ATOM_XML_ENTRY_CS_UTF_8.toContentTypeString());
-      usedContentTypes.add(1, ContentType.APPLICATION_ATOM_XML_ENTRY.toContentTypeString());
-      usedContentTypes.remove(ContentType.APPLICATION_ATOM_XML_FEED.toContentTypeString());
-      usedContentTypes.remove(ContentType.APPLICATION_ATOM_XML_FEED_CS_UTF_8.toContentTypeString());
+      usedContentTypes.add(0, HttpContentType.APPLICATION_ATOM_XML_ENTRY_UTF8);
+//      usedContentTypes.add(1, HttpContentType.APPLICATION_ATOM_XML_ENTRY);
+//      usedContentTypes.remove(HttpContentType.APPLICATION_ATOM_XML_FEED);
+      usedContentTypes.remove(HttpContentType.APPLICATION_ATOM_XML_FEED_UTF8);
     }
     
     if (uriInfo.getFormat() == null) {
@@ -117,21 +118,23 @@ public class ContentNegotiator {
    * @return best correct response content type based on accepted content type, {@link ODataRequest} and {@link UriInfo} combination 
    */
   public ContentType doResponseContentNegotiation(ContentType acceptContentType) {
-      ContentType contentType = acceptContentType;
-      UriType uriType = uriInfo.getUriType();
-      if(contentType != null && contentType.getODataFormat() == ODataFormat.ATOM) {
-        if(uriType == UriType.URI1 || uriType == UriType.URI6B) {
-          if(ODataHttpMethod.GET.equals(odataRequest.getMethod())) {
-            contentType = ContentType.create(contentType, ContentType.PARAMETER_TYPE, "feed");
-          } else {
-            contentType = ContentType.create(contentType, ContentType.PARAMETER_TYPE, "entry");          
-          }
-        } else if(uriType == UriType.URI2 || uriType == UriType.URI6A) {
-          contentType = ContentType.create(contentType, ContentType.PARAMETER_TYPE, "entry");
+    UriType uriType = uriInfo.getUriType();
+    
+    if(uriInfo.isCount() || uriInfo.isValue()) {
+      return ContentType.TEXT_PLAIN_CS_UTF_8;
+    } else if(acceptContentType != null && acceptContentType.getODataFormat() == ODataFormat.ATOM) {
+      if(uriType == UriType.URI1 || uriType == UriType.URI6B) {
+        if(ODataHttpMethod.GET.equals(odataRequest.getMethod())) {
+          return ContentType.create(acceptContentType, ContentType.PARAMETER_TYPE, "feed");
+        } else {
+          return ContentType.create(acceptContentType, ContentType.PARAMETER_TYPE, "entry");          
         }
-      } 
+      } else if(uriType == UriType.URI2 || uriType == UriType.URI6A) {
+        return ContentType.create(acceptContentType, ContentType.PARAMETER_TYPE, "entry");
+      }
+    } 
 
-    return contentType;
+    return acceptContentType;
   }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/99e549dd/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/AtomEntityProvider.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/AtomEntityProvider.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/AtomEntityProvider.java
index bffbe70..07b3c30 100644
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/AtomEntityProvider.java
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/AtomEntityProvider.java
@@ -125,7 +125,7 @@ public class AtomEntityProvider implements ContentTypeBasedEntityProvider {
 
   /**
    * Write service document based on given {@link Edm} and <code>service root</code> as
-   * content type "<code>application/atomsvc+xml; charset=utf-8</code>".
+   * <code>AtomPub Service Document/code> with charset encoding {@value #DEFAULT_CHARSET}.
    * 
    * @param edm the Entity Data Model
    * @param serviceRoot the root URI of the service
@@ -142,11 +142,7 @@ public class AtomEntityProvider implements ContentTypeBasedEntityProvider {
       as.writeServiceDocument(writer);
       csb.closeWrite();
 
-      ODataResponse response = ODataResponse.entity(csb.getInputStream())
-          .contentHeader(ContentType.APPLICATION_ATOM_SVC.receiveWithCharsetParameter(DEFAULT_CHARSET).toContentTypeString())
-          .build();
-
-      return response;
+      return ODataResponse.entity(csb.getInputStream()).build();
     } catch (EntityProviderException e) {
       csb.close();
       throw e;

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/99e549dd/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/BasicEntityProvider.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/BasicEntityProvider.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/BasicEntityProvider.java
index eb964f0..409e92a 100644
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/BasicEntityProvider.java
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/BasicEntityProvider.java
@@ -51,7 +51,6 @@ import org.apache.olingo.odata2.api.edm.provider.Schema;
 import org.apache.olingo.odata2.api.ep.EntityProviderException;
 import org.apache.olingo.odata2.api.processor.ODataResponse;
 import org.apache.olingo.odata2.api.processor.ODataResponse.ODataResponseBuilder;
-import org.apache.olingo.odata2.core.commons.ContentType;
 import org.apache.olingo.odata2.core.ep.producer.XmlMetadataProducer;
 import org.apache.olingo.odata2.core.ep.util.CircleStreamBuffer;
 
@@ -196,7 +195,6 @@ public class BasicEntityProvider {
       builder.entity(stream);
     }
     
-    builder.contentHeader(ContentType.TEXT_PLAIN.receiveWithCharsetParameter(DEFAULT_CHARSET).toContentTypeString());
     return builder.build();
   }
 
@@ -236,7 +234,7 @@ public class BasicEntityProvider {
     OutputStreamWriter writer = null;
     CircleStreamBuffer csb = new CircleStreamBuffer();
     try {
-      writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
+      writer = new OutputStreamWriter(csb.getOutputStream(), DEFAULT_CHARSET);
       XMLStreamWriter xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(writer);
       XmlMetadataProducer.writeMetadata(metadata, xmlStreamWriter, predefinedNamespaces);
     } catch (UnsupportedEncodingException e) {
@@ -247,7 +245,6 @@ public class BasicEntityProvider {
       throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
     }
     builder.entity(csb.getInputStream());
-    builder.contentHeader(ContentType.APPLICATION_XML_CS_UTF_8.toContentTypeString());
     builder.header(ODataHttpHeaders.DATASERVICEVERSION, dataServiceVersion);
     return builder.build();
   }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/99e549dd/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/BasicProviderTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/BasicProviderTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/BasicProviderTest.java
index 3c6cf68..378ca48 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/BasicProviderTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/BasicProviderTest.java
@@ -21,6 +21,7 @@ package org.apache.olingo.odata2.core.ep;
 import static org.custommonkey.xmlunit.XMLAssert.assertXpathExists;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayInputStream;
@@ -65,7 +66,7 @@ public class BasicProviderTest extends AbstractProviderTest {
     ODataResponse response = provider.writeMetadata(null, predefinedNamespaces);
     assertNotNull(response);
     assertNotNull(response.getEntity());
-    assertEquals(ContentType.APPLICATION_XML_CS_UTF_8.toString(), response.getContentHeader());
+    assertNull("BasicProvider should not set content header", response.getContentHeader());
     String metadata = StringHelper.inputStreamToString((InputStream) response.getEntity());
     assertTrue(metadata.contains("xmlns:foo=\"http://foo\""));
     assertTrue(metadata.contains("xmlns:annoPrefix=\"http://annoNamespace\""));
@@ -99,7 +100,7 @@ public class BasicProviderTest extends AbstractProviderTest {
     ODataResponse response = provider.writeMetadata(testProvider.getSchemas(), predefinedNamespaces);
     assertNotNull(response);
     assertNotNull(response.getEntity());
-    assertEquals(ContentType.APPLICATION_XML_CS_UTF_8.toString(), response.getContentHeader());
+    assertNull("BasicProvider should not set content header", response.getContentHeader());
     String metadata = StringHelper.inputStreamToString((InputStream) response.getEntity());
 
     setNamespaces();
@@ -122,7 +123,7 @@ public class BasicProviderTest extends AbstractProviderTest {
     ODataResponse response = provider.writeMetadata(testProvider.getSchemas(), null);
     assertNotNull(response);
     assertNotNull(response.getEntity());
-    assertEquals(ContentType.APPLICATION_XML_CS_UTF_8.toString(), response.getContentHeader());
+    assertNull("BasicProvider should not set content header", response.getContentHeader());
     String metadata = StringHelper.inputStreamToString((InputStream) response.getEntity());
 
     setNamespaces();
@@ -146,7 +147,7 @@ public class BasicProviderTest extends AbstractProviderTest {
     ODataResponse response = provider.writePropertyValue(edmProperty, employeeData.get("Age"));
     assertNotNull(response);
     assertNotNull(response.getEntity());
-    assertEquals(ContentType.TEXT_PLAIN_CS_UTF_8.toString(), response.getContentHeader());
+    assertNull("BasicProvider should not set content header", response.getContentHeader());
     String value = StringHelper.inputStreamToString((InputStream) response.getEntity());
     assertEquals(employeeData.get("Age").toString(), value);
   }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/99e549dd/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/ProviderFacadeImplTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/ProviderFacadeImplTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/ProviderFacadeImplTest.java
index c3820c5..de2214b 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/ProviderFacadeImplTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/ProviderFacadeImplTest.java
@@ -204,14 +204,15 @@ public class ProviderFacadeImplTest {
   public void writePropertyValue() throws Exception {
     final EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("EntryDate");
     final ODataResponse result = new ProviderFacadeImpl().writePropertyValue(property, 987654321000L);
-    assertEquals(HttpContentType.TEXT_PLAIN_UTF8, result.getContentHeader());
+    assertNull("BasicProvider should not set content header", result.getContentHeader());
+    
     assertEquals("2001-04-19T04:25:21", StringHelper.inputStreamToString((InputStream) result.getEntity()));
   }
 
   @Test
   public void writeText() throws Exception {
     final ODataResponse result = new ProviderFacadeImpl().writeText("test");
-    assertEquals(HttpContentType.TEXT_PLAIN_UTF8, result.getContentHeader());
+    assertNull("BasicProvider should not set content header", result.getContentHeader());
     assertEquals("test", StringHelper.inputStreamToString((InputStream) result.getEntity()));
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/99e549dd/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/AtomServiceDocumentProducerTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/AtomServiceDocumentProducerTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/AtomServiceDocumentProducerTest.java
index fa99224..4fcef66 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/AtomServiceDocumentProducerTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/AtomServiceDocumentProducerTest.java
@@ -20,8 +20,8 @@ package org.apache.olingo.odata2.core.ep.producer;
 
 import static org.custommonkey.xmlunit.XMLAssert.assertXpathEvaluatesTo;
 import static org.custommonkey.xmlunit.XMLAssert.assertXpathExists;
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -179,7 +179,7 @@ public class AtomServiceDocumentProducerTest extends AbstractXmlProducerTestHelp
   private String verifyResponse(final ODataResponse response) throws IOException {
     assertNotNull(response);
     assertNotNull(response.getEntity());
-    assertEquals(HttpContentType.APPLICATION_ATOM_SVC_UTF8, response.getContentHeader());
+    assertNull("EntityProvider should not set content header", response.getContentHeader());
     String xmlString = StringHelper.inputStreamToString((InputStream) response.getEntity());
     return xmlString;
   }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/99e549dd/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/ServiceDocumentProducerTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/ServiceDocumentProducerTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/ServiceDocumentProducerTest.java
index ad44f50..bfe4a54 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/ServiceDocumentProducerTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/ServiceDocumentProducerTest.java
@@ -18,7 +18,7 @@
  ******************************************************************************/
 package org.apache.olingo.odata2.core.ep.producer;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -71,7 +71,6 @@ public class ServiceDocumentProducerTest extends AbstractXmlProducerTestHelper {
   public void testServiceDocumentXml() throws EntityProviderException, ODataException {
     ODataResponse response = EntityProvider.writeServiceDocument(HttpContentType.APPLICATION_ATOM_XML, edm, "http://localhost/");
 
-    assertEquals(HttpContentType.APPLICATION_ATOM_SVC_UTF8, response.getContentHeader());
+    assertNull("EntityProvider should not set content header", response.getContentHeader());
   }
-
 }