olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [2/2] git commit: [OLINGO-341] Fix
Date Fri, 04 Jul 2014 09:23:45 GMT
[OLINGO-341] Fix


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

Branch: refs/heads/master
Commit: 098ed145dbafa2bd59d35448ec37fcf0b01bcb98
Parents: 15f7de8
Author: Francesco Chicchiriccò <--global>
Authored: Fri Jul 4 11:23:36 2014 +0200
Committer: Francesco Chicchiriccò <--global>
Committed: Fri Jul 4 11:23:36 2014 +0200

----------------------------------------------------------------------
 .../apache/olingo/fit/tecsvc/BasicITCase.java   | 14 ++++++++++--
 .../retrieve/AbstractODataRetrieveRequest.java  |  6 +----
 .../retrieve/EdmMetadataRequestImpl.java        | 10 ++++++++
 .../retrieve/v4/XMLMetadataRequestImpl.java     | 24 ++++++++++++--------
 4 files changed, 37 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/098ed145/fit/src/test/java/org/apache/olingo/fit/tecsvc/BasicITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/BasicITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/BasicITCase.java
index 136d513..8c5650f 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/BasicITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/BasicITCase.java
@@ -18,14 +18,17 @@
  */
 package org.apache.olingo.fit.tecsvc;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
 import org.apache.olingo.client.api.communication.request.retrieve.EdmMetadataRequest;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataServiceDocumentRequest;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
 import org.apache.olingo.client.api.v4.ODataClient;
 import org.apache.olingo.client.core.ODataClientFactory;
 import org.apache.olingo.commons.api.domain.ODataServiceDocument;
 import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -43,7 +46,7 @@ public class BasicITCase {
   @Test
   public void readServiceDocument() {
     ODataServiceDocumentRequest request =
-        odata.getRetrieveRequestFactory().getServiceDocumentRequest(REF_SERVICE);
+            odata.getRetrieveRequestFactory().getServiceDocumentRequest(REF_SERVICE);
     request.setAccept("application/json;odata.metadata=minimal");
     assertNotNull(request);
     ODataServiceDocument serviceDocument = request.execute().getBody();
@@ -54,7 +57,14 @@ public class BasicITCase {
   public void readMetadata() {
     EdmMetadataRequest request = odata.getRetrieveRequestFactory().getMetadataRequest(REF_SERVICE);
     assertNotNull(request);
-    Edm edm = request.execute().getBody();
+
+    ODataRetrieveResponse<Edm> response = request.execute();
+    assertEquals(200, response.getStatusCode());
+
+    Edm edm = response.getBody();
     assertNotNull(edm);
+    assertEquals("com.sap.odata.test1", edm.getSchema("com.sap.odata.test1").getNamespace());
+    assertEquals("Namespace1_Alias", edm.getSchema("com.sap.odata.test1").getAlias());
+    assertNotNull(edm.getTerm(new FullQualifiedName("Core.Description")));
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/098ed145/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java
index 1a28a14..c42832c 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java
@@ -62,7 +62,7 @@ public abstract class AbstractODataRetrieveRequest<T>
    * Response abstract class about an ODataRetrieveRequest.
    */
   protected abstract class AbstractODataRetrieveResponse
-      extends AbstractODataResponse implements ODataRetrieveResponse<T> {
+          extends AbstractODataResponse implements ODataRetrieveResponse<T> {
 
     /**
      * Constructor.
@@ -83,10 +83,6 @@ public abstract class AbstractODataRetrieveRequest<T>
       super(client, res);
     }
 
-    protected HttpResponse getHttpResponse() {
-      return res;
-    }
-
     @Override
     public abstract T getBody();
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/098ed145/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java
index 5a02a19..64486ff 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java
@@ -58,6 +58,16 @@ class EdmMetadataRequestImpl extends AbstractMetadataRequestImpl<Edm>
implements
       }
 
       @Override
+      public int getStatusCode() {
+        return xmlMetadataResponse.getStatusCode();
+      }
+
+      @Override
+      public String getStatusMessage() {
+        return xmlMetadataResponse.getStatusMessage();
+      }
+
+      @Override
       public Edm getBody() {
         if (metadata == null) {
           try {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/098ed145/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java
index 88fb07a..4645d86 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java
@@ -23,6 +23,8 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
 import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
 import org.apache.olingo.client.api.edm.xml.Schema;
@@ -50,7 +52,7 @@ public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl<Map<Stri
     final SingleXMLMetadatRequestImpl rootReq = new SingleXMLMetadatRequestImpl((ODataClient)
odataClient, uri);
     final ODataRetrieveResponse<XMLMetadata> rootRes = rootReq.execute();
 
-    final XMLMetadataResponseImpl response = new XMLMetadataResponseImpl();
+    final XMLMetadataResponseImpl response = new XMLMetadataResponseImpl(httpClient, rootReq.getHttpResponse());
 
     final XMLMetadata rootMetadata = rootRes.getBody();
     for (Schema schema : rootMetadata.getSchemas()) {
@@ -87,7 +89,7 @@ public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl<Map<Stri
 
           // process all edm:Annotations in each schema of the included document
           for (Annotations annotationGroup : ((SchemaImpl) schema).getAnnotationGroups())
{
-              // take into account only when (TargetNamespace was either not provided or
matches) and
+            // take into account only when (TargetNamespace was either not provided or matches)
and
             // (Qualifier was either not provided or matches)
             if ((StringUtils.isBlank(include.getTargetNamespace())
                     || include.getTargetNamespace().equals(
@@ -123,13 +125,20 @@ public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl<Map<Stri
 
   private class SingleXMLMetadatRequestImpl extends AbstractMetadataRequestImpl<XMLMetadata>
{
 
+    private HttpResponse httpResponse;
+
     public SingleXMLMetadatRequestImpl(final ODataClient odataClient, final URI uri) {
       super(odataClient, uri);
     }
 
+    public HttpResponse getHttpResponse() {
+      return httpResponse;
+    }
+
     @Override
     public ODataRetrieveResponse<XMLMetadata> execute() {
-      return new AbstractODataRetrieveResponse(httpClient, doExecute()) {
+      httpResponse = doExecute();
+      return new AbstractODataRetrieveResponse(httpClient, httpResponse) {
 
         @Override
         public XMLMetadata getBody() {
@@ -147,13 +156,8 @@ public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl<Map<Stri
 
     private final Map<String, Schema> schemas = new HashMap<String, Schema>();
 
-    /**
-     * Constructor.
-     * <br/>
-     * Just to create response templates to be initialized from batch.
-     */
-    private XMLMetadataResponseImpl() {
-      super();
+    private XMLMetadataResponseImpl(final HttpClient client, final HttpResponse res) {
+      super(client, res);
     }
 
     @Override


Mime
View raw message