[OLINGO-341] Fix
This commit is contained in:
parent
15f7de8f6c
commit
098ed145db
|
@ -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;
|
||||
|
||||
|
@ -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")));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,10 +83,6 @@ public abstract class AbstractODataRetrieveRequest<T>
|
|||
super(client, res);
|
||||
}
|
||||
|
||||
protected HttpResponse getHttpResponse() {
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract T getBody();
|
||||
}
|
||||
|
|
|
@ -57,6 +57,16 @@ class EdmMetadataRequestImpl extends AbstractMetadataRequestImpl<Edm> implements
|
|||
xmlMetadataResponse.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusCode() {
|
||||
return xmlMetadataResponse.getStatusCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatusMessage() {
|
||||
return xmlMetadataResponse.getStatusMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Edm getBody() {
|
||||
if (metadata == null) {
|
||||
|
|
|
@ -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()) {
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue