Merge branch 'IEE754Compatible'
This commit is contained in:
commit
9998ba6748
|
@ -34,7 +34,7 @@ import org.apache.olingo.client.core.edm.ClientCsdlEdmProvider;
|
||||||
import org.apache.olingo.commons.api.ODataRuntimeException;
|
import org.apache.olingo.commons.api.ODataRuntimeException;
|
||||||
import org.apache.olingo.commons.api.edm.Edm;
|
import org.apache.olingo.commons.api.edm.Edm;
|
||||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.core.edm.EdmProviderImpl;
|
import org.apache.olingo.commons.core.edm.EdmProviderImpl;
|
||||||
import org.apache.olingo.ext.proxy.api.AbstractTerm;
|
import org.apache.olingo.ext.proxy.api.AbstractTerm;
|
||||||
import org.apache.olingo.ext.proxy.api.PersistenceManager;
|
import org.apache.olingo.ext.proxy.api.PersistenceManager;
|
||||||
|
@ -96,7 +96,7 @@ public abstract class AbstractService<C extends EdmEnabledODataClient> {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.client = ODataClientFactory.getEdmEnabledClient(serviceRoot, edm, metadataETag);
|
this.client = ODataClientFactory.getEdmEnabledClient(serviceRoot, edm, metadataETag);
|
||||||
this.client.getConfiguration().setDefaultPubFormat(ODataFormat.JSON_FULL_METADATA);
|
this.client.getConfiguration().setDefaultPubFormat(ContentType.JSON_FULL_METADATA);
|
||||||
this.transactional = transactional;
|
this.transactional = transactional;
|
||||||
this.context = new Context();
|
this.context = new Context();
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.olingo.client.api.domain.ClientEntity;
|
import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
|
|
|
@ -33,12 +33,12 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
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.retrieve.ODataMediaRequest;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||||
import org.apache.olingo.client.api.uri.URIBuilder;
|
|
||||||
import org.apache.olingo.client.api.domain.ClientAnnotation;
|
import org.apache.olingo.client.api.domain.ClientAnnotation;
|
||||||
import org.apache.olingo.client.api.domain.ClientEntity;
|
import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
import org.apache.olingo.client.api.domain.ClientProperty;
|
import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
|
import org.apache.olingo.client.api.uri.URIBuilder;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.ext.proxy.AbstractService;
|
import org.apache.olingo.ext.proxy.AbstractService;
|
||||||
import org.apache.olingo.ext.proxy.api.AbstractTerm;
|
import org.apache.olingo.ext.proxy.api.AbstractTerm;
|
||||||
import org.apache.olingo.ext.proxy.api.Annotatable;
|
import org.apache.olingo.ext.proxy.api.Annotatable;
|
||||||
|
@ -335,7 +335,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
|
||||||
getClient().getRetrieveRequestFactory().getMediaEntityRequest(contentSource);
|
getClient().getRetrieveRequestFactory().getMediaEntityRequest(contentSource);
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(getEntity().getMediaContentType())) {
|
if (StringUtils.isNotBlank(getEntity().getMediaContentType())) {
|
||||||
retrieveReq.setFormat(ODataFormat.fromString(getEntity().getMediaContentType()));
|
retrieveReq.setFormat(ContentType.parse(getEntity().getMediaContentType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
final ODataRetrieveResponse<InputStream> res = retrieveReq.execute();
|
final ODataRetrieveResponse<InputStream> res = retrieveReq.execute();
|
||||||
|
|
|
@ -29,11 +29,11 @@ import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Triple;
|
import org.apache.commons.lang3.tuple.Triple;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
|
import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
|
||||||
import org.apache.olingo.client.api.uri.URIBuilder;
|
|
||||||
import org.apache.olingo.client.api.domain.ClientAnnotation;
|
import org.apache.olingo.client.api.domain.ClientAnnotation;
|
||||||
import org.apache.olingo.client.api.domain.ClientEntity;
|
import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
|
import org.apache.olingo.client.api.uri.URIBuilder;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.ext.proxy.AbstractService;
|
import org.apache.olingo.ext.proxy.AbstractService;
|
||||||
import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
|
import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
|
||||||
import org.apache.olingo.ext.proxy.api.AbstractSingleton;
|
import org.apache.olingo.ext.proxy.api.AbstractSingleton;
|
||||||
|
@ -95,7 +95,7 @@ public class EntitySetInvocationHandler<
|
||||||
public Long count() {
|
public Long count() {
|
||||||
final ODataValueRequest req = getClient().getRetrieveRequestFactory().
|
final ODataValueRequest req = getClient().getRetrieveRequestFactory().
|
||||||
getValueRequest(getClient().newURIBuilder(this.uri.build().toASCIIString()).count().build());
|
getValueRequest(getClient().newURIBuilder(this.uri.build().toASCIIString()).count().build());
|
||||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
req.setFormat(ContentType.TEXT_PLAIN);
|
||||||
return Long.valueOf(req.execute().getBody().asPrimitive().toString());
|
return Long.valueOf(req.execute().getBody().asPrimitive().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ import org.apache.olingo.commons.api.edm.EdmEntityType;
|
||||||
import org.apache.olingo.commons.api.edm.EdmEnumType;
|
import org.apache.olingo.commons.api.edm.EdmEnumType;
|
||||||
import org.apache.olingo.commons.api.edm.EdmSchema;
|
import org.apache.olingo.commons.api.edm.EdmSchema;
|
||||||
import org.apache.olingo.commons.api.edm.EdmTerm;
|
import org.apache.olingo.commons.api.edm.EdmTerm;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.velocity.Template;
|
import org.apache.velocity.Template;
|
||||||
import org.apache.velocity.VelocityContext;
|
import org.apache.velocity.VelocityContext;
|
||||||
import org.apache.velocity.app.Velocity;
|
import org.apache.velocity.app.Velocity;
|
||||||
|
@ -218,7 +218,7 @@ public abstract class AbstractPOJOGenMojo extends AbstractMojo {
|
||||||
} else if (StringUtils.isNotEmpty(localEdm)) {
|
} else if (StringUtils.isNotEmpty(localEdm)) {
|
||||||
final FileInputStream fis = new FileInputStream(FileUtils.getFile(localEdm));
|
final FileInputStream fis = new FileInputStream(FileUtils.getFile(localEdm));
|
||||||
try {
|
try {
|
||||||
metadata = getClient().getDeserializer(ODataFormat.XML).toMetadata(fis);
|
metadata = getClient().getDeserializer(ContentType.APPLICATION_XML).toMetadata(fis);
|
||||||
edm = getClient().getReader().readMetadata(metadata.getSchemaByNsOrAlias());
|
edm = getClient().getReader().readMetadata(metadata.getSchemaByNsOrAlias());
|
||||||
} finally {
|
} finally {
|
||||||
IOUtils.closeQuietly(fis);
|
IOUtils.closeQuietly(fis);
|
||||||
|
|
|
@ -148,7 +148,7 @@ public abstract class AbstractServices {
|
||||||
atomDeserializer = new FITAtomDeserializer();
|
atomDeserializer = new FITAtomDeserializer();
|
||||||
jsonDeserializer = new JsonDeserializer(true);
|
jsonDeserializer = new JsonDeserializer(true);
|
||||||
atomSerializer = new AtomSerializer(true);
|
atomSerializer = new AtomSerializer(true);
|
||||||
jsonSerializer = new JsonSerializer(true);
|
jsonSerializer = new JsonSerializer(true, ContentType.JSON_FULL_METADATA);
|
||||||
|
|
||||||
xml = new XMLUtilities(metadata);
|
xml = new XMLUtilities(metadata);
|
||||||
json = new JSONUtilities(metadata);
|
json = new JSONUtilities(metadata);
|
||||||
|
|
|
@ -55,6 +55,7 @@ import org.apache.olingo.commons.api.data.Link;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||||
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.fit.UnsupportedMediaTypeException;
|
import org.apache.olingo.fit.UnsupportedMediaTypeException;
|
||||||
import org.apache.olingo.fit.metadata.Metadata;
|
import org.apache.olingo.fit.metadata.Metadata;
|
||||||
import org.apache.olingo.fit.metadata.NavigationProperty;
|
import org.apache.olingo.fit.metadata.NavigationProperty;
|
||||||
|
@ -104,7 +105,7 @@ public abstract class AbstractUtilities {
|
||||||
atomDeserializer = new FITAtomDeserializer();
|
atomDeserializer = new FITAtomDeserializer();
|
||||||
jsonDeserializer = new JsonDeserializer(true);
|
jsonDeserializer = new JsonDeserializer(true);
|
||||||
atomSerializer = new AtomSerializer(true);
|
atomSerializer = new AtomSerializer(true);
|
||||||
jsonSerializer = new JsonSerializer(true);
|
jsonSerializer = new JsonSerializer(true, ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMediaContent(final String entityName) {
|
public boolean isMediaContent(final String entityName) {
|
||||||
|
|
|
@ -44,6 +44,7 @@ import org.apache.olingo.client.core.serialization.JsonSerializer;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||||
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -125,7 +126,7 @@ public class FSManager {
|
||||||
putInMemory(new ByteArrayInputStream(content.toByteArray()), getAbsolutePath(relativePath, Accept.ATOM));
|
putInMemory(new ByteArrayInputStream(content.toByteArray()), getAbsolutePath(relativePath, Accept.ATOM));
|
||||||
content.reset();
|
content.reset();
|
||||||
|
|
||||||
new JsonSerializer(true).write(writer, container);
|
new JsonSerializer(true, ContentType.JSON_FULL_METADATA).write(writer, container);
|
||||||
writer.flush();
|
writer.flush();
|
||||||
|
|
||||||
putInMemory(new ByteArrayInputStream(content.toByteArray()), getAbsolutePath(relativePath, Accept.JSON_FULLMETA));
|
putInMemory(new ByteArrayInputStream(content.toByteArray()), getAbsolutePath(relativePath, Accept.JSON_FULLMETA));
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.apache.olingo.client.api.domain.ClientValue;
|
||||||
import org.apache.olingo.client.api.serialization.ODataSerializerException;
|
import org.apache.olingo.client.api.serialization.ODataSerializerException;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntityCollection;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.fit.server.TomcatTestServer;
|
import org.apache.olingo.fit.server.TomcatTestServer;
|
||||||
import org.apache.olingo.server.tecsvc.TechnicalServlet;
|
import org.apache.olingo.server.tecsvc.TechnicalServlet;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
@ -72,7 +72,7 @@ public abstract class AbstractBaseTestITCase {
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
final StringWriter writer = new StringWriter();
|
final StringWriter writer = new StringWriter();
|
||||||
try {
|
try {
|
||||||
getClient().getSerializer(ODataFormat.JSON).write(writer, entity);
|
getClient().getSerializer(ContentType.JSON).write(writer, entity);
|
||||||
} catch (final ODataSerializerException e) {
|
} catch (final ODataSerializerException e) {
|
||||||
// Debug
|
// Debug
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ public abstract class AbstractBaseTestITCase {
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
final StringWriter writer = new StringWriter();
|
final StringWriter writer = new StringWriter();
|
||||||
try {
|
try {
|
||||||
getClient().getSerializer(ODataFormat.JSON).write(writer, entitySet);
|
getClient().getSerializer(ContentType.JSON).write(writer, entitySet);
|
||||||
} catch (final ODataSerializerException e) {
|
} catch (final ODataSerializerException e) {
|
||||||
// Debug
|
// Debug
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,8 @@ public abstract class AbstractBaseTestITCase {
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
try {
|
try {
|
||||||
getClient().getSerializer(ODataFormat.ATOM).write(writer, getClient().getBinder().getEntity(entity));
|
getClient().getSerializer(ContentType.APPLICATION_ATOM_XML).write(writer, getClient().getBinder()
|
||||||
|
.getEntity(entity));
|
||||||
} catch (final ODataSerializerException e) {
|
} catch (final ODataSerializerException e) {
|
||||||
// Debug
|
// Debug
|
||||||
}
|
}
|
||||||
|
@ -115,7 +116,7 @@ public abstract class AbstractBaseTestITCase {
|
||||||
|
|
||||||
writer = new StringWriter();
|
writer = new StringWriter();
|
||||||
try {
|
try {
|
||||||
getClient().getSerializer(ODataFormat.JSON).write(writer, getClient().getBinder().getEntity(entity));
|
getClient().getSerializer(ContentType.JSON).write(writer, getClient().getBinder().getEntity(entity));
|
||||||
} catch (final ODataSerializerException e) {
|
} catch (final ODataSerializerException e) {
|
||||||
// Debug
|
// Debug
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
import org.apache.olingo.client.api.domain.ClientValue;
|
import org.apache.olingo.client.api.domain.ClientValue;
|
||||||
import org.apache.olingo.client.core.ODataClientFactory;
|
import org.apache.olingo.client.core.ODataClientFactory;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||||
|
@ -309,7 +309,7 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
|
||||||
@Override
|
@Override
|
||||||
protected ODataClient getClient() {
|
protected ODataClient getClient() {
|
||||||
ODataClient odata = ODataClientFactory.getClient();
|
ODataClient odata = ODataClientFactory.getClient();
|
||||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON_NO_METADATA);
|
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON_NO_METADATA);
|
||||||
return odata;
|
return odata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -41,16 +42,19 @@ import org.apache.olingo.client.api.communication.header.HeaderName;
|
||||||
import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
|
import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
|
||||||
import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
|
import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
|
||||||
import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
|
import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
|
||||||
|
import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
|
||||||
import org.apache.olingo.client.api.communication.request.cud.UpdateType;
|
import org.apache.olingo.client.api.communication.request.cud.UpdateType;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.EdmMetadataRequest;
|
import org.apache.olingo.client.api.communication.request.retrieve.EdmMetadataRequest;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
|
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
|
||||||
|
import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataServiceDocumentRequest;
|
import org.apache.olingo.client.api.communication.request.retrieve.ODataServiceDocumentRequest;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
|
import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
|
import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
|
import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
|
import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
|
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
|
||||||
|
import org.apache.olingo.client.api.communication.response.ODataPropertyUpdateResponse;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||||
import org.apache.olingo.client.api.domain.ClientAnnotation;
|
import org.apache.olingo.client.api.domain.ClientAnnotation;
|
||||||
import org.apache.olingo.client.api.domain.ClientComplexValue;
|
import org.apache.olingo.client.api.domain.ClientComplexValue;
|
||||||
|
@ -71,16 +75,31 @@ import org.apache.olingo.commons.api.edm.Edm;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ContentType;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
|
||||||
import org.apache.olingo.commons.api.http.HttpHeader;
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class BasicITCase extends AbstractBaseTestITCase {
|
public class BasicITCase extends AbstractBaseTestITCase {
|
||||||
|
|
||||||
|
private static final String CONTENT_TYPE_JSON_IEEE754_COMPATIBLE = "application/json;odata.metadata=minimal;"
|
||||||
|
+ "IEEE754Compatible=true";
|
||||||
|
private static final String SERVICE_NAMESPACE = "olingo.odata.test1";
|
||||||
|
private static final String ET_ALL_PRIM_NAME = "ETAllPrim";
|
||||||
|
private static final FullQualifiedName ET_ALL_PRIM = new FullQualifiedName(SERVICE_NAMESPACE, ET_ALL_PRIM_NAME);
|
||||||
|
|
||||||
|
private static final String PROPERTY_INT16 = "PropertyInt16";
|
||||||
|
private static final String PROPERTY_INT64 = "PropertyInt64";
|
||||||
|
private static final String PROPERTY_DECIMAL = "PropertyDecimal";
|
||||||
|
private static final String PROPERTY_COMP_ALL_PRIM = "PropertyCompAllPrim";
|
||||||
|
private static final String NAV_PROPERTY_ET_TWO_PRIM_ONE = "NavPropertyETTwoPrimOne";
|
||||||
|
|
||||||
private static final String SERVICE_URI = TecSvcConst.BASE_URI;
|
private static final String SERVICE_URI = TecSvcConst.BASE_URI;
|
||||||
|
private static final String ES_ALL_PRIM = "ESAllPrim";
|
||||||
|
private static final String ES_TWO_PRIM = "ESTwoPrim";
|
||||||
|
private static final String ES_KEY_NAV = "ESKeyNav";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readServiceDocument() {
|
public void readServiceDocument() {
|
||||||
|
@ -377,7 +396,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
||||||
ClientEntity newEntity = factory.newEntity(new FullQualifiedName("olingo.odata.test1", "ETAllPrim"));
|
ClientEntity newEntity = factory.newEntity(new FullQualifiedName("olingo.odata.test1", "ETAllPrim"));
|
||||||
newEntity.getProperties().add(factory.newPrimitiveProperty("PropertyInt64",
|
newEntity.getProperties().add(factory.newPrimitiveProperty("PropertyInt64",
|
||||||
factory.newPrimitiveValueBuilder().buildInt32(42)));
|
factory.newPrimitiveValueBuilder().buildInt32(42)));
|
||||||
newEntity.addLink(factory.newEntityNavigationLink("NavPropertyETTwoPrimOne",
|
newEntity.addLink(factory.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_PRIM_ONE,
|
||||||
client.newURIBuilder(SERVICE_URI)
|
client.newURIBuilder(SERVICE_URI)
|
||||||
.appendEntitySetSegment("ESTwoPrim")
|
.appendEntitySetSegment("ESTwoPrim")
|
||||||
.appendKeySegment(32766)
|
.appendKeySegment(32766)
|
||||||
|
@ -422,7 +441,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
||||||
@Test
|
@Test
|
||||||
public void readEntityWithExpandedNavigationProperty() {
|
public void readEntityWithExpandedNavigationProperty() {
|
||||||
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||||
client.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
|
|
||||||
final URI uri = client.newURIBuilder(SERVICE_URI)
|
final URI uri = client.newURIBuilder(SERVICE_URI)
|
||||||
.appendEntitySetSegment("ESKeyNav")
|
.appendEntitySetSegment("ESKeyNav")
|
||||||
|
@ -927,11 +946,356 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
||||||
.get("PropertyInt16")
|
.get("PropertyInt16")
|
||||||
.hasNullValue());
|
.hasNullValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createEntityWithIEEE754CompatibleParameter() {
|
||||||
|
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||||
|
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
|
final ClientObjectFactory of = client.getObjectFactory();
|
||||||
|
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_ALL_PRIM).build();
|
||||||
|
final URI linkURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_PRIM)
|
||||||
|
.appendKeySegment(32767).build();
|
||||||
|
|
||||||
|
final ClientEntity newEntity = of.newEntity(ET_ALL_PRIM);
|
||||||
|
newEntity.getProperties().add(of.newPrimitiveProperty(PROPERTY_INT64,
|
||||||
|
of.newPrimitiveValueBuilder().buildInt64(Long.MAX_VALUE)));
|
||||||
|
newEntity.getProperties().add(of.newPrimitiveProperty(PROPERTY_DECIMAL,
|
||||||
|
of.newPrimitiveValueBuilder().buildDecimal(BigDecimal.valueOf(34))));
|
||||||
|
newEntity.addLink(of.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_PRIM_ONE, linkURI));
|
||||||
|
|
||||||
|
final ODataEntityCreateRequest<ClientEntity> request = client.getCUDRequestFactory()
|
||||||
|
.getEntityCreateRequest(uri, newEntity);
|
||||||
|
request.setContentType(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
request.setAccept(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
final ODataEntityCreateResponse<ClientEntity> response = request.execute();
|
||||||
|
|
||||||
|
assertEquals(Long.MAX_VALUE, response.getBody().getProperty(PROPERTY_INT64).getPrimitiveValue().toValue());
|
||||||
|
assertEquals(BigDecimal.valueOf(34), response.getBody().getProperty(PROPERTY_DECIMAL)
|
||||||
|
.getPrimitiveValue().toValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createEntityWithIEEE754CompatibleParameterNull() {
|
||||||
|
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||||
|
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
|
final ClientObjectFactory of = client.getObjectFactory();
|
||||||
|
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_ALL_PRIM).build();
|
||||||
|
final URI linkURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_PRIM)
|
||||||
|
.appendKeySegment(32767).build();
|
||||||
|
|
||||||
|
final ClientEntity newEntity = of.newEntity(ET_ALL_PRIM);
|
||||||
|
newEntity.getProperties().add(of.newPrimitiveProperty(PROPERTY_INT64,
|
||||||
|
of.newPrimitiveValueBuilder().buildInt64(null)));
|
||||||
|
newEntity.getProperties().add(of.newPrimitiveProperty(PROPERTY_DECIMAL,
|
||||||
|
of.newPrimitiveValueBuilder().buildDecimal(null)));
|
||||||
|
newEntity.addLink(of.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_PRIM_ONE, linkURI));
|
||||||
|
|
||||||
|
final ODataEntityCreateRequest<ClientEntity> request = client.getCUDRequestFactory()
|
||||||
|
.getEntityCreateRequest(uri, newEntity);
|
||||||
|
request.setContentType(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
request.setAccept(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
final ODataEntityCreateResponse<ClientEntity> response = request.execute();
|
||||||
|
|
||||||
|
assertTrue(response.getBody().getProperty(PROPERTY_INT64).hasNullValue());
|
||||||
|
assertTrue(response.getBody().getProperty(PROPERTY_DECIMAL).hasNullValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateEntityWithIEEE754CompatibleParameter() {
|
||||||
|
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||||
|
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
|
final ClientObjectFactory of = client.getObjectFactory();
|
||||||
|
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_ALL_PRIM).appendKeySegment(0).build();
|
||||||
|
|
||||||
|
final ClientEntity entity = of.newEntity(ET_ALL_PRIM);
|
||||||
|
entity.getProperties().add(of.newPrimitiveProperty(PROPERTY_INT64,
|
||||||
|
of.newPrimitiveValueBuilder().buildInt64(Long.MAX_VALUE)));
|
||||||
|
entity.getProperties().add(of.newPrimitiveProperty(PROPERTY_DECIMAL,
|
||||||
|
of.newPrimitiveValueBuilder().buildDecimal(BigDecimal.valueOf(Long.MAX_VALUE))));
|
||||||
|
|
||||||
|
final ODataEntityUpdateRequest<ClientEntity> requestUpdate = client.getCUDRequestFactory()
|
||||||
|
.getEntityUpdateRequest(uri, UpdateType.PATCH, entity);
|
||||||
|
requestUpdate.setContentType(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
requestUpdate.setAccept(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
final ODataEntityUpdateResponse<ClientEntity> responseUpdate = requestUpdate.execute();
|
||||||
|
|
||||||
|
String cookie = responseUpdate.getHeader(HttpHeader.SET_COOKIE).iterator().next();
|
||||||
|
|
||||||
|
final ODataEntityRequest<ClientEntity> requestGet = client.getRetrieveRequestFactory().getEntityRequest(uri);
|
||||||
|
requestGet.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||||
|
requestGet.setAccept(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
final ODataRetrieveResponse<ClientEntity> responseGet = requestGet.execute();
|
||||||
|
|
||||||
|
assertEquals(Long.MAX_VALUE, responseGet.getBody().getProperty(PROPERTY_INT64).getPrimitiveValue().toValue());
|
||||||
|
assertEquals(BigDecimal.valueOf(Long.MAX_VALUE), responseGet.getBody().getProperty(PROPERTY_DECIMAL)
|
||||||
|
.getPrimitiveValue()
|
||||||
|
.toValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateEntityWithIEEE754CompatibleParameterNull() {
|
||||||
|
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||||
|
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
|
final ClientObjectFactory of = client.getObjectFactory();
|
||||||
|
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_ALL_PRIM).appendKeySegment(0).build();
|
||||||
|
|
||||||
|
final ClientEntity entity = of.newEntity(ET_ALL_PRIM);
|
||||||
|
entity.getProperties().add(of.newPrimitiveProperty(PROPERTY_INT64,
|
||||||
|
of.newPrimitiveValueBuilder().buildInt64(null)));
|
||||||
|
entity.getProperties().add(of.newPrimitiveProperty(PROPERTY_DECIMAL,
|
||||||
|
of.newPrimitiveValueBuilder().buildDecimal(null)));
|
||||||
|
|
||||||
|
final ODataEntityUpdateRequest<ClientEntity> requestUpdate = client.getCUDRequestFactory()
|
||||||
|
.getEntityUpdateRequest(uri, UpdateType.PATCH, entity);
|
||||||
|
requestUpdate.setContentType(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
requestUpdate.setAccept(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
final ODataEntityUpdateResponse<ClientEntity> responseUpdate = requestUpdate.execute();
|
||||||
|
|
||||||
|
String cookie = responseUpdate.getHeader(HttpHeader.SET_COOKIE).iterator().next();
|
||||||
|
|
||||||
|
final ODataEntityRequest<ClientEntity> requestGet = client.getRetrieveRequestFactory().getEntityRequest(uri);
|
||||||
|
requestGet.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||||
|
requestGet.setAccept(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
final ODataRetrieveResponse<ClientEntity> responseGet = requestGet.execute();
|
||||||
|
|
||||||
|
assertTrue(responseGet.getBody().getProperty(PROPERTY_INT64).hasNullValue());
|
||||||
|
assertTrue(responseGet.getBody().getProperty(PROPERTY_DECIMAL).hasNullValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateEntityWithIEEE754CompatibleParameterWithNullString() {
|
||||||
|
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||||
|
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
|
final ClientObjectFactory of = client.getObjectFactory();
|
||||||
|
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_ALL_PRIM).appendKeySegment(0).build();
|
||||||
|
|
||||||
|
final ClientEntity entity = of.newEntity(ET_ALL_PRIM);
|
||||||
|
entity.getProperties().add(of.newPrimitiveProperty(PROPERTY_INT64,
|
||||||
|
of.newPrimitiveValueBuilder().buildString("null")));
|
||||||
|
entity.getProperties().add(of.newPrimitiveProperty(PROPERTY_DECIMAL,
|
||||||
|
of.newPrimitiveValueBuilder().buildString("null")));
|
||||||
|
|
||||||
|
final ODataEntityUpdateRequest<ClientEntity> requestUpdate = client.getCUDRequestFactory()
|
||||||
|
.getEntityUpdateRequest(uri, UpdateType.PATCH, entity);
|
||||||
|
requestUpdate.setContentType(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
requestUpdate.setAccept(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
|
||||||
|
try {
|
||||||
|
requestUpdate.execute();
|
||||||
|
fail();
|
||||||
|
} catch(ODataClientErrorException e) {
|
||||||
|
assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), e.getStatusLine().getStatusCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateEdmInt64PropertyWithIEE754CompatibleParameter() {
|
||||||
|
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||||
|
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
|
final ClientObjectFactory of = client.getObjectFactory();
|
||||||
|
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_ALL_PRIM)
|
||||||
|
.appendKeySegment(0)
|
||||||
|
.appendPropertySegment(PROPERTY_INT64).build();
|
||||||
|
|
||||||
|
final ODataPropertyUpdateRequest requestUpdate = client.getCUDRequestFactory()
|
||||||
|
.getPropertyPrimitiveValueUpdateRequest(uri,
|
||||||
|
of.newPrimitiveProperty(PROPERTY_INT64,
|
||||||
|
of.newPrimitiveValueBuilder().buildInt64(Long.MAX_VALUE)));
|
||||||
|
|
||||||
|
requestUpdate.setContentType(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
requestUpdate.setAccept(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
final ODataPropertyUpdateResponse responseUpdate = requestUpdate.execute();
|
||||||
|
String cookie = responseUpdate.getHeader(HttpHeader.SET_COOKIE).iterator().next();
|
||||||
|
|
||||||
|
final ODataPropertyRequest<ClientProperty> requestGet = client.getRetrieveRequestFactory().getPropertyRequest(uri);
|
||||||
|
requestGet.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||||
|
requestGet.setAccept(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
final ODataRetrieveResponse<ClientProperty> responseGet = requestGet.execute();
|
||||||
|
|
||||||
|
assertEquals(Long.MAX_VALUE, responseGet.getBody().getPrimitiveValue().toValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateComplexPropertyWithIEEE754CompatibleParamter() {
|
||||||
|
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||||
|
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
|
final ClientObjectFactory of = client.getObjectFactory();
|
||||||
|
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
|
||||||
|
.appendKeySegment(1)
|
||||||
|
.appendPropertySegment(PROPERTY_COMP_ALL_PRIM).build();
|
||||||
|
|
||||||
|
final ODataPropertyUpdateRequest requestUpdate = client.getCUDRequestFactory()
|
||||||
|
.getPropertyComplexValueUpdateRequest(uri, UpdateType.PATCH,
|
||||||
|
of.newComplexProperty(PROPERTY_COMP_ALL_PRIM,
|
||||||
|
of.newComplexValue("CTAllPrim")
|
||||||
|
.add(of.newPrimitiveProperty(PROPERTY_INT64,
|
||||||
|
of.newPrimitiveValueBuilder().buildInt64(Long.MIN_VALUE)))
|
||||||
|
.add(of.newPrimitiveProperty(PROPERTY_DECIMAL,
|
||||||
|
of.newPrimitiveValueBuilder().buildDecimal(BigDecimal.valueOf(12345678912L))))
|
||||||
|
.add(of.newPrimitiveProperty(PROPERTY_INT16,
|
||||||
|
of.newPrimitiveValueBuilder().buildInt16((short) 2)))));
|
||||||
|
|
||||||
|
requestUpdate.setContentType(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
requestUpdate.setAccept(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
final ODataPropertyUpdateResponse responseUpdate = requestUpdate.execute();
|
||||||
|
String cookie = responseUpdate.getHeader(HttpHeader.SET_COOKIE).iterator().next();
|
||||||
|
|
||||||
|
final ODataPropertyRequest<ClientProperty> requestGet = client.getRetrieveRequestFactory().getPropertyRequest(uri);
|
||||||
|
requestGet.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||||
|
requestGet.setAccept(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
final ODataRetrieveResponse<ClientProperty> responseGet = requestGet.execute();
|
||||||
|
|
||||||
|
final ClientComplexValue complexValue = responseGet.getBody().getComplexValue();
|
||||||
|
|
||||||
|
assertEquals(Long.MIN_VALUE, complexValue.get(PROPERTY_INT64).getPrimitiveValue().toValue());
|
||||||
|
assertEquals(BigDecimal.valueOf(12345678912L), complexValue.get(PROPERTY_DECIMAL).getPrimitiveValue().toValue());
|
||||||
|
assertEquals(2, complexValue.get(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateProperyEdmDecimaltWithIEE754CompatibleParameter() {
|
||||||
|
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||||
|
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
|
final ClientObjectFactory of = client.getObjectFactory();
|
||||||
|
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_ALL_PRIM)
|
||||||
|
.appendKeySegment(0)
|
||||||
|
.appendPropertySegment(PROPERTY_DECIMAL).build();
|
||||||
|
|
||||||
|
final ODataPropertyUpdateRequest requestUpdate = client.getCUDRequestFactory()
|
||||||
|
.getPropertyPrimitiveValueUpdateRequest(uri,
|
||||||
|
of.newPrimitiveProperty(PROPERTY_DECIMAL,
|
||||||
|
of.newPrimitiveValueBuilder().buildInt64(Long.MAX_VALUE)));
|
||||||
|
|
||||||
|
requestUpdate.setContentType(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
requestUpdate.setAccept(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
final ODataPropertyUpdateResponse responseUpdate = requestUpdate.execute();
|
||||||
|
String cookie = responseUpdate.getHeader(HttpHeader.SET_COOKIE).iterator().next();
|
||||||
|
|
||||||
|
final ODataPropertyRequest<ClientProperty> requestGet = client.getRetrieveRequestFactory().getPropertyRequest(uri);
|
||||||
|
requestGet.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||||
|
requestGet.setAccept(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
final ODataRetrieveResponse<ClientProperty> responseGet = requestGet.execute();
|
||||||
|
|
||||||
|
assertEquals(BigDecimal.valueOf(Long.MAX_VALUE), responseGet.getBody().getPrimitiveValue().toValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void readESAllPrimCollectionWithIEEE754CompatibleParameter() {
|
||||||
|
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||||
|
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_ALL_PRIM)
|
||||||
|
.orderBy(PROPERTY_INT16)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
final ODataEntitySetRequest<ClientEntitySet> request = client.getRetrieveRequestFactory().getEntitySetRequest(uri);
|
||||||
|
request.setAccept(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
final ODataRetrieveResponse<ClientEntitySet> response = request.execute();
|
||||||
|
|
||||||
|
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
|
||||||
|
final List<ClientEntity> entities = response.getBody().getEntities();
|
||||||
|
assertEquals(3, entities.size());
|
||||||
|
|
||||||
|
ClientEntity entity = entities.get(0);
|
||||||
|
assertEquals(-32768, entity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||||
|
assertEquals(Long.MIN_VALUE, entity.getProperty(PROPERTY_INT64).getPrimitiveValue().toValue());
|
||||||
|
assertEquals(BigDecimal.valueOf(-34), entity.getProperty(PROPERTY_DECIMAL).getPrimitiveValue().toValue());
|
||||||
|
|
||||||
|
entity = entities.get(1);
|
||||||
|
assertEquals(0, entity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||||
|
assertEquals(0L, entity.getProperty(PROPERTY_INT64).getPrimitiveValue().toValue());
|
||||||
|
assertEquals(BigDecimal.valueOf(0), entity.getProperty(PROPERTY_DECIMAL).getPrimitiveValue().toValue());
|
||||||
|
|
||||||
|
entity = entities.get(2);
|
||||||
|
assertEquals(32767, entity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||||
|
assertEquals(Long.MAX_VALUE, entity.getProperty(PROPERTY_INT64).getPrimitiveValue().toValue());
|
||||||
|
assertEquals(BigDecimal.valueOf(34), entity.getProperty(PROPERTY_DECIMAL).getPrimitiveValue().toValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void readESKeyNavCheckComplexPropertyWithIEEE754CompatibleParameter() {
|
||||||
|
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||||
|
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(1).build();
|
||||||
|
|
||||||
|
final ODataEntityRequest<ClientEntity> request = client.getRetrieveRequestFactory().getEntityRequest(uri);
|
||||||
|
request.setAccept(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
final ODataRetrieveResponse<ClientEntity> response = request.execute();
|
||||||
|
|
||||||
|
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
|
||||||
|
assertEquals(1, response.getBody().getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||||
|
|
||||||
|
assertEquals(BigDecimal.valueOf(34), response.getBody().getProperty(PROPERTY_COMP_ALL_PRIM)
|
||||||
|
.getComplexValue()
|
||||||
|
.get(PROPERTY_DECIMAL)
|
||||||
|
.getPrimitiveValue()
|
||||||
|
.toValue());
|
||||||
|
|
||||||
|
assertEquals(Long.MAX_VALUE, response.getBody().getProperty(PROPERTY_COMP_ALL_PRIM)
|
||||||
|
.getComplexValue()
|
||||||
|
.get(PROPERTY_INT64)
|
||||||
|
.getPrimitiveValue()
|
||||||
|
.toValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void readESKEyNavComplexPropertyWithIEEE754CompatibleParameter() {
|
||||||
|
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||||
|
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
|
||||||
|
.appendKeySegment(1)
|
||||||
|
.appendNavigationSegment(PROPERTY_COMP_ALL_PRIM)
|
||||||
|
.build();
|
||||||
|
ODataPropertyRequest<ClientProperty> request = client.getRetrieveRequestFactory().getPropertyRequest(uri);
|
||||||
|
request.setAccept(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
final ODataRetrieveResponse<ClientProperty> response = request.execute();
|
||||||
|
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
|
||||||
|
|
||||||
|
assertEquals(BigDecimal.valueOf(34), response.getBody().getComplexValue()
|
||||||
|
.get(PROPERTY_DECIMAL)
|
||||||
|
.getPrimitiveValue()
|
||||||
|
.toValue());
|
||||||
|
|
||||||
|
assertEquals(Long.MAX_VALUE, response.getBody().getComplexValue()
|
||||||
|
.get(PROPERTY_INT64)
|
||||||
|
.getPrimitiveValue()
|
||||||
|
.toValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Ignore
|
||||||
|
public void readEdmInt64PropertyWithIEEE754ComaptibleParameter() {
|
||||||
|
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||||
|
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
|
||||||
|
.appendKeySegment(1)
|
||||||
|
.appendPropertySegment(PROPERTY_COMP_ALL_PRIM)
|
||||||
|
.appendPropertySegment(PROPERTY_INT64)
|
||||||
|
.build();
|
||||||
|
ODataPropertyRequest<ClientProperty> request = client.getRetrieveRequestFactory().getPropertyRequest(uri);
|
||||||
|
request.setAccept(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
final ODataRetrieveResponse<ClientProperty> response = request.execute();
|
||||||
|
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
|
||||||
|
|
||||||
|
assertEquals(Long.MAX_VALUE, response.getBody().getPrimitiveValue().toValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Ignore
|
||||||
|
public void readEdmDecimalPropertyWithIEEE754ComaptibleParameter() {
|
||||||
|
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||||
|
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
|
||||||
|
.appendKeySegment(1)
|
||||||
|
.appendPropertySegment(PROPERTY_COMP_ALL_PRIM)
|
||||||
|
.appendPropertySegment(PROPERTY_DECIMAL)
|
||||||
|
.build();
|
||||||
|
ODataPropertyRequest<ClientProperty> request = client.getRetrieveRequestFactory().getPropertyRequest(uri);
|
||||||
|
request.setAccept(CONTENT_TYPE_JSON_IEEE754_COMPATIBLE);
|
||||||
|
final ODataRetrieveResponse<ClientProperty> response = request.execute();
|
||||||
|
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
|
||||||
|
|
||||||
|
assertEquals(BigDecimal.valueOf(34), response.getBody().getPrimitiveValue().toValue());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ODataClient getClient() {
|
protected ODataClient getClient() {
|
||||||
ODataClient odata = ODataClientFactory.getClient();
|
ODataClient odata = ODataClientFactory.getClient();
|
||||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
return odata;
|
return odata;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,6 @@ import org.apache.olingo.client.core.communication.request.batch.ODataChangesetR
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ContentType;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
|
||||||
import org.apache.olingo.commons.api.http.HttpHeader;
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||||
|
@ -122,7 +121,7 @@ public class BatchClientITCase extends AbstractTestITCase {
|
||||||
assertTrue(changeSetResponse.isBreaking());
|
assertTrue(changeSetResponse.isBreaking());
|
||||||
|
|
||||||
assertEquals(HttpStatusCode.NOT_FOUND.getStatusCode(), updateResponse.getStatusCode());
|
assertEquals(HttpStatusCode.NOT_FOUND.getStatusCode(), updateResponse.getStatusCode());
|
||||||
assertEquals(ODataFormat.JSON.toString(), updateResponse.getContentType());
|
assertEquals(ContentType.JSON.toContentTypeString(), updateResponse.getContentType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -252,7 +251,7 @@ public class BatchClientITCase extends AbstractTestITCase {
|
||||||
final BatchManager payload = request.payloadManager();
|
final BatchManager payload = request.payloadManager();
|
||||||
final URI uri = new URI(SERVICE_URI + "/../ESAllPrim(32767)");
|
final URI uri = new URI(SERVICE_URI + "/../ESAllPrim(32767)");
|
||||||
final ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(uri);
|
final ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(uri);
|
||||||
queryReq.setFormat(ODataFormat.JSON);
|
queryReq.setFormat(ContentType.JSON);
|
||||||
payload.addRequest(queryReq);
|
payload.addRequest(queryReq);
|
||||||
|
|
||||||
// Fetch result
|
// Fetch result
|
||||||
|
@ -276,7 +275,7 @@ public class BatchClientITCase extends AbstractTestITCase {
|
||||||
final BatchManager payload = request.payloadManager();
|
final BatchManager payload = request.payloadManager();
|
||||||
final URI uri = new URI("http://otherhost/odata/ESAllPrim(32767)");
|
final URI uri = new URI("http://otherhost/odata/ESAllPrim(32767)");
|
||||||
final ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(uri);
|
final ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(uri);
|
||||||
queryReq.setFormat(ODataFormat.JSON);
|
queryReq.setFormat(ContentType.JSON);
|
||||||
payload.addRequest(queryReq);
|
payload.addRequest(queryReq);
|
||||||
|
|
||||||
// Fetch result
|
// Fetch result
|
||||||
|
@ -290,7 +289,7 @@ public class BatchClientITCase extends AbstractTestITCase {
|
||||||
final BatchManager payload = request.payloadManager();
|
final BatchManager payload = request.payloadManager();
|
||||||
final URI uri = new URI("/ESAllPrim(32767)");
|
final URI uri = new URI("/ESAllPrim(32767)");
|
||||||
final ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(uri);
|
final ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(uri);
|
||||||
queryReq.setFormat(ODataFormat.JSON);
|
queryReq.setFormat(ContentType.JSON);
|
||||||
payload.addRequest(queryReq);
|
payload.addRequest(queryReq);
|
||||||
|
|
||||||
// Fetch result
|
// Fetch result
|
||||||
|
@ -379,7 +378,7 @@ public class BatchClientITCase extends AbstractTestITCase {
|
||||||
// add create request
|
// add create request
|
||||||
final ODataEntityCreateRequest<ClientEntity> createReq =
|
final ODataEntityCreateRequest<ClientEntity> createReq =
|
||||||
client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), entityESAllPrim);
|
client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), entityESAllPrim);
|
||||||
createReq.setFormat(ODataFormat.JSON);
|
createReq.setFormat(ContentType.JSON);
|
||||||
changeset.addRequest(createReq);
|
changeset.addRequest(createReq);
|
||||||
|
|
||||||
// retrieve request reference
|
// retrieve request reference
|
||||||
|
@ -393,7 +392,7 @@ public class BatchClientITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
final ODataEntityUpdateRequest<ClientEntity> updateReq = client.getCUDRequestFactory().getEntityUpdateRequest(
|
final ODataEntityUpdateRequest<ClientEntity> updateReq = client.getCUDRequestFactory().getEntityUpdateRequest(
|
||||||
URI.create("$" + createRequestRef), UpdateType.PATCH, entityUpdate);
|
URI.create("$" + createRequestRef), UpdateType.PATCH, entityUpdate);
|
||||||
updateReq.setFormat(ODataFormat.JSON);
|
updateReq.setFormat(ContentType.JSON);
|
||||||
|
|
||||||
changeset.addRequest(updateReq);
|
changeset.addRequest(updateReq);
|
||||||
|
|
||||||
|
@ -419,7 +418,7 @@ public class BatchClientITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
final ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest(
|
final ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest(
|
||||||
new URI(createResponse.getHeader(HttpHeader.LOCATION).iterator().next() + "/NavPropertyETTwoPrimMany"));
|
new URI(createResponse.getHeader(HttpHeader.LOCATION).iterator().next() + "/NavPropertyETTwoPrimMany"));
|
||||||
req.setFormat(ODataFormat.JSON);
|
req.setFormat(ContentType.JSON);
|
||||||
req.addCustomHeader(HttpHeader.COOKIE, cookie);
|
req.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||||
final ODataRetrieveResponse<ClientEntitySet> getResponse = req.execute();
|
final ODataRetrieveResponse<ClientEntitySet> getResponse = req.execute();
|
||||||
|
|
||||||
|
@ -466,7 +465,7 @@ public class BatchClientITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
final ODataEntityCreateRequest<ClientEntity> createRequest =
|
final ODataEntityCreateRequest<ClientEntity> createRequest =
|
||||||
client.getCUDRequestFactory().getEntityCreateRequest(editLink, postEntity);
|
client.getCUDRequestFactory().getEntityCreateRequest(editLink, postEntity);
|
||||||
createRequest.setFormat(ODataFormat.JSON);
|
createRequest.setFormat(ContentType.JSON);
|
||||||
|
|
||||||
changeset.addRequest(createRequest);
|
changeset.addRequest(createRequest);
|
||||||
|
|
||||||
|
@ -485,7 +484,7 @@ public class BatchClientITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
ODataEntityUpdateRequest<ClientEntity> changeReq =
|
ODataEntityUpdateRequest<ClientEntity> changeReq =
|
||||||
client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patchEntity);
|
client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patchEntity);
|
||||||
changeReq.setFormat(ODataFormat.JSON);
|
changeReq.setFormat(ContentType.JSON);
|
||||||
changeset.addRequest(changeReq);
|
changeset.addRequest(changeReq);
|
||||||
|
|
||||||
// ------------------------
|
// ------------------------
|
||||||
|
@ -506,7 +505,7 @@ public class BatchClientITCase extends AbstractTestITCase {
|
||||||
.build()));
|
.build()));
|
||||||
|
|
||||||
changeReq = client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patchEntity);
|
changeReq = client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patchEntity);
|
||||||
changeReq.setFormat(ODataFormat.JSON);
|
changeReq.setFormat(ContentType.JSON);
|
||||||
changeset.addRequest(changeReq);
|
changeset.addRequest(changeReq);
|
||||||
|
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
|
@ -586,7 +585,7 @@ public class BatchClientITCase extends AbstractTestITCase {
|
||||||
final URI uri = (isRelative) ? new URI(SERVICE_URI).relativize(targetURI.build()) : targetURI.build();
|
final URI uri = (isRelative) ? new URI(SERVICE_URI).relativize(targetURI.build()) : targetURI.build();
|
||||||
|
|
||||||
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(uri);
|
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(uri);
|
||||||
queryReq.setFormat(ODataFormat.JSON);
|
queryReq.setFormat(ContentType.JSON);
|
||||||
manager.addRequest(queryReq);
|
manager.addRequest(queryReq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ import org.apache.olingo.client.api.domain.ClientValue;
|
||||||
import org.apache.olingo.client.core.ODataClientFactory;
|
import org.apache.olingo.client.core.ODataClientFactory;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpHeader;
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||||
|
@ -324,7 +324,7 @@ public class BindingITCase extends AbstractBaseTestITCase {
|
||||||
@Test
|
@Test
|
||||||
public void testDeepInsertWithBindingSameNavigationProperty() {
|
public void testDeepInsertWithBindingSameNavigationProperty() {
|
||||||
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||||
client.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
final ClientObjectFactory of = client.getObjectFactory();
|
final ClientObjectFactory of = client.getObjectFactory();
|
||||||
|
|
||||||
final ClientEntity entity = of.newEntity(ET_KEY_NAV);
|
final ClientEntity entity = of.newEntity(ET_KEY_NAV);
|
||||||
|
@ -392,7 +392,7 @@ public class BindingITCase extends AbstractBaseTestITCase {
|
||||||
@Override
|
@Override
|
||||||
protected ODataClient getClient() {
|
protected ODataClient getClient() {
|
||||||
ODataClient odata = ODataClientFactory.getClient();
|
ODataClient odata = ODataClientFactory.getClient();
|
||||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
return odata;
|
return odata;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ import org.apache.olingo.client.api.domain.ClientServiceDocument;
|
||||||
import org.apache.olingo.client.api.http.HttpClientException;
|
import org.apache.olingo.client.api.http.HttpClientException;
|
||||||
import org.apache.olingo.client.core.ODataClientFactory;
|
import org.apache.olingo.client.core.ODataClientFactory;
|
||||||
import org.apache.olingo.commons.api.edm.Edm;
|
import org.apache.olingo.commons.api.edm.Edm;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpHeader;
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||||
|
@ -281,7 +281,7 @@ public final class ConditionalITCase extends AbstractBaseTestITCase {
|
||||||
@Override
|
@Override
|
||||||
protected ODataClient getClient() {
|
protected ODataClient getClient() {
|
||||||
ODataClient odata = ODataClientFactory.getClient();
|
ODataClient odata = ODataClientFactory.getClient();
|
||||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
return odata;
|
return odata;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ import org.apache.olingo.client.api.domain.ClientValue;
|
||||||
import org.apache.olingo.client.core.ODataClientFactory;
|
import org.apache.olingo.client.core.ODataClientFactory;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpHeader;
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||||
|
@ -91,7 +91,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
|
||||||
@Test
|
@Test
|
||||||
public void testDeepInsertExpandedResponse() {
|
public void testDeepInsertExpandedResponse() {
|
||||||
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||||
client.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
final URI createURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
|
final URI createURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
|
||||||
final ClientObjectFactory of = client.getObjectFactory();
|
final ClientObjectFactory of = client.getObjectFactory();
|
||||||
final ClientEntity entity = of.newEntity(ET_KEY_NAV);
|
final ClientEntity entity = of.newEntity(ET_KEY_NAV);
|
||||||
|
@ -900,7 +900,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
|
||||||
@Override
|
@Override
|
||||||
protected ODataClient getClient() {
|
protected ODataClient getClient() {
|
||||||
ODataClient odata = ODataClientFactory.getClient();
|
ODataClient odata = ODataClientFactory.getClient();
|
||||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
return odata;
|
return odata;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
||||||
import org.apache.olingo.client.api.uri.QueryOption;
|
import org.apache.olingo.client.api.uri.QueryOption;
|
||||||
import org.apache.olingo.client.core.ODataClientFactory;
|
import org.apache.olingo.client.core.ODataClientFactory;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpHeader;
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||||
|
@ -1002,7 +1002,7 @@ public class EntityReferencesITCase extends AbstractBaseTestITCase {
|
||||||
@Override
|
@Override
|
||||||
protected ODataClient getClient() {
|
protected ODataClient getClient() {
|
||||||
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||||
client.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
||||||
import org.apache.olingo.client.api.uri.QueryOption;
|
import org.apache.olingo.client.api.uri.QueryOption;
|
||||||
import org.apache.olingo.client.core.ODataClientFactory;
|
import org.apache.olingo.client.core.ODataClientFactory;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpHeader;
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||||
|
@ -471,7 +471,7 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
|
||||||
@Override
|
@Override
|
||||||
protected ODataClient getClient() {
|
protected ODataClient getClient() {
|
||||||
EdmEnabledODataClient odata = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
EdmEnabledODataClient odata = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
return odata;
|
return odata;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.apache.olingo.client.api.domain.ClientEntitySet;
|
||||||
import org.apache.olingo.client.api.domain.ClientObjectFactory;
|
import org.apache.olingo.client.api.domain.ClientObjectFactory;
|
||||||
import org.apache.olingo.client.core.ODataClientFactory;
|
import org.apache.olingo.client.core.ODataClientFactory;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpHeader;
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||||
|
@ -1008,7 +1008,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
||||||
@Override
|
@Override
|
||||||
protected ODataClient getClient() {
|
protected ODataClient getClient() {
|
||||||
ODataClient odata = ODataClientFactory.getClient();
|
ODataClient odata = ODataClientFactory.getClient();
|
||||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
return odata;
|
return odata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ import org.apache.olingo.client.api.domain.ClientPrimitiveValue;
|
||||||
import org.apache.olingo.client.api.domain.ClientProperty;
|
import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
import org.apache.olingo.client.api.domain.ClientValue;
|
import org.apache.olingo.client.api.domain.ClientValue;
|
||||||
import org.apache.olingo.client.core.ODataClientFactory;
|
import org.apache.olingo.client.core.ODataClientFactory;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||||
|
@ -223,7 +223,7 @@ public class FunctionImportITCase extends AbstractBaseTestITCase {
|
||||||
@Override
|
@Override
|
||||||
protected ODataClient getClient() {
|
protected ODataClient getClient() {
|
||||||
ODataClient odata = ODataClientFactory.getClient();
|
ODataClient odata = ODataClientFactory.getClient();
|
||||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
return odata;
|
return odata;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,6 @@ import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
import org.apache.olingo.client.api.domain.ClientProperty;
|
import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
import org.apache.olingo.client.core.ODataClientFactory;
|
import org.apache.olingo.client.core.ODataClientFactory;
|
||||||
import org.apache.olingo.commons.api.format.ContentType;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
|
||||||
import org.apache.olingo.commons.api.http.HttpHeader;
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||||
|
@ -156,7 +155,7 @@ public final class MediaITCase extends AbstractBaseTestITCase {
|
||||||
@Override
|
@Override
|
||||||
protected ODataClient getClient() {
|
protected ODataClient getClient() {
|
||||||
ODataClient odata = ODataClientFactory.getClient();
|
ODataClient odata = ODataClientFactory.getClient();
|
||||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
return odata;
|
return odata;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
||||||
import org.apache.olingo.client.api.domain.ClientProperty;
|
import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
import org.apache.olingo.client.core.ODataClientFactory;
|
import org.apache.olingo.client.core.ODataClientFactory;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||||
|
@ -135,7 +135,7 @@ public final class NavigationITCase extends AbstractBaseTestITCase {
|
||||||
@Override
|
@Override
|
||||||
protected ODataClient getClient() {
|
protected ODataClient getClient() {
|
||||||
ODataClient odata = ODataClientFactory.getClient();
|
ODataClient odata = ODataClientFactory.getClient();
|
||||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
return odata;
|
return odata;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
||||||
import org.apache.olingo.client.api.domain.ClientValuable;
|
import org.apache.olingo.client.api.domain.ClientValuable;
|
||||||
import org.apache.olingo.client.core.ODataClientFactory;
|
import org.apache.olingo.client.core.ODataClientFactory;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||||
|
@ -164,7 +164,7 @@ public class OrderBySystemQueryITCase extends AbstractBaseTestITCase {
|
||||||
@Override
|
@Override
|
||||||
protected ODataClient getClient() {
|
protected ODataClient getClient() {
|
||||||
ODataClient odata = ODataClientFactory.getClient();
|
ODataClient odata = ODataClientFactory.getClient();
|
||||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
return odata;
|
return odata;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,6 @@ import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
import org.apache.olingo.client.api.domain.ClientValue;
|
import org.apache.olingo.client.api.domain.ClientValue;
|
||||||
import org.apache.olingo.client.core.ODataClientFactory;
|
import org.apache.olingo.client.core.ODataClientFactory;
|
||||||
import org.apache.olingo.commons.api.format.ContentType;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
|
||||||
import org.apache.olingo.commons.api.http.HttpHeader;
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||||
|
@ -421,7 +420,7 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
|
||||||
@Override
|
@Override
|
||||||
protected ODataClient getClient() {
|
protected ODataClient getClient() {
|
||||||
ODataClient odata = ODataClientFactory.getClient();
|
ODataClient odata = ODataClientFactory.getClient();
|
||||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
return odata;
|
return odata;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse
|
||||||
import org.apache.olingo.client.api.domain.ClientEntity;
|
import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
||||||
import org.apache.olingo.client.core.ODataClientFactory;
|
import org.apache.olingo.client.core.ODataClientFactory;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||||
|
@ -311,7 +311,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
|
||||||
@Override
|
@Override
|
||||||
protected ODataClient getClient() {
|
protected ODataClient getClient() {
|
||||||
ODataClient odata = ODataClientFactory.getClient();
|
ODataClient odata = ODataClientFactory.getClient();
|
||||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
odata.getConfiguration().setDefaultPubFormat(ContentType .JSON);
|
||||||
return odata;
|
return odata;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,15 +19,20 @@
|
||||||
package org.apache.olingo.fit.tecsvc.http;
|
package org.apache.olingo.fit.tecsvc.http;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.commons.api.format.ContentType;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpHeader;
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||||
|
import org.apache.olingo.server.core.deserializer.batch.BufferedReaderIncludingLineEndings;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class BasicHttpITCase extends AbstractBaseTestITCase {
|
public class BasicHttpITCase extends AbstractBaseTestITCase {
|
||||||
|
@ -116,7 +121,54 @@ public class BasicHttpITCase extends AbstractBaseTestITCase {
|
||||||
String v = connection.getHeaderField(HttpHeader.ODATA_VERSION);
|
String v = connection.getHeaderField(HttpHeader.ODATA_VERSION);
|
||||||
assertEquals("4.0", v);
|
assertEquals("4.0", v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIEEE754ParameterContentNegotiation() throws Exception {
|
||||||
|
final URL url = new URL(SERVICE_URI + "/ESAllPrim(32767)?$format=application/json;IEEE754Compatible=true");
|
||||||
|
final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
|
connection.setRequestMethod("GET");
|
||||||
|
connection.setRequestProperty(HttpHeader.ACCEPT, "application/json;IEEE754Compatible=false");
|
||||||
|
connection.connect();
|
||||||
|
|
||||||
|
assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
|
||||||
|
assertEquals(ContentType.create("application/json;IEEE754Compatible=true;odata.metadata=minimal"),
|
||||||
|
ContentType.create(connection.getContentType()));
|
||||||
|
final String content = inputStreamToString(connection.getInputStream());
|
||||||
|
|
||||||
|
assertTrue(content.contains("\"PropertyDecimal\":\"34\""));
|
||||||
|
assertTrue(content.contains("\"PropertyInt64\":\"9223372036854775807\""));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIEEE754ParameterViaAcceptHeader() throws Exception {
|
||||||
|
final URL url = new URL(SERVICE_URI + "/ESAllPrim(32767)");
|
||||||
|
final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
|
connection.setRequestMethod("GET");
|
||||||
|
connection.setRequestProperty(HttpHeader.ACCEPT, "application/json;IEEE754Compatible=true");
|
||||||
|
connection.connect();
|
||||||
|
|
||||||
|
assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
|
||||||
|
assertEquals(ContentType.create("application/json;IEEE754Compatible=true;odata.metadata=minimal"),
|
||||||
|
ContentType.create(connection.getContentType()));
|
||||||
|
final String content = inputStreamToString(connection.getInputStream());
|
||||||
|
|
||||||
|
assertTrue(content.contains("\"PropertyDecimal\":\"34\""));
|
||||||
|
assertTrue(content.contains("\"PropertyInt64\":\"9223372036854775807\""));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String inputStreamToString(final InputStream in) throws Exception {
|
||||||
|
final BufferedReaderIncludingLineEndings reader = new BufferedReaderIncludingLineEndings(new InputStreamReader(in));
|
||||||
|
final StringBuffer buffer = new StringBuffer();
|
||||||
|
String current;
|
||||||
|
|
||||||
|
while((current = reader.readLine()) != null) {
|
||||||
|
buffer.append(current);
|
||||||
|
}
|
||||||
|
|
||||||
|
reader.close();
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ODataClient getClient() {
|
protected ODataClient getClient() {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -46,7 +46,6 @@ import org.apache.olingo.client.core.ODataClientFactory;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ContentType;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
|
||||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
|
@ -97,23 +96,23 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ClientEntity read(final ODataFormat format, final URI editLink) {
|
protected ClientEntity read(final ContentType contentType, final URI editLink) {
|
||||||
final ODataEntityRequest<ClientEntity> req = getClient().getRetrieveRequestFactory().getEntityRequest(editLink);
|
final ODataEntityRequest<ClientEntity> req = getClient().getRetrieveRequestFactory().getEntityRequest(editLink);
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
||||||
final ClientEntity entity = res.getBody();
|
final ClientEntity entity = res.getBody();
|
||||||
|
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
|
|
||||||
if (ODataFormat.JSON_FULL_METADATA == format || ODataFormat.ATOM == format) {
|
if (ContentType.JSON_FULL_METADATA == contentType || ContentType.APPLICATION_ATOM_XML == contentType) {
|
||||||
assertEquals(req.getURI(), entity.getEditLink());
|
assertEquals(req.getURI(), entity.getEditLink());
|
||||||
}
|
}
|
||||||
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createAndDeleteOrder(final String serviceRoot, final ODataFormat format, final int id) {
|
protected void createAndDeleteOrder(final String serviceRoot, final ContentType contentType, final int id) {
|
||||||
|
|
||||||
final ClientEntity order = getClient().getObjectFactory().newEntity(
|
final ClientEntity order = getClient().getObjectFactory().newEntity(
|
||||||
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order"));
|
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order"));
|
||||||
|
@ -147,19 +146,19 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
|
||||||
final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest(
|
final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest(
|
||||||
getClient().newURIBuilder(serviceRoot).
|
getClient().newURIBuilder(serviceRoot).
|
||||||
appendEntitySetSegment("Orders").build(), order);
|
appendEntitySetSegment("Orders").build(), order);
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
final ClientEntity created = req.execute().getBody();
|
final ClientEntity created = req.execute().getBody();
|
||||||
assertNotNull(created);
|
assertNotNull(created);
|
||||||
assertEquals(2, created.getProperty("OrderShelfLifes").getCollectionValue().size());
|
assertEquals(2, created.getProperty("OrderShelfLifes").getCollectionValue().size());
|
||||||
|
|
||||||
if (format == ODataFormat.JSON_NO_METADATA) {
|
if (contentType.equals(ContentType.JSON_NO_METADATA)) {
|
||||||
assertEquals(0, created.getNavigationLinks().size());
|
assertEquals(0, created.getNavigationLinks().size());
|
||||||
assertNull(created.getEditLink());
|
assertNull(created.getEditLink());
|
||||||
} else if (format == ODataFormat.JSON_FULL_METADATA) {
|
} else if (contentType.equals(ContentType.JSON_FULL_METADATA)) {
|
||||||
assertEquals(3, created.getNavigationLinks().size());
|
assertEquals(3, created.getNavigationLinks().size());
|
||||||
assertThat(created.getTypeName().getNamespace(), is("Microsoft.Test.OData.Services.ODataWCFService"));
|
assertThat(created.getTypeName().getNamespace(), is("Microsoft.Test.OData.Services.ODataWCFService"));
|
||||||
assertThat(created.getEditLink().toASCIIString(), startsWith("http://localhost:9080/stub/StaticService"));
|
assertThat(created.getEditLink().toASCIIString(), startsWith("http://localhost:9080/stub/StaticService"));
|
||||||
} else if (format == ODataFormat.JSON || format == ODataFormat.APPLICATION_JSON) {
|
} else if (contentType.equals(ContentType.JSON) || contentType.equals(ContentType.APPLICATION_JSON)) {
|
||||||
assertEquals(0, created.getNavigationLinks().size());
|
assertEquals(0, created.getNavigationLinks().size());
|
||||||
assertNull(created.getEditLink());
|
assertNull(created.getEditLink());
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ import org.apache.olingo.client.api.domain.ClientInlineEntity;
|
||||||
import org.apache.olingo.client.api.domain.ClientLink;
|
import org.apache.olingo.client.api.domain.ClientLink;
|
||||||
import org.apache.olingo.client.api.domain.ClientProperty;
|
import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
import org.apache.olingo.client.api.uri.URIBuilder;
|
import org.apache.olingo.client.api.uri.URIBuilder;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class AsyncTestITCase extends AbstractTestITCase {
|
public class AsyncTestITCase extends AbstractTestITCase {
|
||||||
|
@ -62,13 +62,13 @@ public class AsyncTestITCase extends AbstractTestITCase {
|
||||||
assertFalse(res.getBody().getEntities().isEmpty());
|
assertFalse(res.getBody().getEntities().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void withInlineEntry(final ODataFormat format) {
|
private void withInlineEntry(final ContentType contentType) {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");
|
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");
|
||||||
|
|
||||||
final ODataEntityRequest<ClientEntity> req =
|
final ODataEntityRequest<ClientEntity> req =
|
||||||
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
final AsyncRequestWrapper<ODataRetrieveResponse<ClientEntity>> async =
|
final AsyncRequestWrapper<ODataRetrieveResponse<ClientEntity>> async =
|
||||||
client.getAsyncRequestFactory().<ODataRetrieveResponse<ClientEntity>> getAsyncRequestWrapper(req);
|
client.getAsyncRequestFactory().<ODataRetrieveResponse<ClientEntity>> getAsyncRequestWrapper(req);
|
||||||
|
@ -86,7 +86,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
assertEquals(3, entity.getNavigationLinks().size());
|
assertEquals(3, entity.getNavigationLinks().size());
|
||||||
|
|
||||||
if (ODataFormat.ATOM == format) {
|
if (ContentType.APPLICATION_ATOM_XML.equals(contentType)) {
|
||||||
assertTrue(entity.getAssociationLinks().isEmpty());
|
assertTrue(entity.getAssociationLinks().isEmpty());
|
||||||
// In JSON, association links for each $ref link will exist.
|
// In JSON, association links for each $ref link will exist.
|
||||||
}
|
}
|
||||||
|
@ -121,22 +121,22 @@ public class AsyncTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void withInlineEntryAsAtom() {
|
public void withInlineEntryAsAtom() {
|
||||||
withInlineEntry(ODataFormat.ATOM);
|
withInlineEntry(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void withInlineEntryAsJSON() {
|
public void withInlineEntryAsJSON() {
|
||||||
// this needs to be full, otherwise there is no mean to recognize links
|
// this needs to be full, otherwise there is no mean to recognize links
|
||||||
withInlineEntry(ODataFormat.JSON_FULL_METADATA);
|
withInlineEntry(ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void asyncOrders(final ODataFormat format) {
|
private void asyncOrders(final ContentType contentType) {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("async").appendEntitySetSegment("Orders");
|
appendEntitySetSegment("async").appendEntitySetSegment("Orders");
|
||||||
|
|
||||||
final ODataEntitySetRequest<ClientEntitySet> req =
|
final ODataEntitySetRequest<ClientEntitySet> req =
|
||||||
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
|
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
final AsyncRequestWrapper<ODataRetrieveResponse<ClientEntitySet>> async =
|
final AsyncRequestWrapper<ODataRetrieveResponse<ClientEntitySet>> async =
|
||||||
client.getAsyncRequestFactory().<ODataRetrieveResponse<ClientEntitySet>> getAsyncRequestWrapper(req);
|
client.getAsyncRequestFactory().<ODataRetrieveResponse<ClientEntitySet>> getAsyncRequestWrapper(req);
|
||||||
|
@ -155,11 +155,11 @@ public class AsyncTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void asyncOrdersAsAtom() {
|
public void asyncOrdersAsAtom() {
|
||||||
asyncOrders(ODataFormat.ATOM);
|
asyncOrders(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void asyncOrdersAsJSON() {
|
public void asyncOrdersAsJSON() {
|
||||||
asyncOrders(ODataFormat.JSON);
|
asyncOrders(ContentType.JSON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@ import org.apache.olingo.client.core.http.BasicAuthHttpClientFactory;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ContentType;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class AuthBatchTestITCase extends AbstractTestITCase {
|
public class AuthBatchTestITCase extends AbstractTestITCase {
|
||||||
|
@ -84,7 +83,7 @@ public class AuthBatchTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
// create new request
|
// create new request
|
||||||
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
|
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
|
||||||
queryReq.setFormat(ODataFormat.JSON);
|
queryReq.setFormat(ContentType.JSON);
|
||||||
|
|
||||||
streamManager.addRequest(queryReq);
|
streamManager.addRequest(queryReq);
|
||||||
// -------------------------------------------
|
// -------------------------------------------
|
||||||
|
@ -108,7 +107,7 @@ public class AuthBatchTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
final ODataEntityUpdateRequest<ClientEntity> changeReq =
|
final ODataEntityUpdateRequest<ClientEntity> changeReq =
|
||||||
client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patch);
|
client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patch);
|
||||||
changeReq.setFormat(ODataFormat.JSON_FULL_METADATA);
|
changeReq.setFormat(ContentType.JSON_FULL_METADATA);
|
||||||
|
|
||||||
changeset.addRequest(changeReq);
|
changeset.addRequest(changeReq);
|
||||||
// -------------------------------------------
|
// -------------------------------------------
|
||||||
|
|
|
@ -67,7 +67,6 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ContentType;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class BatchTestITCase extends AbstractTestITCase {
|
public class BatchTestITCase extends AbstractTestITCase {
|
||||||
|
@ -128,20 +127,20 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||||
for (int i = 1; i <= 2; i++) {
|
for (int i = 1; i <= 2; i++) {
|
||||||
// Create Customer into the changeset
|
// Create Customer into the changeset
|
||||||
createReq = client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), newOrder(100 + i));
|
createReq = client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), newOrder(100 + i));
|
||||||
createReq.setFormat(ODataFormat.JSON);
|
createReq.setFormat(ContentType.JSON);
|
||||||
changeset.addRequest(createReq);
|
changeset.addRequest(createReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("WrongEntitySet");
|
targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("WrongEntitySet");
|
||||||
createReq = client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), newOrder(105));
|
createReq = client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), newOrder(105));
|
||||||
createReq.setFormat(ODataFormat.JSON);
|
createReq.setFormat(ContentType.JSON);
|
||||||
changeset.addRequest(createReq);
|
changeset.addRequest(createReq);
|
||||||
|
|
||||||
targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders");
|
targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders");
|
||||||
for (int i = 3; i <= 4; i++) {
|
for (int i = 3; i <= 4; i++) {
|
||||||
// Create Customer into the changeset
|
// Create Customer into the changeset
|
||||||
createReq = client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), newOrder(100 + i));
|
createReq = client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), newOrder(100 + i));
|
||||||
createReq.setFormat(ODataFormat.JSON);
|
createReq.setFormat(ContentType.JSON);
|
||||||
changeset.addRequest(createReq);
|
changeset.addRequest(createReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +192,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
// create new request
|
// create new request
|
||||||
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
|
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
|
||||||
queryReq.setFormat(ODataFormat.JSON);
|
queryReq.setFormat(ContentType.JSON);
|
||||||
|
|
||||||
streamManager.addRequest(queryReq);
|
streamManager.addRequest(queryReq);
|
||||||
// -------------------------------------------
|
// -------------------------------------------
|
||||||
|
@ -340,7 +339,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
// create new request
|
// create new request
|
||||||
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
|
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
|
||||||
queryReq.setFormat(ODataFormat.JSON);
|
queryReq.setFormat(ContentType.JSON);
|
||||||
|
|
||||||
streamManager.addRequest(queryReq);
|
streamManager.addRequest(queryReq);
|
||||||
// -------------------------------------------
|
// -------------------------------------------
|
||||||
|
@ -353,7 +352,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||||
final ClientEntity original = newOrder(2000);
|
final ClientEntity original = newOrder(2000);
|
||||||
final ODataEntityCreateRequest<ClientEntity> createReq =
|
final ODataEntityCreateRequest<ClientEntity> createReq =
|
||||||
client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), original);
|
client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), original);
|
||||||
createReq.setFormat(ODataFormat.JSON);
|
createReq.setFormat(ContentType.JSON);
|
||||||
streamManager.addRequest(createReq);
|
streamManager.addRequest(createReq);
|
||||||
// -------------------------------------------
|
// -------------------------------------------
|
||||||
|
|
||||||
|
@ -407,7 +406,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
// create new request
|
// create new request
|
||||||
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
|
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
|
||||||
queryReq.setFormat(ODataFormat.JSON);
|
queryReq.setFormat(ContentType.JSON);
|
||||||
|
|
||||||
streamManager.addRequest(queryReq);
|
streamManager.addRequest(queryReq);
|
||||||
// -------------------------------------------
|
// -------------------------------------------
|
||||||
|
@ -431,7 +430,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
final ODataEntityUpdateRequest<ClientEntity> changeReq =
|
final ODataEntityUpdateRequest<ClientEntity> changeReq =
|
||||||
client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patch);
|
client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patch);
|
||||||
changeReq.setFormat(ODataFormat.JSON_FULL_METADATA);
|
changeReq.setFormat(ContentType.JSON_FULL_METADATA);
|
||||||
|
|
||||||
changeset.addRequest(changeReq);
|
changeset.addRequest(changeReq);
|
||||||
|
|
||||||
|
@ -440,7 +439,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||||
final ClientEntity original = newOrder(1000);
|
final ClientEntity original = newOrder(1000);
|
||||||
final ODataEntityCreateRequest<ClientEntity> createReq =
|
final ODataEntityCreateRequest<ClientEntity> createReq =
|
||||||
client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), original);
|
client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), original);
|
||||||
createReq.setFormat(ODataFormat.JSON);
|
createReq.setFormat(ContentType.JSON);
|
||||||
changeset.addRequest(createReq);
|
changeset.addRequest(createReq);
|
||||||
// -------------------------------------------
|
// -------------------------------------------
|
||||||
|
|
||||||
|
@ -531,7 +530,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
// create new request
|
// create new request
|
||||||
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
|
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
|
||||||
queryReq.setFormat(ODataFormat.JSON);
|
queryReq.setFormat(ContentType.JSON);
|
||||||
|
|
||||||
async.addRetrieve(queryReq);
|
async.addRetrieve(queryReq);
|
||||||
// -------------------------------------------
|
// -------------------------------------------
|
||||||
|
|
|
@ -45,17 +45,17 @@ import org.apache.olingo.client.api.uri.URIBuilder;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
private void functions(final ODataFormat format) throws EdmPrimitiveTypeException {
|
private void functions(final ContentType contentType) throws EdmPrimitiveTypeException {
|
||||||
// GetEmployeesCount
|
// GetEmployeesCount
|
||||||
URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company");
|
URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company");
|
||||||
final ODataEntityRequest<ClientSingleton> singletonReq =
|
final ODataEntityRequest<ClientSingleton> singletonReq =
|
||||||
client.getRetrieveRequestFactory().getSingletonRequest(builder.build());
|
client.getRetrieveRequestFactory().getSingletonRequest(builder.build());
|
||||||
singletonReq.setFormat(format);
|
singletonReq.setFormat(contentType);
|
||||||
final ClientSingleton company = singletonReq.execute().getBody();
|
final ClientSingleton company = singletonReq.execute().getBody();
|
||||||
assertNotNull(company);
|
assertNotNull(company);
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
final ODataInvokeRequest<ClientProperty> getEmployeesCountReq =
|
final ODataInvokeRequest<ClientProperty> getEmployeesCountReq =
|
||||||
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientProperty.class);
|
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientProperty.class);
|
||||||
getEmployeesCountReq.setFormat(format);
|
getEmployeesCountReq.setFormat(contentType);
|
||||||
final ClientProperty getEmployeesCountRes = getEmployeesCountReq.execute().getBody();
|
final ClientProperty getEmployeesCountRes = getEmployeesCountReq.execute().getBody();
|
||||||
assertNotNull(getEmployeesCountRes);
|
assertNotNull(getEmployeesCountRes);
|
||||||
assertTrue(getEmployeesCountRes.hasPrimitiveValue());
|
assertTrue(getEmployeesCountRes.hasPrimitiveValue());
|
||||||
|
@ -74,7 +74,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||||
appendEntitySetSegment("Products").appendKeySegment(5);
|
appendEntitySetSegment("Products").appendKeySegment(5);
|
||||||
ODataEntityRequest<ClientEntity> entityReq = client.getRetrieveRequestFactory().
|
ODataEntityRequest<ClientEntity> entityReq = client.getRetrieveRequestFactory().
|
||||||
getEntityRequest(builder.build());
|
getEntityRequest(builder.build());
|
||||||
entityReq.setFormat(format);
|
entityReq.setFormat(contentType);
|
||||||
ClientEntity entity = entityReq.execute().getBody();
|
ClientEntity entity = entityReq.execute().getBody();
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||||
final ODataInvokeRequest<ClientEntitySet> getProductDetailsReq =
|
final ODataInvokeRequest<ClientEntitySet> getProductDetailsReq =
|
||||||
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientEntitySet.class,
|
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientEntitySet.class,
|
||||||
Collections.<String, ClientValue> singletonMap("count", count));
|
Collections.<String, ClientValue> singletonMap("count", count));
|
||||||
getProductDetailsReq.setFormat(format);
|
getProductDetailsReq.setFormat(contentType);
|
||||||
final ClientEntitySet getProductDetailsRes = getProductDetailsReq.execute().getBody();
|
final ClientEntitySet getProductDetailsRes = getProductDetailsReq.execute().getBody();
|
||||||
assertNotNull(getProductDetailsRes);
|
assertNotNull(getProductDetailsRes);
|
||||||
assertEquals(1, getProductDetailsRes.getEntities().size());
|
assertEquals(1, getProductDetailsRes.getEntities().size());
|
||||||
|
@ -97,7 +97,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||||
builder = client.newURIBuilder(testStaticServiceRootURL).
|
builder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("ProductDetails").appendKeySegment(keyMap);
|
appendEntitySetSegment("ProductDetails").appendKeySegment(keyMap);
|
||||||
entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build());
|
entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build());
|
||||||
entityReq.setFormat(format);
|
entityReq.setFormat(contentType);
|
||||||
entity = entityReq.execute().getBody();
|
entity = entityReq.execute().getBody();
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
final ODataInvokeRequest<ClientEntity> getRelatedProductReq =
|
final ODataInvokeRequest<ClientEntity> getRelatedProductReq =
|
||||||
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientEntity.class);
|
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientEntity.class);
|
||||||
getRelatedProductReq.setFormat(format);
|
getRelatedProductReq.setFormat(contentType);
|
||||||
final ClientEntity getRelatedProductRes = getRelatedProductReq.execute().getBody();
|
final ClientEntity getRelatedProductRes = getRelatedProductReq.execute().getBody();
|
||||||
assertNotNull(getRelatedProductRes);
|
assertNotNull(getRelatedProductRes);
|
||||||
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Product",
|
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Product",
|
||||||
|
@ -117,7 +117,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||||
builder = client.newURIBuilder(testStaticServiceRootURL).
|
builder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("Accounts").appendKeySegment(102);
|
appendEntitySetSegment("Accounts").appendKeySegment(102);
|
||||||
entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build());
|
entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build());
|
||||||
entityReq.setFormat(format);
|
entityReq.setFormat(contentType);
|
||||||
entity = entityReq.execute().getBody();
|
entity = entityReq.execute().getBody();
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
final ODataInvokeRequest<ClientEntity> getDefaultPIReq =
|
final ODataInvokeRequest<ClientEntity> getDefaultPIReq =
|
||||||
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientEntity.class);
|
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientEntity.class);
|
||||||
getDefaultPIReq.setFormat(format);
|
getDefaultPIReq.setFormat(contentType);
|
||||||
final ClientEntity getDefaultPIRes = getDefaultPIReq.execute().getBody();
|
final ClientEntity getDefaultPIRes = getDefaultPIReq.execute().getBody();
|
||||||
assertNotNull(getDefaultPIRes);
|
assertNotNull(getDefaultPIRes);
|
||||||
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument",
|
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument",
|
||||||
|
@ -140,7 +140,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
final ODataInvokeRequest<ClientProperty> getAccountInfoReq =
|
final ODataInvokeRequest<ClientProperty> getAccountInfoReq =
|
||||||
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientProperty.class);
|
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientProperty.class);
|
||||||
getAccountInfoReq.setFormat(format);
|
getAccountInfoReq.setFormat(contentType);
|
||||||
final ClientProperty getAccountInfoRes = getAccountInfoReq.execute().getBody();
|
final ClientProperty getAccountInfoRes = getAccountInfoReq.execute().getBody();
|
||||||
assertNotNull(getAccountInfoRes);
|
assertNotNull(getAccountInfoRes);
|
||||||
assertTrue(getAccountInfoRes.hasComplexValue());
|
assertTrue(getAccountInfoRes.hasComplexValue());
|
||||||
|
@ -150,7 +150,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||||
// GetActualAmount
|
// GetActualAmount
|
||||||
entityReq = client.getRetrieveRequestFactory().getEntityRequest(
|
entityReq = client.getRetrieveRequestFactory().getEntityRequest(
|
||||||
entity.getNavigationLink("MyGiftCard").getLink());
|
entity.getNavigationLink("MyGiftCard").getLink());
|
||||||
entityReq.setFormat(format);
|
entityReq.setFormat(contentType);
|
||||||
entity = entityReq.execute().getBody();
|
entity = entityReq.execute().getBody();
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
assertEquals(301, entity.getProperty("GiftCardID").getPrimitiveValue().toCastValue(Integer.class), 0);
|
assertEquals(301, entity.getProperty("GiftCardID").getPrimitiveValue().toCastValue(Integer.class), 0);
|
||||||
|
@ -162,7 +162,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||||
final ODataInvokeRequest<ClientProperty> getActualAmountReq =
|
final ODataInvokeRequest<ClientProperty> getActualAmountReq =
|
||||||
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientProperty.class,
|
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientProperty.class,
|
||||||
Collections.<String, ClientValue> singletonMap("bonusRate", bonusRate));
|
Collections.<String, ClientValue> singletonMap("bonusRate", bonusRate));
|
||||||
getActualAmountReq.setFormat(format);
|
getActualAmountReq.setFormat(contentType);
|
||||||
final ClientProperty getActualAmountRes = getActualAmountReq.execute().getBody();
|
final ClientProperty getActualAmountRes = getActualAmountReq.execute().getBody();
|
||||||
assertNotNull(getActualAmountRes);
|
assertNotNull(getActualAmountRes);
|
||||||
assertEquals(41.79, getActualAmountRes.getPrimitiveValue().toCastValue(Double.class), 0);
|
assertEquals(41.79, getActualAmountRes.getPrimitiveValue().toCastValue(Double.class), 0);
|
||||||
|
@ -170,12 +170,12 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomFunctions() throws EdmPrimitiveTypeException {
|
public void atomFunctions() throws EdmPrimitiveTypeException {
|
||||||
functions(ODataFormat.ATOM);
|
functions(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonFunctions() throws EdmPrimitiveTypeException {
|
public void jsonFunctions() throws EdmPrimitiveTypeException {
|
||||||
functions(ODataFormat.JSON_FULL_METADATA);
|
functions(ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -264,12 +264,12 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||||
assertEquals(41.79, getActualAmountRes.getPrimitiveValue().toCastValue(Double.class), 0);
|
assertEquals(41.79, getActualAmountRes.getPrimitiveValue().toCastValue(Double.class), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void actions(final ODataFormat format) throws EdmPrimitiveTypeException {
|
private void actions(final ContentType contentType) throws EdmPrimitiveTypeException {
|
||||||
// IncreaseRevenue
|
// IncreaseRevenue
|
||||||
URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company");
|
URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company");
|
||||||
ODataEntityRequest<ClientEntity> entityReq =
|
ODataEntityRequest<ClientEntity> entityReq =
|
||||||
client.getRetrieveRequestFactory().getEntityRequest(builder.build());
|
client.getRetrieveRequestFactory().getEntityRequest(builder.build());
|
||||||
entityReq.setFormat(format);
|
entityReq.setFormat(contentType);
|
||||||
ClientEntity entity = entityReq.execute().getBody();
|
ClientEntity entity = entityReq.execute().getBody();
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||||
final ODataInvokeRequest<ClientProperty> increaseRevenueReq =
|
final ODataInvokeRequest<ClientProperty> increaseRevenueReq =
|
||||||
client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ClientProperty.class,
|
client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ClientProperty.class,
|
||||||
Collections.<String, ClientValue> singletonMap("IncreaseValue", increaseValue));
|
Collections.<String, ClientValue> singletonMap("IncreaseValue", increaseValue));
|
||||||
increaseRevenueReq.setFormat(format);
|
increaseRevenueReq.setFormat(contentType);
|
||||||
final ClientProperty increaseRevenueRes = increaseRevenueReq.execute().getBody();
|
final ClientProperty increaseRevenueRes = increaseRevenueReq.execute().getBody();
|
||||||
assertNotNull(increaseRevenueRes);
|
assertNotNull(increaseRevenueRes);
|
||||||
assertTrue(increaseRevenueRes.hasPrimitiveValue());
|
assertTrue(increaseRevenueRes.hasPrimitiveValue());
|
||||||
|
@ -290,7 +290,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||||
builder = client.newURIBuilder(testStaticServiceRootURL).
|
builder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("Products").appendKeySegment(5);
|
appendEntitySetSegment("Products").appendKeySegment(5);
|
||||||
entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build());
|
entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build());
|
||||||
entityReq.setFormat(format);
|
entityReq.setFormat(contentType);
|
||||||
entity = entityReq.execute().getBody();
|
entity = entityReq.execute().getBody();
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||||
final ODataInvokeRequest<ClientProperty> getProductDetailsReq =
|
final ODataInvokeRequest<ClientProperty> getProductDetailsReq =
|
||||||
client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ClientProperty.class,
|
client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ClientProperty.class,
|
||||||
Collections.<String, ClientValue> singletonMap("accessRight", accessRight));
|
Collections.<String, ClientValue> singletonMap("accessRight", accessRight));
|
||||||
getProductDetailsReq.setFormat(format);
|
getProductDetailsReq.setFormat(contentType);
|
||||||
final ClientProperty getProductDetailsRes = getProductDetailsReq.execute().getBody();
|
final ClientProperty getProductDetailsRes = getProductDetailsReq.execute().getBody();
|
||||||
assertNotNull(getProductDetailsRes);
|
assertNotNull(getProductDetailsRes);
|
||||||
assertTrue(getProductDetailsRes.hasEnumValue());
|
assertTrue(getProductDetailsRes.hasEnumValue());
|
||||||
|
@ -311,7 +311,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||||
builder = client.newURIBuilder(testStaticServiceRootURL).
|
builder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("Customers").appendKeySegment(2);
|
appendEntitySetSegment("Customers").appendKeySegment(2);
|
||||||
entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build());
|
entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build());
|
||||||
entityReq.setFormat(format);
|
entityReq.setFormat(contentType);
|
||||||
entity = entityReq.execute().getBody();
|
entity = entityReq.execute().getBody();
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||||
params.put("index", index);
|
params.put("index", index);
|
||||||
final ODataInvokeRequest<ClientEntity> resetAddressReq =
|
final ODataInvokeRequest<ClientEntity> resetAddressReq =
|
||||||
client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ClientEntity.class, params);
|
client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ClientEntity.class, params);
|
||||||
resetAddressReq.setFormat(format);
|
resetAddressReq.setFormat(contentType);
|
||||||
final ClientEntity resetAddressRes = resetAddressReq.execute().getBody();
|
final ClientEntity resetAddressRes = resetAddressReq.execute().getBody();
|
||||||
assertNotNull(resetAddressRes);
|
assertNotNull(resetAddressRes);
|
||||||
assertEquals(2, resetAddressRes.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0);
|
assertEquals(2, resetAddressRes.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0);
|
||||||
|
@ -345,7 +345,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||||
builder = client.newURIBuilder(testStaticServiceRootURL).
|
builder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("Accounts").appendKeySegment(102);
|
appendEntitySetSegment("Accounts").appendKeySegment(102);
|
||||||
entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build());
|
entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build());
|
||||||
entityReq.setFormat(format);
|
entityReq.setFormat(contentType);
|
||||||
entity = entityReq.execute().getBody();
|
entity = entityReq.execute().getBody();
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
|
|
||||||
|
@ -359,7 +359,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||||
final ODataInvokeRequest<ClientEntity> getDefaultPIReq =
|
final ODataInvokeRequest<ClientEntity> getDefaultPIReq =
|
||||||
client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ClientEntity.class,
|
client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ClientEntity.class,
|
||||||
Collections.<String, ClientValue> singletonMap("newDate", newDate));
|
Collections.<String, ClientValue> singletonMap("newDate", newDate));
|
||||||
getDefaultPIReq.setFormat(format);
|
getDefaultPIReq.setFormat(contentType);
|
||||||
final ClientEntity getDefaultPIRes = getDefaultPIReq.execute().getBody();
|
final ClientEntity getDefaultPIRes = getDefaultPIReq.execute().getBody();
|
||||||
assertNotNull(getDefaultPIRes);
|
assertNotNull(getDefaultPIRes);
|
||||||
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument",
|
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument",
|
||||||
|
@ -370,12 +370,12 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomActions() throws EdmPrimitiveTypeException {
|
public void atomActions() throws EdmPrimitiveTypeException {
|
||||||
actions(ODataFormat.ATOM);
|
actions(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonActions() throws EdmPrimitiveTypeException {
|
public void jsonActions() throws EdmPrimitiveTypeException {
|
||||||
actions(ODataFormat.JSON_FULL_METADATA);
|
actions(ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -54,7 +54,7 @@ import org.apache.olingo.client.core.http.DefaultHttpClientFactory;
|
||||||
import org.apache.olingo.client.core.uri.URIUtils;
|
import org.apache.olingo.client.core.uri.URIUtils;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -118,7 +118,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||||
final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest(
|
final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest(
|
||||||
getClient().newURIBuilder(testStaticServiceRootURL).
|
getClient().newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("Orders").build(), order);
|
appendEntitySetSegment("Orders").build(), order);
|
||||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
req.setFormat(ContentType.JSON_FULL_METADATA);
|
||||||
|
|
||||||
// check for OData-Version
|
// check for OData-Version
|
||||||
assertEquals("4.0", req.getHeader("OData-Version"));
|
assertEquals("4.0", req.getHeader("OData-Version"));
|
||||||
|
@ -126,13 +126,13 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
// check for Content-Type
|
// check for Content-Type
|
||||||
assertEquals(
|
assertEquals(
|
||||||
ODataFormat.JSON_FULL_METADATA.getContentType().toContentTypeString(),
|
ContentType.JSON_FULL_METADATA.toContentTypeString(),
|
||||||
req.getHeader("Content-Type"));
|
req.getHeader("Content-Type"));
|
||||||
assertEquals(
|
assertEquals(
|
||||||
ODataFormat.JSON_FULL_METADATA.getContentType().toContentTypeString(),
|
ContentType.JSON_FULL_METADATA.toContentTypeString(),
|
||||||
req.getHeader(HeaderName.contentType.toString()));
|
req.getHeader(HeaderName.contentType.toString()));
|
||||||
assertEquals(
|
assertEquals(
|
||||||
ODataFormat.JSON_FULL_METADATA.getContentType().toContentTypeString(),
|
ContentType.JSON_FULL_METADATA.toContentTypeString(),
|
||||||
req.getContentType());
|
req.getContentType());
|
||||||
|
|
||||||
final ClientEntity created = req.execute().getBody();
|
final ClientEntity created = req.execute().getBody();
|
||||||
|
@ -179,7 +179,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().
|
ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().
|
||||||
getEntitySetRequest(uriBuilder.build());
|
getEntitySetRequest(uriBuilder.build());
|
||||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
req.setFormat(ContentType.JSON_FULL_METADATA);
|
||||||
req.setPrefer(client.newPreferences().maxPageSize(5));
|
req.setPrefer(client.newPreferences().maxPageSize(5));
|
||||||
|
|
||||||
ODataRetrieveResponse<ClientEntitySet> res = req.execute();
|
ODataRetrieveResponse<ClientEntitySet> res = req.execute();
|
||||||
|
@ -196,7 +196,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||||
assertEquals(expected, found);
|
assertEquals(expected, found);
|
||||||
|
|
||||||
req = client.getRetrieveRequestFactory().getEntitySetRequest(found);
|
req = client.getRetrieveRequestFactory().getEntitySetRequest(found);
|
||||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
req.setFormat(ContentType.JSON_FULL_METADATA);
|
||||||
|
|
||||||
res = req.execute();
|
res = req.execute();
|
||||||
feed = res.getBody();
|
feed = res.getBody();
|
||||||
|
@ -236,7 +236,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||||
final URIBuilder builder = getClient().newURIBuilder(testOpenTypeServiceRootURL).
|
final URIBuilder builder = getClient().newURIBuilder(testOpenTypeServiceRootURL).
|
||||||
appendEntitySetSegment("RowIndex").appendKeySegment(id);
|
appendEntitySetSegment("RowIndex").appendKeySegment(id);
|
||||||
|
|
||||||
rowIndex = read(ODataFormat.JSON_FULL_METADATA, builder.build());
|
rowIndex = read(ContentType.JSON_FULL_METADATA, builder.build());
|
||||||
assertNotNull(rowIndex);
|
assertNotNull(rowIndex);
|
||||||
assertEquals(EdmPrimitiveTypeKind.Int32, rowIndex.getProperty("Id").getPrimitiveValue().getTypeKind());
|
assertEquals(EdmPrimitiveTypeKind.Int32, rowIndex.getProperty("Id").getPrimitiveValue().getTypeKind());
|
||||||
assertEquals(EdmPrimitiveTypeKind.String, rowIndex.getProperty("aString").getPrimitiveValue().getTypeKind());
|
assertEquals(EdmPrimitiveTypeKind.String, rowIndex.getProperty("aString").getPrimitiveValue().getTypeKind());
|
||||||
|
@ -269,7 +269,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||||
final ODataEntityUpdateResponse<ClientEntity> res = req.execute();
|
final ODataEntityUpdateResponse<ClientEntity> res = req.execute();
|
||||||
assertEquals(204, res.getStatusCode());
|
assertEquals(204, res.getStatusCode());
|
||||||
|
|
||||||
final ClientEntity actual = read(ODataFormat.JSON, uri);
|
final ClientEntity actual = read(ContentType.JSON, uri);
|
||||||
|
|
||||||
assertEquals(newname, actual.getProperty("FirstName").getPrimitiveValue().toString());
|
assertEquals(newname, actual.getProperty("FirstName").getPrimitiveValue().toString());
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
final ODataEntityRequest<ClientEntity> req =
|
final ODataEntityRequest<ClientEntity> req =
|
||||||
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
req.setFormat(ContentType.JSON_FULL_METADATA);
|
||||||
|
|
||||||
assertNotNull(req.execute().getBody());
|
assertNotNull(req.execute().getBody());
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||||
appendRefSegment();
|
appendRefSegment();
|
||||||
|
|
||||||
ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
req.setFormat(ContentType.JSON_FULL_METADATA);
|
||||||
|
|
||||||
ODataRetrieveResponse<ClientEntity> res = req.execute();
|
ODataRetrieveResponse<ClientEntity> res = req.execute();
|
||||||
assertNotNull(res);
|
assertNotNull(res);
|
||||||
|
@ -318,7 +318,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||||
appendEntityIdSegment(entity.getId().toASCIIString()).build();
|
appendEntityIdSegment(entity.getId().toASCIIString()).build();
|
||||||
|
|
||||||
req = client.getRetrieveRequestFactory().getEntityRequest(referenceURI);
|
req = client.getRetrieveRequestFactory().getEntityRequest(referenceURI);
|
||||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
req.setFormat(ContentType.JSON_FULL_METADATA);
|
||||||
|
|
||||||
res = req.execute();
|
res = req.execute();
|
||||||
assertNotNull(res);
|
assertNotNull(res);
|
||||||
|
@ -339,7 +339,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||||
assertNotNull(customers.getDeltaLink());
|
assertNotNull(customers.getDeltaLink());
|
||||||
|
|
||||||
final ODataDeltaRequest deltaReq = client.getRetrieveRequestFactory().getDeltaRequest(customers.getDeltaLink());
|
final ODataDeltaRequest deltaReq = client.getRetrieveRequestFactory().getDeltaRequest(customers.getDeltaLink());
|
||||||
deltaReq.setFormat(ODataFormat.JSON_FULL_METADATA);
|
deltaReq.setFormat(ContentType.JSON_FULL_METADATA);
|
||||||
|
|
||||||
final ClientDelta delta = deltaReq.execute().getBody();
|
final ClientDelta delta = deltaReq.execute().getBody();
|
||||||
assertNotNull(delta);
|
assertNotNull(delta);
|
||||||
|
@ -381,7 +381,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
final ODataEntitySetRequest<ClientEntitySet> req =
|
final ODataEntitySetRequest<ClientEntitySet> req =
|
||||||
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
|
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
|
||||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
req.setFormat(ContentType.JSON_FULL_METADATA);
|
||||||
|
|
||||||
final AsyncRequestWrapper<ODataRetrieveResponse<ClientEntitySet>> async =
|
final AsyncRequestWrapper<ODataRetrieveResponse<ClientEntitySet>> async =
|
||||||
client.getAsyncRequestFactory().<ODataRetrieveResponse<ClientEntitySet>> getAsyncRequestWrapper(req);
|
client.getAsyncRequestFactory().<ODataRetrieveResponse<ClientEntitySet>> getAsyncRequestWrapper(req);
|
||||||
|
@ -408,7 +408,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
final ODataEntityRequest<ClientEntity> req =
|
final ODataEntityRequest<ClientEntity> req =
|
||||||
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||||
req.setFormat(ODataFormat.JSON);
|
req.setFormat(ContentType.JSON);
|
||||||
|
|
||||||
assertEquals("application/json;odata.metadata=minimal", req.getHeader("Accept"));
|
assertEquals("application/json;odata.metadata=minimal", req.getHeader("Accept"));
|
||||||
assertEquals("application/json;odata.metadata=minimal", req.getHeader(HeaderName.accept.toString()));
|
assertEquals("application/json;odata.metadata=minimal", req.getHeader(HeaderName.accept.toString()));
|
||||||
|
|
|
@ -27,12 +27,12 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySe
|
||||||
import org.apache.olingo.client.api.domain.ClientDelta;
|
import org.apache.olingo.client.api.domain.ClientDelta;
|
||||||
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
||||||
import org.apache.olingo.client.api.domain.ClientProperty;
|
import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class DeltaTestITCase extends AbstractTestITCase {
|
public class DeltaTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
private void parse(final ODataFormat format) {
|
private void parse(final ContentType format) {
|
||||||
final ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest(
|
final ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest(
|
||||||
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").build());
|
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").build());
|
||||||
req.setPrefer(client.newPreferences().trackChanges());
|
req.setPrefer(client.newPreferences().trackChanges());
|
||||||
|
@ -76,11 +76,11 @@ public class DeltaTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomParse() {
|
public void atomParse() {
|
||||||
parse(ODataFormat.ATOM);
|
parse(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonParse() {
|
public void jsonParse() {
|
||||||
parse(ODataFormat.JSON);
|
parse(ContentType.JSON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,19 +36,19 @@ import org.apache.olingo.client.api.domain.ClientValuable;
|
||||||
import org.apache.olingo.client.api.uri.URIBuilder;
|
import org.apache.olingo.client.api.uri.URIBuilder;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class DerivedTypeTestITCase extends AbstractTestITCase {
|
public class DerivedTypeTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
private void read(final ODataFormat format) {
|
private void read(final ContentType contentType) {
|
||||||
// 1. entity set
|
// 1. entity set
|
||||||
URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("People").
|
appendEntitySetSegment("People").
|
||||||
appendDerivedEntityTypeSegment("Microsoft.Test.OData.Services.ODataWCFService.Customer");
|
appendDerivedEntityTypeSegment("Microsoft.Test.OData.Services.ODataWCFService.Customer");
|
||||||
ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().
|
ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().
|
||||||
getEntitySetRequest(uriBuilder.build());
|
getEntitySetRequest(uriBuilder.build());
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
for (ClientEntity customer : req.execute().getBody().getEntities()) {
|
for (ClientEntity customer : req.execute().getBody().getEntities()) {
|
||||||
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", customer.getTypeName().toString());
|
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", customer.getTypeName().toString());
|
||||||
|
@ -60,7 +60,7 @@ public class DerivedTypeTestITCase extends AbstractTestITCase {
|
||||||
appendNavigationSegment("MyPaymentInstruments").
|
appendNavigationSegment("MyPaymentInstruments").
|
||||||
appendDerivedEntityTypeSegment("Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI");
|
appendDerivedEntityTypeSegment("Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI");
|
||||||
req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
|
req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
for (ClientEntity customer : req.execute().getBody().getEntities()) {
|
for (ClientEntity customer : req.execute().getBody().getEntities()) {
|
||||||
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI", customer.getTypeName().toString());
|
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI", customer.getTypeName().toString());
|
||||||
|
@ -69,15 +69,15 @@ public class DerivedTypeTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readfromAtom() {
|
public void readfromAtom() {
|
||||||
read(ODataFormat.ATOM);
|
read(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readfromJSON() {
|
public void readfromJSON() {
|
||||||
read(ODataFormat.JSON_FULL_METADATA);
|
read(ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createDelete(final ODataFormat format) {
|
private void createDelete(final ContentType conentType) {
|
||||||
final ClientEntity customer = client.getObjectFactory().
|
final ClientEntity customer = client.getObjectFactory().
|
||||||
newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
|
newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ public class DerivedTypeTestITCase extends AbstractTestITCase {
|
||||||
getEntityCreateRequest(
|
getEntityCreateRequest(
|
||||||
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People").build(),
|
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People").build(),
|
||||||
customer);
|
customer);
|
||||||
createReq.setFormat(format);
|
createReq.setFormat(conentType);
|
||||||
|
|
||||||
final ODataEntityCreateResponse<ClientEntity> createRes = createReq.execute();
|
final ODataEntityCreateResponse<ClientEntity> createRes = createReq.execute();
|
||||||
assertEquals(201, createRes.getStatusCode());
|
assertEquals(201, createRes.getStatusCode());
|
||||||
|
@ -127,7 +127,7 @@ public class DerivedTypeTestITCase extends AbstractTestITCase {
|
||||||
final ODataEntityRequest<ClientEntity> fetchReq = client.getRetrieveRequestFactory().
|
final ODataEntityRequest<ClientEntity> fetchReq = client.getRetrieveRequestFactory().
|
||||||
getEntityRequest(client.newURIBuilder(testStaticServiceRootURL).
|
getEntityRequest(client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("People").appendKeySegment(976).build());
|
appendEntitySetSegment("People").appendKeySegment(976).build());
|
||||||
fetchReq.setFormat(format);
|
fetchReq.setFormat(conentType);
|
||||||
|
|
||||||
final ClientEntity actual = fetchReq.execute().getBody();
|
final ClientEntity actual = fetchReq.execute().getBody();
|
||||||
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", actual.getTypeName().toString());
|
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", actual.getTypeName().toString());
|
||||||
|
@ -140,11 +140,11 @@ public class DerivedTypeTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createDeleteAsAtom() {
|
public void createDeleteAsAtom() {
|
||||||
createDelete(ODataFormat.ATOM);
|
createDelete(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createDeleteAsJSON() {
|
public void createDeleteAsJSON() {
|
||||||
createDelete(ODataFormat.JSON_FULL_METADATA);
|
createDelete(ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,24 +35,24 @@ import org.apache.olingo.client.api.domain.ClientLink;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class EntityCreateTestITCase extends AbstractTestITCase {
|
public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomCreateAndDelete() {
|
public void atomCreateAndDelete() {
|
||||||
createAndDeleteOrder(testStaticServiceRootURL, ODataFormat.ATOM, 1000);
|
createAndDeleteOrder(testStaticServiceRootURL, ContentType.APPLICATION_ATOM_XML, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonCreateAndDelete() {
|
public void jsonCreateAndDelete() {
|
||||||
createAndDeleteOrder(testStaticServiceRootURL, ODataFormat.JSON, 1001);
|
createAndDeleteOrder(testStaticServiceRootURL, ContentType.JSON, 1001);
|
||||||
createAndDeleteOrder(testStaticServiceRootURL, ODataFormat.JSON_NO_METADATA, 1001);
|
createAndDeleteOrder(testStaticServiceRootURL, ContentType.JSON_NO_METADATA, 1001);
|
||||||
createAndDeleteOrder(testStaticServiceRootURL, ODataFormat.JSON_FULL_METADATA, 1001);
|
createAndDeleteOrder(testStaticServiceRootURL, ContentType.JSON_FULL_METADATA, 1001);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onContained(final ODataFormat format) {
|
private void onContained(final ContentType contentType) {
|
||||||
final URI uri = getClient().newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Accounts").
|
final URI uri = getClient().newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Accounts").
|
||||||
appendKeySegment(101).appendNavigationSegment("MyPaymentInstruments").build();
|
appendKeySegment(101).appendNavigationSegment("MyPaymentInstruments").build();
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||||
// 3. create it as contained entity
|
// 3. create it as contained entity
|
||||||
final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
|
final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
|
||||||
getEntityCreateRequest(uri, instrument);
|
getEntityCreateRequest(uri, instrument);
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
final ODataEntityCreateResponse<ClientEntity> res = req.execute();
|
final ODataEntityCreateResponse<ClientEntity> res = req.execute();
|
||||||
assertEquals(201, res.getStatusCode());
|
assertEquals(201, res.getStatusCode());
|
||||||
|
@ -102,15 +102,15 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomOnContained() {
|
public void atomOnContained() {
|
||||||
onContained(ODataFormat.ATOM);
|
onContained(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonOnContained() {
|
public void jsonOnContained() {
|
||||||
onContained(ODataFormat.JSON);
|
onContained(ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deepInsert(final ODataFormat format, final int productId, final int productDetailId)
|
private void deepInsert(final ContentType contentType, final int productId, final int productDetailId)
|
||||||
throws EdmPrimitiveTypeException {
|
throws EdmPrimitiveTypeException {
|
||||||
|
|
||||||
final ClientEntity product = getClient().getObjectFactory().
|
final ClientEntity product = getClient().getObjectFactory().
|
||||||
|
@ -161,7 +161,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest(
|
final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest(
|
||||||
getClient().newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Products").build(), product);
|
getClient().newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Products").build(), product);
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
final ODataEntityCreateResponse<ClientEntity> res = req.execute();
|
final ODataEntityCreateResponse<ClientEntity> res = req.execute();
|
||||||
assertEquals(201, res.getStatusCode());
|
assertEquals(201, res.getStatusCode());
|
||||||
|
|
||||||
|
@ -181,11 +181,11 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomDeepInsert() throws EdmPrimitiveTypeException {
|
public void atomDeepInsert() throws EdmPrimitiveTypeException {
|
||||||
deepInsert(ODataFormat.ATOM, 10, 10);
|
deepInsert(ContentType.APPLICATION_ATOM_XML, 10, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonDeepInsert() throws EdmPrimitiveTypeException {
|
public void jsonDeepInsert() throws EdmPrimitiveTypeException {
|
||||||
deepInsert(ODataFormat.JSON_FULL_METADATA, 11, 11);
|
deepInsert(ContentType.JSON_FULL_METADATA, 11, 11);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
import org.apache.olingo.client.api.uri.URIBuilder;
|
import org.apache.olingo.client.api.uri.URIBuilder;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,13 +53,13 @@ import org.junit.Test;
|
||||||
*/
|
*/
|
||||||
public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
private void withInlineEntity(final ODataClient client, final ODataFormat format) {
|
private void withInlineEntity(final ODataClient client, final ContentType contentType) {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");
|
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");
|
||||||
|
|
||||||
final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().
|
final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().
|
||||||
getEntityRequest(uriBuilder.build());
|
getEntityRequest(uriBuilder.build());
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
||||||
final ClientEntity entity = res.getBody();
|
final ClientEntity entity = res.getBody();
|
||||||
|
@ -70,11 +70,14 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||||
assertEquals("Edm.GeographyPoint", entity.getProperty("Home").getPrimitiveValue().getTypeName());
|
assertEquals("Edm.GeographyPoint", entity.getProperty("Home").getPrimitiveValue().getTypeName());
|
||||||
|
|
||||||
// In JSON with minimal metadata, links are not provided
|
// In JSON with minimal metadata, links are not provided
|
||||||
if (format == ODataFormat.ATOM || format == ODataFormat.JSON_FULL_METADATA) {
|
if(contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML)
|
||||||
|
|| (contentType.isCompatible(ContentType.JSON)
|
||||||
|
&& ContentType.VALUE_ODATA_METADATA_FULL
|
||||||
|
.equals(contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA)))) {
|
||||||
assertEquals(testStaticServiceRootURL + "/Customers(1)", entity.getEditLink().toASCIIString());
|
assertEquals(testStaticServiceRootURL + "/Customers(1)", entity.getEditLink().toASCIIString());
|
||||||
assertEquals(3, entity.getNavigationLinks().size());
|
assertEquals(3, entity.getNavigationLinks().size());
|
||||||
|
|
||||||
if (ODataFormat.ATOM == format) {
|
if (ContentType.APPLICATION_ATOM_XML == contentType) {
|
||||||
assertTrue(entity.getAssociationLinks().isEmpty());
|
assertTrue(entity.getAssociationLinks().isEmpty());
|
||||||
// In JSON, association links for each $ref link will exist.
|
// In JSON, association links for each $ref link will exist.
|
||||||
}
|
}
|
||||||
|
@ -110,26 +113,26 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void withInlineEntityFromAtom() {
|
public void withInlineEntityFromAtom() {
|
||||||
withInlineEntity(client, ODataFormat.ATOM);
|
withInlineEntity(client, ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void withInlineEntityFromFullJSON() {
|
public void withInlineEntityFromFullJSON() {
|
||||||
withInlineEntity(client, ODataFormat.JSON_FULL_METADATA);
|
withInlineEntity(client, ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void withInlineEntityFromJSON() {
|
public void withInlineEntityFromJSON() {
|
||||||
withInlineEntity(edmClient, ODataFormat.JSON);
|
withInlineEntity(edmClient, ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void withInlineEntitySet(final ODataClient client, final ODataFormat format) {
|
private void withInlineEntitySet(final ODataClient client, final ContentType contentType) {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Orders");
|
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Orders");
|
||||||
|
|
||||||
final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().
|
final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().
|
||||||
getEntityRequest(uriBuilder.build());
|
getEntityRequest(uriBuilder.build());
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
||||||
final ClientEntity entity = res.getBody();
|
final ClientEntity entity = res.getBody();
|
||||||
|
@ -137,7 +140,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||||
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
|
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
|
||||||
|
|
||||||
// In JSON with minimal metadata, links are not provided
|
// In JSON with minimal metadata, links are not provided
|
||||||
if (format == ODataFormat.ATOM || format == ODataFormat.JSON_FULL_METADATA) {
|
if (contentType.equals(ContentType.APPLICATION_ATOM_XML) || contentType.equals(ContentType.JSON_FULL_METADATA)) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (ClientLink link : entity.getNavigationLinks()) {
|
for (ClientLink link : entity.getNavigationLinks()) {
|
||||||
if (link instanceof ClientInlineEntitySet) {
|
if (link instanceof ClientInlineEntitySet) {
|
||||||
|
@ -153,25 +156,25 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void withInlineEntitySetFromAtom() {
|
public void withInlineEntitySetFromAtom() {
|
||||||
withInlineEntitySet(client, ODataFormat.ATOM);
|
withInlineEntitySet(client, ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void withInlineEntitySetFromFullJSON() {
|
public void withInlineEntitySetFromFullJSON() {
|
||||||
withInlineEntitySet(client, ODataFormat.JSON_FULL_METADATA);
|
withInlineEntitySet(client, ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void withInlineEntitySetFromJSON() {
|
public void withInlineEntitySetFromJSON() {
|
||||||
withInlineEntitySet(edmClient, ODataFormat.JSON);
|
withInlineEntitySet(edmClient, ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rawRequest(final ODataFormat format) {
|
private void rawRequest(final ContentType contentType) {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("People").appendKeySegment(5);
|
appendEntitySetSegment("People").appendKeySegment(5);
|
||||||
|
|
||||||
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
|
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
|
||||||
req.setFormat(format.getContentType().toContentTypeString());
|
req.setFormat(contentType.toContentTypeString());
|
||||||
|
|
||||||
final ODataRawResponse res = req.execute();
|
final ODataRawResponse res = req.execute();
|
||||||
assertNotNull(res);
|
assertNotNull(res);
|
||||||
|
@ -185,16 +188,16 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void rawRequestAsAtom() {
|
public void rawRequestAsAtom() {
|
||||||
rawRequest(ODataFormat.ATOM);
|
rawRequest(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void rawRequestAsJSON() {
|
public void rawRequestAsJSON() {
|
||||||
// this needs to be full, otherwise reference will not be provided
|
// this needs to be full, otherwise reference will not be provided
|
||||||
rawRequest(ODataFormat.JSON_FULL_METADATA);
|
rawRequest(ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void multiKey(final ODataFormat format) throws EdmPrimitiveTypeException {
|
private void multiKey(final ContentType contentType) throws EdmPrimitiveTypeException {
|
||||||
final LinkedHashMap<String, Object> multiKey = new LinkedHashMap<String, Object>();
|
final LinkedHashMap<String, Object> multiKey = new LinkedHashMap<String, Object>();
|
||||||
multiKey.put("ProductID", "6");
|
multiKey.put("ProductID", "6");
|
||||||
multiKey.put("ProductDetailID", 1);
|
multiKey.put("ProductDetailID", 1);
|
||||||
|
@ -204,7 +207,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
final ODataEntityRequest<ClientEntity> req =
|
final ODataEntityRequest<ClientEntity> req =
|
||||||
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
||||||
final ClientEntity entity = res.getBody();
|
final ClientEntity entity = res.getBody();
|
||||||
|
@ -215,21 +218,21 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void multiKeyAsAtom() throws EdmPrimitiveTypeException {
|
public void multiKeyAsAtom() throws EdmPrimitiveTypeException {
|
||||||
multiKey(ODataFormat.ATOM);
|
multiKey(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void multiKeyAsJSON() throws EdmPrimitiveTypeException {
|
public void multiKeyAsJSON() throws EdmPrimitiveTypeException {
|
||||||
multiKey(ODataFormat.JSON_FULL_METADATA);
|
multiKey(ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForETag(final ODataClient client, final ODataFormat format) {
|
private void checkForETag(final ODataClient client, final ContentType contentType) {
|
||||||
final URIBuilder uriBuilder =
|
final URIBuilder uriBuilder =
|
||||||
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders").appendKeySegment(8);
|
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders").appendKeySegment(8);
|
||||||
|
|
||||||
final ODataEntityRequest<ClientEntity> req =
|
final ODataEntityRequest<ClientEntity> req =
|
||||||
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
||||||
assertEquals(200, res.getStatusCode());
|
assertEquals(200, res.getStatusCode());
|
||||||
|
@ -248,17 +251,17 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkForETagAsAtom() {
|
public void checkForETagAsAtom() {
|
||||||
checkForETag(client, ODataFormat.ATOM);
|
checkForETag(client, ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkForETagAsFullJSON() {
|
public void checkForETagAsFullJSON() {
|
||||||
checkForETag(client, ODataFormat.JSON_FULL_METADATA);
|
checkForETag(client, ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkForETagAsJSON() {
|
public void checkForETagAsJSON() {
|
||||||
checkForETag(edmClient, ODataFormat.JSON);
|
checkForETag(edmClient, ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
@ -267,20 +270,20 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
final ODataEntityRequest<ClientEntity> req =
|
final ODataEntityRequest<ClientEntity> req =
|
||||||
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||||
req.setFormat(ODataFormat.JSON);
|
req.setFormat(ContentType.JSON);
|
||||||
|
|
||||||
// this statement should cause an IllegalArgumentException bearing JsonParseException
|
// this statement should cause an IllegalArgumentException bearing JsonParseException
|
||||||
// since we are attempting to parse an EntitySet as if it was an Entity
|
// since we are attempting to parse an EntitySet as if it was an Entity
|
||||||
req.execute().getBody();
|
req.execute().getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reference(final ODataFormat format) {
|
private void reference(final ContentType contentType) {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("Orders").appendKeySegment(8).appendNavigationSegment("CustomerForOrder").
|
appendEntitySetSegment("Orders").appendKeySegment(8).appendNavigationSegment("CustomerForOrder").
|
||||||
appendRefSegment();
|
appendRefSegment();
|
||||||
|
|
||||||
ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
ODataRetrieveResponse<ClientEntity> res = req.execute();
|
ODataRetrieveResponse<ClientEntity> res = req.execute();
|
||||||
assertNotNull(res);
|
assertNotNull(res);
|
||||||
|
@ -293,7 +296,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||||
appendEntityIdSegment(entity.getId().toASCIIString()).build();
|
appendEntityIdSegment(entity.getId().toASCIIString()).build();
|
||||||
|
|
||||||
req = client.getRetrieveRequestFactory().getEntityRequest(referenceURI);
|
req = client.getRetrieveRequestFactory().getEntityRequest(referenceURI);
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
res = req.execute();
|
res = req.execute();
|
||||||
assertNotNull(res);
|
assertNotNull(res);
|
||||||
|
@ -302,20 +305,20 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomReference() {
|
public void atomReference() {
|
||||||
reference(ODataFormat.ATOM);
|
reference(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonReference() {
|
public void jsonReference() {
|
||||||
reference(ODataFormat.JSON_FULL_METADATA);
|
reference(ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void contained(final ODataClient client, final ODataFormat format) throws EdmPrimitiveTypeException {
|
private void contained(final ODataClient client, final ContentType contentType) throws EdmPrimitiveTypeException {
|
||||||
final URI uri = client.newURIBuilder(testStaticServiceRootURL).
|
final URI uri = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("Accounts").appendKeySegment(101).
|
appendEntitySetSegment("Accounts").appendKeySegment(101).
|
||||||
appendNavigationSegment("MyPaymentInstruments").appendKeySegment(101902).build();
|
appendNavigationSegment("MyPaymentInstruments").appendKeySegment(101902).build();
|
||||||
final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uri);
|
final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uri);
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
final ClientEntity contained = req.execute().getBody();
|
final ClientEntity contained = req.execute().getBody();
|
||||||
assertNotNull(contained);
|
assertNotNull(contained);
|
||||||
|
@ -328,30 +331,30 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void containedFromAtom() throws EdmPrimitiveTypeException {
|
public void containedFromAtom() throws EdmPrimitiveTypeException {
|
||||||
contained(client, ODataFormat.ATOM);
|
contained(client, ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void containedFromFullJSON() throws EdmPrimitiveTypeException {
|
public void containedFromFullJSON() throws EdmPrimitiveTypeException {
|
||||||
contained(client, ODataFormat.JSON_FULL_METADATA);
|
contained(client, ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void containedFromJSON() throws EdmPrimitiveTypeException {
|
public void containedFromJSON() throws EdmPrimitiveTypeException {
|
||||||
contained(edmClient, ODataFormat.JSON);
|
contained(edmClient, ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void entitySetNavigationLink(final ODataClient client, final ODataFormat format) {
|
private void entitySetNavigationLink(final ODataClient client, final ContentType contentType) {
|
||||||
final URI uri = client.newURIBuilder(testStaticServiceRootURL).
|
final URI uri = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("Accounts").appendKeySegment(101).build();
|
appendEntitySetSegment("Accounts").appendKeySegment(101).build();
|
||||||
final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uri);
|
final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uri);
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
final ClientEntity entity = req.execute().getBody();
|
final ClientEntity entity = req.execute().getBody();
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
|
|
||||||
// With JSON, entity set navigation links are only recognizable via Edm
|
// With JSON, entity set navigation links are only recognizable via Edm
|
||||||
if (format == ODataFormat.ATOM || client instanceof EdmEnabledODataClient) {
|
if (contentType.equals(ContentType.APPLICATION_ATOM_XML) || client instanceof EdmEnabledODataClient) {
|
||||||
assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("MyPaymentInstruments").getType());
|
assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("MyPaymentInstruments").getType());
|
||||||
assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("ActiveSubscriptions").getType());
|
assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("ActiveSubscriptions").getType());
|
||||||
}
|
}
|
||||||
|
@ -359,13 +362,13 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void entitySetNavigationLinkFromAtom() {
|
public void entitySetNavigationLinkFromAtom() {
|
||||||
entitySetNavigationLink(client, ODataFormat.ATOM);
|
entitySetNavigationLink(client, ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void entitySetNavigationLinkFromJSON() {
|
public void entitySetNavigationLinkFromJSON() {
|
||||||
// only JSON_FULL_METADATA has links, only Edm can recognize entity set navigation
|
// only JSON_FULL_METADATA has links, only Edm can recognize entity set navigation
|
||||||
entitySetNavigationLink(edmClient, ODataFormat.JSON_FULL_METADATA);
|
entitySetNavigationLink(edmClient, ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ import org.apache.olingo.client.api.domain.ClientEntitySetIterator;
|
||||||
import org.apache.olingo.client.api.uri.URIBuilder;
|
import org.apache.olingo.client.api.uri.URIBuilder;
|
||||||
import org.apache.olingo.client.core.uri.URIUtils;
|
import org.apache.olingo.client.core.uri.URIUtils;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,11 +45,11 @@ import org.junit.Test;
|
||||||
*/
|
*/
|
||||||
public class EntitySetTestITCase extends AbstractTestITCase {
|
public class EntitySetTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
private void rawRequest(final ODataFormat format) {
|
private void rawRequest(final ContentType contentType) {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
|
||||||
|
|
||||||
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
|
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
|
||||||
req.setFormat(format.getContentType().toContentTypeString());
|
req.setFormat(contentType.toContentTypeString());
|
||||||
|
|
||||||
final ODataRawResponse res = req.execute();
|
final ODataRawResponse res = req.execute();
|
||||||
assertNotNull(res);
|
assertNotNull(res);
|
||||||
|
@ -61,20 +61,20 @@ public class EntitySetTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void rawRequestAsAtom() throws IOException {
|
public void rawRequestAsAtom() throws IOException {
|
||||||
rawRequest(ODataFormat.ATOM);
|
rawRequest(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void rawRequestAsJSON() throws IOException {
|
public void rawRequestAsJSON() throws IOException {
|
||||||
rawRequest(ODataFormat.JSON);
|
rawRequest(ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readWithInlineCount(final ODataClient client, final ODataFormat format) {
|
private void readWithInlineCount(final ODataClient client, final ContentType contentType) {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("People").count(true);
|
appendEntitySetSegment("People").count(true);
|
||||||
|
|
||||||
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
|
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
|
||||||
req.setFormat(format.getContentType().toContentTypeString());
|
req.setFormat(contentType.toContentTypeString());
|
||||||
|
|
||||||
final ODataRawResponse res = req.execute();
|
final ODataRawResponse res = req.execute();
|
||||||
assertNotNull(res);
|
assertNotNull(res);
|
||||||
|
@ -88,25 +88,25 @@ public class EntitySetTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readWithInlineCountAsJSON() throws IOException {
|
public void readWithInlineCountAsJSON() throws IOException {
|
||||||
readWithInlineCount(edmClient, ODataFormat.JSON);
|
readWithInlineCount(edmClient, ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readWithInlineCountAsFullJSON() throws IOException {
|
public void readWithInlineCountAsFullJSON() throws IOException {
|
||||||
readWithInlineCount(client, ODataFormat.JSON_FULL_METADATA);
|
readWithInlineCount(client, ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readWithInlineCountAsAtom() throws IOException {
|
public void readWithInlineCountAsAtom() throws IOException {
|
||||||
readWithInlineCount(client, ODataFormat.ATOM);
|
readWithInlineCount(client, ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readODataEntitySetIterator(final ODataFormat format) {
|
private void readODataEntitySetIterator(final ContentType contentType) {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
|
||||||
|
|
||||||
final ODataEntitySetIteratorRequest<ClientEntitySet, ClientEntity> req =
|
final ODataEntitySetIteratorRequest<ClientEntitySet, ClientEntity> req =
|
||||||
client.getRetrieveRequestFactory().getEntitySetIteratorRequest(uriBuilder.build());
|
client.getRetrieveRequestFactory().getEntitySetIteratorRequest(uriBuilder.build());
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
final ODataRetrieveResponse<ClientEntitySetIterator<ClientEntitySet, ClientEntity>> res = req.execute();
|
final ODataRetrieveResponse<ClientEntitySetIterator<ClientEntitySet, ClientEntity>> res = req.execute();
|
||||||
final ClientEntitySetIterator<ClientEntitySet, ClientEntity> feedIterator = res.getBody();
|
final ClientEntitySetIterator<ClientEntitySet, ClientEntity> feedIterator = res.getBody();
|
||||||
|
@ -125,25 +125,25 @@ public class EntitySetTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readODataEntitySetIteratorFromAtom() {
|
public void readODataEntitySetIteratorFromAtom() {
|
||||||
readODataEntitySetIterator(ODataFormat.ATOM);
|
readODataEntitySetIterator(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readODataEntitySetIteratorFromJSON() {
|
public void readODataEntitySetIteratorFromJSON() {
|
||||||
readODataEntitySetIterator(ODataFormat.JSON);
|
readODataEntitySetIterator(ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readODataEntitySetIteratorFromJSONFull() {
|
public void readODataEntitySetIteratorFromJSONFull() {
|
||||||
readODataEntitySetIterator(ODataFormat.JSON_FULL_METADATA);
|
readODataEntitySetIterator(ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readODataEntitySetIteratorFromJSONNo() {
|
public void readODataEntitySetIteratorFromJSONNo() {
|
||||||
readODataEntitySetIterator(ODataFormat.JSON_NO_METADATA);
|
readODataEntitySetIterator(ContentType.JSON_NO_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readWithNext(final ODataFormat format) {
|
private void readWithNext(final ContentType format) {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
|
||||||
|
|
||||||
final ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().
|
final ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().
|
||||||
|
@ -167,12 +167,12 @@ public class EntitySetTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readWithNextFromAtom() {
|
public void readWithNextFromAtom() {
|
||||||
readWithNext(ODataFormat.ATOM);
|
readWithNext(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readWithNextFromJSON() {
|
public void readWithNextFromJSON() {
|
||||||
readWithNext(ODataFormat.JSON_FULL_METADATA);
|
readWithNext(ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,13 +37,13 @@ import org.apache.olingo.client.api.domain.ClientLink;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class EntityUpdateTestITCase extends AbstractTestITCase {
|
public class EntityUpdateTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
private void upsert(final UpdateType updateType, final ODataFormat format) {
|
private void upsert(final UpdateType updateType, final ContentType contentType) {
|
||||||
final ClientEntity order = getClient().getObjectFactory().
|
final ClientEntity order = getClient().getObjectFactory().
|
||||||
newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order"));
|
newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order"));
|
||||||
|
|
||||||
|
@ -61,11 +61,11 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
||||||
appendEntitySetSegment("Orders").appendKeySegment(9).build();
|
appendEntitySetSegment("Orders").appendKeySegment(9).build();
|
||||||
final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
|
final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
|
||||||
getEntityUpdateRequest(upsertURI, updateType, order);
|
getEntityUpdateRequest(upsertURI, updateType, order);
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
req.execute();
|
req.execute();
|
||||||
try {
|
try {
|
||||||
final ClientEntity read = read(format, upsertURI);
|
final ClientEntity read = read(contentType, upsertURI);
|
||||||
assertNotNull(read);
|
assertNotNull(read);
|
||||||
assertEquals(order.getProperty("OrderID"), read.getProperty("OrderID"));
|
assertEquals(order.getProperty("OrderID"), read.getProperty("OrderID"));
|
||||||
assertEquals(order.getProperty("OrderDate").getPrimitiveValue().toString(),
|
assertEquals(order.getProperty("OrderDate").getPrimitiveValue().toString(),
|
||||||
|
@ -103,17 +103,17 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomUpsert() {
|
public void atomUpsert() {
|
||||||
upsert(UpdateType.PATCH, ODataFormat.ATOM);
|
upsert(UpdateType.PATCH, ContentType.APPLICATION_ATOM_XML);
|
||||||
upsert(UpdateType.REPLACE, ODataFormat.ATOM);
|
upsert(UpdateType.REPLACE, ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonUpsert() {
|
public void jsonUpsert() {
|
||||||
upsert(UpdateType.PATCH, ODataFormat.JSON);
|
upsert(UpdateType.PATCH, ContentType.JSON);
|
||||||
upsert(UpdateType.REPLACE, ODataFormat.JSON);
|
upsert(UpdateType.REPLACE, ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onContained(final ODataFormat format) {
|
private void onContained(final ContentType contentType) {
|
||||||
final String newName = UUID.randomUUID().toString();
|
final String newName = UUID.randomUUID().toString();
|
||||||
final ClientEntity changes = getClient().getObjectFactory().newEntity(
|
final ClientEntity changes = getClient().getObjectFactory().newEntity(
|
||||||
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument"));
|
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument"));
|
||||||
|
@ -125,7 +125,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
||||||
appendNavigationSegment("MyPaymentInstruments").appendKeySegment(101901).build();
|
appendNavigationSegment("MyPaymentInstruments").appendKeySegment(101901).build();
|
||||||
final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
|
final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
|
||||||
getEntityUpdateRequest(uri, UpdateType.PATCH, changes);
|
getEntityUpdateRequest(uri, UpdateType.PATCH, changes);
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
final ODataEntityUpdateResponse<ClientEntity> res = req.execute();
|
final ODataEntityUpdateResponse<ClientEntity> res = req.execute();
|
||||||
assertEquals(204, res.getStatusCode());
|
assertEquals(204, res.getStatusCode());
|
||||||
|
@ -137,15 +137,15 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomOnContained() {
|
public void atomOnContained() {
|
||||||
onContained(ODataFormat.ATOM);
|
onContained(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonOnContained() {
|
public void jsonOnContained() {
|
||||||
onContained(ODataFormat.JSON);
|
onContained(ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bindOperation(final ODataFormat format) throws EdmPrimitiveTypeException {
|
private void bindOperation(final ContentType contentType) throws EdmPrimitiveTypeException {
|
||||||
final ClientEntity changes = getClient().getObjectFactory().newEntity(
|
final ClientEntity changes = getClient().getObjectFactory().newEntity(
|
||||||
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
|
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
|
||||||
final ClientLink parent = getClient().getObjectFactory().newEntityNavigationLink("Parent",
|
final ClientLink parent = getClient().getObjectFactory().newEntityNavigationLink("Parent",
|
||||||
|
@ -157,7 +157,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
||||||
appendEntitySetSegment("People").appendKeySegment(5).build();
|
appendEntitySetSegment("People").appendKeySegment(5).build();
|
||||||
final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
|
final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
|
||||||
getEntityUpdateRequest(uri, UpdateType.PATCH, changes);
|
getEntityUpdateRequest(uri, UpdateType.PATCH, changes);
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
final ODataEntityUpdateResponse<ClientEntity> res = req.execute();
|
final ODataEntityUpdateResponse<ClientEntity> res = req.execute();
|
||||||
assertEquals(204, res.getStatusCode());
|
assertEquals(204, res.getStatusCode());
|
||||||
|
@ -175,11 +175,11 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomBindOperation() throws EdmPrimitiveTypeException {
|
public void atomBindOperation() throws EdmPrimitiveTypeException {
|
||||||
bindOperation(ODataFormat.ATOM);
|
bindOperation(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonBindOperation() throws EdmPrimitiveTypeException {
|
public void jsonBindOperation() throws EdmPrimitiveTypeException {
|
||||||
bindOperation(ODataFormat.JSON);
|
bindOperation(ContentType.JSON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.util.Map;
|
||||||
import org.apache.olingo.client.api.communication.ODataClientErrorException;
|
import org.apache.olingo.client.api.communication.ODataClientErrorException;
|
||||||
import org.apache.olingo.commons.api.ODataError;
|
import org.apache.olingo.commons.api.ODataError;
|
||||||
import org.apache.olingo.commons.api.ODataErrorDetail;
|
import org.apache.olingo.commons.api.ODataErrorDetail;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class ErrorResponseTestITCase extends AbstractTestITCase {
|
public class ErrorResponseTestITCase extends AbstractTestITCase {
|
||||||
|
@ -39,7 +39,7 @@ public class ErrorResponseTestITCase extends AbstractTestITCase {
|
||||||
build();
|
build();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
read(ODataFormat.JSON, readURI);
|
read(ContentType.JSON, readURI);
|
||||||
fail("should have got exception");
|
fail("should have got exception");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
final ODataError err = ((ODataClientErrorException) ex).getODataError();
|
final ODataError err = ((ODataClientErrorException) ex).getODataError();
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.olingo.client.api.uri.FilterArgFactory;
|
||||||
import org.apache.olingo.client.api.uri.FilterFactory;
|
import org.apache.olingo.client.api.uri.FilterFactory;
|
||||||
import org.apache.olingo.client.api.uri.URIBuilder;
|
import org.apache.olingo.client.api.uri.URIBuilder;
|
||||||
import org.apache.olingo.client.api.uri.URIFilter;
|
import org.apache.olingo.client.api.uri.URIFilter;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class FilterFactoryTestITCase extends AbstractTestITCase {
|
public class FilterFactoryTestITCase extends AbstractTestITCase {
|
||||||
|
@ -50,7 +50,7 @@ public class FilterFactoryTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
final ODataEntitySetRequest<ClientEntitySet> req =
|
final ODataEntitySetRequest<ClientEntitySet> req =
|
||||||
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
|
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
|
||||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
req.setFormat(ContentType.JSON_FULL_METADATA);
|
||||||
|
|
||||||
final ClientEntitySet feed = req.execute().getBody();
|
final ClientEntitySet feed = req.execute().getBody();
|
||||||
assertEquals(3, feed.getEntities().size());
|
assertEquals(3, feed.getEntities().size());
|
||||||
|
|
|
@ -40,7 +40,7 @@ import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,7 +91,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
|
||||||
final URI uri = edmClient.newURIBuilder(testStaticServiceRootURL).
|
final URI uri = edmClient.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("Accounts").appendKeySegment(102).build();
|
appendEntitySetSegment("Accounts").appendKeySegment(102).build();
|
||||||
final ODataEntityRequest<ClientEntity> req = edmClient.getRetrieveRequestFactory().getEntityRequest(uri);
|
final ODataEntityRequest<ClientEntity> req = edmClient.getRetrieveRequestFactory().getEntityRequest(uri);
|
||||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
req.setFormat(ContentType.JSON_FULL_METADATA);
|
||||||
|
|
||||||
// request format (via Accept header) is set to full metadata
|
// request format (via Accept header) is set to full metadata
|
||||||
assertEquals("application/json;odata.metadata=full", req.getAccept());
|
assertEquals("application/json;odata.metadata=full", req.getAccept());
|
||||||
|
@ -148,7 +148,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
|
||||||
+ "\"GeographyPoint\": {\"type\": \"Point\",\"coordinates\":[142.1,64.1]}"
|
+ "\"GeographyPoint\": {\"type\": \"Point\",\"coordinates\":[142.1,64.1]}"
|
||||||
+ "}";
|
+ "}";
|
||||||
|
|
||||||
final ClientEntity entity = client.getReader().readEntity(IOUtils.toInputStream(fromSection71), ODataFormat.JSON);
|
final ClientEntity entity = client.getReader().readEntity(IOUtils.toInputStream(fromSection71), ContentType.JSON);
|
||||||
|
|
||||||
assertTrue(entity.getProperty("NullValue").hasNullValue());
|
assertTrue(entity.getProperty("NullValue").hasNullValue());
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
|
||||||
+ "}";
|
+ "}";
|
||||||
|
|
||||||
final ResWrap<Entity> entity =
|
final ResWrap<Entity> entity =
|
||||||
client.getDeserializer(ODataFormat.JSON).toEntity(IOUtils.toInputStream(fromSection45_1));
|
client.getDeserializer(ContentType.JSON).toEntity(IOUtils.toInputStream(fromSection45_1));
|
||||||
|
|
||||||
assertEquals("http://host/service/$metadata#Customers/$entity", entity.getContextURL().toASCIIString());
|
assertEquals("http://host/service/$metadata#Customers/$entity", entity.getContextURL().toASCIIString());
|
||||||
assertEquals("W/\"A1FF3E230954908F\"", entity.getMetadataETag());
|
assertEquals("W/\"A1FF3E230954908F\"", entity.getMetadataETag());
|
||||||
|
@ -241,7 +241,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
|
||||||
+ "}";
|
+ "}";
|
||||||
|
|
||||||
final ResWrap<EntityCollection> entitySet =
|
final ResWrap<EntityCollection> entitySet =
|
||||||
client.getDeserializer(ODataFormat.JSON).toEntitySet(IOUtils.toInputStream(fromSection45_2));
|
client.getDeserializer(ContentType.JSON).toEntitySet(IOUtils.toInputStream(fromSection45_2));
|
||||||
|
|
||||||
assertEquals(5, entitySet.getPayload().getCount(), 0);
|
assertEquals(5, entitySet.getPayload().getCount(), 0);
|
||||||
assertEquals("Customers?$expand=Orders&$skipToken=5", entitySet.getPayload().getNext().toASCIIString());
|
assertEquals("Customers?$expand=Orders&$skipToken=5", entitySet.getPayload().getNext().toASCIIString());
|
||||||
|
@ -271,7 +271,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
|
||||||
+ "}";
|
+ "}";
|
||||||
|
|
||||||
final ClientEntitySet entitySet = client.getReader().
|
final ClientEntitySet entitySet = client.getReader().
|
||||||
readEntitySet(IOUtils.toInputStream(sample), ODataFormat.JSON);
|
readEntitySet(IOUtils.toInputStream(sample), ContentType.JSON);
|
||||||
|
|
||||||
assertEquals(2, entitySet.getAnnotations().size());
|
assertEquals(2, entitySet.getAnnotations().size());
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
import org.apache.olingo.client.api.domain.ClientProperty;
|
import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
import org.apache.olingo.client.api.uri.URIBuilder;
|
import org.apache.olingo.client.api.uri.URIBuilder;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -50,20 +50,20 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
|
||||||
client.getConfiguration().setKeyAsSegment(false);
|
client.getConfiguration().setKeyAsSegment(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void read(final ODataFormat format) {
|
private void read(final ContentType contentType) {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testKeyAsSegmentServiceRootURL).
|
final URIBuilder uriBuilder = client.newURIBuilder(testKeyAsSegmentServiceRootURL).
|
||||||
appendEntitySetSegment("Accounts").appendKeySegment(101);
|
appendEntitySetSegment("Accounts").appendKeySegment(101);
|
||||||
|
|
||||||
final ODataEntityRequest<ClientEntity> req =
|
final ODataEntityRequest<ClientEntity> req =
|
||||||
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
||||||
final ClientEntity entity = res.getBody();
|
final ClientEntity entity = res.getBody();
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
|
|
||||||
// In JSON with minimal metadata, links are not provided
|
// In JSON with minimal metadata, links are not provided
|
||||||
if (format == ODataFormat.ATOM || format == ODataFormat.JSON_FULL_METADATA) {
|
if (contentType.equals(ContentType.APPLICATION_ATOM_XML) || contentType.equals(ContentType.JSON_FULL_METADATA)) {
|
||||||
assertFalse(entity.getEditLink().toASCIIString().contains("("));
|
assertFalse(entity.getEditLink().toASCIIString().contains("("));
|
||||||
assertFalse(entity.getEditLink().toASCIIString().contains(")"));
|
assertFalse(entity.getEditLink().toASCIIString().contains(")"));
|
||||||
}
|
}
|
||||||
|
@ -71,25 +71,25 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomRead() {
|
public void atomRead() {
|
||||||
read(ODataFormat.ATOM);
|
read(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonRead() {
|
public void jsonRead() {
|
||||||
read(ODataFormat.JSON);
|
read(ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomCreateAndDelete() {
|
public void atomCreateAndDelete() {
|
||||||
createAndDeleteOrder(testKeyAsSegmentServiceRootURL, ODataFormat.ATOM, 1000);
|
createAndDeleteOrder(testKeyAsSegmentServiceRootURL, ContentType.APPLICATION_ATOM_XML, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonCreateAndDelete() {
|
public void jsonCreateAndDelete() {
|
||||||
createAndDeleteOrder(testKeyAsSegmentServiceRootURL, ODataFormat.JSON_FULL_METADATA, 1001);
|
createAndDeleteOrder(testKeyAsSegmentServiceRootURL, ContentType.JSON_FULL_METADATA, 1001);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void update(final ODataFormat format) {
|
private void update(final ContentType contentType) {
|
||||||
final ClientEntity changes = getClient().getObjectFactory().newEntity(
|
final ClientEntity changes = getClient().getObjectFactory().newEntity(
|
||||||
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
|
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
|
||||||
final ClientProperty middleName = getClient().getObjectFactory().newPrimitiveProperty("MiddleName",
|
final ClientProperty middleName = getClient().getObjectFactory().newPrimitiveProperty("MiddleName",
|
||||||
|
@ -100,7 +100,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
|
||||||
appendEntitySetSegment("People").appendKeySegment(5).build();
|
appendEntitySetSegment("People").appendKeySegment(5).build();
|
||||||
final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
|
final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
|
||||||
getEntityUpdateRequest(uri, UpdateType.PATCH, changes);
|
getEntityUpdateRequest(uri, UpdateType.PATCH, changes);
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
final ODataEntityUpdateResponse<ClientEntity> res = req.execute();
|
final ODataEntityUpdateResponse<ClientEntity> res = req.execute();
|
||||||
assertEquals(204, res.getStatusCode());
|
assertEquals(204, res.getStatusCode());
|
||||||
|
@ -117,11 +117,11 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomUpdate() {
|
public void atomUpdate() {
|
||||||
update(ODataFormat.ATOM);
|
update(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonUpdate() {
|
public void jsonUpdate() {
|
||||||
update(ODataFormat.JSON);
|
update(ContentType.JSON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,18 +52,18 @@ import org.apache.olingo.client.core.ODataClientFactory;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class MediaEntityTestITCase extends AbstractTestITCase {
|
public class MediaEntityTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
private void read(final ODataClient client, final ODataFormat format) throws IOException {
|
private void read(final ODataClient client, final ContentType contentType) throws IOException {
|
||||||
final URIBuilder builder = client.newURIBuilder(testDemoServiceRootURL).
|
final URIBuilder builder = client.newURIBuilder(testDemoServiceRootURL).
|
||||||
appendEntitySetSegment("Advertisements").
|
appendEntitySetSegment("Advertisements").
|
||||||
appendKeySegment(UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7"));
|
appendKeySegment(UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7"));
|
||||||
final ODataEntityRequest<ClientEntity> entityReq =
|
final ODataEntityRequest<ClientEntity> entityReq =
|
||||||
client.getRetrieveRequestFactory().getEntityRequest(builder.build());
|
client.getRetrieveRequestFactory().getEntityRequest(builder.build());
|
||||||
entityReq.setFormat(format);
|
entityReq.setFormat(contentType);
|
||||||
|
|
||||||
final ClientEntity entity = entityReq.execute().getBody();
|
final ClientEntity entity = entityReq.execute().getBody();
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
|
@ -83,20 +83,20 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readAsAtom() throws IOException {
|
public void readAsAtom() throws IOException {
|
||||||
read(client, ODataFormat.ATOM);
|
read(client, ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readAsJSON() throws IOException {
|
public void readAsJSON() throws IOException {
|
||||||
read(ODataClientFactory.getEdmEnabledClient(testDemoServiceRootURL), ODataFormat.JSON);
|
read(ODataClientFactory.getEdmEnabledClient(testDemoServiceRootURL), ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readAsJSONFull() throws IOException {
|
public void readAsJSONFull() throws IOException {
|
||||||
read(client, ODataFormat.JSON_FULL_METADATA);
|
read(client, ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void create(final ODataFormat format) throws IOException {
|
private void create(final ContentType contentType) throws IOException {
|
||||||
final String random = RandomStringUtils.random(110);
|
final String random = RandomStringUtils.random(110);
|
||||||
final InputStream input = IOUtils.toInputStream(random);
|
final InputStream input = IOUtils.toInputStream(random);
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
final ODataEntityUpdateRequest<ClientEntity> updateReq = getClient().getCUDRequestFactory().
|
final ODataEntityUpdateRequest<ClientEntity> updateReq = getClient().getCUDRequestFactory().
|
||||||
getEntityUpdateRequest(createdLocation, UpdateType.PATCH, changes);
|
getEntityUpdateRequest(createdLocation, UpdateType.PATCH, changes);
|
||||||
updateReq.setFormat(format);
|
updateReq.setFormat(contentType);
|
||||||
|
|
||||||
final ODataEntityUpdateResponse<ClientEntity> updateRes = updateReq.execute();
|
final ODataEntityUpdateResponse<ClientEntity> updateRes = updateReq.execute();
|
||||||
assertEquals(204, updateRes.getStatusCode());
|
assertEquals(204, updateRes.getStatusCode());
|
||||||
|
@ -137,15 +137,15 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createAsAtom() throws IOException {
|
public void createAsAtom() throws IOException {
|
||||||
create(ODataFormat.ATOM);
|
create(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createAsJSON() throws IOException {
|
public void createAsJSON() throws IOException {
|
||||||
create(ODataFormat.JSON);
|
create(ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void update(final ODataFormat format) throws IOException, EdmPrimitiveTypeException {
|
private void update(final ContentType contentType) throws IOException, EdmPrimitiveTypeException {
|
||||||
final URI uri = client.newURIBuilder(testDemoServiceRootURL).
|
final URI uri = client.newURIBuilder(testDemoServiceRootURL).
|
||||||
appendEntitySetSegment("Advertisements").
|
appendEntitySetSegment("Advertisements").
|
||||||
appendKeySegment(UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7")).build();
|
appendKeySegment(UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7")).build();
|
||||||
|
@ -155,7 +155,7 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
|
||||||
// 1. update providing media content
|
// 1. update providing media content
|
||||||
final ODataMediaEntityUpdateRequest<ClientEntity> updateReq = client.getCUDRequestFactory().
|
final ODataMediaEntityUpdateRequest<ClientEntity> updateReq = client.getCUDRequestFactory().
|
||||||
getMediaEntityUpdateRequest(uri, IOUtils.toInputStream(random));
|
getMediaEntityUpdateRequest(uri, IOUtils.toInputStream(random));
|
||||||
updateReq.setFormat(format);
|
updateReq.setFormat(contentType);
|
||||||
|
|
||||||
final MediaEntityUpdateStreamManager<ClientEntity> streamManager = updateReq.payloadManager();
|
final MediaEntityUpdateStreamManager<ClientEntity> streamManager = updateReq.payloadManager();
|
||||||
final ODataMediaEntityUpdateResponse<ClientEntity> createRes = streamManager.getResponse();
|
final ODataMediaEntityUpdateResponse<ClientEntity> createRes = streamManager.getResponse();
|
||||||
|
@ -173,11 +173,11 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateAsAtom() throws IOException, EdmPrimitiveTypeException {
|
public void updateAsAtom() throws IOException, EdmPrimitiveTypeException {
|
||||||
update(ODataFormat.ATOM);
|
update(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateAsJSON() throws IOException, EdmPrimitiveTypeException {
|
public void updateAsJSON() throws IOException, EdmPrimitiveTypeException {
|
||||||
update(ODataFormat.JSON);
|
update(ContentType.JSON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
import org.apache.olingo.client.api.uri.URIBuilder;
|
import org.apache.olingo.client.api.uri.URIBuilder;
|
||||||
import org.apache.olingo.client.core.ODataClientFactory;
|
import org.apache.olingo.client.core.ODataClientFactory;
|
||||||
import org.apache.olingo.client.core.http.DefaultHttpClientFactory;
|
import org.apache.olingo.client.core.http.DefaultHttpClientFactory;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.fit.CXFOAuth2HttpClientFactory;
|
import org.apache.olingo.fit.CXFOAuth2HttpClientFactory;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
@ -76,13 +76,13 @@ public class OAuth2TestITCase extends AbstractTestITCase {
|
||||||
return _edmClient;
|
return _edmClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void read(final ODataClient client, final ODataFormat format) {
|
private void read(final ODataClient client, final ContentType contentType) {
|
||||||
final URIBuilder uriBuilder =
|
final URIBuilder uriBuilder =
|
||||||
client.newURIBuilder(testOAuth2ServiceRootURL).appendEntitySetSegment("Orders").appendKeySegment(8);
|
client.newURIBuilder(testOAuth2ServiceRootURL).appendEntitySetSegment("Orders").appendKeySegment(8);
|
||||||
|
|
||||||
final ODataEntityRequest<ClientEntity> req =
|
final ODataEntityRequest<ClientEntity> req =
|
||||||
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
||||||
assertEquals(200, res.getStatusCode());
|
assertEquals(200, res.getStatusCode());
|
||||||
|
@ -127,19 +127,19 @@ public class OAuth2TestITCase extends AbstractTestITCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readAsAtom() {
|
public void readAsAtom() {
|
||||||
read(getLocalClient(), ODataFormat.ATOM);
|
read(getLocalClient(), ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readAsFullJSON() {
|
public void readAsFullJSON() {
|
||||||
read(getLocalClient(), ODataFormat.JSON_FULL_METADATA);
|
read(getLocalClient(), ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readAsJSON() {
|
public void readAsJSON() {
|
||||||
read(getEdmClient(), ODataFormat.JSON);
|
read(getEdmClient(), ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createAndDelete() {
|
public void createAndDelete() {
|
||||||
createAndDeleteOrder(testOAuth2ServiceRootURL, ODataFormat.JSON, 1002);
|
createAndDeleteOrder(testOAuth2ServiceRootURL, ContentType.JSON, 1002);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.apache.olingo.commons.api.edm.Edm;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
import org.apache.olingo.commons.api.edm.EdmSchema;
|
import org.apache.olingo.commons.api.edm.EdmSchema;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class OpenTypeTestITCase extends AbstractTestITCase {
|
public class OpenTypeTestITCase extends AbstractTestITCase {
|
||||||
|
@ -53,32 +53,32 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
|
||||||
assertTrue(metadata.getEntityType(new FullQualifiedName(schema.getNamespace(), "RowIndex")).isOpenType());
|
assertTrue(metadata.getEntityType(new FullQualifiedName(schema.getNamespace(), "RowIndex")).isOpenType());
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClientEntity readRow(final ODataFormat format, final String uuid) {
|
private ClientEntity readRow(final ContentType contentType, final String uuid) {
|
||||||
final URIBuilder builder = getClient().newURIBuilder(testOpenTypeServiceRootURL).
|
final URIBuilder builder = getClient().newURIBuilder(testOpenTypeServiceRootURL).
|
||||||
appendEntitySetSegment("Row").appendKeySegment(UUID.fromString(uuid));
|
appendEntitySetSegment("Row").appendKeySegment(UUID.fromString(uuid));
|
||||||
return read(format, builder.build());
|
return read(contentType, builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void read(final ODataFormat format) {
|
private void read(final ContentType contentType) {
|
||||||
ClientEntity row = readRow(format, "71f7d0dc-ede4-45eb-b421-555a2aa1e58f");
|
ClientEntity row = readRow(contentType, "71f7d0dc-ede4-45eb-b421-555a2aa1e58f");
|
||||||
assertEquals(EdmPrimitiveTypeKind.Double, row.getProperty("Double").getPrimitiveValue().getTypeKind());
|
assertEquals(EdmPrimitiveTypeKind.Double, row.getProperty("Double").getPrimitiveValue().getTypeKind());
|
||||||
assertEquals(EdmPrimitiveTypeKind.Guid, row.getProperty("Id").getPrimitiveValue().getTypeKind());
|
assertEquals(EdmPrimitiveTypeKind.Guid, row.getProperty("Id").getPrimitiveValue().getTypeKind());
|
||||||
|
|
||||||
row = readRow(format, "672b8250-1e6e-4785-80cf-b94b572e42b3");
|
row = readRow(contentType, "672b8250-1e6e-4785-80cf-b94b572e42b3");
|
||||||
assertEquals(EdmPrimitiveTypeKind.Decimal, row.getProperty("Decimal").getPrimitiveValue().getTypeKind());
|
assertEquals(EdmPrimitiveTypeKind.Decimal, row.getProperty("Decimal").getPrimitiveValue().getTypeKind());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readAsAtom() {
|
public void readAsAtom() {
|
||||||
read(ODataFormat.ATOM);
|
read(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readAsJSON() {
|
public void readAsJSON() {
|
||||||
read(ODataFormat.JSON_FULL_METADATA);
|
read(ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cud(final ODataFormat format) {
|
private void cud(final ContentType contentType) {
|
||||||
final Integer id = 1426;
|
final Integer id = 1426;
|
||||||
|
|
||||||
ClientEntity rowIndex = getClient().getObjectFactory().newEntity(
|
ClientEntity rowIndex = getClient().getObjectFactory().newEntity(
|
||||||
|
@ -154,13 +154,13 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
|
||||||
final ODataEntityCreateRequest<ClientEntity> createReq = getClient().getCUDRequestFactory().
|
final ODataEntityCreateRequest<ClientEntity> createReq = getClient().getCUDRequestFactory().
|
||||||
getEntityCreateRequest(getClient().newURIBuilder(testOpenTypeServiceRootURL).
|
getEntityCreateRequest(getClient().newURIBuilder(testOpenTypeServiceRootURL).
|
||||||
appendEntitySetSegment("RowIndex").build(), rowIndex);
|
appendEntitySetSegment("RowIndex").build(), rowIndex);
|
||||||
createReq.setFormat(format);
|
createReq.setFormat(contentType);
|
||||||
final ODataEntityCreateResponse<ClientEntity> createRes = createReq.execute();
|
final ODataEntityCreateResponse<ClientEntity> createRes = createReq.execute();
|
||||||
assertEquals(201, createRes.getStatusCode());
|
assertEquals(201, createRes.getStatusCode());
|
||||||
|
|
||||||
final URIBuilder builder = getClient().newURIBuilder(testOpenTypeServiceRootURL).
|
final URIBuilder builder = getClient().newURIBuilder(testOpenTypeServiceRootURL).
|
||||||
appendEntitySetSegment("RowIndex").appendKeySegment(id);
|
appendEntitySetSegment("RowIndex").appendKeySegment(id);
|
||||||
rowIndex = read(format, builder.build());
|
rowIndex = read(contentType, builder.build());
|
||||||
assertNotNull(rowIndex);
|
assertNotNull(rowIndex);
|
||||||
assertEquals(EdmPrimitiveTypeKind.Int32, rowIndex.getProperty("Id").getPrimitiveValue().getTypeKind());
|
assertEquals(EdmPrimitiveTypeKind.Int32, rowIndex.getProperty("Id").getPrimitiveValue().getTypeKind());
|
||||||
assertEquals(EdmPrimitiveTypeKind.String, rowIndex.getProperty("aString").getPrimitiveValue().getTypeKind());
|
assertEquals(EdmPrimitiveTypeKind.String, rowIndex.getProperty("aString").getPrimitiveValue().getTypeKind());
|
||||||
|
@ -179,12 +179,12 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void cudAsAtom() {
|
public void cudAsAtom() {
|
||||||
cud(ODataFormat.ATOM);
|
cud(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void cudAsJSON() {
|
public void cudAsJSON() {
|
||||||
cud(ODataFormat.JSON_FULL_METADATA);
|
cud(ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,17 +37,17 @@ import org.apache.olingo.client.api.domain.ClientPrimitiveValue;
|
||||||
import org.apache.olingo.client.api.domain.ClientProperty;
|
import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
import org.apache.olingo.client.api.domain.ClientValue;
|
import org.apache.olingo.client.api.domain.ClientValue;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
private void functionImports(final ODataFormat format) throws EdmPrimitiveTypeException {
|
private void functionImports(final ContentType contentType) throws EdmPrimitiveTypeException {
|
||||||
// GetDefaultColor
|
// GetDefaultColor
|
||||||
final ODataInvokeRequest<ClientProperty> defaultColorReq = getClient().getInvokeRequestFactory().
|
final ODataInvokeRequest<ClientProperty> defaultColorReq = getClient().getInvokeRequestFactory().
|
||||||
getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
||||||
appendOperationCallSegment("GetDefaultColor").build(), ClientProperty.class);
|
appendOperationCallSegment("GetDefaultColor").build(), ClientProperty.class);
|
||||||
defaultColorReq.setFormat(format);
|
defaultColorReq.setFormat(contentType);
|
||||||
final ClientProperty defaultColor = defaultColorReq.execute().getBody();
|
final ClientProperty defaultColor = defaultColorReq.execute().getBody();
|
||||||
assertNotNull(defaultColor);
|
assertNotNull(defaultColor);
|
||||||
assertTrue(defaultColor.hasEnumValue());
|
assertTrue(defaultColor.hasEnumValue());
|
||||||
|
@ -61,7 +61,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
||||||
getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
||||||
appendOperationCallSegment("GetPerson2").build(), ClientEntity.class,
|
appendOperationCallSegment("GetPerson2").build(), ClientEntity.class,
|
||||||
Collections.<String, ClientValue> singletonMap("city", city));
|
Collections.<String, ClientValue> singletonMap("city", city));
|
||||||
person2Req.setFormat(format);
|
person2Req.setFormat(contentType);
|
||||||
final ClientEntity person2 = person2Req.execute().getBody();
|
final ClientEntity person2 = person2Req.execute().getBody();
|
||||||
assertNotNull(person2);
|
assertNotNull(person2);
|
||||||
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", person2.getTypeName().toString());
|
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", person2.getTypeName().toString());
|
||||||
|
@ -81,7 +81,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
||||||
getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
||||||
appendOperationCallSegment("GetPerson").build(), ClientEntity.class,
|
appendOperationCallSegment("GetPerson").build(), ClientEntity.class,
|
||||||
Collections.<String, ClientValue> singletonMap("address", address));
|
Collections.<String, ClientValue> singletonMap("address", address));
|
||||||
personReq.setFormat(format);
|
personReq.setFormat(contentType);
|
||||||
final ClientEntity person = personReq.execute().getBody();
|
final ClientEntity person = personReq.execute().getBody();
|
||||||
assertNotNull(person);
|
assertNotNull(person);
|
||||||
assertEquals(person2, person);
|
assertEquals(person2, person);
|
||||||
|
@ -90,7 +90,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
||||||
final ODataInvokeRequest<ClientEntitySet> productsReq = getClient().getInvokeRequestFactory()
|
final ODataInvokeRequest<ClientEntitySet> productsReq = getClient().getInvokeRequestFactory()
|
||||||
.getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
.getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
||||||
appendOperationCallSegment("GetAllProducts").build(), ClientEntitySet.class);
|
appendOperationCallSegment("GetAllProducts").build(), ClientEntitySet.class);
|
||||||
productsReq.setFormat(format);
|
productsReq.setFormat(contentType);
|
||||||
final ClientEntitySet products = productsReq.execute().getBody();
|
final ClientEntitySet products = productsReq.execute().getBody();
|
||||||
assertNotNull(products);
|
assertNotNull(products);
|
||||||
assertEquals(5, products.getEntities().size());
|
assertEquals(5, products.getEntities().size());
|
||||||
|
@ -103,7 +103,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
||||||
getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
||||||
appendOperationCallSegment("GetProductsByAccessLevel").build(), ClientProperty.class,
|
appendOperationCallSegment("GetProductsByAccessLevel").build(), ClientProperty.class,
|
||||||
Collections.<String, ClientValue> singletonMap("accessLevel", accessLevel));
|
Collections.<String, ClientValue> singletonMap("accessLevel", accessLevel));
|
||||||
prodByALReq.setFormat(format);
|
prodByALReq.setFormat(contentType);
|
||||||
final ClientProperty prodByAL = prodByALReq.execute().getBody();
|
final ClientProperty prodByAL = prodByALReq.execute().getBody();
|
||||||
assertNotNull(prodByAL);
|
assertNotNull(prodByAL);
|
||||||
assertTrue(prodByAL.hasCollectionValue());
|
assertTrue(prodByAL.hasCollectionValue());
|
||||||
|
@ -113,12 +113,12 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomFunctionImports() throws EdmPrimitiveTypeException {
|
public void atomFunctionImports() throws EdmPrimitiveTypeException {
|
||||||
functionImports(ODataFormat.ATOM);
|
functionImports(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonFunctionImports() throws EdmPrimitiveTypeException {
|
public void jsonFunctionImports() throws EdmPrimitiveTypeException {
|
||||||
functionImports(ODataFormat.JSON_FULL_METADATA);
|
functionImports(ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -182,14 +182,14 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
||||||
assertTrue(prodByAL.getCollectionValue().asJavaCollection().contains("Car"));
|
assertTrue(prodByAL.getCollectionValue().asJavaCollection().contains("Car"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void actionImports(final ODataFormat format) {
|
private void actionImports(final ContentType contentType) {
|
||||||
// Discount
|
// Discount
|
||||||
final ClientPrimitiveValue percentage = getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(22);
|
final ClientPrimitiveValue percentage = getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(22);
|
||||||
final ODataInvokeRequest<ClientNoContent> discountReq = getClient().getInvokeRequestFactory().
|
final ODataInvokeRequest<ClientNoContent> discountReq = getClient().getInvokeRequestFactory().
|
||||||
getActionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
getActionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
||||||
appendOperationCallSegment("Discount").build(), ClientNoContent.class,
|
appendOperationCallSegment("Discount").build(), ClientNoContent.class,
|
||||||
Collections.<String, ClientValue> singletonMap("percentage", percentage));
|
Collections.<String, ClientValue> singletonMap("percentage", percentage));
|
||||||
discountReq.setFormat(format);
|
discountReq.setFormat(contentType);
|
||||||
final ClientNoContent discount = discountReq.execute().getBody();
|
final ClientNoContent discount = discountReq.execute().getBody();
|
||||||
assertNotNull(discount);
|
assertNotNull(discount);
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
||||||
getActionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
getActionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
||||||
appendOperationCallSegment("ResetBossAddress").build(), ClientProperty.class,
|
appendOperationCallSegment("ResetBossAddress").build(), ClientProperty.class,
|
||||||
Collections.<String, ClientValue> singletonMap("address", address));
|
Collections.<String, ClientValue> singletonMap("address", address));
|
||||||
resetBossAddressReq.setFormat(format);
|
resetBossAddressReq.setFormat(contentType);
|
||||||
final ClientProperty resetBossAddress = resetBossAddressReq.execute().getBody();
|
final ClientProperty resetBossAddress = resetBossAddressReq.execute().getBody();
|
||||||
assertNotNull(resetBossAddress);
|
assertNotNull(resetBossAddress);
|
||||||
assertEquals(address, resetBossAddress.getComplexValue());
|
assertEquals(address, resetBossAddress.getComplexValue());
|
||||||
|
@ -215,12 +215,12 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomActionImports() {
|
public void atomActionImports() {
|
||||||
actionImports(ODataFormat.ATOM);
|
actionImports(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonActionImports() {
|
public void jsonActionImports() {
|
||||||
actionImports(ODataFormat.JSON_FULL_METADATA);
|
actionImports(ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -251,7 +251,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
||||||
assertEquals(address.getTypeName(), resetBossAddress.getComplexValue().getTypeName());
|
assertEquals(address.getTypeName(), resetBossAddress.getComplexValue().getTypeName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bossEmails(final ODataFormat format) {
|
private void bossEmails(final ContentType contentType) {
|
||||||
// ResetBossEmail
|
// ResetBossEmail
|
||||||
final ClientCollectionValue<ClientValue> emails =
|
final ClientCollectionValue<ClientValue> emails =
|
||||||
getClient().getObjectFactory().newCollectionValue("Collection(Edm.String)");
|
getClient().getObjectFactory().newCollectionValue("Collection(Edm.String)");
|
||||||
|
@ -261,7 +261,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
||||||
getActionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
getActionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
||||||
appendOperationCallSegment("ResetBossEmail").build(), ClientProperty.class,
|
appendOperationCallSegment("ResetBossEmail").build(), ClientProperty.class,
|
||||||
Collections.<String, ClientValue> singletonMap("emails", emails));
|
Collections.<String, ClientValue> singletonMap("emails", emails));
|
||||||
bossEmailsReq.setFormat(format);
|
bossEmailsReq.setFormat(contentType);
|
||||||
final ClientProperty bossEmails = bossEmailsReq.execute().getBody();
|
final ClientProperty bossEmails = bossEmailsReq.execute().getBody();
|
||||||
assertNotNull(bossEmails);
|
assertNotNull(bossEmails);
|
||||||
assertTrue(bossEmails.hasCollectionValue());
|
assertTrue(bossEmails.hasCollectionValue());
|
||||||
|
@ -273,7 +273,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
||||||
bossEmailsReq = getClient().getInvokeRequestFactory().getFunctionInvokeRequest(
|
bossEmailsReq = getClient().getInvokeRequestFactory().getFunctionInvokeRequest(
|
||||||
getClient().newURIBuilder(testStaticServiceRootURL).
|
getClient().newURIBuilder(testStaticServiceRootURL).
|
||||||
appendOperationCallSegment("GetBossEmails").build(), ClientProperty.class, params);
|
appendOperationCallSegment("GetBossEmails").build(), ClientProperty.class, params);
|
||||||
bossEmailsReq.setFormat(format);
|
bossEmailsReq.setFormat(contentType);
|
||||||
final ClientProperty bossEmailsViaGET = bossEmailsReq.execute().getBody();
|
final ClientProperty bossEmailsViaGET = bossEmailsReq.execute().getBody();
|
||||||
assertNotNull(bossEmailsViaGET);
|
assertNotNull(bossEmailsViaGET);
|
||||||
assertTrue(bossEmailsViaGET.hasCollectionValue());
|
assertTrue(bossEmailsViaGET.hasCollectionValue());
|
||||||
|
@ -284,11 +284,11 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomBossEmails() throws EdmPrimitiveTypeException {
|
public void atomBossEmails() throws EdmPrimitiveTypeException {
|
||||||
bossEmails(ODataFormat.ATOM);
|
bossEmails(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonBossEmails() throws EdmPrimitiveTypeException {
|
public void jsonBossEmails() throws EdmPrimitiveTypeException {
|
||||||
bossEmails(ODataFormat.JSON_FULL_METADATA);
|
bossEmails(ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,18 +37,18 @@ import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
import org.apache.olingo.client.api.domain.ClientProperty;
|
import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
import org.apache.olingo.client.api.domain.ClientValuable;
|
import org.apache.olingo.client.api.domain.ClientValuable;
|
||||||
import org.apache.olingo.client.api.uri.URIBuilder;
|
import org.apache.olingo.client.api.uri.URIBuilder;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class PropertyTestITCase extends AbstractTestITCase {
|
public class PropertyTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
private void _enum(final ODataClient client, final ODataFormat format) {
|
private void _enum(final ODataClient client, final ContentType contentType) {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("Products").appendKeySegment(5).appendPropertySegment("CoverColors");
|
appendEntitySetSegment("Products").appendKeySegment(5).appendPropertySegment("CoverColors");
|
||||||
final ODataPropertyRequest<ClientProperty> req = client.getRetrieveRequestFactory().
|
final ODataPropertyRequest<ClientProperty> req = client.getRetrieveRequestFactory().
|
||||||
getPropertyRequest(uriBuilder.build());
|
getPropertyRequest(uriBuilder.build());
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
final ClientProperty prop = req.execute().getBody();
|
final ClientProperty prop = req.execute().getBody();
|
||||||
assertNotNull(prop);
|
assertNotNull(prop);
|
||||||
|
@ -59,25 +59,25 @@ public class PropertyTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void enumFromXML() {
|
public void enumFromXML() {
|
||||||
_enum(client, ODataFormat.XML);
|
_enum(client, ContentType.APPLICATION_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void enumFromJSON() {
|
public void enumFromJSON() {
|
||||||
_enum(edmClient, ODataFormat.JSON);
|
_enum(edmClient, ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void enumFromFullJSON() {
|
public void enumFromFullJSON() {
|
||||||
_enum(client, ODataFormat.JSON_FULL_METADATA);
|
_enum(client, ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void geospatial(final ODataClient client, final ODataFormat format) {
|
private void geospatial(final ODataClient client, final ContentType contentType) {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Home");
|
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Home");
|
||||||
final ODataPropertyRequest<ClientProperty> req = client.getRetrieveRequestFactory().
|
final ODataPropertyRequest<ClientProperty> req = client.getRetrieveRequestFactory().
|
||||||
getPropertyRequest(uriBuilder.build());
|
getPropertyRequest(uriBuilder.build());
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
final ClientProperty prop = req.execute().getBody();
|
final ClientProperty prop = req.execute().getBody();
|
||||||
assertNotNull(prop);
|
assertNotNull(prop);
|
||||||
|
@ -87,25 +87,25 @@ public class PropertyTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void geospatialFromXML() {
|
public void geospatialFromXML() {
|
||||||
geospatial(client, ODataFormat.XML);
|
geospatial(client, ContentType.APPLICATION_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void geospatialFromJSON() {
|
public void geospatialFromJSON() {
|
||||||
geospatial(edmClient, ODataFormat.JSON);
|
geospatial(edmClient, ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void geospatialFromFullJSON() {
|
public void geospatialFromFullJSON() {
|
||||||
geospatial(client, ODataFormat.JSON_FULL_METADATA);
|
geospatial(client, ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void complex(final ODataClient client, final ODataFormat format) {
|
private void complex(final ODataClient client, final ContentType contentType) {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("Customers").appendKeySegment(2).appendPropertySegment("HomeAddress");
|
appendEntitySetSegment("Customers").appendKeySegment(2).appendPropertySegment("HomeAddress");
|
||||||
final ODataPropertyRequest<ClientProperty> req = client.getRetrieveRequestFactory().
|
final ODataPropertyRequest<ClientProperty> req = client.getRetrieveRequestFactory().
|
||||||
getPropertyRequest(uriBuilder.build());
|
getPropertyRequest(uriBuilder.build());
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
final ClientProperty prop = req.execute().getBody();
|
final ClientProperty prop = req.execute().getBody();
|
||||||
assertNotNull(prop);
|
assertNotNull(prop);
|
||||||
|
@ -116,26 +116,26 @@ public class PropertyTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void complexFromXML() {
|
public void complexFromXML() {
|
||||||
complex(client, ODataFormat.XML);
|
complex(client, ContentType.APPLICATION_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void complexFromJSON() {
|
public void complexFromJSON() {
|
||||||
complex(edmClient, ODataFormat.JSON);
|
complex(edmClient, ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void complexFromFullJSON() {
|
public void complexFromFullJSON() {
|
||||||
complex(client, ODataFormat.JSON_FULL_METADATA);
|
complex(client, ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateComplexProperty(final ODataFormat format, final UpdateType type) throws IOException {
|
private void updateComplexProperty(final ContentType contentType, final UpdateType type) throws IOException {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("Customers").appendKeySegment(1).appendPropertySegment("HomeAddress");
|
appendEntitySetSegment("Customers").appendKeySegment(1).appendPropertySegment("HomeAddress");
|
||||||
|
|
||||||
ODataPropertyRequest<ClientProperty> retrieveReq =
|
ODataPropertyRequest<ClientProperty> retrieveReq =
|
||||||
client.getRetrieveRequestFactory().getPropertyRequest(uriBuilder.build());
|
client.getRetrieveRequestFactory().getPropertyRequest(uriBuilder.build());
|
||||||
retrieveReq.setFormat(format);
|
retrieveReq.setFormat(contentType);
|
||||||
|
|
||||||
ODataRetrieveResponse<ClientProperty> retrieveRes = retrieveReq.execute();
|
ODataRetrieveResponse<ClientProperty> retrieveRes = retrieveReq.execute();
|
||||||
assertEquals(200, retrieveRes.getStatusCode());
|
assertEquals(200, retrieveRes.getStatusCode());
|
||||||
|
@ -153,13 +153,13 @@ public class PropertyTestITCase extends AbstractTestITCase {
|
||||||
} else {
|
} else {
|
||||||
assertEquals(type.getMethod(), updateReq.getMethod());
|
assertEquals(type.getMethod(), updateReq.getMethod());
|
||||||
}
|
}
|
||||||
updateReq.setFormat(format);
|
updateReq.setFormat(contentType);
|
||||||
|
|
||||||
final ODataPropertyUpdateResponse updateRes = updateReq.execute();
|
final ODataPropertyUpdateResponse updateRes = updateReq.execute();
|
||||||
assertEquals(204, updateRes.getStatusCode());
|
assertEquals(204, updateRes.getStatusCode());
|
||||||
|
|
||||||
retrieveReq = client.getRetrieveRequestFactory().getPropertyRequest(uriBuilder.build());
|
retrieveReq = client.getRetrieveRequestFactory().getPropertyRequest(uriBuilder.build());
|
||||||
retrieveReq.setFormat(format);
|
retrieveReq.setFormat(contentType);
|
||||||
|
|
||||||
retrieveRes = retrieveReq.execute();
|
retrieveRes = retrieveReq.execute();
|
||||||
assertEquals(200, retrieveRes.getStatusCode());
|
assertEquals(200, retrieveRes.getStatusCode());
|
||||||
|
@ -170,7 +170,7 @@ public class PropertyTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void patchComplexPropertyAsJSON() throws IOException {
|
public void patchComplexPropertyAsJSON() throws IOException {
|
||||||
updateComplexProperty(ODataFormat.JSON_FULL_METADATA, UpdateType.PATCH);
|
updateComplexProperty(ContentType.JSON_FULL_METADATA, UpdateType.PATCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
import org.apache.olingo.client.api.domain.ClientValuable;
|
import org.apache.olingo.client.api.domain.ClientValuable;
|
||||||
import org.apache.olingo.client.api.uri.URIBuilder;
|
import org.apache.olingo.client.api.uri.URIBuilder;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class PropertyValueTestITCase extends AbstractTestITCase {
|
public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||||
|
@ -42,7 +42,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PersonID");
|
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PersonID");
|
||||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
req.setFormat(ContentType.TEXT_PLAIN);
|
||||||
assertEquals("5", req.execute().getBody().toString());
|
assertEquals("5", req.execute().getBody().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("IsRegistered");
|
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("IsRegistered");
|
||||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
req.setFormat(ContentType.TEXT_PLAIN);
|
||||||
assertEquals("true", req.execute().getBody().toString());
|
assertEquals("true", req.execute().getBody().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("FirstName");
|
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("FirstName");
|
||||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
req.setFormat(ContentType.TEXT_PLAIN);
|
||||||
assertEquals("Peter", req.execute().getBody().toString());
|
assertEquals("Peter", req.execute().getBody().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("Orders").appendKeySegment(8).appendPropertySegment("OrderDate");
|
appendEntitySetSegment("Orders").appendKeySegment(8).appendPropertySegment("OrderDate");
|
||||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
req.setFormat(ContentType.TEXT_PLAIN);
|
||||||
final ClientPrimitiveValue property = req.execute().getBody();
|
final ClientPrimitiveValue property = req.execute().getBody();
|
||||||
assertEquals("2011-03-04T16:03:57Z", property.toString());
|
assertEquals("2011-03-04T16:03:57Z", property.toString());
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Height");
|
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Height");
|
||||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
req.setFormat(ContentType.TEXT_PLAIN);
|
||||||
final ClientPrimitiveValue property = req.execute().getBody();
|
final ClientPrimitiveValue property = req.execute().getBody();
|
||||||
assertEquals("179", property.toString());
|
assertEquals("179", property.toString());
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
|
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
|
||||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
req.setFormat(ContentType.TEXT_PLAIN);
|
||||||
final ClientPrimitiveValue property = req.execute().getBody();
|
final ClientPrimitiveValue property = req.execute().getBody();
|
||||||
assertEquals("fi653p3+MklA/LdoBlhWgnMTUUEo8tEgtbMXnF0a3CUNL9BZxXpSRiD9ebTnmNR0zWPjJ"
|
assertEquals("fi653p3+MklA/LdoBlhWgnMTUUEo8tEgtbMXnF0a3CUNL9BZxXpSRiD9ebTnmNR0zWPjJ"
|
||||||
+ "VIDx4tdmCnq55XrJh+RW9aI/b34wAogK3kcORw=", property.toString());
|
+ "VIDx4tdmCnq55XrJh+RW9aI/b34wAogK3kcORw=", property.toString());
|
||||||
|
@ -100,7 +100,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
|
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
|
||||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||||
req.setAccept(ODataFormat.ATOM.getContentType().toContentTypeString());
|
req.setAccept(ContentType.APPLICATION_ATOM_XML.toContentTypeString());
|
||||||
req.execute().getBody();
|
req.execute().getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
|
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
|
||||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||||
req.setAccept(ODataFormat.XML.getContentType().toContentTypeString());
|
req.setAccept(ContentType.APPLICATION_XML.toContentTypeString());
|
||||||
req.execute().getBody();
|
req.execute().getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Numbers");
|
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Numbers");
|
||||||
final ODataPropertyRequest<ClientProperty> req = client.getRetrieveRequestFactory().
|
final ODataPropertyRequest<ClientProperty> req = client.getRetrieveRequestFactory().
|
||||||
getPropertyRequest(uriBuilder.build());
|
getPropertyRequest(uriBuilder.build());
|
||||||
req.setFormat(ODataFormat.XML);
|
req.setFormat(ContentType.APPLICATION_XML);
|
||||||
final ClientProperty property = req.execute().getBody();
|
final ClientProperty property = req.execute().getBody();
|
||||||
// cast to workaround JDK 6 bug, fixed in JDK 7
|
// cast to workaround JDK 6 bug, fixed in JDK 7
|
||||||
assertTrue(((ClientValuable) property).getValue().isCollection());
|
assertTrue(((ClientValuable) property).getValue().isCollection());
|
||||||
|
@ -131,7 +131,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("HomeAddress");
|
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("HomeAddress");
|
||||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
req.setFormat(ContentType.TEXT_PLAIN);
|
||||||
final ClientPrimitiveValue property = req.execute().getBody();
|
final ClientPrimitiveValue property = req.execute().getBody();
|
||||||
assertTrue(StringUtils.isBlank(property.toString()));
|
assertTrue(StringUtils.isBlank(property.toString()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.apache.olingo.client.api.domain.ClientInlineEntitySet;
|
||||||
import org.apache.olingo.client.api.uri.QueryOption;
|
import org.apache.olingo.client.api.uri.QueryOption;
|
||||||
import org.apache.olingo.client.api.uri.URIBuilder;
|
import org.apache.olingo.client.api.uri.URIBuilder;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,12 +128,12 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
final ODataEntityRequest<ClientEntity> req =
|
final ODataEntityRequest<ClientEntity> req =
|
||||||
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||||
req.setFormat(ODataFormat.ATOM);
|
req.setFormat(ContentType.APPLICATION_ATOM_XML);
|
||||||
|
|
||||||
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
||||||
assertNotNull(res);
|
assertNotNull(res);
|
||||||
assertTrue(res.getContentType().replaceAll(" ", "").
|
assertTrue(res.getContentType().replaceAll(" ", "").
|
||||||
startsWith(ODataFormat.JSON.getContentType().toContentTypeString()));
|
startsWith(ContentType.JSON.toContentTypeString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -25,15 +25,15 @@ import java.net.URI;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataServiceDocumentRequest;
|
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.communication.response.ODataRetrieveResponse;
|
||||||
import org.apache.olingo.client.api.domain.ClientServiceDocument;
|
import org.apache.olingo.client.api.domain.ClientServiceDocument;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class ServiceDocumentTestITCase extends AbstractTestITCase {
|
public class ServiceDocumentTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
private void retrieveServiceDocument(final ODataFormat format) {
|
private void retrieveServiceDocument(final ContentType contentType) {
|
||||||
final ODataServiceDocumentRequest req =
|
final ODataServiceDocumentRequest req =
|
||||||
client.getRetrieveRequestFactory().getServiceDocumentRequest(testStaticServiceRootURL);
|
client.getRetrieveRequestFactory().getServiceDocumentRequest(testStaticServiceRootURL);
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
final ODataRetrieveResponse<ClientServiceDocument> res = req.execute();
|
final ODataRetrieveResponse<ClientServiceDocument> res = req.execute();
|
||||||
assertEquals(200, res.getStatusCode());
|
assertEquals(200, res.getStatusCode());
|
||||||
|
@ -53,11 +53,11 @@ public class ServiceDocumentTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void retrieveServiceDocumentAsXML() {
|
public void retrieveServiceDocumentAsXML() {
|
||||||
retrieveServiceDocument(ODataFormat.XML);
|
retrieveServiceDocument(ContentType.APPLICATION_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void retrieveServiceDocumentAsJSON() {
|
public void retrieveServiceDocumentAsJSON() {
|
||||||
retrieveServiceDocument(ODataFormat.JSON);
|
retrieveServiceDocument(ContentType.JSON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,16 +36,16 @@ import org.apache.olingo.client.api.domain.ClientValuable;
|
||||||
import org.apache.olingo.client.api.uri.URIBuilder;
|
import org.apache.olingo.client.api.uri.URIBuilder;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class SingletonTestITCase extends AbstractTestITCase {
|
public class SingletonTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
private void read(final ODataClient client, final ODataFormat format) throws EdmPrimitiveTypeException {
|
private void read(final ODataClient client, final ContentType contentType) throws EdmPrimitiveTypeException {
|
||||||
final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company");
|
final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company");
|
||||||
final ODataEntityRequest<ClientSingleton> singleton =
|
final ODataEntityRequest<ClientSingleton> singleton =
|
||||||
client.getRetrieveRequestFactory().getSingletonRequest(builder.build());
|
client.getRetrieveRequestFactory().getSingletonRequest(builder.build());
|
||||||
singleton.setFormat(format);
|
singleton.setFormat(contentType);
|
||||||
final ClientSingleton company = singleton.execute().getBody();
|
final ClientSingleton company = singleton.execute().getBody();
|
||||||
assertNotNull(company);
|
assertNotNull(company);
|
||||||
|
|
||||||
|
@ -58,26 +58,26 @@ public class SingletonTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readFromAtom() throws EdmPrimitiveTypeException {
|
public void readFromAtom() throws EdmPrimitiveTypeException {
|
||||||
read(client, ODataFormat.ATOM);
|
read(client, ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readFromJSON() throws EdmPrimitiveTypeException {
|
public void readFromJSON() throws EdmPrimitiveTypeException {
|
||||||
read(edmClient, ODataFormat.JSON);
|
read(edmClient, ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readfromJSONFull() throws EdmPrimitiveTypeException {
|
public void readfromJSONFull() throws EdmPrimitiveTypeException {
|
||||||
read(client, ODataFormat.JSON_FULL_METADATA);
|
read(client, ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readWithAnnotations(final ODataClient client, final ODataFormat format)
|
private void readWithAnnotations(final ODataClient client, final ContentType contentType)
|
||||||
throws EdmPrimitiveTypeException {
|
throws EdmPrimitiveTypeException {
|
||||||
|
|
||||||
final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Boss");
|
final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Boss");
|
||||||
final ODataEntityRequest<ClientSingleton> singleton =
|
final ODataEntityRequest<ClientSingleton> singleton =
|
||||||
client.getRetrieveRequestFactory().getSingletonRequest(builder.build());
|
client.getRetrieveRequestFactory().getSingletonRequest(builder.build());
|
||||||
singleton.setFormat(format);
|
singleton.setFormat(contentType);
|
||||||
singleton.setPrefer(client.newPreferences().includeAnnotations("*"));
|
singleton.setPrefer(client.newPreferences().includeAnnotations("*"));
|
||||||
final ClientSingleton boss = singleton.execute().getBody();
|
final ClientSingleton boss = singleton.execute().getBody();
|
||||||
assertNotNull(boss);
|
assertNotNull(boss);
|
||||||
|
@ -89,20 +89,20 @@ public class SingletonTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readWithAnnotationsFromAtom() throws EdmPrimitiveTypeException {
|
public void readWithAnnotationsFromAtom() throws EdmPrimitiveTypeException {
|
||||||
readWithAnnotations(client, ODataFormat.ATOM);
|
readWithAnnotations(client, ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readWithAnnotationsFromJSON() throws EdmPrimitiveTypeException {
|
public void readWithAnnotationsFromJSON() throws EdmPrimitiveTypeException {
|
||||||
readWithAnnotations(edmClient, ODataFormat.JSON);
|
readWithAnnotations(edmClient, ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readWithAnnotationsFromJSONFull() throws EdmPrimitiveTypeException {
|
public void readWithAnnotationsFromJSONFull() throws EdmPrimitiveTypeException {
|
||||||
readWithAnnotations(client, ODataFormat.JSON_FULL_METADATA);
|
readWithAnnotations(client, ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void update(final ODataFormat format) throws EdmPrimitiveTypeException {
|
private void update(final ContentType contentType) throws EdmPrimitiveTypeException {
|
||||||
final ClientSingleton changes = getClient().getObjectFactory().newSingleton(
|
final ClientSingleton changes = getClient().getObjectFactory().newSingleton(
|
||||||
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Company"));
|
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Company"));
|
||||||
changes.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("Revenue",
|
changes.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("Revenue",
|
||||||
|
@ -111,7 +111,7 @@ public class SingletonTestITCase extends AbstractTestITCase {
|
||||||
final URI uri = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company").build();
|
final URI uri = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company").build();
|
||||||
final ODataEntityUpdateRequest<ClientSingleton> req = getClient().getCUDRequestFactory().
|
final ODataEntityUpdateRequest<ClientSingleton> req = getClient().getCUDRequestFactory().
|
||||||
getSingletonUpdateRequest(uri, UpdateType.PATCH, changes);
|
getSingletonUpdateRequest(uri, UpdateType.PATCH, changes);
|
||||||
req.setFormat(format);
|
req.setFormat(contentType);
|
||||||
|
|
||||||
final ODataEntityUpdateResponse<ClientSingleton> res = req.execute();
|
final ODataEntityUpdateResponse<ClientSingleton> res = req.execute();
|
||||||
assertEquals(204, res.getStatusCode());
|
assertEquals(204, res.getStatusCode());
|
||||||
|
@ -124,12 +124,12 @@ public class SingletonTestITCase extends AbstractTestITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomUpdate() throws EdmPrimitiveTypeException {
|
public void atomUpdate() throws EdmPrimitiveTypeException {
|
||||||
update(ODataFormat.ATOM);
|
update(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonUpdate() throws EdmPrimitiveTypeException {
|
public void jsonUpdate() throws EdmPrimitiveTypeException {
|
||||||
update(ODataFormat.JSON);
|
update(ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.util.concurrent.ExecutorService;
|
||||||
import org.apache.olingo.client.api.http.HttpClientFactory;
|
import org.apache.olingo.client.api.http.HttpClientFactory;
|
||||||
import org.apache.olingo.client.api.http.HttpUriRequestFactory;
|
import org.apache.olingo.client.api.http.HttpUriRequestFactory;
|
||||||
import org.apache.olingo.commons.api.format.ContentType;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration wrapper.
|
* Configuration wrapper.
|
||||||
|
@ -49,16 +48,15 @@ public interface Configuration {
|
||||||
* JSON_FULL_METADATA format will be used as default.
|
* JSON_FULL_METADATA format will be used as default.
|
||||||
*
|
*
|
||||||
* @return configured OData format for AtomPub if specified; JSON_FULL_METADATA format otherwise.
|
* @return configured OData format for AtomPub if specified; JSON_FULL_METADATA format otherwise.
|
||||||
* @see ODataFormat#JSON_FULL_METADATA
|
|
||||||
*/
|
*/
|
||||||
ODataFormat getDefaultPubFormat();
|
ContentType getDefaultPubFormat();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the default OData format for AtomPub exchanges.
|
* Sets the default OData format for AtomPub exchanges.
|
||||||
*
|
*
|
||||||
* @param format default format.
|
* @param format default format.
|
||||||
*/
|
*/
|
||||||
void setDefaultPubFormat(ODataFormat format);
|
void setDefaultPubFormat(ContentType format);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the configured OData format. This value depends on what is returned from <tt>getDefaultPubFormat()</tt>.
|
* Gets the configured OData format. This value depends on what is returned from <tt>getDefaultPubFormat()</tt>.
|
||||||
|
@ -66,23 +64,22 @@ public interface Configuration {
|
||||||
* @return configured OData format
|
* @return configured OData format
|
||||||
* @see #getDefaultPubFormat()
|
* @see #getDefaultPubFormat()
|
||||||
*/
|
*/
|
||||||
ODataFormat getDefaultFormat();
|
ContentType getDefaultFormat();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the configured OData value format. If this configuration parameter doesn't exist the TEXT format will be used
|
* Gets the configured OData value format. If this configuration parameter doesn't exist the TEXT format will be used
|
||||||
* as default.
|
* as default.
|
||||||
*
|
*
|
||||||
* @return configured OData value format if specified; TEXT_PLAIN format otherwise.
|
* @return configured OData value format if specified; TEXT_PLAIN format otherwise.
|
||||||
* @see ODataFormat#TEXT_PLAIN
|
|
||||||
*/
|
*/
|
||||||
ODataFormat getDefaultValueFormat();
|
ContentType getDefaultValueFormat();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the default OData value format.
|
* Sets the default OData value format.
|
||||||
*
|
*
|
||||||
* @param format default format.
|
* @param format default format.
|
||||||
*/
|
*/
|
||||||
void setDefaultValueFormat(ODataFormat format);
|
void setDefaultValueFormat(ContentType format);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the configured OData media format. If this configuration parameter doesn't exist the APPLICATION_OCTET_STREAM
|
* Gets the configured OData media format. If this configuration parameter doesn't exist the APPLICATION_OCTET_STREAM
|
||||||
|
@ -90,14 +87,14 @@ public interface Configuration {
|
||||||
*
|
*
|
||||||
* @return configured OData media format if specified; APPLICATION_OCTET_STREAM format otherwise.
|
* @return configured OData media format if specified; APPLICATION_OCTET_STREAM format otherwise.
|
||||||
*/
|
*/
|
||||||
ODataFormat getDefaultMediaFormat();
|
ContentType getDefaultMediaFormat();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the default OData media format.
|
* Sets the default OData media format.
|
||||||
*
|
*
|
||||||
* @param format default format.
|
* @param format default format.
|
||||||
*/
|
*/
|
||||||
void setDefaultMediaFormat(ODataFormat format);
|
void setDefaultMediaFormat(ContentType format);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the HttpClient factory to be used for executing requests.
|
* Gets the HttpClient factory to be used for executing requests.
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.olingo.client.api.communication.request.batch.BatchRequestFact
|
||||||
import org.apache.olingo.client.api.communication.request.cud.CUDRequestFactory;
|
import org.apache.olingo.client.api.communication.request.cud.CUDRequestFactory;
|
||||||
import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory;
|
import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.RetrieveRequestFactory;
|
import org.apache.olingo.client.api.communication.request.retrieve.RetrieveRequestFactory;
|
||||||
|
import org.apache.olingo.client.api.domain.ClientObjectFactory;
|
||||||
import org.apache.olingo.client.api.serialization.ClientODataDeserializer;
|
import org.apache.olingo.client.api.serialization.ClientODataDeserializer;
|
||||||
import org.apache.olingo.client.api.serialization.ODataBinder;
|
import org.apache.olingo.client.api.serialization.ODataBinder;
|
||||||
import org.apache.olingo.client.api.serialization.ODataReader;
|
import org.apache.olingo.client.api.serialization.ODataReader;
|
||||||
|
@ -33,9 +34,9 @@ import org.apache.olingo.client.api.serialization.ODataWriter;
|
||||||
import org.apache.olingo.client.api.uri.FilterFactory;
|
import org.apache.olingo.client.api.uri.FilterFactory;
|
||||||
import org.apache.olingo.client.api.uri.SearchFactory;
|
import org.apache.olingo.client.api.uri.SearchFactory;
|
||||||
import org.apache.olingo.client.api.uri.URIBuilder;
|
import org.apache.olingo.client.api.uri.URIBuilder;
|
||||||
import org.apache.olingo.client.api.domain.ClientObjectFactory;
|
|
||||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
|
|
||||||
|
|
||||||
public interface ODataClient {
|
public interface ODataClient {
|
||||||
|
|
||||||
|
@ -47,13 +48,13 @@ public interface ODataClient {
|
||||||
|
|
||||||
ODataPreferences newPreferences();
|
ODataPreferences newPreferences();
|
||||||
|
|
||||||
ODataSerializer getSerializer(ODataFormat format);
|
ODataSerializer getSerializer(ContentType contentType);
|
||||||
|
|
||||||
ODataWriter getWriter();
|
ODataWriter getWriter();
|
||||||
|
|
||||||
InvokeRequestFactory getInvokeRequestFactory();
|
InvokeRequestFactory getInvokeRequestFactory();
|
||||||
|
|
||||||
ClientODataDeserializer getDeserializer(ODataFormat format);
|
ClientODataDeserializer getDeserializer(ContentType contentType);
|
||||||
|
|
||||||
ODataReader getReader();
|
ODataReader getReader();
|
||||||
|
|
||||||
|
|
|
@ -18,12 +18,12 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.olingo.client.api;
|
package org.apache.olingo.client.api;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.edm.Edm;
|
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
|
import org.apache.olingo.commons.api.edm.Edm;
|
||||||
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Builder to create an ODataClient for the API client library.
|
* Builder to create an ODataClient for the API client library.
|
||||||
|
@ -142,7 +142,7 @@ public final class ODataClientBuilder {
|
||||||
loadClass(EdmEnabledODataClient.class, clientImplClassName,
|
loadClass(EdmEnabledODataClient.class, clientImplClassName,
|
||||||
new Class[] { String.class, Edm.class, String.class },
|
new Class[] { String.class, Edm.class, String.class },
|
||||||
new Object[] { serviceRoot, edm, metadataETag });
|
new Object[] { serviceRoot, edm, metadataETag });
|
||||||
instance.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
instance.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.olingo.client.api.communication.request;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.apache.olingo.client.api.communication.response.ODataResponse;
|
import org.apache.olingo.client.api.communication.response.ODataResponse;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic OData request.
|
* Basic OData request.
|
||||||
|
@ -45,9 +45,9 @@ public interface ODataBasicRequest<T extends ODataResponse> extends ODataRequest
|
||||||
Future<T> asyncExecute();
|
Future<T> asyncExecute();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override configured request format.
|
* Override configured request Content-Type.
|
||||||
*
|
*
|
||||||
* @param format request format.
|
* @param contentType request Content-Type.
|
||||||
*/
|
*/
|
||||||
void setFormat(ODataFormat format);
|
void setFormat(ContentType contentType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.olingo.client.api.communication.request.streamed;
|
||||||
import org.apache.olingo.client.api.communication.request.ODataPayloadManager;
|
import org.apache.olingo.client.api.communication.request.ODataPayloadManager;
|
||||||
import org.apache.olingo.client.api.communication.request.ODataStreamedRequest;
|
import org.apache.olingo.client.api.communication.request.ODataStreamedRequest;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataResponse;
|
import org.apache.olingo.client.api.communication.response.ODataResponse;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class representing a request concerning a streamed entity.
|
* Abstract class representing a request concerning a streamed entity.
|
||||||
|
@ -38,13 +38,12 @@ public interface ODataStreamedEntityRequest<V extends ODataResponse, T extends O
|
||||||
* @return the configured format (or default if not specified).
|
* @return the configured format (or default if not specified).
|
||||||
* @see org.apache.olingo.client.api.Configuration#getDefaultPubFormat()
|
* @see org.apache.olingo.client.api.Configuration#getDefaultPubFormat()
|
||||||
*/
|
*/
|
||||||
ODataFormat getFormat();
|
ContentType getFormat();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override configured request format.
|
* Override configured request format.
|
||||||
*
|
*
|
||||||
* @param format request format.
|
* @param format request format.
|
||||||
* @see ODataFormat
|
|
||||||
*/
|
*/
|
||||||
void setFormat(final ODataFormat format);
|
void setFormat(final ContentType contentType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
||||||
import org.apache.olingo.commons.api.Constants;
|
import org.apache.olingo.commons.api.Constants;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public class ClientEntitySetIterator<ES extends ClientEntitySet, E extends Clien
|
||||||
|
|
||||||
private final InputStream stream;
|
private final InputStream stream;
|
||||||
|
|
||||||
private final ODataFormat format;
|
private final ContentType contentType;
|
||||||
|
|
||||||
private ES entitySet;
|
private ES entitySet;
|
||||||
|
|
||||||
|
@ -75,17 +75,17 @@ public class ClientEntitySetIterator<ES extends ClientEntitySet, E extends Clien
|
||||||
*
|
*
|
||||||
* @param odataClient client instance getting this request
|
* @param odataClient client instance getting this request
|
||||||
* @param stream source stream.
|
* @param stream source stream.
|
||||||
* @param format OData format.
|
* @param contentType OData format.
|
||||||
*/
|
*/
|
||||||
public ClientEntitySetIterator(final ODataClient odataClient, final InputStream stream,
|
public ClientEntitySetIterator(final ODataClient odataClient, final InputStream stream,
|
||||||
final ODataFormat format) {
|
final ContentType contentType) {
|
||||||
|
|
||||||
this.odataClient = odataClient;
|
this.odataClient = odataClient;
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
this.format = format;
|
this.contentType = contentType;
|
||||||
this.osEntitySet = new ByteArrayOutputStream();
|
this.osEntitySet = new ByteArrayOutputStream();
|
||||||
|
|
||||||
if (format == ODataFormat.ATOM) {
|
if(contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML)) {
|
||||||
namespaces = getAllElementAttributes(stream, "feed", osEntitySet);
|
namespaces = getAllElementAttributes(stream, "feed", osEntitySet);
|
||||||
} else {
|
} else {
|
||||||
namespaces = null;
|
namespaces = null;
|
||||||
|
@ -110,7 +110,7 @@ public class ClientEntitySetIterator<ES extends ClientEntitySet, E extends Clien
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
if (available && cached == null) {
|
if (available && cached == null) {
|
||||||
if (format == ODataFormat.ATOM) {
|
if (contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML)) {
|
||||||
cached = nextAtomEntityFromEntitySet(stream, osEntitySet, namespaces);
|
cached = nextAtomEntityFromEntitySet(stream, osEntitySet, namespaces);
|
||||||
} else {
|
} else {
|
||||||
cached = nextJSONEntityFromEntitySet(stream, osEntitySet);
|
cached = nextJSONEntityFromEntitySet(stream, osEntitySet);
|
||||||
|
@ -120,7 +120,7 @@ public class ClientEntitySetIterator<ES extends ClientEntitySet, E extends Clien
|
||||||
available = false;
|
available = false;
|
||||||
try {
|
try {
|
||||||
entitySet = (ES) odataClient.getReader().
|
entitySet = (ES) odataClient.getReader().
|
||||||
readEntitySet(new ByteArrayInputStream(osEntitySet.toByteArray()), format);
|
readEntitySet(new ByteArrayInputStream(osEntitySet.toByteArray()), contentType);
|
||||||
} catch (final ODataDeserializerException e) {
|
} catch (final ODataDeserializerException e) {
|
||||||
available = false;
|
available = false;
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ public class ClientEntitySetIterator<ES extends ClientEntitySet, E extends Clien
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c >= 0) {
|
if (c >= 0) {
|
||||||
jsonEntity = odataClient.getDeserializer(ODataFormat.JSON).toEntity(
|
jsonEntity = odataClient.getDeserializer(ContentType.JSON).toEntity(
|
||||||
new ByteArrayInputStream(entity.toByteArray()));
|
new ByteArrayInputStream(entity.toByteArray()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -240,7 +240,7 @@ public class ClientEntitySetIterator<ES extends ClientEntitySet, E extends Clien
|
||||||
entity.write(">".getBytes(Constants.UTF8));
|
entity.write(">".getBytes(Constants.UTF8));
|
||||||
|
|
||||||
if (consume(input, "</entry>", entity, true) >= 0) {
|
if (consume(input, "</entry>", entity, true) >= 0) {
|
||||||
atomEntity = odataClient.getDeserializer(ODataFormat.ATOM).
|
atomEntity = odataClient.getDeserializer(ContentType.APPLICATION_ATOM_XML).
|
||||||
toEntity(new ByteArrayInputStream(entity.toByteArray()));
|
toEntity(new ByteArrayInputStream(entity.toByteArray()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
import org.apache.olingo.commons.api.edm.EdmType;
|
import org.apache.olingo.commons.api.edm.EdmType;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface ClientPrimitiveValue extends ClientValue {
|
public interface ClientPrimitiveValue extends ClientValue {
|
||||||
|
@ -54,6 +55,8 @@ public interface ClientPrimitiveValue extends ClientValue {
|
||||||
ClientPrimitiveValue buildGuid(UUID value);
|
ClientPrimitiveValue buildGuid(UUID value);
|
||||||
|
|
||||||
ClientPrimitiveValue buildBinary(byte[] value);
|
ClientPrimitiveValue buildBinary(byte[] value);
|
||||||
|
|
||||||
|
ClientPrimitiveValue buildDecimal(BigDecimal value);
|
||||||
}
|
}
|
||||||
|
|
||||||
EdmPrimitiveTypeKind getTypeKind();
|
EdmPrimitiveTypeKind getTypeKind();
|
||||||
|
|
|
@ -21,15 +21,16 @@ package org.apache.olingo.client.api.serialization;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
|
||||||
import org.apache.olingo.client.api.domain.ClientEntity;
|
import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
||||||
import org.apache.olingo.commons.api.ODataError;
|
|
||||||
import org.apache.olingo.client.api.domain.ClientProperty;
|
import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
import org.apache.olingo.client.api.domain.ClientServiceDocument;
|
import org.apache.olingo.client.api.domain.ClientServiceDocument;
|
||||||
|
import org.apache.olingo.commons.api.ODataError;
|
||||||
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.edm.Edm;
|
import org.apache.olingo.commons.api.edm.Edm;
|
||||||
import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
|
import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OData reader.
|
* OData reader.
|
||||||
|
@ -60,51 +61,52 @@ public interface ODataReader {
|
||||||
* Parses an OData service document.
|
* Parses an OData service document.
|
||||||
*
|
*
|
||||||
* @param input stream to de-serialize.
|
* @param input stream to de-serialize.
|
||||||
* @param format de-serialize as XML or JSON
|
* @param contentType de-serialize as XML or JSON
|
||||||
* @return List of URIs.
|
* @return List of URIs.
|
||||||
* @throws ODataDeserializerException
|
* @throws ODataDeserializerException
|
||||||
*/
|
*/
|
||||||
ClientServiceDocument readServiceDocument(InputStream input, ODataFormat format) throws ODataDeserializerException;
|
ClientServiceDocument readServiceDocument(InputStream input, ContentType contentType)
|
||||||
|
throws ODataDeserializerException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* De-Serializes a stream into an OData entity set.
|
* De-Serializes a stream into an OData entity set.
|
||||||
*
|
*
|
||||||
* @param input stream to de-serialize.
|
* @param input stream to de-serialize.
|
||||||
* @param format de-serialize format
|
* @param contentType de-serialize format
|
||||||
* @return de-serialized entity set.
|
* @return de-serialized entity set.
|
||||||
* @throws ODataDeserializerException
|
* @throws ODataDeserializerException
|
||||||
*/
|
*/
|
||||||
ClientEntitySet readEntitySet(InputStream input, ODataFormat format) throws ODataDeserializerException;
|
ClientEntitySet readEntitySet(InputStream input, ContentType contentType) throws ODataDeserializerException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a stream taking care to de-serializes the first OData entity found.
|
* Parses a stream taking care to de-serializes the first OData entity found.
|
||||||
*
|
*
|
||||||
* @param input stream to de-serialize.
|
* @param input stream to de-serialize.
|
||||||
* @param format de-serialize format
|
* @param contentType de-serialize format
|
||||||
* @return entity de-serialized.
|
* @return entity de-serialized.
|
||||||
* @throws ODataDeserializerException
|
* @throws ODataDeserializerException
|
||||||
*/
|
*/
|
||||||
ClientEntity readEntity(InputStream input, ODataFormat format) throws ODataDeserializerException;
|
ClientEntity readEntity(InputStream input, ContentType contentType) throws ODataDeserializerException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a stream taking care to de-serialize the first OData entity property found.
|
* Parses a stream taking care to de-serialize the first OData entity property found.
|
||||||
*
|
*
|
||||||
* @param input stream to de-serialize.
|
* @param input stream to de-serialize.
|
||||||
* @param format de-serialize as XML or JSON
|
* @param contentType de-serialize as XML or JSON
|
||||||
* @return OData entity property de-serialized.
|
* @return OData entity property de-serialized.
|
||||||
* @throws ODataDeserializerException
|
* @throws ODataDeserializerException
|
||||||
*/
|
*/
|
||||||
ClientProperty readProperty(InputStream input, ODataFormat format) throws ODataDeserializerException;
|
ClientProperty readProperty(InputStream input, ContentType contentType) throws ODataDeserializerException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a stream into an OData error.
|
* Parses a stream into an OData error.
|
||||||
*
|
*
|
||||||
* @param inputStream stream to de-serialize.
|
* @param inputStream stream to de-serialize.
|
||||||
* @param format format
|
* @param contentType format
|
||||||
* @return OData error.
|
* @return OData error.
|
||||||
* @throws ODataDeserializerException
|
* @throws ODataDeserializerException
|
||||||
*/
|
*/
|
||||||
ODataError readError(InputStream inputStream, ODataFormat format) throws ODataDeserializerException;
|
ODataError readError(InputStream inputStream, ContentType contentType) throws ODataDeserializerException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a stream into the object type specified by the given reference.
|
* Parses a stream into the object type specified by the given reference.
|
||||||
|
|
|
@ -22,11 +22,11 @@ import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
|
||||||
import org.apache.olingo.client.api.domain.ClientEntity;
|
import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
import org.apache.olingo.client.api.domain.ClientProperty;
|
|
||||||
import org.apache.olingo.client.api.domain.ClientLink;
|
import org.apache.olingo.client.api.domain.ClientLink;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OData writer.
|
* OData writer.
|
||||||
|
@ -41,54 +41,54 @@ public interface ODataWriter {
|
||||||
* Writes a collection of OData entities.
|
* Writes a collection of OData entities.
|
||||||
*
|
*
|
||||||
* @param entities entities to be serialized.
|
* @param entities entities to be serialized.
|
||||||
* @param format serialization format.
|
* @param contentType serialization format.
|
||||||
* @return stream of serialized objects.
|
* @return stream of serialized objects.
|
||||||
* @throws ODataSerializerException
|
* @throws ODataSerializerException
|
||||||
*/
|
*/
|
||||||
InputStream writeEntities(Collection<ClientEntity> entities, ODataFormat format)
|
InputStream writeEntities(Collection<ClientEntity> entities, ContentType contentType)
|
||||||
throws ODataSerializerException;
|
throws ODataSerializerException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serializes a single OData entity.
|
* Serializes a single OData entity.
|
||||||
*
|
*
|
||||||
* @param entity entity to be serialized.
|
* @param entity entity to be serialized.
|
||||||
* @param format serialization format.
|
* @param contentType serialization format.
|
||||||
* @return stream of serialized object.
|
* @return stream of serialized object.
|
||||||
* @throws ODataSerializerException
|
* @throws ODataSerializerException
|
||||||
*/
|
*/
|
||||||
InputStream writeEntity(ClientEntity entity, ODataFormat format)
|
InputStream writeEntity(ClientEntity entity, ContentType format)
|
||||||
throws ODataSerializerException;
|
throws ODataSerializerException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a single OData entity property.
|
* Writes a single OData entity property.
|
||||||
*
|
*
|
||||||
* @param property entity property to be serialized.
|
* @param property entity property to be serialized.
|
||||||
* @param format serialization format.
|
* @param contentType serialization format.
|
||||||
* @return stream of serialized object.
|
* @return stream of serialized object.
|
||||||
* @throws ODataSerializerException
|
* @throws ODataSerializerException
|
||||||
*/
|
*/
|
||||||
InputStream writeProperty(ClientProperty property, ODataFormat format)
|
InputStream writeProperty(ClientProperty property, ContentType format)
|
||||||
throws ODataSerializerException;
|
throws ODataSerializerException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes an OData link.
|
* Writes an OData link.
|
||||||
*
|
*
|
||||||
* @param link link to be serialized.
|
* @param link link to be serialized.
|
||||||
* @param format serialization format.
|
* @param contentType serialization format.
|
||||||
* @return stream of serialized object.
|
* @return stream of serialized object.
|
||||||
* @throws ODataSerializerException
|
* @throws ODataSerializerException
|
||||||
*/
|
*/
|
||||||
InputStream writeLink(ClientLink link, ODataFormat format)
|
InputStream writeLink(ClientLink link, ContentType format)
|
||||||
throws ODataSerializerException;
|
throws ODataSerializerException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a entity reference
|
* Writes a entity reference
|
||||||
*
|
*
|
||||||
* @param reference reference to be serialized
|
* @param reference reference to be serialized
|
||||||
* @param format serialization format
|
* @param contentType serialization format
|
||||||
* @return stream of serialized objects
|
* @return stream of serialized objects
|
||||||
* @throws ODataSerializerException
|
* @throws ODataSerializerException
|
||||||
*/
|
*/
|
||||||
InputStream writeReference(ResWrap<URI> reference, ODataFormat format)
|
InputStream writeReference(ResWrap<URI> reference, ContentType format)
|
||||||
throws ODataSerializerException;
|
throws ODataSerializerException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ import org.apache.olingo.client.api.http.HttpUriRequestFactory;
|
||||||
import org.apache.olingo.client.core.http.DefaultHttpClientFactory;
|
import org.apache.olingo.client.core.http.DefaultHttpClientFactory;
|
||||||
import org.apache.olingo.client.core.http.DefaultHttpUriRequestFactory;
|
import org.apache.olingo.client.core.http.DefaultHttpUriRequestFactory;
|
||||||
import org.apache.olingo.commons.api.format.ContentType;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
|
||||||
|
|
||||||
public class ConfigurationImpl implements Configuration {
|
public class ConfigurationImpl implements Configuration {
|
||||||
|
|
||||||
|
@ -96,39 +95,39 @@ public class ConfigurationImpl implements Configuration {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataFormat getDefaultPubFormat() {
|
public ContentType getDefaultPubFormat() {
|
||||||
return (ODataFormat) getProperty(DEFAULT_PUB_FORMAT, ODataFormat.JSON_FULL_METADATA);
|
return (ContentType) getProperty(DEFAULT_PUB_FORMAT, ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultPubFormat(final ODataFormat format) {
|
public void setDefaultPubFormat(final ContentType contentType) {
|
||||||
setProperty(DEFAULT_PUB_FORMAT, format);
|
setProperty(DEFAULT_PUB_FORMAT, contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataFormat getDefaultFormat() {
|
public ContentType getDefaultFormat() {
|
||||||
final ODataFormat format = getDefaultPubFormat();
|
final ContentType contenType = getDefaultPubFormat();
|
||||||
return format == ODataFormat.ATOM ? ODataFormat.XML : format;
|
return contenType == ContentType.APPLICATION_ATOM_XML ? ContentType.APPLICATION_XML : contenType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataFormat getDefaultValueFormat() {
|
public ContentType getDefaultValueFormat() {
|
||||||
return (ODataFormat) getProperty(DEFAULT_VALUE_FORMAT, ODataFormat.TEXT_PLAIN);
|
return (ContentType) getProperty(DEFAULT_VALUE_FORMAT, ContentType.TEXT_PLAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultValueFormat(final ODataFormat format) {
|
public void setDefaultValueFormat(final ContentType contentType) {
|
||||||
setProperty(DEFAULT_VALUE_FORMAT, format);
|
setProperty(DEFAULT_VALUE_FORMAT, contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataFormat getDefaultMediaFormat() {
|
public ContentType getDefaultMediaFormat() {
|
||||||
return (ODataFormat) getProperty(DEFAULT_VALUE_FORMAT, ODataFormat.APPLICATION_OCTET_STREAM);
|
return (ContentType) getProperty(DEFAULT_VALUE_FORMAT, ContentType.APPLICATION_OCTET_STREAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultMediaFormat(final ODataFormat format) {
|
public void setDefaultMediaFormat(final ContentType contentType) {
|
||||||
setProperty(DEFAULT_MEDIA_FORMAT, format);
|
setProperty(DEFAULT_MEDIA_FORMAT, contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.olingo.client.core;
|
||||||
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.commons.api.edm.Edm;
|
import org.apache.olingo.commons.api.edm.Edm;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
|
|
||||||
public final class ODataClientFactory {
|
public final class ODataClientFactory {
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public final class ODataClientFactory {
|
||||||
|
|
||||||
final EdmEnabledODataClient instance =
|
final EdmEnabledODataClient instance =
|
||||||
new EdmEnabledODataClientImpl(serviceRoot, edm, metadataETag);
|
new EdmEnabledODataClientImpl(serviceRoot, edm, metadataETag);
|
||||||
instance.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
instance.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.olingo.client.api.communication.request.batch.BatchRequestFact
|
||||||
import org.apache.olingo.client.api.communication.request.cud.CUDRequestFactory;
|
import org.apache.olingo.client.api.communication.request.cud.CUDRequestFactory;
|
||||||
import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory;
|
import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.RetrieveRequestFactory;
|
import org.apache.olingo.client.api.communication.request.retrieve.RetrieveRequestFactory;
|
||||||
|
import org.apache.olingo.client.api.domain.ClientObjectFactory;
|
||||||
import org.apache.olingo.client.api.serialization.ClientODataDeserializer;
|
import org.apache.olingo.client.api.serialization.ClientODataDeserializer;
|
||||||
import org.apache.olingo.client.api.serialization.ODataBinder;
|
import org.apache.olingo.client.api.serialization.ODataBinder;
|
||||||
import org.apache.olingo.client.api.serialization.ODataReader;
|
import org.apache.olingo.client.api.serialization.ODataReader;
|
||||||
|
@ -42,6 +43,7 @@ import org.apache.olingo.client.core.communication.request.batch.BatchRequestFac
|
||||||
import org.apache.olingo.client.core.communication.request.cud.CUDRequestFactoryImpl;
|
import org.apache.olingo.client.core.communication.request.cud.CUDRequestFactoryImpl;
|
||||||
import org.apache.olingo.client.core.communication.request.invoke.InvokeRequestFactoryImpl;
|
import org.apache.olingo.client.core.communication.request.invoke.InvokeRequestFactoryImpl;
|
||||||
import org.apache.olingo.client.core.communication.request.retrieve.RetrieveRequestFactoryImpl;
|
import org.apache.olingo.client.core.communication.request.retrieve.RetrieveRequestFactoryImpl;
|
||||||
|
import org.apache.olingo.client.core.domain.ClientObjectFactoryImpl;
|
||||||
import org.apache.olingo.client.core.serialization.AtomSerializer;
|
import org.apache.olingo.client.core.serialization.AtomSerializer;
|
||||||
import org.apache.olingo.client.core.serialization.ClientODataDeserializerImpl;
|
import org.apache.olingo.client.core.serialization.ClientODataDeserializerImpl;
|
||||||
import org.apache.olingo.client.core.serialization.JsonSerializer;
|
import org.apache.olingo.client.core.serialization.JsonSerializer;
|
||||||
|
@ -50,10 +52,8 @@ import org.apache.olingo.client.core.serialization.ODataReaderImpl;
|
||||||
import org.apache.olingo.client.core.serialization.ODataWriterImpl;
|
import org.apache.olingo.client.core.serialization.ODataWriterImpl;
|
||||||
import org.apache.olingo.client.core.uri.FilterFactoryImpl;
|
import org.apache.olingo.client.core.uri.FilterFactoryImpl;
|
||||||
import org.apache.olingo.client.core.uri.URIBuilderImpl;
|
import org.apache.olingo.client.core.uri.URIBuilderImpl;
|
||||||
import org.apache.olingo.client.api.domain.ClientObjectFactory;
|
|
||||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.client.core.domain.ClientObjectFactoryImpl;
|
|
||||||
|
|
||||||
public class ODataClientImpl implements ODataClient {
|
public class ODataClientImpl implements ODataClient {
|
||||||
|
|
||||||
|
@ -125,15 +125,16 @@ public class ODataClientImpl implements ODataClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClientODataDeserializer getDeserializer(final ODataFormat format) {
|
public ClientODataDeserializer getDeserializer(final ContentType contentType) {
|
||||||
return new ClientODataDeserializerImpl(false, format);
|
return new ClientODataDeserializerImpl(false, contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataSerializer getSerializer(final ODataFormat format) {
|
public ODataSerializer getSerializer(final ContentType contentType) {
|
||||||
return format == ODataFormat.ATOM || format == ODataFormat.XML ?
|
return contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML,
|
||||||
new AtomSerializer() :
|
ContentType.APPLICATION_XML) ?
|
||||||
new JsonSerializer(false, format);
|
new AtomSerializer() : new JsonSerializer(false, contentType);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* or more contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
* to you under the Apache License, Version 2.0 (the
|
* to you under the Apache License, Version 2.0 (the
|
||||||
* "License"); you may not use this file except in compliance
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
@ -24,10 +24,11 @@ import org.apache.http.StatusLine;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.ODataClientErrorException;
|
import org.apache.olingo.client.api.communication.ODataClientErrorException;
|
||||||
import org.apache.olingo.client.api.communication.ODataServerErrorException;
|
import org.apache.olingo.client.api.communication.ODataServerErrorException;
|
||||||
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
|
||||||
import org.apache.olingo.commons.api.ODataRuntimeException;
|
|
||||||
import org.apache.olingo.commons.api.ODataError;
|
import org.apache.olingo.commons.api.ODataError;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.ODataRuntimeException;
|
||||||
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
|
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -43,29 +44,29 @@ public final class ODataErrorResponseChecker {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ODataRuntimeException checkResponse(
|
public static ODataRuntimeException checkResponse(
|
||||||
final ODataClient odataClient, final StatusLine statusLine, final InputStream entity,
|
final ODataClient odataClient, final StatusLine statusLine, final InputStream entity,
|
||||||
final String accept) {
|
final String accept) {
|
||||||
|
|
||||||
ODataRuntimeException result = null;
|
ODataRuntimeException result = null;
|
||||||
|
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
result = new ODataClientErrorException(statusLine);
|
result = new ODataClientErrorException(statusLine);
|
||||||
} else {
|
} else {
|
||||||
final ODataFormat format = accept.contains("xml") ? ODataFormat.XML : ODataFormat.JSON;
|
final ContentType contentType = accept.contains("xml") ? ContentType.APPLICATION_ATOM_XML : ContentType.JSON;
|
||||||
|
|
||||||
ODataError error;
|
ODataError error;
|
||||||
try {
|
try {
|
||||||
error = odataClient.getReader().readError(entity, format);
|
error = odataClient.getReader().readError(entity, contentType);
|
||||||
} catch (final RuntimeException e) {
|
} catch (final RuntimeException e) {
|
||||||
LOG.warn("Error deserializing error response", e);
|
LOG.warn("Error deserializing error response", e);
|
||||||
error = getGenericError(
|
error = getGenericError(
|
||||||
statusLine.getStatusCode(),
|
statusLine.getStatusCode(),
|
||||||
statusLine.getReasonPhrase());
|
statusLine.getReasonPhrase());
|
||||||
} catch (final ODataDeserializerException e) {
|
} catch (final ODataDeserializerException e) {
|
||||||
LOG.warn("Error deserializing error response", e);
|
LOG.warn("Error deserializing error response", e);
|
||||||
error = getGenericError(
|
error = getGenericError(
|
||||||
statusLine.getStatusCode(),
|
statusLine.getStatusCode(),
|
||||||
statusLine.getReasonPhrase());
|
statusLine.getReasonPhrase());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (statusLine.getStatusCode() >= 500) {
|
if (statusLine.getStatusCode() >= 500) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.apache.olingo.client.api.communication.request.ODataBasicRequest;
|
||||||
import org.apache.olingo.client.api.communication.request.ODataStreamer;
|
import org.apache.olingo.client.api.communication.request.ODataStreamer;
|
||||||
import org.apache.olingo.client.api.communication.request.batch.ODataBatchRequest;
|
import org.apache.olingo.client.api.communication.request.batch.ODataBatchRequest;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataResponse;
|
import org.apache.olingo.client.api.communication.response.ODataResponse;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,9 +55,9 @@ public abstract class AbstractODataBasicRequest<T extends ODataResponse>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFormat(final ODataFormat format) {
|
public void setFormat(final ContentType contentType) {
|
||||||
if (format != null) {
|
if (contentType != null) {
|
||||||
final String formatString = format.getContentType().toContentTypeString();
|
final String formatString = contentType.toContentTypeString();
|
||||||
setAccept(formatString);
|
setAccept(formatString);
|
||||||
setContentType(formatString);
|
setContentType(formatString);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ import org.apache.olingo.client.api.communication.request.ODataStreamer;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataResponse;
|
import org.apache.olingo.client.api.communication.response.ODataResponse;
|
||||||
import org.apache.olingo.client.api.http.HttpClientException;
|
import org.apache.olingo.client.api.http.HttpClientException;
|
||||||
import org.apache.olingo.commons.api.ODataRuntimeException;
|
import org.apache.olingo.commons.api.ODataRuntimeException;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,7 +102,7 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD
|
||||||
this.request = odataClient.getConfiguration().getHttpUriRequestFactory().create(this.method, uri);
|
this.request = odataClient.getConfiguration().getHttpUriRequestFactory().create(this.method, uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract ODataFormat getDefaultFormat();
|
public abstract ContentType getDefaultFormat();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URI getURI() {
|
public URI getURI() {
|
||||||
|
@ -178,7 +178,7 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD
|
||||||
public String getAccept() {
|
public String getAccept() {
|
||||||
final String acceptHead = odataHeaders.getHeader(HeaderName.accept);
|
final String acceptHead = odataHeaders.getHeader(HeaderName.accept);
|
||||||
return StringUtils.isBlank(acceptHead)
|
return StringUtils.isBlank(acceptHead)
|
||||||
? getDefaultFormat().getContentType().toContentTypeString()
|
? getDefaultFormat().toContentTypeString()
|
||||||
: acceptHead;
|
: acceptHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD
|
||||||
public String getContentType() {
|
public String getContentType() {
|
||||||
final String contentTypeHead = odataHeaders.getHeader(HeaderName.contentType);
|
final String contentTypeHead = odataHeaders.getHeader(HeaderName.contentType);
|
||||||
return StringUtils.isBlank(contentTypeHead)
|
return StringUtils.isBlank(contentTypeHead)
|
||||||
? getDefaultFormat().getContentType().toContentTypeString()
|
? getDefaultFormat().toContentTypeString()
|
||||||
: contentTypeHead;
|
: contentTypeHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest
|
||||||
import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
|
import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
|
||||||
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
|
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
|
||||||
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
|
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,7 +42,7 @@ public class ODataDeleteRequestImpl extends AbstractODataBasicRequest<ODataDelet
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataFormat getDefaultFormat() {
|
public ContentType getDefaultFormat() {
|
||||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,15 +28,15 @@ import org.apache.http.client.methods.HttpPost;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
|
import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
|
import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
|
||||||
|
import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
|
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
|
||||||
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
|
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
|
||||||
import org.apache.olingo.client.core.uri.URIUtils;
|
import org.apache.olingo.client.core.uri.URIUtils;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.client.api.domain.ClientEntity;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
||||||
import org.apache.olingo.client.api.serialization.ODataSerializerException;
|
import org.apache.olingo.client.api.serialization.ODataSerializerException;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
|
||||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,14 +66,14 @@ public class ODataEntityCreateRequestImpl<E extends ClientEntity>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataFormat getDefaultFormat() {
|
public ContentType getDefaultFormat() {
|
||||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected InputStream getPayload() {
|
protected InputStream getPayload() {
|
||||||
try {
|
try {
|
||||||
return odataClient.getWriter().writeEntity(entity, ODataFormat.fromString(getContentType()));
|
return odataClient.getWriter().writeEntity(entity, ContentType.parse(getContentType()));
|
||||||
} catch (final ODataSerializerException e) {
|
} catch (final ODataSerializerException e) {
|
||||||
throw new IllegalArgumentException(e);
|
throw new IllegalArgumentException(e);
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ public class ODataEntityCreateRequestImpl<E extends ClientEntity>
|
||||||
public E getBody() {
|
public E getBody() {
|
||||||
if (resEntity == null) {
|
if (resEntity == null) {
|
||||||
try {
|
try {
|
||||||
final ResWrap<Entity> resource = odataClient.getDeserializer(ODataFormat.fromString(getAccept())).
|
final ResWrap<Entity> resource = odataClient.getDeserializer(ContentType.parse(getAccept())).
|
||||||
toEntity(getRawResponse());
|
toEntity(getRawResponse());
|
||||||
|
|
||||||
resEntity = (E) odataClient.getBinder().getODataEntity(resource);
|
resEntity = (E) odataClient.getBinder().getODataEntity(resource);
|
||||||
|
|
|
@ -29,15 +29,15 @@ import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
|
import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
|
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
|
||||||
|
import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
|
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
|
||||||
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
|
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
|
||||||
import org.apache.olingo.client.core.uri.URIUtils;
|
import org.apache.olingo.client.core.uri.URIUtils;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.client.api.domain.ClientEntity;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
||||||
import org.apache.olingo.client.api.serialization.ODataSerializerException;
|
import org.apache.olingo.client.api.serialization.ODataSerializerException;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
|
||||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,14 +70,14 @@ public class ODataEntityUpdateRequestImpl<E extends ClientEntity>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataFormat getDefaultFormat() {
|
public ContentType getDefaultFormat() {
|
||||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected InputStream getPayload() {
|
protected InputStream getPayload() {
|
||||||
try {
|
try {
|
||||||
return odataClient.getWriter().writeEntity(changes, ODataFormat.fromString(getContentType()));
|
return odataClient.getWriter().writeEntity(changes, ContentType.parse(getContentType()));
|
||||||
} catch (final ODataSerializerException e) {
|
} catch (final ODataSerializerException e) {
|
||||||
throw new IllegalArgumentException(e);
|
throw new IllegalArgumentException(e);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ public class ODataEntityUpdateRequestImpl<E extends ClientEntity>
|
||||||
public E getBody() {
|
public E getBody() {
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
try {
|
try {
|
||||||
final ResWrap<Entity> resource = odataClient.getDeserializer(ODataFormat.fromString(getAccept())).
|
final ResWrap<Entity> resource = odataClient.getDeserializer(ContentType.parse(getAccept())).
|
||||||
toEntity(getRawResponse());
|
toEntity(getRawResponse());
|
||||||
|
|
||||||
entity = (E) odataClient.getBinder().getODataEntity(resource);
|
entity = (E) odataClient.getBinder().getODataEntity(resource);
|
||||||
|
|
|
@ -28,15 +28,15 @@ import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
|
import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataPropertyUpdateResponse;
|
import org.apache.olingo.client.api.communication.response.ODataPropertyUpdateResponse;
|
||||||
|
import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
|
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
|
||||||
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
|
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
|
||||||
import org.apache.olingo.client.core.uri.URIUtils;
|
import org.apache.olingo.client.core.uri.URIUtils;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.client.api.domain.ClientProperty;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
||||||
import org.apache.olingo.client.api.serialization.ODataSerializerException;
|
import org.apache.olingo.client.api.serialization.ODataSerializerException;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
|
||||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,7 +67,7 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataFormat getDefaultFormat() {
|
public ContentType getDefaultFormat() {
|
||||||
return odataClient.getConfiguration().getDefaultFormat();
|
return odataClient.getConfiguration().getDefaultFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
|
||||||
@Override
|
@Override
|
||||||
protected InputStream getPayload() {
|
protected InputStream getPayload() {
|
||||||
try {
|
try {
|
||||||
return odataClient.getWriter().writeProperty(property, ODataFormat.fromString(getContentType()));
|
return odataClient.getWriter().writeProperty(property, ContentType.parse(getContentType()));
|
||||||
} catch (final ODataSerializerException e) {
|
} catch (final ODataSerializerException e) {
|
||||||
throw new IllegalArgumentException(e);
|
throw new IllegalArgumentException(e);
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
|
||||||
public ClientProperty getBody() {
|
public ClientProperty getBody() {
|
||||||
if (resProperty == null) {
|
if (resProperty == null) {
|
||||||
try {
|
try {
|
||||||
final ResWrap<Property> resource = odataClient.getDeserializer(ODataFormat.fromString(getAccept())).
|
final ResWrap<Property> resource = odataClient.getDeserializer(ContentType.parse(getAccept())).
|
||||||
toProperty(getRawResponse());
|
toProperty(getRawResponse());
|
||||||
|
|
||||||
resProperty = odataClient.getBinder().getODataProperty(resource);
|
resProperty = odataClient.getBinder().getODataProperty(resource);
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.apache.olingo.client.core.communication.request.AbstractODataBasicReq
|
||||||
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
|
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
|
||||||
import org.apache.olingo.client.core.uri.URIUtils;
|
import org.apache.olingo.client.core.uri.URIUtils;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +54,7 @@ public class ODataReferenceAddingRequestImpl extends AbstractODataBasicRequest<O
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataFormat getDefaultFormat() {
|
public ContentType getDefaultFormat() {
|
||||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public class ODataReferenceAddingRequestImpl extends AbstractODataBasicRequest<O
|
||||||
} else {
|
} else {
|
||||||
ODataWriter writer = odataClient.getWriter();
|
ODataWriter writer = odataClient.getWriter();
|
||||||
try {
|
try {
|
||||||
return writer.writeReference(reference, ODataFormat.fromString(getContentType()));
|
return writer.writeReference(reference, ContentType.parse(getContentType()));
|
||||||
} catch (ODataSerializerException e) {
|
} catch (ODataSerializerException e) {
|
||||||
LOG.warn("Error serializing reference {}", reference);
|
LOG.warn("Error serializing reference {}", reference);
|
||||||
throw new IllegalArgumentException(e);
|
throw new IllegalArgumentException(e);
|
||||||
|
|
|
@ -28,13 +28,13 @@ import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.request.cud.ODataValueUpdateRequest;
|
import org.apache.olingo.client.api.communication.request.cud.ODataValueUpdateRequest;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataValueUpdateResponse;
|
import org.apache.olingo.client.api.communication.response.ODataValueUpdateResponse;
|
||||||
|
import org.apache.olingo.client.api.domain.ClientPrimitiveValue;
|
||||||
import org.apache.olingo.client.api.http.HttpClientException;
|
import org.apache.olingo.client.api.http.HttpClientException;
|
||||||
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
|
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
|
||||||
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
|
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
|
||||||
import org.apache.olingo.client.core.uri.URIUtils;
|
import org.apache.olingo.client.core.uri.URIUtils;
|
||||||
import org.apache.olingo.client.api.domain.ClientPrimitiveValue;
|
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,7 +65,7 @@ public class ODataValueUpdateRequestImpl extends AbstractODataBasicRequest<OData
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataFormat getDefaultFormat() {
|
public ContentType getDefaultFormat() {
|
||||||
return odataClient.getConfiguration().getDefaultValueFormat();
|
return odataClient.getConfiguration().getDefaultValueFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,11 +105,11 @@ public class ODataValueUpdateRequestImpl extends AbstractODataBasicRequest<OData
|
||||||
@Override
|
@Override
|
||||||
public ClientPrimitiveValue getBody() {
|
public ClientPrimitiveValue getBody() {
|
||||||
if (resValue == null) {
|
if (resValue == null) {
|
||||||
final ODataFormat format = ODataFormat.fromString(getAccept());
|
final ContentType contentType = ContentType.parse(getAccept());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
resValue = odataClient.getObjectFactory().newPrimitiveValueBuilder().
|
resValue = odataClient.getObjectFactory().newPrimitiveValueBuilder().
|
||||||
setType(format == ODataFormat.TEXT_PLAIN
|
setType(contentType.isCompatible(ContentType.TEXT_PLAIN)
|
||||||
? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
|
? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
|
||||||
setValue(getRawResponse()).
|
setValue(getRawResponse()).
|
||||||
build();
|
build();
|
||||||
|
|
|
@ -31,8 +31,8 @@ import org.apache.http.client.methods.HttpPost;
|
||||||
import org.apache.http.client.methods.HttpRequestBase;
|
import org.apache.http.client.methods.HttpRequestBase;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
|
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
|
||||||
import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
|
|
||||||
import org.apache.olingo.client.api.communication.request.invoke.ClientNoContent;
|
import org.apache.olingo.client.api.communication.request.invoke.ClientNoContent;
|
||||||
|
import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataInvokeResponse;
|
import org.apache.olingo.client.api.communication.response.ODataInvokeResponse;
|
||||||
import org.apache.olingo.client.api.http.HttpClientException;
|
import org.apache.olingo.client.api.http.HttpClientException;
|
||||||
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
||||||
|
@ -45,7 +45,7 @@ import org.apache.olingo.client.api.domain.ClientEntitySet;
|
||||||
import org.apache.olingo.client.api.domain.ClientInvokeResult;
|
import org.apache.olingo.client.api.domain.ClientInvokeResult;
|
||||||
import org.apache.olingo.client.api.domain.ClientProperty;
|
import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
import org.apache.olingo.client.api.domain.ClientValue;
|
import org.apache.olingo.client.api.domain.ClientValue;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,23 +91,24 @@ public abstract class AbstractODataInvokeRequest<T extends ClientInvokeResult>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataFormat getDefaultFormat() {
|
public ContentType getDefaultFormat() {
|
||||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getActualFormat(final ODataFormat format) {
|
private String getActualFormat(final ContentType contentType) {
|
||||||
return ((ClientProperty.class.isAssignableFrom(reference) && format == ODataFormat.ATOM)
|
return ((ClientProperty.class.isAssignableFrom(reference)
|
||||||
? ODataFormat.XML : format).getContentType().toContentTypeString();
|
&& contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML))
|
||||||
|
? ContentType.APPLICATION_XML : contentType).toContentTypeString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFormat(final ODataFormat format) {
|
public void setFormat(final ContentType contentType) {
|
||||||
final String _format = getActualFormat(format);
|
final String _contentType = getActualFormat(contentType);
|
||||||
setAccept(_format);
|
setAccept(_contentType);
|
||||||
setContentType(_format);
|
setContentType(_contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract ODataFormat getPOSTParameterFormat();
|
protected abstract ContentType getPOSTParameterFormat();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected InputStream getPayload() {
|
protected InputStream getPayload() {
|
||||||
|
@ -197,13 +198,13 @@ public abstract class AbstractODataInvokeRequest<T extends ClientInvokeResult>
|
||||||
final InputStream responseStream = this.payload == null ? res.getEntity().getContent() : this.payload;
|
final InputStream responseStream = this.payload == null ? res.getEntity().getContent() : this.payload;
|
||||||
if (ClientEntitySet.class.isAssignableFrom(reference)) {
|
if (ClientEntitySet.class.isAssignableFrom(reference)) {
|
||||||
invokeResult = reference.cast(odataClient.getReader().readEntitySet(responseStream,
|
invokeResult = reference.cast(odataClient.getReader().readEntitySet(responseStream,
|
||||||
ODataFormat.fromString(getContentType())));
|
ContentType.parse(getContentType())));
|
||||||
} else if (ClientEntity.class.isAssignableFrom(reference)) {
|
} else if (ClientEntity.class.isAssignableFrom(reference)) {
|
||||||
invokeResult = reference.cast(odataClient.getReader().readEntity(responseStream,
|
invokeResult = reference.cast(odataClient.getReader().readEntity(responseStream,
|
||||||
ODataFormat.fromString(getContentType())));
|
ContentType.parse(getContentType())));
|
||||||
} else if (ClientProperty.class.isAssignableFrom(reference)) {
|
} else if (ClientProperty.class.isAssignableFrom(reference)) {
|
||||||
invokeResult = reference.cast(odataClient.getReader().readProperty(responseStream,
|
invokeResult = reference.cast(odataClient.getReader().readProperty(responseStream,
|
||||||
ODataFormat.fromString(getContentType())));
|
ContentType.parse(getContentType())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -22,12 +22,12 @@ import java.net.URI;
|
||||||
|
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.domain.ClientInvokeResult;
|
import org.apache.olingo.client.api.domain.ClientInvokeResult;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||||
|
|
||||||
public class ODataInvokeRequestImpl<T extends ClientInvokeResult> extends AbstractODataInvokeRequest<T> {
|
public class ODataInvokeRequestImpl<T extends ClientInvokeResult> extends AbstractODataInvokeRequest<T> {
|
||||||
|
|
||||||
private ODataFormat format;
|
private ContentType contentType;
|
||||||
|
|
||||||
public ODataInvokeRequestImpl(final ODataClient odataClient, final Class<T> reference,
|
public ODataInvokeRequestImpl(final ODataClient odataClient, final Class<T> reference,
|
||||||
final HttpMethod method, final URI uri) {
|
final HttpMethod method, final URI uri) {
|
||||||
|
@ -36,13 +36,13 @@ public class ODataInvokeRequestImpl<T extends ClientInvokeResult> extends Abstra
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFormat(final ODataFormat format) {
|
public void setFormat(final ContentType contentType) {
|
||||||
super.setFormat(format);
|
super.setFormat(contentType);
|
||||||
this.format = format;
|
this.contentType = contentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ODataFormat getPOSTParameterFormat() {
|
protected ContentType getPOSTParameterFormat() {
|
||||||
return format == null ? getDefaultFormat() : format;
|
return contentType == null ? getDefaultFormat() : contentType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.net.URI;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.request.ODataRequest;
|
import org.apache.olingo.client.api.communication.request.ODataRequest;
|
||||||
import org.apache.olingo.commons.api.format.ContentType;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
|
||||||
|
|
||||||
public abstract class AbstractMetadataRequestImpl<V> extends AbstractODataRetrieveRequest<V> {
|
public abstract class AbstractMetadataRequestImpl<V> extends AbstractODataRetrieveRequest<V> {
|
||||||
|
|
||||||
|
@ -34,8 +33,8 @@ public abstract class AbstractMetadataRequestImpl<V> extends AbstractODataRetrie
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataFormat getDefaultFormat() {
|
public ContentType getDefaultFormat() {
|
||||||
return ODataFormat.XML;
|
return ContentType.APPLICATION_XML;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -26,12 +26,12 @@ import org.apache.http.client.HttpClient;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataDeltaRequest;
|
import org.apache.olingo.client.api.communication.request.retrieve.ODataDeltaRequest;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||||
|
import org.apache.olingo.client.api.domain.ClientDelta;
|
||||||
import org.apache.olingo.client.api.http.HttpClientException;
|
import org.apache.olingo.client.api.http.HttpClientException;
|
||||||
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
||||||
import org.apache.olingo.commons.api.data.Delta;
|
import org.apache.olingo.commons.api.data.Delta;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.client.api.domain.ClientDelta;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
|
||||||
|
|
||||||
public class ODataDeltaRequestImpl extends AbstractODataRetrieveRequest<ClientDelta>
|
public class ODataDeltaRequestImpl extends AbstractODataRetrieveRequest<ClientDelta>
|
||||||
implements ODataDeltaRequest {
|
implements ODataDeltaRequest {
|
||||||
|
@ -41,7 +41,7 @@ public class ODataDeltaRequestImpl extends AbstractODataRetrieveRequest<ClientDe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataFormat getDefaultFormat() {
|
public ContentType getDefaultFormat() {
|
||||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ public class ODataDeltaRequestImpl extends AbstractODataRetrieveRequest<ClientDe
|
||||||
public ClientDelta getBody() {
|
public ClientDelta getBody() {
|
||||||
if (delta == null) {
|
if (delta == null) {
|
||||||
try {
|
try {
|
||||||
final ResWrap<Delta> resource = odataClient.getDeserializer(ODataFormat.fromString(getContentType())).
|
final ResWrap<Delta> resource = odataClient.getDeserializer(ContentType.parse(getContentType())).
|
||||||
toDelta(res.getEntity().getContent());
|
toDelta(res.getEntity().getContent());
|
||||||
|
|
||||||
delta = odataClient.getBinder().getODataDelta(resource);
|
delta = odataClient.getBinder().getODataDelta(resource);
|
||||||
|
|
|
@ -25,11 +25,11 @@ import org.apache.http.client.HttpClient;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||||
|
import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.client.api.domain.ClientEntity;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class implements an OData retrieve query request returning a single entity.
|
* This class implements an OData retrieve query request returning a single entity.
|
||||||
|
@ -48,7 +48,7 @@ public class ODataEntityRequestImpl<E extends ClientEntity>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataFormat getDefaultFormat() {
|
public ContentType getDefaultFormat() {
|
||||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ public class ODataEntityRequestImpl<E extends ClientEntity>
|
||||||
public E getBody() {
|
public E getBody() {
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
try {
|
try {
|
||||||
final ResWrap<Entity> resource = odataClient.getDeserializer(ODataFormat.fromString(getContentType())).
|
final ResWrap<Entity> resource = odataClient.getDeserializer(ContentType.parse(getContentType())).
|
||||||
toEntity(getRawResponse());
|
toEntity(getRawResponse());
|
||||||
|
|
||||||
entity = (E) odataClient.getBinder().getODataEntity(resource);
|
entity = (E) odataClient.getBinder().getODataEntity(resource);
|
||||||
|
|
|
@ -25,10 +25,10 @@ import org.apache.http.client.HttpClient;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetIteratorRequest;
|
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetIteratorRequest;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||||
import org.apache.olingo.client.api.domain.ClientEntitySetIterator;
|
|
||||||
import org.apache.olingo.client.api.domain.ClientEntity;
|
import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.client.api.domain.ClientEntitySetIterator;
|
||||||
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class implements an OData EntitySet query request.
|
* This class implements an OData EntitySet query request.
|
||||||
|
@ -50,7 +50,7 @@ public class ODataEntitySetIteratorRequestImpl<ES extends ClientEntitySet, E ext
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataFormat getDefaultFormat() {
|
public ContentType getDefaultFormat() {
|
||||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ public class ODataEntitySetIteratorRequestImpl<ES extends ClientEntitySet, E ext
|
||||||
public ClientEntitySetIterator<ES, E> getBody() {
|
public ClientEntitySetIterator<ES, E> getBody() {
|
||||||
if (entitySetIterator == null) {
|
if (entitySetIterator == null) {
|
||||||
entitySetIterator = new ClientEntitySetIterator<ES, E>(
|
entitySetIterator = new ClientEntitySetIterator<ES, E>(
|
||||||
odataClient, getRawResponse(), ODataFormat.fromString(getContentType()));
|
odataClient, getRawResponse(), ContentType.parse(getContentType()));
|
||||||
}
|
}
|
||||||
return entitySetIterator;
|
return entitySetIterator;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,11 @@ import org.apache.http.client.HttpClient;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
|
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||||
|
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
||||||
import org.apache.olingo.commons.api.data.EntityCollection;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class implements an OData EntitySet query request.
|
* This class implements an OData EntitySet query request.
|
||||||
|
@ -52,7 +52,7 @@ public class ODataEntitySetRequestImpl<ES extends ClientEntitySet>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataFormat getDefaultFormat() {
|
public ContentType getDefaultFormat() {
|
||||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ public class ODataEntitySetRequestImpl<ES extends ClientEntitySet>
|
||||||
if (entitySet == null) {
|
if (entitySet == null) {
|
||||||
try {
|
try {
|
||||||
final ResWrap<EntityCollection> resource =
|
final ResWrap<EntityCollection> resource =
|
||||||
odataClient.getDeserializer(ODataFormat.fromString(getContentType())).
|
odataClient.getDeserializer(ContentType.parse(getContentType())).
|
||||||
toEntitySet(getRawResponse());
|
toEntitySet(getRawResponse());
|
||||||
|
|
||||||
entitySet = (ES) odataClient.getBinder().getODataEntitySet(resource);
|
entitySet = (ES) odataClient.getBinder().getODataEntitySet(resource);
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataMediaRequest;
|
import org.apache.olingo.client.api.communication.request.retrieve.ODataMediaRequest;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||||
import org.apache.olingo.client.api.http.HttpClientException;
|
import org.apache.olingo.client.api.http.HttpClientException;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class implements an OData media query request.
|
* This class implements an OData media query request.
|
||||||
|
@ -44,12 +44,12 @@ public class ODataMediaRequestImpl extends AbstractODataRetrieveRequest<InputStr
|
||||||
ODataMediaRequestImpl(final ODataClient odataClient, final URI query) {
|
ODataMediaRequestImpl(final ODataClient odataClient, final URI query) {
|
||||||
super(odataClient, query);
|
super(odataClient, query);
|
||||||
|
|
||||||
setAccept(ODataFormat.APPLICATION_OCTET_STREAM.toString());
|
setAccept(ContentType.APPLICATION_OCTET_STREAM.toString());
|
||||||
setContentType(ODataFormat.APPLICATION_OCTET_STREAM.toString());
|
setContentType(ContentType.APPLICATION_OCTET_STREAM.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataFormat getDefaultFormat() {
|
public ContentType getDefaultFormat() {
|
||||||
return odataClient.getConfiguration().getDefaultMediaFormat();
|
return odataClient.getConfiguration().getDefaultMediaFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,12 +26,12 @@ import org.apache.http.client.HttpClient;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
|
import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||||
|
import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
import org.apache.olingo.client.api.http.HttpClientException;
|
import org.apache.olingo.client.api.http.HttpClientException;
|
||||||
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.client.api.domain.ClientProperty;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class implements an OData entity property query request.
|
* This class implements an OData entity property query request.
|
||||||
|
@ -50,7 +50,7 @@ public class ODataPropertyRequestImpl<T extends ClientProperty>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataFormat getDefaultFormat() {
|
public ContentType getDefaultFormat() {
|
||||||
return odataClient.getConfiguration().getDefaultFormat();
|
return odataClient.getConfiguration().getDefaultFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ public class ODataPropertyRequestImpl<T extends ClientProperty>
|
||||||
public T getBody() {
|
public T getBody() {
|
||||||
if (property == null) {
|
if (property == null) {
|
||||||
try {
|
try {
|
||||||
final ResWrap<Property> resource = odataClient.getDeserializer(ODataFormat.fromString(getContentType()))
|
final ResWrap<Property> resource = odataClient.getDeserializer(ContentType.parse(getContentType()))
|
||||||
.toProperty(res.getEntity().getContent());
|
.toProperty(res.getEntity().getContent());
|
||||||
|
|
||||||
property = (T) odataClient.getBinder().getODataProperty(resource);
|
property = (T) odataClient.getBinder().getODataProperty(resource);
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
||||||
import org.apache.olingo.client.core.communication.request.AbstractODataRequest;
|
import org.apache.olingo.client.core.communication.request.AbstractODataRequest;
|
||||||
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
|
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,7 +51,7 @@ public class ODataRawRequestImpl extends AbstractODataRequest implements ODataRa
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataFormat getDefaultFormat() {
|
public ContentType getDefaultFormat() {
|
||||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,10 @@ import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataServiceDocumentRequest;
|
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.communication.response.ODataRetrieveResponse;
|
||||||
import org.apache.olingo.client.api.data.ServiceDocument;
|
import org.apache.olingo.client.api.data.ServiceDocument;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
|
||||||
import org.apache.olingo.client.api.domain.ClientServiceDocument;
|
import org.apache.olingo.client.api.domain.ClientServiceDocument;
|
||||||
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class implements an OData service document request.
|
* This class implements an OData service document request.
|
||||||
|
@ -48,7 +48,7 @@ public class ODataServiceDocumentRequestImpl extends AbstractODataRetrieveReques
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataFormat getDefaultFormat() {
|
public ContentType getDefaultFormat() {
|
||||||
return odataClient.getConfiguration().getDefaultFormat();
|
return odataClient.getConfiguration().getDefaultFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ public class ODataServiceDocumentRequestImpl extends AbstractODataRetrieveReques
|
||||||
if (serviceDocument == null) {
|
if (serviceDocument == null) {
|
||||||
try {
|
try {
|
||||||
final ResWrap<ServiceDocument> resource = odataClient.
|
final ResWrap<ServiceDocument> resource = odataClient.
|
||||||
getDeserializer(ODataFormat.fromString(getContentType())).toServiceDocument(getRawResponse());
|
getDeserializer(ContentType.parse(getContentType())).toServiceDocument(getRawResponse());
|
||||||
|
|
||||||
serviceDocument = odataClient.getBinder().getODataServiceDocument(resource.getPayload());
|
serviceDocument = odataClient.getBinder().getODataServiceDocument(resource.getPayload());
|
||||||
} catch (final ODataDeserializerException e) {
|
} catch (final ODataDeserializerException e) {
|
||||||
|
|
|
@ -26,10 +26,10 @@ import org.apache.http.client.HttpClient;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
|
import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||||
import org.apache.olingo.client.api.http.HttpClientException;
|
|
||||||
import org.apache.olingo.client.api.domain.ClientPrimitiveValue;
|
import org.apache.olingo.client.api.domain.ClientPrimitiveValue;
|
||||||
|
import org.apache.olingo.client.api.http.HttpClientException;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class implements an OData entity property value query request.
|
* This class implements an OData entity property value query request.
|
||||||
|
@ -48,7 +48,7 @@ public class ODataValueRequestImpl extends AbstractODataRetrieveRequest<ClientPr
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataFormat getDefaultFormat() {
|
public ContentType getDefaultFormat() {
|
||||||
return odataClient.getConfiguration().getDefaultValueFormat();
|
return odataClient.getConfiguration().getDefaultValueFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,11 +74,11 @@ public class ODataValueRequestImpl extends AbstractODataRetrieveRequest<ClientPr
|
||||||
@Override
|
@Override
|
||||||
public ClientPrimitiveValue getBody() {
|
public ClientPrimitiveValue getBody() {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
final ODataFormat format = ODataFormat.fromString(getContentType());
|
final ContentType contentType = ContentType.parse(getContentType());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
value = odataClient.getObjectFactory().newPrimitiveValueBuilder().
|
value = odataClient.getObjectFactory().newPrimitiveValueBuilder().
|
||||||
setType(format == ODataFormat.TEXT_PLAIN
|
setType(contentType.isCompatible(ContentType.TEXT_PLAIN)
|
||||||
? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
|
? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
|
||||||
setValue(IOUtils.toString(getRawResponse())).build();
|
setValue(IOUtils.toString(getRawResponse())).build();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.apache.olingo.client.api.edm.xml.XMLMetadata;
|
||||||
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation;
|
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation;
|
||||||
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotations;
|
import org.apache.olingo.commons.api.edm.provider.CsdlAnnotations;
|
||||||
import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
|
import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||||
|
|
||||||
public class XMLMetadataRequestImpl
|
public class XMLMetadataRequestImpl
|
||||||
|
@ -170,7 +170,7 @@ public class XMLMetadataRequestImpl
|
||||||
public XMLMetadata getBody() {
|
public XMLMetadata getBody() {
|
||||||
if (metadata == null) {
|
if (metadata == null) {
|
||||||
try {
|
try {
|
||||||
metadata = odataClient.getDeserializer(ODataFormat.XML).toMetadata(getRawResponse());
|
metadata = odataClient.getDeserializer(ContentType.APPLICATION_XML).toMetadata(getRawResponse());
|
||||||
} finally {
|
} finally {
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.communication.request.ODataPayloadManager;
|
import org.apache.olingo.client.api.communication.request.ODataPayloadManager;
|
||||||
import org.apache.olingo.client.api.communication.request.streamed.ODataStreamedEntityRequest;
|
import org.apache.olingo.client.api.communication.request.streamed.ODataStreamedEntityRequest;
|
||||||
import org.apache.olingo.client.api.communication.response.ODataResponse;
|
import org.apache.olingo.client.api.communication.response.ODataResponse;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +37,7 @@ public abstract class AbstractODataStreamedEntityRequest<V extends ODataResponse
|
||||||
extends AbstractODataStreamedRequest<V, T>
|
extends AbstractODataStreamedRequest<V, T>
|
||||||
implements ODataStreamedEntityRequest<V, T> {
|
implements ODataStreamedEntityRequest<V, T> {
|
||||||
|
|
||||||
private ODataFormat format;
|
private ContentType contentType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
@ -50,17 +50,17 @@ public abstract class AbstractODataStreamedEntityRequest<V extends ODataResponse
|
||||||
final URI uri) {
|
final URI uri) {
|
||||||
|
|
||||||
super(odataClient, method, uri);
|
super(odataClient, method, uri);
|
||||||
setAccept(getFormat().getContentType().toContentTypeString());
|
setAccept(getFormat().toContentTypeString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final ODataFormat getFormat() {
|
public final ContentType getFormat() {
|
||||||
return format == null ? odataClient.getConfiguration().getDefaultPubFormat() : format;
|
return contentType == null ? odataClient.getConfiguration().getDefaultPubFormat() : contentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void setFormat(final ODataFormat format) {
|
public final void setFormat(final ContentType contentType) {
|
||||||
this.format = format;
|
this.contentType = contentType;
|
||||||
setAccept(format.getContentType().toContentTypeString());
|
setAccept(contentType.toContentTypeString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@ import org.apache.olingo.client.core.communication.request.AbstractODataRequest;
|
||||||
import org.apache.olingo.client.core.communication.request.Wrapper;
|
import org.apache.olingo.client.core.communication.request.Wrapper;
|
||||||
import org.apache.olingo.client.core.uri.URIUtils;
|
import org.apache.olingo.client.core.uri.URIUtils;
|
||||||
import org.apache.olingo.commons.api.format.ContentType;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
|
||||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,7 +77,7 @@ public abstract class AbstractODataStreamedRequest<V extends ODataResponse, T ex
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataFormat getDefaultFormat() {
|
public ContentType getDefaultFormat() {
|
||||||
return odataClient.getConfiguration().getDefaultMediaFormat();
|
return odataClient.getConfiguration().getDefaultMediaFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.olingo.client.core.domain;
|
package org.apache.olingo.client.core.domain;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.Constants;
|
import org.apache.olingo.commons.api.Constants;
|
||||||
|
@ -133,6 +134,11 @@ public class ClientPrimitiveValueImpl extends AbstractClientValue implements Cli
|
||||||
return setType(EdmPrimitiveTypeKind.Binary).setValue(value).build();
|
return setType(EdmPrimitiveTypeKind.Binary).setValue(value).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClientPrimitiveValue buildDecimal(BigDecimal value) {
|
||||||
|
return setType(EdmPrimitiveTypeKind.Decimal).setValue(value).build();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -30,17 +30,16 @@ import org.apache.olingo.client.api.serialization.ODataDeserializer;
|
||||||
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
||||||
import org.apache.olingo.client.core.data.JSONServiceDocumentDeserializer;
|
import org.apache.olingo.client.core.data.JSONServiceDocumentDeserializer;
|
||||||
import org.apache.olingo.client.core.data.XMLServiceDocumentDeserializer;
|
import org.apache.olingo.client.core.data.XMLServiceDocumentDeserializer;
|
||||||
import org.apache.olingo.client.core.edm.xml.ClientCsdlEdmx;
|
|
||||||
import org.apache.olingo.client.core.edm.ClientCsdlXMLMetadata;
|
import org.apache.olingo.client.core.edm.ClientCsdlXMLMetadata;
|
||||||
|
import org.apache.olingo.client.core.edm.xml.ClientCsdlEdmx;
|
||||||
|
import org.apache.olingo.commons.api.ODataError;
|
||||||
import org.apache.olingo.commons.api.data.Delta;
|
import org.apache.olingo.commons.api.data.Delta;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntityCollection;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.ODataError;
|
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
|
|
||||||
import com.fasterxml.aalto.stax.InputFactoryImpl;
|
import com.fasterxml.aalto.stax.InputFactoryImpl;
|
||||||
import com.fasterxml.aalto.stax.OutputFactoryImpl;
|
import com.fasterxml.aalto.stax.OutputFactoryImpl;
|
||||||
import com.fasterxml.jackson.core.JsonParser;
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
|
@ -56,11 +55,12 @@ public class ClientODataDeserializerImpl implements ClientODataDeserializer {
|
||||||
|
|
||||||
private final ODataDeserializer deserializer;
|
private final ODataDeserializer deserializer;
|
||||||
|
|
||||||
private final ODataFormat format;
|
private final ContentType contentType;
|
||||||
|
|
||||||
public ClientODataDeserializerImpl(final boolean serverMode, final ODataFormat format) {
|
public ClientODataDeserializerImpl(final boolean serverMode, final ContentType contentType) {
|
||||||
this.format = format;
|
this.contentType = contentType;
|
||||||
if (format == ODataFormat.XML || format == ODataFormat.ATOM) {
|
if(contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML,
|
||||||
|
ContentType.APPLICATION_XML )) {
|
||||||
deserializer = new AtomDeserializer();
|
deserializer = new AtomDeserializer();
|
||||||
} else {
|
} else {
|
||||||
deserializer = new JsonDeserializer(serverMode);
|
deserializer = new JsonDeserializer(serverMode);
|
||||||
|
@ -119,7 +119,7 @@ public class ClientODataDeserializerImpl implements ClientODataDeserializer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResWrap<ServiceDocument> toServiceDocument(final InputStream input) throws ODataDeserializerException {
|
public ResWrap<ServiceDocument> toServiceDocument(final InputStream input) throws ODataDeserializerException {
|
||||||
return format == ODataFormat.XML ?
|
return contentType.isCompatible(ContentType.APPLICATION_XML) ?
|
||||||
new XMLServiceDocumentDeserializer(false).toServiceDocument(input) :
|
new XMLServiceDocumentDeserializer(false).toServiceDocument(input) :
|
||||||
new JSONServiceDocumentDeserializer(false).toServiceDocument(input);
|
new JSONServiceDocumentDeserializer(false).toServiceDocument(input);
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ public class ClientODataDeserializerImpl implements ClientODataDeserializer {
|
||||||
@Override
|
@Override
|
||||||
public ResWrap<Delta> toDelta(final InputStream input) throws ODataDeserializerException {
|
public ResWrap<Delta> toDelta(final InputStream input) throws ODataDeserializerException {
|
||||||
try {
|
try {
|
||||||
return format == ODataFormat.ATOM ?
|
return contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML) ?
|
||||||
new AtomDeserializer().delta(input) :
|
new AtomDeserializer().delta(input) :
|
||||||
new JsonDeltaDeserializer(false).toDelta(input);
|
new JsonDeltaDeserializer(false).toDelta(input);
|
||||||
} catch (XMLStreamException e) {
|
} catch (XMLStreamException e) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.apache.olingo.commons.api.data.Operation;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
|
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
|
@ -39,12 +39,8 @@ import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
*/
|
*/
|
||||||
public class JsonEntitySerializer extends JsonSerializer {
|
public class JsonEntitySerializer extends JsonSerializer {
|
||||||
|
|
||||||
public JsonEntitySerializer(final boolean serverMode) {
|
public JsonEntitySerializer(final boolean serverMode, final ContentType contentType) {
|
||||||
super(serverMode);
|
super(serverMode, contentType);
|
||||||
}
|
|
||||||
|
|
||||||
public JsonEntitySerializer(final boolean serverMode, final ODataFormat format) {
|
|
||||||
super(serverMode, format);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doSerialize(final Entity entity, final JsonGenerator jgen)
|
protected void doSerialize(final Entity entity, final JsonGenerator jgen)
|
||||||
|
@ -73,12 +69,12 @@ public class JsonEntitySerializer extends JsonSerializer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(entity.getType()) && format != ODataFormat.JSON_NO_METADATA) {
|
if (StringUtils.isNotBlank(entity.getType()) && !isODataMetadataNone(contentType)) {
|
||||||
jgen.writeStringField(Constants.JSON_TYPE,
|
jgen.writeStringField(Constants.JSON_TYPE,
|
||||||
new EdmTypeInfo.Builder().setTypeExpression(entity.getType()).build().external());
|
new EdmTypeInfo.Builder().setTypeExpression(entity.getType()).build().external());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.getId() != null && format != ODataFormat.JSON_NO_METADATA) {
|
if (entity.getId() != null && !isODataMetadataNone(contentType)) {
|
||||||
jgen.writeStringField(Constants.JSON_ID, entity.getId().toASCIIString());
|
jgen.writeStringField(Constants.JSON_ID, entity.getId().toASCIIString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +96,7 @@ public class JsonEntitySerializer extends JsonSerializer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format != ODataFormat.JSON_NO_METADATA) {
|
if (!isODataMetadataNone(contentType)) {
|
||||||
links(entity, jgen);
|
links(entity, jgen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,13 +27,14 @@ import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntityCollection;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
|
|
||||||
public class JsonEntitySetSerializer extends JsonSerializer {
|
public class JsonEntitySetSerializer extends JsonSerializer {
|
||||||
|
|
||||||
public JsonEntitySetSerializer(final boolean serverMode) {
|
public JsonEntitySetSerializer(final boolean serverMode, final ContentType contentType) {
|
||||||
super(serverMode);
|
super(serverMode, contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doSerialize(final EntityCollection entitySet, final JsonGenerator jgen)
|
protected void doSerialize(final EntityCollection entitySet, final JsonGenerator jgen)
|
||||||
|
@ -81,7 +82,7 @@ public class JsonEntitySetSerializer extends JsonSerializer {
|
||||||
}
|
}
|
||||||
|
|
||||||
jgen.writeArrayFieldStart(Constants.VALUE);
|
jgen.writeArrayFieldStart(Constants.VALUE);
|
||||||
final JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode);
|
final JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode, contentType);
|
||||||
for (Entity entity : entitySet.getEntities()) {
|
for (Entity entity : entitySet.getEntities()) {
|
||||||
entitySerializer.doSerialize(entity, jgen);
|
entitySerializer.doSerialize(entity, jgen);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.olingo.commons.api.data.Annotation;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
|
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
|
@ -36,8 +37,8 @@ import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
*/
|
*/
|
||||||
public class JsonPropertySerializer extends JsonSerializer {
|
public class JsonPropertySerializer extends JsonSerializer {
|
||||||
|
|
||||||
public JsonPropertySerializer(final boolean serverMode) {
|
public JsonPropertySerializer(final boolean serverMode, final ContentType contentType) {
|
||||||
super(serverMode);
|
super(serverMode, contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doSerialize(final Property property, final JsonGenerator jgen)
|
protected void doSerialize(final Property property, final JsonGenerator jgen)
|
||||||
|
|
57
lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonSerializer.java
Normal file → Executable file
57
lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonSerializer.java
Normal file → Executable file
|
@ -45,7 +45,7 @@ import org.apache.olingo.commons.api.data.ValueType;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
import org.apache.olingo.commons.api.edm.geo.Geospatial;
|
import org.apache.olingo.commons.api.edm.geo.Geospatial;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
|
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
|
||||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
|
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
|
||||||
|
|
||||||
|
@ -64,16 +64,13 @@ public class JsonSerializer implements ODataSerializer {
|
||||||
private final JsonGeoValueSerializer geoSerializer = new JsonGeoValueSerializer();
|
private final JsonGeoValueSerializer geoSerializer = new JsonGeoValueSerializer();
|
||||||
|
|
||||||
protected boolean serverMode;
|
protected boolean serverMode;
|
||||||
|
protected final boolean isIEEE754Compatible;
|
||||||
|
protected ContentType contentType;
|
||||||
|
|
||||||
protected ODataFormat format;
|
public JsonSerializer(final boolean serverMode, final ContentType contentType) {
|
||||||
|
|
||||||
public JsonSerializer(final boolean serverMode) {
|
|
||||||
this(serverMode, ODataFormat.JSON_FULL_METADATA);
|
|
||||||
}
|
|
||||||
|
|
||||||
public JsonSerializer(final boolean serverMode, final ODataFormat format) {
|
|
||||||
this.serverMode = serverMode;
|
this.serverMode = serverMode;
|
||||||
this.format = format;
|
this.contentType = contentType;
|
||||||
|
this.isIEEE754Compatible = isIEEE754Compatible();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -81,11 +78,11 @@ public class JsonSerializer implements ODataSerializer {
|
||||||
try {
|
try {
|
||||||
final JsonGenerator json = new JsonFactory().createGenerator(writer);
|
final JsonGenerator json = new JsonFactory().createGenerator(writer);
|
||||||
if (obj instanceof EntityCollection) {
|
if (obj instanceof EntityCollection) {
|
||||||
new JsonEntitySetSerializer(serverMode).doSerialize((EntityCollection) obj, json);
|
new JsonEntitySetSerializer(serverMode, contentType).doSerialize((EntityCollection) obj, json);
|
||||||
} else if (obj instanceof Entity) {
|
} else if (obj instanceof Entity) {
|
||||||
new JsonEntitySerializer(serverMode, format).doSerialize((Entity) obj, json);
|
new JsonEntitySerializer(serverMode, contentType).doSerialize((Entity) obj, json);
|
||||||
} else if (obj instanceof Property) {
|
} else if (obj instanceof Property) {
|
||||||
new JsonPropertySerializer(serverMode).doSerialize((Property) obj, json);
|
new JsonPropertySerializer(serverMode, contentType).doSerialize((Property) obj, json);
|
||||||
} else if (obj instanceof Link) {
|
} else if (obj instanceof Link) {
|
||||||
link((Link) obj, json);
|
link((Link) obj, json);
|
||||||
}
|
}
|
||||||
|
@ -113,11 +110,12 @@ public class JsonSerializer implements ODataSerializer {
|
||||||
try {
|
try {
|
||||||
final JsonGenerator json = new JsonFactory().createGenerator(writer);
|
final JsonGenerator json = new JsonFactory().createGenerator(writer);
|
||||||
if (obj instanceof EntityCollection) {
|
if (obj instanceof EntityCollection) {
|
||||||
new JsonEntitySetSerializer(serverMode).doContainerSerialize((ResWrap<EntityCollection>) container, json);
|
new JsonEntitySetSerializer(serverMode, contentType).doContainerSerialize(
|
||||||
|
(ResWrap<EntityCollection>) container, json);
|
||||||
} else if (obj instanceof Entity) {
|
} else if (obj instanceof Entity) {
|
||||||
new JsonEntitySerializer(serverMode).doContainerSerialize((ResWrap<Entity>) container, json);
|
new JsonEntitySerializer(serverMode, contentType).doContainerSerialize((ResWrap<Entity>) container, json);
|
||||||
} else if (obj instanceof Property) {
|
} else if (obj instanceof Property) {
|
||||||
new JsonPropertySerializer(serverMode).doContainerSerialize((ResWrap<Property>) container, json);
|
new JsonPropertySerializer(serverMode, contentType).doContainerSerialize((ResWrap<Property>) container, json);
|
||||||
} else if (obj instanceof Link) {
|
} else if (obj instanceof Link) {
|
||||||
link((Link) obj, json);
|
link((Link) obj, json);
|
||||||
} else if (obj instanceof URI) {
|
} else if (obj instanceof URI) {
|
||||||
|
@ -175,10 +173,10 @@ public class JsonSerializer implements ODataSerializer {
|
||||||
|
|
||||||
if (link.getInlineEntity() != null) {
|
if (link.getInlineEntity() != null) {
|
||||||
jgen.writeFieldName(link.getTitle());
|
jgen.writeFieldName(link.getTitle());
|
||||||
new JsonEntitySerializer(serverMode).doSerialize(link.getInlineEntity(), jgen);
|
new JsonEntitySerializer(serverMode, contentType).doSerialize(link.getInlineEntity(), jgen);
|
||||||
} else if (link.getInlineEntitySet() != null) {
|
} else if (link.getInlineEntitySet() != null) {
|
||||||
jgen.writeArrayFieldStart(link.getTitle());
|
jgen.writeArrayFieldStart(link.getTitle());
|
||||||
final JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode);
|
final JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode, contentType);
|
||||||
for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
|
for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
|
||||||
entitySerializer.doSerialize(subEntry, jgen);
|
entitySerializer.doSerialize(subEntry, jgen);
|
||||||
}
|
}
|
||||||
|
@ -233,10 +231,10 @@ public class JsonSerializer implements ODataSerializer {
|
||||||
|
|
||||||
if (link.getInlineEntity() != null) {
|
if (link.getInlineEntity() != null) {
|
||||||
jgen.writeFieldName(link.getTitle());
|
jgen.writeFieldName(link.getTitle());
|
||||||
new JsonEntitySerializer(serverMode).doSerialize(link.getInlineEntity(), jgen);
|
new JsonEntitySerializer(serverMode, contentType).doSerialize(link.getInlineEntity(), jgen);
|
||||||
} else if (link.getInlineEntitySet() != null) {
|
} else if (link.getInlineEntitySet() != null) {
|
||||||
jgen.writeArrayFieldStart(link.getTitle());
|
jgen.writeArrayFieldStart(link.getTitle());
|
||||||
JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode);
|
JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode, contentType);
|
||||||
for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
|
for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
|
||||||
entitySerializer.doSerialize(subEntry, jgen);
|
entitySerializer.doSerialize(subEntry, jgen);
|
||||||
}
|
}
|
||||||
|
@ -294,12 +292,15 @@ public class JsonSerializer implements ODataSerializer {
|
||||||
} else if (isBoolean) {
|
} else if (isBoolean) {
|
||||||
jgen.writeBoolean((Boolean) value);
|
jgen.writeBoolean((Boolean) value);
|
||||||
} else {
|
} else {
|
||||||
final String serialized = kind == null
|
String serialized = kind == null
|
||||||
? value.toString()
|
? value.toString()
|
||||||
// TODO: add facets
|
// TODO: add facets
|
||||||
: EdmPrimitiveTypeFactory.getInstance(kind).
|
: EdmPrimitiveTypeFactory.getInstance(kind).
|
||||||
valueToString(value, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null);
|
valueToString(value, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null);
|
||||||
if (isNumber) {
|
|
||||||
|
if(isIEEE754Compatible && (kind == EdmPrimitiveTypeKind.Int64 || kind == EdmPrimitiveTypeKind.Decimal)) {
|
||||||
|
jgen.writeString(serialized);
|
||||||
|
} else if(isNumber) {
|
||||||
jgen.writeNumber(serialized);
|
jgen.writeNumber(serialized);
|
||||||
} else {
|
} else {
|
||||||
jgen.writeString(serialized);
|
jgen.writeString(serialized);
|
||||||
|
@ -312,7 +313,7 @@ public class JsonSerializer implements ODataSerializer {
|
||||||
throws IOException, EdmPrimitiveTypeException {
|
throws IOException, EdmPrimitiveTypeException {
|
||||||
jgen.writeStartObject();
|
jgen.writeStartObject();
|
||||||
|
|
||||||
if (typeInfo != null && format != ODataFormat.JSON_NO_METADATA) {
|
if (typeInfo != null && !isODataMetadataNone(contentType)) {
|
||||||
jgen.writeStringField(Constants.JSON_TYPE, typeInfo.external());
|
jgen.writeStringField(Constants.JSON_TYPE, typeInfo.external());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,7 +360,7 @@ public class JsonSerializer implements ODataSerializer {
|
||||||
valuable.isPrimitive()) || valuable.isNull()) {
|
valuable.isPrimitive()) || valuable.isNull()) {
|
||||||
type = EdmPrimitiveTypeKind.String.getFullQualifiedName().toString();
|
type = EdmPrimitiveTypeKind.String.getFullQualifiedName().toString();
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(type) && format != ODataFormat.JSON_NO_METADATA) {
|
if (StringUtils.isNotBlank(type) && !isODataMetadataNone(contentType)) {
|
||||||
jgen.writeFieldName(
|
jgen.writeFieldName(
|
||||||
name + StringUtils.prependIfMissing(Constants.JSON_TYPE, "@"));
|
name + StringUtils.prependIfMissing(Constants.JSON_TYPE, "@"));
|
||||||
jgen.writeString(new EdmTypeInfo.Builder().setTypeExpression(type).build().external());
|
jgen.writeString(new EdmTypeInfo.Builder().setTypeExpression(type).build().external());
|
||||||
|
@ -373,4 +374,14 @@ public class JsonSerializer implements ODataSerializer {
|
||||||
jgen.writeFieldName(name);
|
jgen.writeFieldName(name);
|
||||||
value(jgen, valuable.getType(), valuable);
|
value(jgen, valuable.getType(), valuable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isIEEE754Compatible() {
|
||||||
|
final String parameter = contentType.getParameters().get(ContentType.PARAMETER_IEEE754_COMPATIBLE);
|
||||||
|
return parameter == null ? false : "true".equals(parameter.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isODataMetadataNone(final ContentType contentType) {
|
||||||
|
return contentType.isCompatible(ContentType.APPLICATION_JSON)
|
||||||
|
&& ContentType.VALUE_ODATA_METADATA_NONE.equals(contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA));
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -69,6 +69,10 @@ import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
import org.apache.olingo.client.api.domain.ClientServiceDocument;
|
import org.apache.olingo.client.api.domain.ClientServiceDocument;
|
||||||
import org.apache.olingo.client.api.domain.ClientValuable;
|
import org.apache.olingo.client.api.domain.ClientValuable;
|
||||||
import org.apache.olingo.client.api.domain.ClientValue;
|
import org.apache.olingo.client.api.domain.ClientValue;
|
||||||
|
import org.apache.olingo.client.core.domain.ClientAnnotationImpl;
|
||||||
|
import org.apache.olingo.client.core.domain.ClientDeletedEntityImpl;
|
||||||
|
import org.apache.olingo.client.core.domain.ClientDeltaLinkImpl;
|
||||||
|
import org.apache.olingo.client.core.domain.ClientPropertyImpl;
|
||||||
import org.apache.olingo.commons.api.edm.Edm;
|
import org.apache.olingo.commons.api.edm.Edm;
|
||||||
import org.apache.olingo.commons.api.edm.EdmBindingTarget;
|
import org.apache.olingo.commons.api.edm.EdmBindingTarget;
|
||||||
import org.apache.olingo.commons.api.edm.EdmComplexType;
|
import org.apache.olingo.commons.api.edm.EdmComplexType;
|
||||||
|
@ -87,13 +91,9 @@ import org.apache.olingo.commons.api.edm.EdmTerm;
|
||||||
import org.apache.olingo.commons.api.edm.EdmType;
|
import org.apache.olingo.commons.api.edm.EdmType;
|
||||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||||
import org.apache.olingo.commons.api.edm.geo.Geospatial;
|
import org.apache.olingo.commons.api.edm.geo.Geospatial;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.client.core.domain.ClientAnnotationImpl;
|
|
||||||
import org.apache.olingo.client.core.domain.ClientDeletedEntityImpl;
|
|
||||||
import org.apache.olingo.client.core.domain.ClientDeltaLinkImpl;
|
|
||||||
import org.apache.olingo.client.core.domain.ClientPropertyImpl;
|
|
||||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
|
|
||||||
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
|
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
|
||||||
|
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ public class ODataBinderImpl implements ODataBinder {
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
final StringWriter writer = new StringWriter();
|
final StringWriter writer = new StringWriter();
|
||||||
try {
|
try {
|
||||||
client.getSerializer(ODataFormat.JSON).write(writer, resource.getPayload());
|
client.getSerializer(ContentType.JSON).write(writer, resource.getPayload());
|
||||||
} catch (final ODataSerializerException e) {
|
} catch (final ODataSerializerException e) {
|
||||||
LOG.debug("EntitySet -> ODataEntitySet:\n{}", writer.toString());
|
LOG.debug("EntitySet -> ODataEntitySet:\n{}", writer.toString());
|
||||||
}
|
}
|
||||||
|
@ -588,7 +588,7 @@ public class ODataBinderImpl implements ODataBinder {
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
final StringWriter writer = new StringWriter();
|
final StringWriter writer = new StringWriter();
|
||||||
try {
|
try {
|
||||||
client.getSerializer(ODataFormat.JSON).write(writer, resource.getPayload());
|
client.getSerializer(ContentType.JSON).write(writer, resource.getPayload());
|
||||||
} catch (final ODataSerializerException e) {
|
} catch (final ODataSerializerException e) {
|
||||||
LOG.debug("EntityResource -> ODataEntity:\n{}", writer.toString());
|
LOG.debug("EntityResource -> ODataEntity:\n{}", writer.toString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,25 +25,25 @@ import java.util.Map;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.data.ServiceDocument;
|
import org.apache.olingo.client.api.data.ServiceDocument;
|
||||||
|
import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
|
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
||||||
import org.apache.olingo.client.api.domain.ClientEntitySetIterator;
|
import org.apache.olingo.client.api.domain.ClientEntitySetIterator;
|
||||||
|
import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
|
import org.apache.olingo.client.api.domain.ClientServiceDocument;
|
||||||
|
import org.apache.olingo.client.api.domain.ClientValue;
|
||||||
import org.apache.olingo.client.api.edm.xml.XMLMetadata;
|
import org.apache.olingo.client.api.edm.xml.XMLMetadata;
|
||||||
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
||||||
import org.apache.olingo.client.api.serialization.ODataReader;
|
import org.apache.olingo.client.api.serialization.ODataReader;
|
||||||
import org.apache.olingo.client.core.edm.ClientCsdlEdmProvider;
|
import org.apache.olingo.client.core.edm.ClientCsdlEdmProvider;
|
||||||
|
import org.apache.olingo.commons.api.ODataError;
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
import org.apache.olingo.commons.api.data.EntityCollection;
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
import org.apache.olingo.commons.api.data.Property;
|
import org.apache.olingo.commons.api.data.Property;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.client.api.domain.ClientEntity;
|
|
||||||
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
|
||||||
import org.apache.olingo.commons.api.ODataError;
|
|
||||||
import org.apache.olingo.client.api.domain.ClientProperty;
|
|
||||||
import org.apache.olingo.client.api.domain.ClientServiceDocument;
|
|
||||||
import org.apache.olingo.client.api.domain.ClientValue;
|
|
||||||
import org.apache.olingo.commons.api.edm.Edm;
|
import org.apache.olingo.commons.api.edm.Edm;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||||
import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
|
import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.core.edm.EdmProviderImpl;
|
import org.apache.olingo.commons.core.edm.EdmProviderImpl;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -63,7 +63,7 @@ public class ODataReaderImpl implements ODataReader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Edm readMetadata(final InputStream input) {
|
public Edm readMetadata(final InputStream input) {
|
||||||
return readMetadata(client.getDeserializer(ODataFormat.XML).toMetadata(input).getSchemaByNsOrAlias());
|
return readMetadata(client.getDeserializer(ContentType.APPLICATION_XML).toMetadata(input).getSchemaByNsOrAlias());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -73,16 +73,16 @@ public class ODataReaderImpl implements ODataReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClientServiceDocument readServiceDocument(final InputStream input, final ODataFormat format)
|
public ClientServiceDocument readServiceDocument(final InputStream input, final ContentType contentType)
|
||||||
throws ODataDeserializerException {
|
throws ODataDeserializerException {
|
||||||
return client.getBinder().getODataServiceDocument(
|
return client.getBinder().getODataServiceDocument(
|
||||||
client.getDeserializer(format).toServiceDocument(input).getPayload());
|
client.getDeserializer(contentType).toServiceDocument(input).getPayload());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataError readError(final InputStream inputStream, final ODataFormat format)
|
public ODataError readError(final InputStream inputStream, final ContentType contentType)
|
||||||
throws ODataDeserializerException {
|
throws ODataDeserializerException {
|
||||||
return client.getDeserializer(format).toError(inputStream);
|
return client.getDeserializer(contentType).toError(inputStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -96,22 +96,22 @@ public class ODataReaderImpl implements ODataReader {
|
||||||
(URI) null,
|
(URI) null,
|
||||||
null,
|
null,
|
||||||
reference.cast(new ClientEntitySetIterator<ClientEntitySet, ClientEntity>(
|
reference.cast(new ClientEntitySetIterator<ClientEntitySet, ClientEntity>(
|
||||||
client, src, ODataFormat.fromString(format))));
|
client, src, ContentType.parse(format))));
|
||||||
} else if (ClientEntitySet.class.isAssignableFrom(reference)) {
|
} else if (ClientEntitySet.class.isAssignableFrom(reference)) {
|
||||||
final ResWrap<EntityCollection> resource = client.getDeserializer(ODataFormat.fromString(format))
|
final ResWrap<EntityCollection> resource = client.getDeserializer(ContentType.parse(format))
|
||||||
.toEntitySet(src);
|
.toEntitySet(src);
|
||||||
res = new ResWrap<T>(
|
res = new ResWrap<T>(
|
||||||
resource.getContextURL(),
|
resource.getContextURL(),
|
||||||
resource.getMetadataETag(),
|
resource.getMetadataETag(),
|
||||||
reference.cast(client.getBinder().getODataEntitySet(resource)));
|
reference.cast(client.getBinder().getODataEntitySet(resource)));
|
||||||
} else if (ClientEntity.class.isAssignableFrom(reference)) {
|
} else if (ClientEntity.class.isAssignableFrom(reference)) {
|
||||||
final ResWrap<Entity> container = client.getDeserializer(ODataFormat.fromString(format)).toEntity(src);
|
final ResWrap<Entity> container = client.getDeserializer(ContentType.parse(format)).toEntity(src);
|
||||||
res = new ResWrap<T>(
|
res = new ResWrap<T>(
|
||||||
container.getContextURL(),
|
container.getContextURL(),
|
||||||
container.getMetadataETag(),
|
container.getMetadataETag(),
|
||||||
reference.cast(client.getBinder().getODataEntity(container)));
|
reference.cast(client.getBinder().getODataEntity(container)));
|
||||||
} else if (ClientProperty.class.isAssignableFrom(reference)) {
|
} else if (ClientProperty.class.isAssignableFrom(reference)) {
|
||||||
final ResWrap<Property> container = client.getDeserializer(ODataFormat.fromString(format)).toProperty(src);
|
final ResWrap<Property> container = client.getDeserializer(ContentType.parse(format)).toProperty(src);
|
||||||
res = new ResWrap<T>(
|
res = new ResWrap<T>(
|
||||||
container.getContextURL(),
|
container.getContextURL(),
|
||||||
container.getMetadataETag(),
|
container.getMetadataETag(),
|
||||||
|
@ -121,7 +121,7 @@ public class ODataReaderImpl implements ODataReader {
|
||||||
(URI) null,
|
(URI) null,
|
||||||
null,
|
null,
|
||||||
reference.cast(client.getObjectFactory().newPrimitiveValueBuilder().
|
reference.cast(client.getObjectFactory().newPrimitiveValueBuilder().
|
||||||
setType(ODataFormat.fromString(format) == ODataFormat.TEXT_PLAIN
|
setType(ContentType.parse(format).equals(ContentType.TEXT_PLAIN)
|
||||||
? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
|
? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
|
||||||
setValue(IOUtils.toString(src)) // TODO: set correct value
|
setValue(IOUtils.toString(src)) // TODO: set correct value
|
||||||
.build()));
|
.build()));
|
||||||
|
@ -132,7 +132,7 @@ public class ODataReaderImpl implements ODataReader {
|
||||||
reference.cast(readMetadata(src)));
|
reference.cast(readMetadata(src)));
|
||||||
} else if (ClientServiceDocument.class.isAssignableFrom(reference)) {
|
} else if (ClientServiceDocument.class.isAssignableFrom(reference)) {
|
||||||
final ResWrap<ServiceDocument> resource =
|
final ResWrap<ServiceDocument> resource =
|
||||||
client.getDeserializer(ODataFormat.fromString(format)).toServiceDocument(src);
|
client.getDeserializer(ContentType.parse(format)).toServiceDocument(src);
|
||||||
res = new ResWrap<T>(
|
res = new ResWrap<T>(
|
||||||
resource.getContextURL(),
|
resource.getContextURL(),
|
||||||
resource.getMetadataETag(),
|
resource.getMetadataETag(),
|
||||||
|
@ -141,7 +141,7 @@ public class ODataReaderImpl implements ODataReader {
|
||||||
res = new ResWrap<T>(
|
res = new ResWrap<T>(
|
||||||
(URI) null,
|
(URI) null,
|
||||||
null,
|
null,
|
||||||
reference.cast(readError(src, ODataFormat.fromString(format))));
|
reference.cast(readError(src, ContentType.parse(format))));
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Invalid reference type " + reference);
|
throw new IllegalArgumentException("Invalid reference type " + reference);
|
||||||
}
|
}
|
||||||
|
@ -158,20 +158,20 @@ public class ODataReaderImpl implements ODataReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClientEntitySet readEntitySet(final InputStream input, final ODataFormat format)
|
public ClientEntitySet readEntitySet(final InputStream input, final ContentType contentType)
|
||||||
throws ODataDeserializerException {
|
throws ODataDeserializerException {
|
||||||
return client.getBinder().getODataEntitySet(client.getDeserializer(format).toEntitySet(input));
|
return client.getBinder().getODataEntitySet(client.getDeserializer(contentType).toEntitySet(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClientEntity readEntity(final InputStream input, final ODataFormat format)
|
public ClientEntity readEntity(final InputStream input, final ContentType contentType)
|
||||||
throws ODataDeserializerException {
|
throws ODataDeserializerException {
|
||||||
return client.getBinder().getODataEntity(client.getDeserializer(format).toEntity(input));
|
return client.getBinder().getODataEntity(client.getDeserializer(contentType).toEntity(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClientProperty readProperty(final InputStream input, final ODataFormat format)
|
public ClientProperty readProperty(final InputStream input, final ContentType contentType)
|
||||||
throws ODataDeserializerException {
|
throws ODataDeserializerException {
|
||||||
return client.getBinder().getODataProperty(client.getDeserializer(format).toProperty(input));
|
return client.getBinder().getODataProperty(client.getDeserializer(contentType).toProperty(input));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,14 +29,14 @@ import java.util.Collections;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.serialization.ODataSerializerException;
|
|
||||||
import org.apache.olingo.client.api.serialization.ODataWriter;
|
|
||||||
import org.apache.olingo.commons.api.Constants;
|
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
|
||||||
import org.apache.olingo.client.api.domain.ClientEntity;
|
import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
import org.apache.olingo.client.api.domain.ClientLink;
|
import org.apache.olingo.client.api.domain.ClientLink;
|
||||||
import org.apache.olingo.client.api.domain.ClientProperty;
|
import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.client.api.serialization.ODataWriter;
|
||||||
|
import org.apache.olingo.commons.api.Constants;
|
||||||
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
|
import org.apache.olingo.client.api.serialization.ODataSerializerException;
|
||||||
|
|
||||||
public class ODataWriterImpl implements ODataWriter {
|
public class ODataWriterImpl implements ODataWriter {
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public class ODataWriterImpl implements ODataWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream writeEntities(final Collection<ClientEntity> entities, final ODataFormat format)
|
public InputStream writeEntities(final Collection<ClientEntity> entities, final ContentType contentType)
|
||||||
throws ODataSerializerException {
|
throws ODataSerializerException {
|
||||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||||
OutputStreamWriter writer;
|
OutputStreamWriter writer;
|
||||||
|
@ -58,7 +58,7 @@ public class ODataWriterImpl implements ODataWriter {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
for (ClientEntity entity : entities) {
|
for (ClientEntity entity : entities) {
|
||||||
client.getSerializer(format).write(writer, client.getBinder().getEntity(entity));
|
client.getSerializer(contentType).write(writer, client.getBinder().getEntity(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ByteArrayInputStream(output.toByteArray());
|
return new ByteArrayInputStream(output.toByteArray());
|
||||||
|
@ -68,13 +68,13 @@ public class ODataWriterImpl implements ODataWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream writeEntity(final ClientEntity entity, final ODataFormat format)
|
public InputStream writeEntity(final ClientEntity entity, final ContentType contentType)
|
||||||
throws ODataSerializerException {
|
throws ODataSerializerException {
|
||||||
return writeEntities(Collections.<ClientEntity>singleton(entity), format);
|
return writeEntities(Collections.<ClientEntity>singleton(entity), contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream writeProperty(final ClientProperty property, final ODataFormat format)
|
public InputStream writeProperty(final ClientProperty property, final ContentType contentType)
|
||||||
throws ODataSerializerException {
|
throws ODataSerializerException {
|
||||||
final ByteArrayOutputStream output = new ByteArrayOutputStream();
|
final ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||||
OutputStreamWriter writer;
|
OutputStreamWriter writer;
|
||||||
|
@ -84,7 +84,7 @@ public class ODataWriterImpl implements ODataWriter {
|
||||||
writer = null;
|
writer = null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
client.getSerializer(format).write(writer, client.getBinder().getProperty(property));
|
client.getSerializer(contentType).write(writer, client.getBinder().getProperty(property));
|
||||||
|
|
||||||
return new ByteArrayInputStream(output.toByteArray());
|
return new ByteArrayInputStream(output.toByteArray());
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -93,7 +93,7 @@ public class ODataWriterImpl implements ODataWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream writeLink(final ClientLink link, final ODataFormat format) throws ODataSerializerException {
|
public InputStream writeLink(final ClientLink link, final ContentType contentType) throws ODataSerializerException {
|
||||||
final ByteArrayOutputStream output = new ByteArrayOutputStream();
|
final ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||||
OutputStreamWriter writer;
|
OutputStreamWriter writer;
|
||||||
try {
|
try {
|
||||||
|
@ -102,7 +102,7 @@ public class ODataWriterImpl implements ODataWriter {
|
||||||
writer = null;
|
writer = null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
client.getSerializer(format).write(writer, client.getBinder().getLink(link));
|
client.getSerializer(contentType).write(writer, client.getBinder().getLink(link));
|
||||||
|
|
||||||
return new ByteArrayInputStream(output.toByteArray());
|
return new ByteArrayInputStream(output.toByteArray());
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -111,7 +111,7 @@ public class ODataWriterImpl implements ODataWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream writeReference(ResWrap<URI> reference, ODataFormat format) throws ODataSerializerException {
|
public InputStream writeReference(ResWrap<URI> reference, ContentType contenType) throws ODataSerializerException {
|
||||||
final ByteArrayOutputStream output = new ByteArrayOutputStream();
|
final ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||||
OutputStreamWriter writer;
|
OutputStreamWriter writer;
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ public class ODataWriterImpl implements ODataWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client.getSerializer(format).write(writer, reference);
|
client.getSerializer(contenType).write(writer, reference);
|
||||||
|
|
||||||
return new ByteArrayInputStream(output.toByteArray());
|
return new ByteArrayInputStream(output.toByteArray());
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
package org.apache.olingo.client.core;
|
package org.apache.olingo.client.core;
|
||||||
|
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.custommonkey.xmlunit.XMLUnit;
|
import org.custommonkey.xmlunit.XMLUnit;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
|
@ -43,7 +43,8 @@ public abstract class AbstractTest {
|
||||||
v4Client = ODataClientFactory.getClient();
|
v4Client = ODataClientFactory.getClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getSuffix(final ODataFormat format) {
|
protected String getSuffix(final ContentType contentType) {
|
||||||
return format == ODataFormat.ATOM || format == ODataFormat.XML ? "xml" : "json";
|
return contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML,
|
||||||
|
ContentType.APPLICATION_XML) ? "xml": "json";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,11 +20,8 @@ package org.apache.olingo.client.core.v4;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import java.io.ByteArrayInputStream;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import java.io.StringWriter;
|
||||||
import org.apache.olingo.client.core.AtomLinksQualifier;
|
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
|
||||||
import org.custommonkey.xmlunit.Diff;
|
|
||||||
|
|
||||||
import javax.xml.transform.Source;
|
import javax.xml.transform.Source;
|
||||||
import javax.xml.transform.Transformer;
|
import javax.xml.transform.Transformer;
|
||||||
|
@ -32,8 +29,11 @@ import javax.xml.transform.TransformerFactory;
|
||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
import javax.xml.transform.stream.StreamSource;
|
import javax.xml.transform.stream.StreamSource;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import org.apache.commons.io.IOUtils;
|
||||||
import java.io.StringWriter;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
|
import org.apache.olingo.client.core.AtomLinksQualifier;
|
||||||
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
|
import org.custommonkey.xmlunit.Diff;
|
||||||
|
|
||||||
public class AtomTest extends JSONTest {
|
public class AtomTest extends JSONTest {
|
||||||
|
|
||||||
|
@ -43,13 +43,13 @@ public class AtomTest extends JSONTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ODataFormat getODataPubFormat() {
|
protected ContentType getODataPubFormat() {
|
||||||
return ODataFormat.ATOM;
|
return ContentType.APPLICATION_ATOM_XML;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ODataFormat getODataFormat() {
|
protected ContentType getODataFormat() {
|
||||||
return ODataFormat.XML;
|
return ContentType.APPLICATION_XML;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String cleanup(final String input) throws Exception {
|
private String cleanup(final String input) throws Exception {
|
||||||
|
|
|
@ -18,23 +18,23 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.olingo.client.core.v4;
|
package org.apache.olingo.client.core.v4;
|
||||||
|
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import static org.junit.Assert.assertEquals;
|
||||||
import org.apache.olingo.client.core.AbstractTest;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import org.apache.olingo.commons.api.data.EntityCollection;
|
import static org.junit.Assert.assertNull;
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
|
||||||
import org.apache.olingo.client.api.domain.ClientEntity;
|
|
||||||
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
|
||||||
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
import static org.junit.Assert.assertNull;
|
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
||||||
|
import org.apache.olingo.client.core.AbstractTest;
|
||||||
|
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||||
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
|
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
public class EntitySetTest extends AbstractTest {
|
public class EntitySetTest extends AbstractTest {
|
||||||
|
|
||||||
|
@ -43,10 +43,10 @@ public class EntitySetTest extends AbstractTest {
|
||||||
return v4Client;
|
return v4Client;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void read(final ODataFormat format) throws IOException, ODataDeserializerException {
|
private void read(final ContentType contentType) throws IOException, ODataDeserializerException {
|
||||||
final InputStream input = getClass().getResourceAsStream("Customers." + getSuffix(format));
|
final InputStream input = getClass().getResourceAsStream("Customers." + getSuffix(contentType));
|
||||||
final ClientEntitySet entitySet = getClient().getBinder().getODataEntitySet(
|
final ClientEntitySet entitySet = getClient().getBinder().getODataEntitySet(
|
||||||
getClient().getDeserializer(format).toEntitySet(input));
|
getClient().getDeserializer(contentType).toEntitySet(input));
|
||||||
assertNotNull(entitySet);
|
assertNotNull(entitySet);
|
||||||
|
|
||||||
assertEquals(2, entitySet.getEntities().size());
|
assertEquals(2, entitySet.getEntities().size());
|
||||||
|
@ -60,18 +60,18 @@ public class EntitySetTest extends AbstractTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void fromAtom() throws Exception {
|
public void fromAtom() throws Exception {
|
||||||
read(ODataFormat.ATOM);
|
read(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void fromJSON() throws Exception {
|
public void fromJSON() throws Exception {
|
||||||
read(ODataFormat.JSON);
|
read(ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ref(final ODataFormat format) throws ODataDeserializerException {
|
private void ref(final ContentType contentType) throws ODataDeserializerException {
|
||||||
final InputStream input = getClass().getResourceAsStream("collectionOfEntityReferences." + getSuffix(format));
|
final InputStream input = getClass().getResourceAsStream("collectionOfEntityReferences." + getSuffix(contentType));
|
||||||
final ClientEntitySet entitySet = getClient().getBinder().getODataEntitySet(
|
final ClientEntitySet entitySet = getClient().getBinder().getODataEntitySet(
|
||||||
getClient().getDeserializer(format).toEntitySet(input));
|
getClient().getDeserializer(contentType).toEntitySet(input));
|
||||||
assertNotNull(entitySet);
|
assertNotNull(entitySet);
|
||||||
|
|
||||||
for (ClientEntity entity : entitySet.getEntities()) {
|
for (ClientEntity entity : entitySet.getEntities()) {
|
||||||
|
@ -87,11 +87,11 @@ public class EntitySetTest extends AbstractTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomRef() throws Exception {
|
public void atomRef() throws Exception {
|
||||||
ref(ODataFormat.ATOM);
|
ref(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonRef() throws Exception {
|
public void jsonRef() throws Exception {
|
||||||
ref(ODataFormat.JSON);
|
ref(ContentType.JSON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,6 @@ import java.util.Iterator;
|
||||||
|
|
||||||
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.core.AbstractTest;
|
|
||||||
import org.apache.olingo.client.core.EdmEnabledODataClientImpl;
|
|
||||||
import org.apache.olingo.commons.api.data.Entity;
|
|
||||||
import org.apache.olingo.commons.api.data.ResWrap;
|
|
||||||
import org.apache.olingo.client.api.domain.ClientAnnotation;
|
import org.apache.olingo.client.api.domain.ClientAnnotation;
|
||||||
import org.apache.olingo.client.api.domain.ClientComplexValue;
|
import org.apache.olingo.client.api.domain.ClientComplexValue;
|
||||||
import org.apache.olingo.client.api.domain.ClientEntity;
|
import org.apache.olingo.client.api.domain.ClientEntity;
|
||||||
|
@ -42,9 +38,13 @@ import org.apache.olingo.client.api.domain.ClientLinkType;
|
||||||
import org.apache.olingo.client.api.domain.ClientProperty;
|
import org.apache.olingo.client.api.domain.ClientProperty;
|
||||||
import org.apache.olingo.client.api.domain.ClientValuable;
|
import org.apache.olingo.client.api.domain.ClientValuable;
|
||||||
import org.apache.olingo.client.api.domain.ClientValue;
|
import org.apache.olingo.client.api.domain.ClientValue;
|
||||||
|
import org.apache.olingo.client.core.AbstractTest;
|
||||||
|
import org.apache.olingo.client.core.EdmEnabledODataClientImpl;
|
||||||
|
import org.apache.olingo.commons.api.data.Entity;
|
||||||
|
import org.apache.olingo.commons.api.data.ResWrap;
|
||||||
import org.apache.olingo.commons.api.edm.Edm;
|
import org.apache.olingo.commons.api.edm.Edm;
|
||||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmDateTimeOffset;
|
import org.apache.olingo.commons.core.edm.primitivetype.EdmDateTimeOffset;
|
||||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmDuration;
|
import org.apache.olingo.commons.core.edm.primitivetype.EdmDuration;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
|
@ -78,10 +78,10 @@ public class EntityTest extends AbstractTest {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void singleton(final ODataFormat format) throws Exception {
|
private void singleton(final ContentType contentType) throws Exception {
|
||||||
final InputStream input = getClass().getResourceAsStream("VipCustomer." + getSuffix(format));
|
final InputStream input = getClass().getResourceAsStream("VipCustomer." + getSuffix(contentType));
|
||||||
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
||||||
getClient().getDeserializer(format).toEntity(input));
|
getClient().getDeserializer(contentType).toEntity(input));
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
|
|
||||||
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
|
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
|
||||||
|
@ -102,7 +102,7 @@ public class EntityTest extends AbstractTest {
|
||||||
}
|
}
|
||||||
if ("Orders".equals(link.getName())) {
|
if ("Orders".equals(link.getName())) {
|
||||||
checked++;
|
checked++;
|
||||||
if (format == ODataFormat.ATOM) {
|
if(contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML)) {
|
||||||
assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, link.getType());
|
assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, link.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,18 +129,18 @@ public class EntityTest extends AbstractTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomSingleton() throws Exception {
|
public void atomSingleton() throws Exception {
|
||||||
singleton(ODataFormat.ATOM);
|
singleton(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonSingleton() throws Exception {
|
public void jsonSingleton() throws Exception {
|
||||||
singleton(ODataFormat.JSON_FULL_METADATA);
|
singleton(ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void withEnums(final ODataFormat format) throws Exception {
|
private void withEnums(final ContentType contentType) throws Exception {
|
||||||
final InputStream input = getClass().getResourceAsStream("Products_5." + getSuffix(format));
|
final InputStream input = getClass().getResourceAsStream("Products_5." + getSuffix(contentType));
|
||||||
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
||||||
getClient().getDeserializer(format).toEntity(input));
|
getClient().getDeserializer(contentType).toEntity(input));
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
|
|
||||||
final ClientProperty skinColor = entity.getProperty("SkinColor");
|
final ClientProperty skinColor = entity.getProperty("SkinColor");
|
||||||
|
@ -165,19 +165,19 @@ public class EntityTest extends AbstractTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomWithEnums() throws Exception {
|
public void atomWithEnums() throws Exception {
|
||||||
withEnums(ODataFormat.ATOM);
|
withEnums(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonWithEnums() throws Exception {
|
public void jsonWithEnums() throws Exception {
|
||||||
withEnums(ODataFormat.JSON_FULL_METADATA);
|
withEnums(ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void withInlineEntitySet(final ODataFormat format) throws Exception {
|
private void withInlineEntitySet(final ContentType contentType) throws Exception {
|
||||||
final InputStream input = getClass().getResourceAsStream(
|
final InputStream input = getClass().getResourceAsStream(
|
||||||
"Accounts_101_expand_MyPaymentInstruments." + getSuffix(format));
|
"Accounts_101_expand_MyPaymentInstruments." + getSuffix(contentType));
|
||||||
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
||||||
getClient().getDeserializer(format).toEntity(input));
|
getClient().getDeserializer(contentType).toEntity(input));
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
|
|
||||||
final ClientLink instruments = entity.getNavigationLink("MyPaymentInstruments");
|
final ClientLink instruments = entity.getNavigationLink("MyPaymentInstruments");
|
||||||
|
@ -200,19 +200,19 @@ public class EntityTest extends AbstractTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomWithInlineEntitySet() throws Exception {
|
public void atomWithInlineEntitySet() throws Exception {
|
||||||
withInlineEntitySet(ODataFormat.ATOM);
|
withInlineEntitySet(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonWithInlineEntitySet() throws Exception {
|
public void jsonWithInlineEntitySet() throws Exception {
|
||||||
withInlineEntitySet(ODataFormat.JSON_FULL_METADATA);
|
withInlineEntitySet(ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mediaEntity(final ODataFormat format) throws Exception {
|
private void mediaEntity(final ContentType contentType) throws Exception {
|
||||||
final InputStream input = getClass().getResourceAsStream(
|
final InputStream input = getClass().getResourceAsStream(
|
||||||
"Advertisements_f89dee73-af9f-4cd4-b330-db93c25ff3c7." + getSuffix(format));
|
"Advertisements_f89dee73-af9f-4cd4-b330-db93c25ff3c7." + getSuffix(contentType));
|
||||||
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
||||||
getClient().getDeserializer(format).toEntity(input));
|
getClient().getDeserializer(contentType).toEntity(input));
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
|
|
||||||
assertTrue(entity.isMediaEntity());
|
assertTrue(entity.isMediaEntity());
|
||||||
|
@ -227,18 +227,18 @@ public class EntityTest extends AbstractTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomMediaEntity() throws Exception {
|
public void atomMediaEntity() throws Exception {
|
||||||
mediaEntity(ODataFormat.ATOM);
|
mediaEntity(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonMediaEntity() throws Exception {
|
public void jsonMediaEntity() throws Exception {
|
||||||
mediaEntity(ODataFormat.JSON_FULL_METADATA);
|
mediaEntity(ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void withStream(final ODataFormat format) throws Exception {
|
private void withStream(final ContentType contentType) throws Exception {
|
||||||
final InputStream input = getClass().getResourceAsStream("PersonDetails_1." + getSuffix(format));
|
final InputStream input = getClass().getResourceAsStream("PersonDetails_1." + getSuffix(contentType));
|
||||||
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
||||||
getClient().getDeserializer(format).toEntity(input));
|
getClient().getDeserializer(contentType).toEntity(input));
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
|
|
||||||
assertFalse(entity.isMediaEntity());
|
assertFalse(entity.isMediaEntity());
|
||||||
|
@ -254,18 +254,18 @@ public class EntityTest extends AbstractTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomWithStream() throws Exception {
|
public void atomWithStream() throws Exception {
|
||||||
withStream(ODataFormat.ATOM);
|
withStream(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonWithStream() throws Exception {
|
public void jsonWithStream() throws Exception {
|
||||||
withStream(ODataFormat.JSON_FULL_METADATA);
|
withStream(ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ref(final ODataFormat format) throws Exception {
|
private void ref(final ContentType contentType) throws Exception {
|
||||||
final InputStream input = getClass().getResourceAsStream("entityReference." + getSuffix(format));
|
final InputStream input = getClass().getResourceAsStream("entityReference." + getSuffix(contentType));
|
||||||
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
||||||
getClient().getDeserializer(format).toEntity(input));
|
getClient().getDeserializer(contentType).toEntity(input));
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
|
|
||||||
assertNotNull(entity.getId());
|
assertNotNull(entity.getId());
|
||||||
|
@ -278,18 +278,18 @@ public class EntityTest extends AbstractTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomRef() throws Exception {
|
public void atomRef() throws Exception {
|
||||||
ref(ODataFormat.ATOM);
|
ref(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonRef() throws Exception {
|
public void jsonRef() throws Exception {
|
||||||
ref(ODataFormat.JSON);
|
ref(ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void complexNavigationProperties(final ODataFormat format) throws Exception {
|
private void complexNavigationProperties(final ContentType contentType) throws Exception {
|
||||||
final InputStream input = getClass().getResourceAsStream("entity.withcomplexnavigation." + getSuffix(format));
|
final InputStream input = getClass().getResourceAsStream("entity.withcomplexnavigation." + getSuffix(contentType));
|
||||||
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
||||||
getClient().getDeserializer(format).toEntity(input));
|
getClient().getDeserializer(contentType).toEntity(input));
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
|
|
||||||
final ClientComplexValue addressValue = entity.getProperty("Address").getComplexValue();
|
final ClientComplexValue addressValue = entity.getProperty("Address").getComplexValue();
|
||||||
|
@ -306,18 +306,18 @@ public class EntityTest extends AbstractTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomComplexNavigationProperties() throws Exception {
|
public void atomComplexNavigationProperties() throws Exception {
|
||||||
complexNavigationProperties(ODataFormat.ATOM);
|
complexNavigationProperties(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonComplexNavigationProperties() throws Exception {
|
public void jsonComplexNavigationProperties() throws Exception {
|
||||||
complexNavigationProperties(ODataFormat.JSON);
|
complexNavigationProperties(ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void annotated(final ODataFormat format) throws EdmPrimitiveTypeException, Exception {
|
private void annotated(final ContentType contentType) throws EdmPrimitiveTypeException, Exception {
|
||||||
final InputStream input = getClass().getResourceAsStream("annotated." + getSuffix(format));
|
final InputStream input = getClass().getResourceAsStream("annotated." + getSuffix(contentType));
|
||||||
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
||||||
getClient().getDeserializer(format).toEntity(input));
|
getClient().getDeserializer(contentType).toEntity(input));
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
|
|
||||||
assertFalse(entity.getAnnotations().isEmpty());
|
assertFalse(entity.getAnnotations().isEmpty());
|
||||||
|
@ -353,18 +353,18 @@ public class EntityTest extends AbstractTest {
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
@Ignore
|
||||||
public void atomAnnotated() throws Exception {
|
public void atomAnnotated() throws Exception {
|
||||||
annotated(ODataFormat.ATOM);
|
annotated(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
@Ignore
|
||||||
public void jsonAnnotated() throws Exception {
|
public void jsonAnnotated() throws Exception {
|
||||||
annotated(ODataFormat.JSON);
|
annotated(ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void derived(final ODataClient client, final ODataFormat format) throws Exception {
|
private void derived(final ODataClient client, final ContentType contentType) throws Exception {
|
||||||
final InputStream input = getClass().getResourceAsStream("Customer." + getSuffix(format));
|
final InputStream input = getClass().getResourceAsStream("Customer." + getSuffix(contentType));
|
||||||
final ClientEntity entity = client.getBinder().getODataEntity(client.getDeserializer(format).toEntity(input));
|
final ClientEntity entity = client.getBinder().getODataEntity(client.getDeserializer(contentType).toEntity(input));
|
||||||
assertNotNull(entity);
|
assertNotNull(entity);
|
||||||
|
|
||||||
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
|
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
|
||||||
|
@ -375,16 +375,16 @@ public class EntityTest extends AbstractTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void derivedFromAtom() throws Exception {
|
public void derivedFromAtom() throws Exception {
|
||||||
derived(getClient(), ODataFormat.ATOM);
|
derived(getClient(), ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void derivedFromJSON() throws Exception {
|
public void derivedFromJSON() throws Exception {
|
||||||
derived(getEdmEnabledClient(), ODataFormat.JSON);
|
derived(getEdmEnabledClient(), ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void derivedFromFullJSON() throws Exception {
|
public void derivedFromFullJSON() throws Exception {
|
||||||
derived(getClient(), ODataFormat.JSON_FULL_METADATA);
|
derived(getClient(), ContentType.JSON_FULL_METADATA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,16 +18,16 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.olingo.client.core.v4;
|
package org.apache.olingo.client.core.v4;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
import org.apache.olingo.client.api.ODataClient;
|
import org.apache.olingo.client.api.ODataClient;
|
||||||
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
||||||
import org.apache.olingo.client.core.AbstractTest;
|
import org.apache.olingo.client.core.AbstractTest;
|
||||||
import org.apache.olingo.commons.api.ODataError;
|
import org.apache.olingo.commons.api.ODataError;
|
||||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
|
|
||||||
public class ErrorTest extends AbstractTest {
|
public class ErrorTest extends AbstractTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,15 +35,15 @@ public class ErrorTest extends AbstractTest {
|
||||||
return v4Client;
|
return v4Client;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ODataError error(final String name, final ODataFormat format) throws ODataDeserializerException {
|
private ODataError error(final String name, final ContentType contentType) throws ODataDeserializerException {
|
||||||
final ODataError error = getClient().getDeserializer(format).toError(
|
final ODataError error = getClient().getDeserializer(contentType).toError(
|
||||||
getClass().getResourceAsStream(name + "." + getSuffix(format)));
|
getClass().getResourceAsStream(name + "." + getSuffix(contentType)));
|
||||||
assertNotNull(error);
|
assertNotNull(error);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void simple(final ODataFormat format) throws ODataDeserializerException {
|
private void simple(final ContentType contentType) throws ODataDeserializerException {
|
||||||
final ODataError error = error("error", format);
|
final ODataError error = error("error", contentType);
|
||||||
assertEquals("501", error.getCode());
|
assertEquals("501", error.getCode());
|
||||||
assertEquals("Unsupported functionality", error.getMessage());
|
assertEquals("Unsupported functionality", error.getMessage());
|
||||||
assertEquals("query", error.getTarget());
|
assertEquals("query", error.getTarget());
|
||||||
|
@ -51,12 +51,12 @@ public class ErrorTest extends AbstractTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonSimple() throws Exception {
|
public void jsonSimple() throws Exception {
|
||||||
simple(ODataFormat.JSON);
|
simple(ContentType.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void atomSimple() throws Exception {
|
public void atomSimple() throws Exception {
|
||||||
simple(ODataFormat.ATOM);
|
simple(ContentType.APPLICATION_ATOM_XML);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue