You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2015/04/27 15:49:05 UTC

olingo-odata2 git commit: [OLINGO-639] format=atom now supported for function imports

Repository: olingo-odata2
Updated Branches:
  refs/heads/master d2804b744 -> 7c4eae45f


[OLINGO-639] format=atom now supported for function imports


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

Branch: refs/heads/master
Commit: 7c4eae45f9020cd904f6ca6f5969e596b47e527e
Parents: d2804b7
Author: Christian Amend <ch...@apache.org>
Authored: Mon Apr 27 15:41:42 2015 +0200
Committer: Christian Amend <ch...@apache.org>
Committed: Mon Apr 27 15:45:45 2015 +0200

----------------------------------------------------------------------
 .../olingo/odata2/core/ContentNegotiator.java      |  2 +-
 .../odata2/fit/ref/FunctionImportXmlTest.java      | 17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/7c4eae45/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ContentNegotiator.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ContentNegotiator.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ContentNegotiator.java
index 824cf83..dab0efa 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ContentNegotiator.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ContentNegotiator.java
@@ -130,7 +130,7 @@ public class ContentNegotiator {
         return ContentType.APPLICATION_ATOM_SVC;
       } else if (uriInfo.getUriType() == UriType.URI1) {
         return ContentType.APPLICATION_ATOM_XML_FEED;
-      } else if (uriInfo.getUriType() == UriType.URI2) {
+      } else if (uriInfo.getUriType() == UriType.URI2 || uriInfo.getUriType() == UriType.URI10) {
         return ContentType.APPLICATION_ATOM_XML_ENTRY;
       }
     } else if (URI_INFO_FORMAT_JSON.equals(format)) {

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/7c4eae45/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/FunctionImportXmlTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/FunctionImportXmlTest.java b/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/FunctionImportXmlTest.java
index fdf43e5..97187f5 100644
--- a/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/FunctionImportXmlTest.java
+++ b/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/FunctionImportXmlTest.java
@@ -66,7 +66,7 @@ public class FunctionImportXmlTest extends AbstractRefXmlTest {
     checkMediaType(response, HttpContentType.APPLICATION_XML_UTF8);
     String body = getBody(response);
     assertXpathExists("/d:AllLocations/d:element/d:City[d:CityName=\"" + CITY_2_NAME + "\"]", body);
-    final HttpResponse metadataResponse = callUri("$metadata"); 
+    final HttpResponse metadataResponse = callUri("$metadata");
     final EdmEntityContainer entityContainer = EntityProvider.readMetadata(metadataResponse.getEntity().getContent(),
         false).getDefaultEntityContainer();
     getBody(metadataResponse);
@@ -124,6 +124,21 @@ public class FunctionImportXmlTest extends AbstractRefXmlTest {
   }
 
   @Test
+  public void functionImportsAcceptFormatEqualsAtom() throws Exception {
+    HttpResponse response = callUri("OldestEmployee?$format=atom");
+    checkMediaType(response, HttpContentType.APPLICATION_ATOM_XML_ENTRY_UTF8);
+    assertXpathEvaluatesTo(EMPLOYEE_3_NAME, "/atom:entry/m:properties/d:EmployeeName", getBody(response));
+  }
+
+  @Test
+  public void functionImportsAcceptEqualsAtom() throws Exception {
+    HttpResponse response =
+        callUri("OldestEmployee?$format=atom", HttpHeaders.ACCEPT, HttpContentType.APPLICATION_ATOM_XML_ENTRY);
+    checkMediaType(response, HttpContentType.APPLICATION_ATOM_XML_ENTRY_UTF8);
+    assertXpathEvaluatesTo(EMPLOYEE_3_NAME, "/atom:entry/m:properties/d:EmployeeName", getBody(response));
+  }
+
+  @Test
   public void functionImportsDefaultAccept() throws Exception {
     HttpResponse response = callUri("EmployeeSearch('1')/ne_Room/Id/$value?q='alter'");
     checkMediaType(response, HttpContentType.TEXT_PLAIN_UTF8);