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.edm.Edm;
|
||||
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.ext.proxy.api.AbstractTerm;
|
||||
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.getConfiguration().setDefaultPubFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
this.client.getConfiguration().setDefaultPubFormat(ContentType.JSON_FULL_METADATA);
|
||||
this.transactional = transactional;
|
||||
this.context = new Context();
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.lang.annotation.Annotation;
|
|||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.olingo.client.api.domain.ClientEntity;
|
||||
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.ODataMediaRequest;
|
||||
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.ClientEntity;
|
||||
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.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.apache.olingo.ext.proxy.AbstractService;
|
||||
import org.apache.olingo.ext.proxy.api.AbstractTerm;
|
||||
import org.apache.olingo.ext.proxy.api.Annotatable;
|
||||
|
@ -335,7 +335,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
|
|||
getClient().getRetrieveRequestFactory().getMediaEntityRequest(contentSource);
|
||||
|
||||
if (StringUtils.isNotBlank(getEntity().getMediaContentType())) {
|
||||
retrieveReq.setFormat(ODataFormat.fromString(getEntity().getMediaContentType()));
|
||||
retrieveReq.setFormat(ContentType.parse(getEntity().getMediaContentType()));
|
||||
}
|
||||
|
||||
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.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.ClientEntity;
|
||||
import org.apache.olingo.client.api.uri.URIBuilder;
|
||||
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.api.AbstractEntitySet;
|
||||
import org.apache.olingo.ext.proxy.api.AbstractSingleton;
|
||||
|
@ -95,7 +95,7 @@ public class EntitySetInvocationHandler<
|
|||
public Long count() {
|
||||
final ODataValueRequest req = getClient().getRetrieveRequestFactory().
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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.EdmSchema;
|
||||
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.VelocityContext;
|
||||
import org.apache.velocity.app.Velocity;
|
||||
|
@ -218,7 +218,7 @@ public abstract class AbstractPOJOGenMojo extends AbstractMojo {
|
|||
} else if (StringUtils.isNotEmpty(localEdm)) {
|
||||
final FileInputStream fis = new FileInputStream(FileUtils.getFile(localEdm));
|
||||
try {
|
||||
metadata = getClient().getDeserializer(ODataFormat.XML).toMetadata(fis);
|
||||
metadata = getClient().getDeserializer(ContentType.APPLICATION_XML).toMetadata(fis);
|
||||
edm = getClient().getReader().readMetadata(metadata.getSchemaByNsOrAlias());
|
||||
} finally {
|
||||
IOUtils.closeQuietly(fis);
|
||||
|
|
|
@ -148,7 +148,7 @@ public abstract class AbstractServices {
|
|||
atomDeserializer = new FITAtomDeserializer();
|
||||
jsonDeserializer = new JsonDeserializer(true);
|
||||
atomSerializer = new AtomSerializer(true);
|
||||
jsonSerializer = new JsonSerializer(true);
|
||||
jsonSerializer = new JsonSerializer(true, ContentType.JSON_FULL_METADATA);
|
||||
|
||||
xml = new XMLUtilities(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.ResWrap;
|
||||
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.metadata.Metadata;
|
||||
import org.apache.olingo.fit.metadata.NavigationProperty;
|
||||
|
@ -104,7 +105,7 @@ public abstract class AbstractUtilities {
|
|||
atomDeserializer = new FITAtomDeserializer();
|
||||
jsonDeserializer = new JsonDeserializer(true);
|
||||
atomSerializer = new AtomSerializer(true);
|
||||
jsonSerializer = new JsonSerializer(true);
|
||||
jsonSerializer = new JsonSerializer(true, ContentType.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
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.ResWrap;
|
||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -125,7 +126,7 @@ public class FSManager {
|
|||
putInMemory(new ByteArrayInputStream(content.toByteArray()), getAbsolutePath(relativePath, Accept.ATOM));
|
||||
content.reset();
|
||||
|
||||
new JsonSerializer(true).write(writer, container);
|
||||
new JsonSerializer(true, ContentType.JSON_FULL_METADATA).write(writer, container);
|
||||
writer.flush();
|
||||
|
||||
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.commons.api.data.Entity;
|
||||
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.server.tecsvc.TechnicalServlet;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -72,7 +72,7 @@ public abstract class AbstractBaseTestITCase {
|
|||
if (LOG.isDebugEnabled()) {
|
||||
final StringWriter writer = new StringWriter();
|
||||
try {
|
||||
getClient().getSerializer(ODataFormat.JSON).write(writer, entity);
|
||||
getClient().getSerializer(ContentType.JSON).write(writer, entity);
|
||||
} catch (final ODataSerializerException e) {
|
||||
// Debug
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public abstract class AbstractBaseTestITCase {
|
|||
if (LOG.isDebugEnabled()) {
|
||||
final StringWriter writer = new StringWriter();
|
||||
try {
|
||||
getClient().getSerializer(ODataFormat.JSON).write(writer, entitySet);
|
||||
getClient().getSerializer(ContentType.JSON).write(writer, entitySet);
|
||||
} catch (final ODataSerializerException e) {
|
||||
// Debug
|
||||
}
|
||||
|
@ -106,7 +106,8 @@ public abstract class AbstractBaseTestITCase {
|
|||
if (LOG.isDebugEnabled()) {
|
||||
StringWriter writer = new StringWriter();
|
||||
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) {
|
||||
// Debug
|
||||
}
|
||||
|
@ -115,7 +116,7 @@ public abstract class AbstractBaseTestITCase {
|
|||
|
||||
writer = new StringWriter();
|
||||
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) {
|
||||
// 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.core.ODataClientFactory;
|
||||
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.fit.AbstractBaseTestITCase;
|
||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||
|
@ -309,7 +309,7 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
|
|||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON_NO_METADATA);
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON_NO_METADATA);
|
||||
return odata;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import static org.junit.Assert.assertThat;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
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.ODataEntityCreateRequest;
|
||||
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.retrieve.EdmMetadataRequest;
|
||||
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.ODataPropertyRequest;
|
||||
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.XMLMetadataRequest;
|
||||
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.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.domain.ClientAnnotation;
|
||||
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.FullQualifiedName;
|
||||
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.HttpStatusCode;
|
||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
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 ES_ALL_PRIM = "ESAllPrim";
|
||||
private static final String ES_TWO_PRIM = "ESTwoPrim";
|
||||
private static final String ES_KEY_NAV = "ESKeyNav";
|
||||
|
||||
@Test
|
||||
public void readServiceDocument() {
|
||||
|
@ -377,7 +396,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
ClientEntity newEntity = factory.newEntity(new FullQualifiedName("olingo.odata.test1", "ETAllPrim"));
|
||||
newEntity.getProperties().add(factory.newPrimitiveProperty("PropertyInt64",
|
||||
factory.newPrimitiveValueBuilder().buildInt32(42)));
|
||||
newEntity.addLink(factory.newEntityNavigationLink("NavPropertyETTwoPrimOne",
|
||||
newEntity.addLink(factory.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_PRIM_ONE,
|
||||
client.newURIBuilder(SERVICE_URI)
|
||||
.appendEntitySetSegment("ESTwoPrim")
|
||||
.appendKeySegment(32766)
|
||||
|
@ -422,7 +441,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
@Test
|
||||
public void readEntityWithExpandedNavigationProperty() {
|
||||
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
client.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
|
||||
final URI uri = client.newURIBuilder(SERVICE_URI)
|
||||
.appendEntitySetSegment("ESKeyNav")
|
||||
|
@ -927,11 +946,356 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
.get("PropertyInt16")
|
||||
.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
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
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.FullQualifiedName;
|
||||
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.HttpStatusCode;
|
||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||
|
@ -122,7 +121,7 @@ public class BatchClientITCase extends AbstractTestITCase {
|
|||
assertTrue(changeSetResponse.isBreaking());
|
||||
|
||||
assertEquals(HttpStatusCode.NOT_FOUND.getStatusCode(), updateResponse.getStatusCode());
|
||||
assertEquals(ODataFormat.JSON.toString(), updateResponse.getContentType());
|
||||
assertEquals(ContentType.JSON.toContentTypeString(), updateResponse.getContentType());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -252,7 +251,7 @@ public class BatchClientITCase extends AbstractTestITCase {
|
|||
final BatchManager payload = request.payloadManager();
|
||||
final URI uri = new URI(SERVICE_URI + "/../ESAllPrim(32767)");
|
||||
final ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(uri);
|
||||
queryReq.setFormat(ODataFormat.JSON);
|
||||
queryReq.setFormat(ContentType.JSON);
|
||||
payload.addRequest(queryReq);
|
||||
|
||||
// Fetch result
|
||||
|
@ -276,7 +275,7 @@ public class BatchClientITCase extends AbstractTestITCase {
|
|||
final BatchManager payload = request.payloadManager();
|
||||
final URI uri = new URI("http://otherhost/odata/ESAllPrim(32767)");
|
||||
final ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(uri);
|
||||
queryReq.setFormat(ODataFormat.JSON);
|
||||
queryReq.setFormat(ContentType.JSON);
|
||||
payload.addRequest(queryReq);
|
||||
|
||||
// Fetch result
|
||||
|
@ -290,7 +289,7 @@ public class BatchClientITCase extends AbstractTestITCase {
|
|||
final BatchManager payload = request.payloadManager();
|
||||
final URI uri = new URI("/ESAllPrim(32767)");
|
||||
final ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(uri);
|
||||
queryReq.setFormat(ODataFormat.JSON);
|
||||
queryReq.setFormat(ContentType.JSON);
|
||||
payload.addRequest(queryReq);
|
||||
|
||||
// Fetch result
|
||||
|
@ -379,7 +378,7 @@ public class BatchClientITCase extends AbstractTestITCase {
|
|||
// add create request
|
||||
final ODataEntityCreateRequest<ClientEntity> createReq =
|
||||
client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), entityESAllPrim);
|
||||
createReq.setFormat(ODataFormat.JSON);
|
||||
createReq.setFormat(ContentType.JSON);
|
||||
changeset.addRequest(createReq);
|
||||
|
||||
// retrieve request reference
|
||||
|
@ -393,7 +392,7 @@ public class BatchClientITCase extends AbstractTestITCase {
|
|||
|
||||
final ODataEntityUpdateRequest<ClientEntity> updateReq = client.getCUDRequestFactory().getEntityUpdateRequest(
|
||||
URI.create("$" + createRequestRef), UpdateType.PATCH, entityUpdate);
|
||||
updateReq.setFormat(ODataFormat.JSON);
|
||||
updateReq.setFormat(ContentType.JSON);
|
||||
|
||||
changeset.addRequest(updateReq);
|
||||
|
||||
|
@ -419,7 +418,7 @@ public class BatchClientITCase extends AbstractTestITCase {
|
|||
|
||||
final ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest(
|
||||
new URI(createResponse.getHeader(HttpHeader.LOCATION).iterator().next() + "/NavPropertyETTwoPrimMany"));
|
||||
req.setFormat(ODataFormat.JSON);
|
||||
req.setFormat(ContentType.JSON);
|
||||
req.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||
final ODataRetrieveResponse<ClientEntitySet> getResponse = req.execute();
|
||||
|
||||
|
@ -466,7 +465,7 @@ public class BatchClientITCase extends AbstractTestITCase {
|
|||
|
||||
final ODataEntityCreateRequest<ClientEntity> createRequest =
|
||||
client.getCUDRequestFactory().getEntityCreateRequest(editLink, postEntity);
|
||||
createRequest.setFormat(ODataFormat.JSON);
|
||||
createRequest.setFormat(ContentType.JSON);
|
||||
|
||||
changeset.addRequest(createRequest);
|
||||
|
||||
|
@ -485,7 +484,7 @@ public class BatchClientITCase extends AbstractTestITCase {
|
|||
|
||||
ODataEntityUpdateRequest<ClientEntity> changeReq =
|
||||
client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patchEntity);
|
||||
changeReq.setFormat(ODataFormat.JSON);
|
||||
changeReq.setFormat(ContentType.JSON);
|
||||
changeset.addRequest(changeReq);
|
||||
|
||||
// ------------------------
|
||||
|
@ -506,7 +505,7 @@ public class BatchClientITCase extends AbstractTestITCase {
|
|||
.build()));
|
||||
|
||||
changeReq = client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patchEntity);
|
||||
changeReq.setFormat(ODataFormat.JSON);
|
||||
changeReq.setFormat(ContentType.JSON);
|
||||
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();
|
||||
|
||||
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(uri);
|
||||
queryReq.setFormat(ODataFormat.JSON);
|
||||
queryReq.setFormat(ContentType.JSON);
|
||||
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.commons.api.edm.EdmPrimitiveTypeException;
|
||||
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.HttpStatusCode;
|
||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
|
@ -324,7 +324,7 @@ public class BindingITCase extends AbstractBaseTestITCase {
|
|||
@Test
|
||||
public void testDeepInsertWithBindingSameNavigationProperty() {
|
||||
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
client.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
|
||||
final ClientEntity entity = of.newEntity(ET_KEY_NAV);
|
||||
|
@ -392,7 +392,7 @@ public class BindingITCase extends AbstractBaseTestITCase {
|
|||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
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.core.ODataClientFactory;
|
||||
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.HttpStatusCode;
|
||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
|
@ -281,7 +281,7 @@ public final class ConditionalITCase extends AbstractBaseTestITCase {
|
|||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
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.commons.api.edm.EdmPrimitiveTypeException;
|
||||
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.HttpStatusCode;
|
||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
|
@ -91,7 +91,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
|
|||
@Test
|
||||
public void testDeepInsertExpandedResponse() {
|
||||
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 ClientObjectFactory of = client.getObjectFactory();
|
||||
final ClientEntity entity = of.newEntity(ET_KEY_NAV);
|
||||
|
@ -900,7 +900,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
|
|||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
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.uri.QueryOption;
|
||||
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.HttpStatusCode;
|
||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
|
@ -1002,7 +1002,7 @@ public class EntityReferencesITCase extends AbstractBaseTestITCase {
|
|||
@Override
|
||||
protected ODataClient getClient() {
|
||||
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
client.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
|
||||
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.uri.QueryOption;
|
||||
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.HttpStatusCode;
|
||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
|
@ -471,7 +471,7 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
|
|||
@Override
|
||||
protected ODataClient getClient() {
|
||||
EdmEnabledODataClient odata = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
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.core.ODataClientFactory;
|
||||
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.HttpStatusCode;
|
||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
|
@ -1008,7 +1008,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
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.ClientValue;
|
||||
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.fit.AbstractBaseTestITCase;
|
||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||
|
@ -223,7 +223,7 @@ public class FunctionImportITCase extends AbstractBaseTestITCase {
|
|||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
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.core.ODataClientFactory;
|
||||
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.HttpStatusCode;
|
||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
|
@ -156,7 +155,7 @@ public final class MediaITCase extends AbstractBaseTestITCase {
|
|||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
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.ClientProperty;
|
||||
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.fit.AbstractBaseTestITCase;
|
||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||
|
@ -135,7 +135,7 @@ public final class NavigationITCase extends AbstractBaseTestITCase {
|
|||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
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.ClientValuable;
|
||||
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.fit.AbstractBaseTestITCase;
|
||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||
|
@ -164,7 +164,7 @@ public class OrderBySystemQueryITCase extends AbstractBaseTestITCase {
|
|||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
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.core.ODataClientFactory;
|
||||
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.HttpStatusCode;
|
||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
|
@ -421,7 +420,7 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
|
|||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
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.ClientEntitySet;
|
||||
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.fit.AbstractBaseTestITCase;
|
||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||
|
@ -311,7 +311,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
|
|||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType .JSON);
|
||||
return odata;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,15 +19,20 @@
|
|||
package org.apache.olingo.fit.tecsvc.http;
|
||||
|
||||
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.URL;
|
||||
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
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.tecsvc.TecSvcConst;
|
||||
import org.apache.olingo.server.core.deserializer.batch.BufferedReaderIncludingLineEndings;
|
||||
import org.junit.Test;
|
||||
|
||||
public class BasicHttpITCase extends AbstractBaseTestITCase {
|
||||
|
@ -116,7 +121,54 @@ public class BasicHttpITCase extends AbstractBaseTestITCase {
|
|||
String v = connection.getHeaderField(HttpHeader.ODATA_VERSION);
|
||||
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
|
||||
protected ODataClient getClient() {
|
||||
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.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
|
@ -97,23 +96,23 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
|
|||
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);
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
||||
final ClientEntity entity = res.getBody();
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
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(
|
||||
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(
|
||||
getClient().newURIBuilder(serviceRoot).
|
||||
appendEntitySetSegment("Orders").build(), order);
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
final ClientEntity created = req.execute().getBody();
|
||||
assertNotNull(created);
|
||||
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());
|
||||
assertNull(created.getEditLink());
|
||||
} else if (format == ODataFormat.JSON_FULL_METADATA) {
|
||||
} else if (contentType.equals(ContentType.JSON_FULL_METADATA)) {
|
||||
assertEquals(3, created.getNavigationLinks().size());
|
||||
assertThat(created.getTypeName().getNamespace(), is("Microsoft.Test.OData.Services.ODataWCFService"));
|
||||
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());
|
||||
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.ClientProperty;
|
||||
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;
|
||||
|
||||
public class AsyncTestITCase extends AbstractTestITCase {
|
||||
|
@ -62,13 +62,13 @@ public class AsyncTestITCase extends AbstractTestITCase {
|
|||
assertFalse(res.getBody().getEntities().isEmpty());
|
||||
}
|
||||
|
||||
private void withInlineEntry(final ODataFormat format) {
|
||||
private void withInlineEntry(final ContentType contentType) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");
|
||||
|
||||
final ODataEntityRequest<ClientEntity> req =
|
||||
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
final AsyncRequestWrapper<ODataRetrieveResponse<ClientEntity>> async =
|
||||
client.getAsyncRequestFactory().<ODataRetrieveResponse<ClientEntity>> getAsyncRequestWrapper(req);
|
||||
|
@ -86,7 +86,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
|
|||
|
||||
assertEquals(3, entity.getNavigationLinks().size());
|
||||
|
||||
if (ODataFormat.ATOM == format) {
|
||||
if (ContentType.APPLICATION_ATOM_XML.equals(contentType)) {
|
||||
assertTrue(entity.getAssociationLinks().isEmpty());
|
||||
// In JSON, association links for each $ref link will exist.
|
||||
}
|
||||
|
@ -121,22 +121,22 @@ public class AsyncTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void withInlineEntryAsAtom() {
|
||||
withInlineEntry(ODataFormat.ATOM);
|
||||
withInlineEntry(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withInlineEntryAsJSON() {
|
||||
// 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).
|
||||
appendEntitySetSegment("async").appendEntitySetSegment("Orders");
|
||||
|
||||
final ODataEntitySetRequest<ClientEntitySet> req =
|
||||
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
final AsyncRequestWrapper<ODataRetrieveResponse<ClientEntitySet>> async =
|
||||
client.getAsyncRequestFactory().<ODataRetrieveResponse<ClientEntitySet>> getAsyncRequestWrapper(req);
|
||||
|
@ -155,11 +155,11 @@ public class AsyncTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void asyncOrdersAsAtom() {
|
||||
asyncOrders(ODataFormat.ATOM);
|
||||
asyncOrders(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
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.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class AuthBatchTestITCase extends AbstractTestITCase {
|
||||
|
@ -84,7 +83,7 @@ public class AuthBatchTestITCase extends AbstractTestITCase {
|
|||
|
||||
// create new request
|
||||
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
|
||||
queryReq.setFormat(ODataFormat.JSON);
|
||||
queryReq.setFormat(ContentType.JSON);
|
||||
|
||||
streamManager.addRequest(queryReq);
|
||||
// -------------------------------------------
|
||||
|
@ -108,7 +107,7 @@ public class AuthBatchTestITCase extends AbstractTestITCase {
|
|||
|
||||
final ODataEntityUpdateRequest<ClientEntity> changeReq =
|
||||
client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patch);
|
||||
changeReq.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
changeReq.setFormat(ContentType.JSON_FULL_METADATA);
|
||||
|
||||
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.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class BatchTestITCase extends AbstractTestITCase {
|
||||
|
@ -128,20 +127,20 @@ public class BatchTestITCase extends AbstractTestITCase {
|
|||
for (int i = 1; i <= 2; i++) {
|
||||
// Create Customer into the changeset
|
||||
createReq = client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), newOrder(100 + i));
|
||||
createReq.setFormat(ODataFormat.JSON);
|
||||
createReq.setFormat(ContentType.JSON);
|
||||
changeset.addRequest(createReq);
|
||||
}
|
||||
|
||||
targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("WrongEntitySet");
|
||||
createReq = client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), newOrder(105));
|
||||
createReq.setFormat(ODataFormat.JSON);
|
||||
createReq.setFormat(ContentType.JSON);
|
||||
changeset.addRequest(createReq);
|
||||
|
||||
targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders");
|
||||
for (int i = 3; i <= 4; i++) {
|
||||
// Create Customer into the changeset
|
||||
createReq = client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), newOrder(100 + i));
|
||||
createReq.setFormat(ODataFormat.JSON);
|
||||
createReq.setFormat(ContentType.JSON);
|
||||
changeset.addRequest(createReq);
|
||||
}
|
||||
|
||||
|
@ -193,7 +192,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
|||
|
||||
// create new request
|
||||
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
|
||||
queryReq.setFormat(ODataFormat.JSON);
|
||||
queryReq.setFormat(ContentType.JSON);
|
||||
|
||||
streamManager.addRequest(queryReq);
|
||||
// -------------------------------------------
|
||||
|
@ -340,7 +339,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
|||
|
||||
// create new request
|
||||
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
|
||||
queryReq.setFormat(ODataFormat.JSON);
|
||||
queryReq.setFormat(ContentType.JSON);
|
||||
|
||||
streamManager.addRequest(queryReq);
|
||||
// -------------------------------------------
|
||||
|
@ -353,7 +352,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
|||
final ClientEntity original = newOrder(2000);
|
||||
final ODataEntityCreateRequest<ClientEntity> createReq =
|
||||
client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), original);
|
||||
createReq.setFormat(ODataFormat.JSON);
|
||||
createReq.setFormat(ContentType.JSON);
|
||||
streamManager.addRequest(createReq);
|
||||
// -------------------------------------------
|
||||
|
||||
|
@ -407,7 +406,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
|||
|
||||
// create new request
|
||||
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
|
||||
queryReq.setFormat(ODataFormat.JSON);
|
||||
queryReq.setFormat(ContentType.JSON);
|
||||
|
||||
streamManager.addRequest(queryReq);
|
||||
// -------------------------------------------
|
||||
|
@ -431,7 +430,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
|||
|
||||
final ODataEntityUpdateRequest<ClientEntity> changeReq =
|
||||
client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patch);
|
||||
changeReq.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
changeReq.setFormat(ContentType.JSON_FULL_METADATA);
|
||||
|
||||
changeset.addRequest(changeReq);
|
||||
|
||||
|
@ -440,7 +439,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
|||
final ClientEntity original = newOrder(1000);
|
||||
final ODataEntityCreateRequest<ClientEntity> createReq =
|
||||
client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), original);
|
||||
createReq.setFormat(ODataFormat.JSON);
|
||||
createReq.setFormat(ContentType.JSON);
|
||||
changeset.addRequest(createReq);
|
||||
// -------------------------------------------
|
||||
|
||||
|
@ -531,7 +530,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
|||
|
||||
// create new request
|
||||
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
|
||||
queryReq.setFormat(ODataFormat.JSON);
|
||||
queryReq.setFormat(ContentType.JSON);
|
||||
|
||||
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.EdmPrimitiveTypeKind;
|
||||
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;
|
||||
|
||||
public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||
|
||||
private void functions(final ODataFormat format) throws EdmPrimitiveTypeException {
|
||||
private void functions(final ContentType contentType) throws EdmPrimitiveTypeException {
|
||||
// GetEmployeesCount
|
||||
URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company");
|
||||
final ODataEntityRequest<ClientSingleton> singletonReq =
|
||||
client.getRetrieveRequestFactory().getSingletonRequest(builder.build());
|
||||
singletonReq.setFormat(format);
|
||||
singletonReq.setFormat(contentType);
|
||||
final ClientSingleton company = singletonReq.execute().getBody();
|
||||
assertNotNull(company);
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
|||
|
||||
final ODataInvokeRequest<ClientProperty> getEmployeesCountReq =
|
||||
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientProperty.class);
|
||||
getEmployeesCountReq.setFormat(format);
|
||||
getEmployeesCountReq.setFormat(contentType);
|
||||
final ClientProperty getEmployeesCountRes = getEmployeesCountReq.execute().getBody();
|
||||
assertNotNull(getEmployeesCountRes);
|
||||
assertTrue(getEmployeesCountRes.hasPrimitiveValue());
|
||||
|
@ -74,7 +74,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
|||
appendEntitySetSegment("Products").appendKeySegment(5);
|
||||
ODataEntityRequest<ClientEntity> entityReq = client.getRetrieveRequestFactory().
|
||||
getEntityRequest(builder.build());
|
||||
entityReq.setFormat(format);
|
||||
entityReq.setFormat(contentType);
|
||||
ClientEntity entity = entityReq.execute().getBody();
|
||||
assertNotNull(entity);
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
|||
final ODataInvokeRequest<ClientEntitySet> getProductDetailsReq =
|
||||
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientEntitySet.class,
|
||||
Collections.<String, ClientValue> singletonMap("count", count));
|
||||
getProductDetailsReq.setFormat(format);
|
||||
getProductDetailsReq.setFormat(contentType);
|
||||
final ClientEntitySet getProductDetailsRes = getProductDetailsReq.execute().getBody();
|
||||
assertNotNull(getProductDetailsRes);
|
||||
assertEquals(1, getProductDetailsRes.getEntities().size());
|
||||
|
@ -97,7 +97,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
|||
builder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("ProductDetails").appendKeySegment(keyMap);
|
||||
entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build());
|
||||
entityReq.setFormat(format);
|
||||
entityReq.setFormat(contentType);
|
||||
entity = entityReq.execute().getBody();
|
||||
assertNotNull(entity);
|
||||
|
||||
|
@ -106,7 +106,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
|||
|
||||
final ODataInvokeRequest<ClientEntity> getRelatedProductReq =
|
||||
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientEntity.class);
|
||||
getRelatedProductReq.setFormat(format);
|
||||
getRelatedProductReq.setFormat(contentType);
|
||||
final ClientEntity getRelatedProductRes = getRelatedProductReq.execute().getBody();
|
||||
assertNotNull(getRelatedProductRes);
|
||||
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Product",
|
||||
|
@ -117,7 +117,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
|||
builder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Accounts").appendKeySegment(102);
|
||||
entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build());
|
||||
entityReq.setFormat(format);
|
||||
entityReq.setFormat(contentType);
|
||||
entity = entityReq.execute().getBody();
|
||||
assertNotNull(entity);
|
||||
|
||||
|
@ -126,7 +126,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
|||
|
||||
final ODataInvokeRequest<ClientEntity> getDefaultPIReq =
|
||||
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientEntity.class);
|
||||
getDefaultPIReq.setFormat(format);
|
||||
getDefaultPIReq.setFormat(contentType);
|
||||
final ClientEntity getDefaultPIRes = getDefaultPIReq.execute().getBody();
|
||||
assertNotNull(getDefaultPIRes);
|
||||
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument",
|
||||
|
@ -140,7 +140,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
|||
|
||||
final ODataInvokeRequest<ClientProperty> getAccountInfoReq =
|
||||
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientProperty.class);
|
||||
getAccountInfoReq.setFormat(format);
|
||||
getAccountInfoReq.setFormat(contentType);
|
||||
final ClientProperty getAccountInfoRes = getAccountInfoReq.execute().getBody();
|
||||
assertNotNull(getAccountInfoRes);
|
||||
assertTrue(getAccountInfoRes.hasComplexValue());
|
||||
|
@ -150,7 +150,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
|||
// GetActualAmount
|
||||
entityReq = client.getRetrieveRequestFactory().getEntityRequest(
|
||||
entity.getNavigationLink("MyGiftCard").getLink());
|
||||
entityReq.setFormat(format);
|
||||
entityReq.setFormat(contentType);
|
||||
entity = entityReq.execute().getBody();
|
||||
assertNotNull(entity);
|
||||
assertEquals(301, entity.getProperty("GiftCardID").getPrimitiveValue().toCastValue(Integer.class), 0);
|
||||
|
@ -162,7 +162,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
|||
final ODataInvokeRequest<ClientProperty> getActualAmountReq =
|
||||
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientProperty.class,
|
||||
Collections.<String, ClientValue> singletonMap("bonusRate", bonusRate));
|
||||
getActualAmountReq.setFormat(format);
|
||||
getActualAmountReq.setFormat(contentType);
|
||||
final ClientProperty getActualAmountRes = getActualAmountReq.execute().getBody();
|
||||
assertNotNull(getActualAmountRes);
|
||||
assertEquals(41.79, getActualAmountRes.getPrimitiveValue().toCastValue(Double.class), 0);
|
||||
|
@ -170,12 +170,12 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void atomFunctions() throws EdmPrimitiveTypeException {
|
||||
functions(ODataFormat.ATOM);
|
||||
functions(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonFunctions() throws EdmPrimitiveTypeException {
|
||||
functions(ODataFormat.JSON_FULL_METADATA);
|
||||
functions(ContentType.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -264,12 +264,12 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
|||
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
|
||||
URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company");
|
||||
ODataEntityRequest<ClientEntity> entityReq =
|
||||
client.getRetrieveRequestFactory().getEntityRequest(builder.build());
|
||||
entityReq.setFormat(format);
|
||||
entityReq.setFormat(contentType);
|
||||
ClientEntity entity = entityReq.execute().getBody();
|
||||
assertNotNull(entity);
|
||||
|
||||
|
@ -281,7 +281,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
|||
final ODataInvokeRequest<ClientProperty> increaseRevenueReq =
|
||||
client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ClientProperty.class,
|
||||
Collections.<String, ClientValue> singletonMap("IncreaseValue", increaseValue));
|
||||
increaseRevenueReq.setFormat(format);
|
||||
increaseRevenueReq.setFormat(contentType);
|
||||
final ClientProperty increaseRevenueRes = increaseRevenueReq.execute().getBody();
|
||||
assertNotNull(increaseRevenueRes);
|
||||
assertTrue(increaseRevenueRes.hasPrimitiveValue());
|
||||
|
@ -290,7 +290,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
|||
builder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Products").appendKeySegment(5);
|
||||
entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build());
|
||||
entityReq.setFormat(format);
|
||||
entityReq.setFormat(contentType);
|
||||
entity = entityReq.execute().getBody();
|
||||
assertNotNull(entity);
|
||||
|
||||
|
@ -302,7 +302,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
|||
final ODataInvokeRequest<ClientProperty> getProductDetailsReq =
|
||||
client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ClientProperty.class,
|
||||
Collections.<String, ClientValue> singletonMap("accessRight", accessRight));
|
||||
getProductDetailsReq.setFormat(format);
|
||||
getProductDetailsReq.setFormat(contentType);
|
||||
final ClientProperty getProductDetailsRes = getProductDetailsReq.execute().getBody();
|
||||
assertNotNull(getProductDetailsRes);
|
||||
assertTrue(getProductDetailsRes.hasEnumValue());
|
||||
|
@ -311,7 +311,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
|||
builder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Customers").appendKeySegment(2);
|
||||
entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build());
|
||||
entityReq.setFormat(format);
|
||||
entityReq.setFormat(contentType);
|
||||
entity = entityReq.execute().getBody();
|
||||
assertNotNull(entity);
|
||||
|
||||
|
@ -336,7 +336,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
|||
params.put("index", index);
|
||||
final ODataInvokeRequest<ClientEntity> resetAddressReq =
|
||||
client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ClientEntity.class, params);
|
||||
resetAddressReq.setFormat(format);
|
||||
resetAddressReq.setFormat(contentType);
|
||||
final ClientEntity resetAddressRes = resetAddressReq.execute().getBody();
|
||||
assertNotNull(resetAddressRes);
|
||||
assertEquals(2, resetAddressRes.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0);
|
||||
|
@ -345,7 +345,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
|||
builder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Accounts").appendKeySegment(102);
|
||||
entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build());
|
||||
entityReq.setFormat(format);
|
||||
entityReq.setFormat(contentType);
|
||||
entity = entityReq.execute().getBody();
|
||||
assertNotNull(entity);
|
||||
|
||||
|
@ -359,7 +359,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
|||
final ODataInvokeRequest<ClientEntity> getDefaultPIReq =
|
||||
client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ClientEntity.class,
|
||||
Collections.<String, ClientValue> singletonMap("newDate", newDate));
|
||||
getDefaultPIReq.setFormat(format);
|
||||
getDefaultPIReq.setFormat(contentType);
|
||||
final ClientEntity getDefaultPIRes = getDefaultPIReq.execute().getBody();
|
||||
assertNotNull(getDefaultPIRes);
|
||||
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument",
|
||||
|
@ -370,12 +370,12 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void atomActions() throws EdmPrimitiveTypeException {
|
||||
actions(ODataFormat.ATOM);
|
||||
actions(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonActions() throws EdmPrimitiveTypeException {
|
||||
actions(ODataFormat.JSON_FULL_METADATA);
|
||||
actions(ContentType.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@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.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -118,7 +118,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
|||
final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest(
|
||||
getClient().newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Orders").build(), order);
|
||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
req.setFormat(ContentType.JSON_FULL_METADATA);
|
||||
|
||||
// check for OData-Version
|
||||
assertEquals("4.0", req.getHeader("OData-Version"));
|
||||
|
@ -126,13 +126,13 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
|||
|
||||
// check for Content-Type
|
||||
assertEquals(
|
||||
ODataFormat.JSON_FULL_METADATA.getContentType().toContentTypeString(),
|
||||
ContentType.JSON_FULL_METADATA.toContentTypeString(),
|
||||
req.getHeader("Content-Type"));
|
||||
assertEquals(
|
||||
ODataFormat.JSON_FULL_METADATA.getContentType().toContentTypeString(),
|
||||
ContentType.JSON_FULL_METADATA.toContentTypeString(),
|
||||
req.getHeader(HeaderName.contentType.toString()));
|
||||
assertEquals(
|
||||
ODataFormat.JSON_FULL_METADATA.getContentType().toContentTypeString(),
|
||||
ContentType.JSON_FULL_METADATA.toContentTypeString(),
|
||||
req.getContentType());
|
||||
|
||||
final ClientEntity created = req.execute().getBody();
|
||||
|
@ -179,7 +179,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
|||
|
||||
ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().
|
||||
getEntitySetRequest(uriBuilder.build());
|
||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
req.setFormat(ContentType.JSON_FULL_METADATA);
|
||||
req.setPrefer(client.newPreferences().maxPageSize(5));
|
||||
|
||||
ODataRetrieveResponse<ClientEntitySet> res = req.execute();
|
||||
|
@ -196,7 +196,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
|||
assertEquals(expected, found);
|
||||
|
||||
req = client.getRetrieveRequestFactory().getEntitySetRequest(found);
|
||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
req.setFormat(ContentType.JSON_FULL_METADATA);
|
||||
|
||||
res = req.execute();
|
||||
feed = res.getBody();
|
||||
|
@ -236,7 +236,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
|||
final URIBuilder builder = getClient().newURIBuilder(testOpenTypeServiceRootURL).
|
||||
appendEntitySetSegment("RowIndex").appendKeySegment(id);
|
||||
|
||||
rowIndex = read(ODataFormat.JSON_FULL_METADATA, builder.build());
|
||||
rowIndex = read(ContentType.JSON_FULL_METADATA, builder.build());
|
||||
assertNotNull(rowIndex);
|
||||
assertEquals(EdmPrimitiveTypeKind.Int32, rowIndex.getProperty("Id").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();
|
||||
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());
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
|||
|
||||
final ODataEntityRequest<ClientEntity> req =
|
||||
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
req.setFormat(ContentType.JSON_FULL_METADATA);
|
||||
|
||||
assertNotNull(req.execute().getBody());
|
||||
|
||||
|
@ -305,7 +305,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
|||
appendRefSegment();
|
||||
|
||||
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();
|
||||
assertNotNull(res);
|
||||
|
@ -318,7 +318,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
|||
appendEntityIdSegment(entity.getId().toASCIIString()).build();
|
||||
|
||||
req = client.getRetrieveRequestFactory().getEntityRequest(referenceURI);
|
||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
req.setFormat(ContentType.JSON_FULL_METADATA);
|
||||
|
||||
res = req.execute();
|
||||
assertNotNull(res);
|
||||
|
@ -339,7 +339,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
|||
assertNotNull(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();
|
||||
assertNotNull(delta);
|
||||
|
@ -381,7 +381,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
|||
|
||||
final ODataEntitySetRequest<ClientEntitySet> req =
|
||||
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
|
||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
req.setFormat(ContentType.JSON_FULL_METADATA);
|
||||
|
||||
final AsyncRequestWrapper<ODataRetrieveResponse<ClientEntitySet>> async =
|
||||
client.getAsyncRequestFactory().<ODataRetrieveResponse<ClientEntitySet>> getAsyncRequestWrapper(req);
|
||||
|
@ -408,7 +408,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
|||
|
||||
final ODataEntityRequest<ClientEntity> req =
|
||||
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(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.ClientEntitySet;
|
||||
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;
|
||||
|
||||
public class DeltaTestITCase extends AbstractTestITCase {
|
||||
|
||||
private void parse(final ODataFormat format) {
|
||||
private void parse(final ContentType format) {
|
||||
final ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest(
|
||||
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").build());
|
||||
req.setPrefer(client.newPreferences().trackChanges());
|
||||
|
@ -76,11 +76,11 @@ public class DeltaTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void atomParse() {
|
||||
parse(ODataFormat.ATOM);
|
||||
parse(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
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.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
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;
|
||||
|
||||
public class DerivedTypeTestITCase extends AbstractTestITCase {
|
||||
|
||||
private void read(final ODataFormat format) {
|
||||
private void read(final ContentType contentType) {
|
||||
// 1. entity set
|
||||
URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("People").
|
||||
appendDerivedEntityTypeSegment("Microsoft.Test.OData.Services.ODataWCFService.Customer");
|
||||
ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().
|
||||
getEntitySetRequest(uriBuilder.build());
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
for (ClientEntity customer : req.execute().getBody().getEntities()) {
|
||||
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", customer.getTypeName().toString());
|
||||
|
@ -60,7 +60,7 @@ public class DerivedTypeTestITCase extends AbstractTestITCase {
|
|||
appendNavigationSegment("MyPaymentInstruments").
|
||||
appendDerivedEntityTypeSegment("Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI");
|
||||
req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
for (ClientEntity customer : req.execute().getBody().getEntities()) {
|
||||
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI", customer.getTypeName().toString());
|
||||
|
@ -69,15 +69,15 @@ public class DerivedTypeTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void readfromAtom() {
|
||||
read(ODataFormat.ATOM);
|
||||
read(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
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().
|
||||
newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
|
||||
|
||||
|
@ -119,7 +119,7 @@ public class DerivedTypeTestITCase extends AbstractTestITCase {
|
|||
getEntityCreateRequest(
|
||||
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People").build(),
|
||||
customer);
|
||||
createReq.setFormat(format);
|
||||
createReq.setFormat(conentType);
|
||||
|
||||
final ODataEntityCreateResponse<ClientEntity> createRes = createReq.execute();
|
||||
assertEquals(201, createRes.getStatusCode());
|
||||
|
@ -127,7 +127,7 @@ public class DerivedTypeTestITCase extends AbstractTestITCase {
|
|||
final ODataEntityRequest<ClientEntity> fetchReq = client.getRetrieveRequestFactory().
|
||||
getEntityRequest(client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("People").appendKeySegment(976).build());
|
||||
fetchReq.setFormat(format);
|
||||
fetchReq.setFormat(conentType);
|
||||
|
||||
final ClientEntity actual = fetchReq.execute().getBody();
|
||||
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", actual.getTypeName().toString());
|
||||
|
@ -140,11 +140,11 @@ public class DerivedTypeTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void createDeleteAsAtom() {
|
||||
createDelete(ODataFormat.ATOM);
|
||||
createDelete(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
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.EdmPrimitiveTypeKind;
|
||||
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;
|
||||
|
||||
public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void atomCreateAndDelete() {
|
||||
createAndDeleteOrder(testStaticServiceRootURL, ODataFormat.ATOM, 1000);
|
||||
createAndDeleteOrder(testStaticServiceRootURL, ContentType.APPLICATION_ATOM_XML, 1000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonCreateAndDelete() {
|
||||
createAndDeleteOrder(testStaticServiceRootURL, ODataFormat.JSON, 1001);
|
||||
createAndDeleteOrder(testStaticServiceRootURL, ODataFormat.JSON_NO_METADATA, 1001);
|
||||
createAndDeleteOrder(testStaticServiceRootURL, ODataFormat.JSON_FULL_METADATA, 1001);
|
||||
createAndDeleteOrder(testStaticServiceRootURL, ContentType.JSON, 1001);
|
||||
createAndDeleteOrder(testStaticServiceRootURL, ContentType.JSON_NO_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").
|
||||
appendKeySegment(101).appendNavigationSegment("MyPaymentInstruments").build();
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
|||
// 3. create it as contained entity
|
||||
final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
|
||||
getEntityCreateRequest(uri, instrument);
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
final ODataEntityCreateResponse<ClientEntity> res = req.execute();
|
||||
assertEquals(201, res.getStatusCode());
|
||||
|
@ -102,15 +102,15 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void atomOnContained() {
|
||||
onContained(ODataFormat.ATOM);
|
||||
onContained(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
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 {
|
||||
|
||||
final ClientEntity product = getClient().getObjectFactory().
|
||||
|
@ -161,7 +161,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
|||
|
||||
final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest(
|
||||
getClient().newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Products").build(), product);
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
final ODataEntityCreateResponse<ClientEntity> res = req.execute();
|
||||
assertEquals(201, res.getStatusCode());
|
||||
|
||||
|
@ -181,11 +181,11 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void atomDeepInsert() throws EdmPrimitiveTypeException {
|
||||
deepInsert(ODataFormat.ATOM, 10, 10);
|
||||
deepInsert(ContentType.APPLICATION_ATOM_XML, 10, 10);
|
||||
}
|
||||
|
||||
@Test
|
||||
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.commons.api.data.ResWrap;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -53,13 +53,13 @@ import org.junit.Test;
|
|||
*/
|
||||
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).
|
||||
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");
|
||||
|
||||
final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().
|
||||
getEntityRequest(uriBuilder.build());
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
||||
final ClientEntity entity = res.getBody();
|
||||
|
@ -70,11 +70,14 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
|||
assertEquals("Edm.GeographyPoint", entity.getProperty("Home").getPrimitiveValue().getTypeName());
|
||||
|
||||
// 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(3, entity.getNavigationLinks().size());
|
||||
|
||||
if (ODataFormat.ATOM == format) {
|
||||
if (ContentType.APPLICATION_ATOM_XML == contentType) {
|
||||
assertTrue(entity.getAssociationLinks().isEmpty());
|
||||
// In JSON, association links for each $ref link will exist.
|
||||
}
|
||||
|
@ -110,26 +113,26 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void withInlineEntityFromAtom() {
|
||||
withInlineEntity(client, ODataFormat.ATOM);
|
||||
withInlineEntity(client, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withInlineEntityFromFullJSON() {
|
||||
withInlineEntity(client, ODataFormat.JSON_FULL_METADATA);
|
||||
withInlineEntity(client, ContentType.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
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).
|
||||
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Orders");
|
||||
|
||||
final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().
|
||||
getEntityRequest(uriBuilder.build());
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
||||
final ClientEntity entity = res.getBody();
|
||||
|
@ -137,7 +140,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
|||
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
|
||||
|
||||
// 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;
|
||||
for (ClientLink link : entity.getNavigationLinks()) {
|
||||
if (link instanceof ClientInlineEntitySet) {
|
||||
|
@ -153,25 +156,25 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void withInlineEntitySetFromAtom() {
|
||||
withInlineEntitySet(client, ODataFormat.ATOM);
|
||||
withInlineEntitySet(client, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withInlineEntitySetFromFullJSON() {
|
||||
withInlineEntitySet(client, ODataFormat.JSON_FULL_METADATA);
|
||||
withInlineEntitySet(client, ContentType.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
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).
|
||||
appendEntitySetSegment("People").appendKeySegment(5);
|
||||
|
||||
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
|
||||
req.setFormat(format.getContentType().toContentTypeString());
|
||||
req.setFormat(contentType.toContentTypeString());
|
||||
|
||||
final ODataRawResponse res = req.execute();
|
||||
assertNotNull(res);
|
||||
|
@ -185,16 +188,16 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void rawRequestAsAtom() {
|
||||
rawRequest(ODataFormat.ATOM);
|
||||
rawRequest(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rawRequestAsJSON() {
|
||||
// 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>();
|
||||
multiKey.put("ProductID", "6");
|
||||
multiKey.put("ProductDetailID", 1);
|
||||
|
@ -204,7 +207,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
|||
|
||||
final ODataEntityRequest<ClientEntity> req =
|
||||
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
||||
final ClientEntity entity = res.getBody();
|
||||
|
@ -215,21 +218,21 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void multiKeyAsAtom() throws EdmPrimitiveTypeException {
|
||||
multiKey(ODataFormat.ATOM);
|
||||
multiKey(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
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 =
|
||||
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders").appendKeySegment(8);
|
||||
|
||||
final ODataEntityRequest<ClientEntity> req =
|
||||
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
||||
assertEquals(200, res.getStatusCode());
|
||||
|
@ -248,17 +251,17 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void checkForETagAsAtom() {
|
||||
checkForETag(client, ODataFormat.ATOM);
|
||||
checkForETag(client, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkForETagAsFullJSON() {
|
||||
checkForETag(client, ODataFormat.JSON_FULL_METADATA);
|
||||
checkForETag(client, ContentType.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkForETagAsJSON() {
|
||||
checkForETag(edmClient, ODataFormat.JSON);
|
||||
checkForETag(edmClient, ContentType.JSON);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
|
@ -267,20 +270,20 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
|||
|
||||
final ODataEntityRequest<ClientEntity> req =
|
||||
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||
req.setFormat(ODataFormat.JSON);
|
||||
req.setFormat(ContentType.JSON);
|
||||
|
||||
// this statement should cause an IllegalArgumentException bearing JsonParseException
|
||||
// since we are attempting to parse an EntitySet as if it was an Entity
|
||||
req.execute().getBody();
|
||||
}
|
||||
|
||||
private void reference(final ODataFormat format) {
|
||||
private void reference(final ContentType contentType) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Orders").appendKeySegment(8).appendNavigationSegment("CustomerForOrder").
|
||||
appendRefSegment();
|
||||
|
||||
ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
ODataRetrieveResponse<ClientEntity> res = req.execute();
|
||||
assertNotNull(res);
|
||||
|
@ -293,7 +296,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
|||
appendEntityIdSegment(entity.getId().toASCIIString()).build();
|
||||
|
||||
req = client.getRetrieveRequestFactory().getEntityRequest(referenceURI);
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
res = req.execute();
|
||||
assertNotNull(res);
|
||||
|
@ -302,20 +305,20 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void atomReference() {
|
||||
reference(ODataFormat.ATOM);
|
||||
reference(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
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).
|
||||
appendEntitySetSegment("Accounts").appendKeySegment(101).
|
||||
appendNavigationSegment("MyPaymentInstruments").appendKeySegment(101902).build();
|
||||
final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uri);
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
final ClientEntity contained = req.execute().getBody();
|
||||
assertNotNull(contained);
|
||||
|
@ -328,30 +331,30 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void containedFromAtom() throws EdmPrimitiveTypeException {
|
||||
contained(client, ODataFormat.ATOM);
|
||||
contained(client, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void containedFromFullJSON() throws EdmPrimitiveTypeException {
|
||||
contained(client, ODataFormat.JSON_FULL_METADATA);
|
||||
contained(client, ContentType.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
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).
|
||||
appendEntitySetSegment("Accounts").appendKeySegment(101).build();
|
||||
final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uri);
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
final ClientEntity entity = req.execute().getBody();
|
||||
assertNotNull(entity);
|
||||
|
||||
// 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("ActiveSubscriptions").getType());
|
||||
}
|
||||
|
@ -359,13 +362,13 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void entitySetNavigationLinkFromAtom() {
|
||||
entitySetNavigationLink(client, ODataFormat.ATOM);
|
||||
entitySetNavigationLink(client, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entitySetNavigationLinkFromJSON() {
|
||||
// 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.core.uri.URIUtils;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -45,11 +45,11 @@ import org.junit.Test;
|
|||
*/
|
||||
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 ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
|
||||
req.setFormat(format.getContentType().toContentTypeString());
|
||||
req.setFormat(contentType.toContentTypeString());
|
||||
|
||||
final ODataRawResponse res = req.execute();
|
||||
assertNotNull(res);
|
||||
|
@ -61,20 +61,20 @@ public class EntitySetTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void rawRequestAsAtom() throws IOException {
|
||||
rawRequest(ODataFormat.ATOM);
|
||||
rawRequest(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
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).
|
||||
appendEntitySetSegment("People").count(true);
|
||||
|
||||
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
|
||||
req.setFormat(format.getContentType().toContentTypeString());
|
||||
req.setFormat(contentType.toContentTypeString());
|
||||
|
||||
final ODataRawResponse res = req.execute();
|
||||
assertNotNull(res);
|
||||
|
@ -88,25 +88,25 @@ public class EntitySetTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void readWithInlineCountAsJSON() throws IOException {
|
||||
readWithInlineCount(edmClient, ODataFormat.JSON);
|
||||
readWithInlineCount(edmClient, ContentType.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readWithInlineCountAsFullJSON() throws IOException {
|
||||
readWithInlineCount(client, ODataFormat.JSON_FULL_METADATA);
|
||||
readWithInlineCount(client, ContentType.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
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 ODataEntitySetIteratorRequest<ClientEntitySet, ClientEntity> req =
|
||||
client.getRetrieveRequestFactory().getEntitySetIteratorRequest(uriBuilder.build());
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
final ODataRetrieveResponse<ClientEntitySetIterator<ClientEntitySet, ClientEntity>> res = req.execute();
|
||||
final ClientEntitySetIterator<ClientEntitySet, ClientEntity> feedIterator = res.getBody();
|
||||
|
@ -125,25 +125,25 @@ public class EntitySetTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void readODataEntitySetIteratorFromAtom() {
|
||||
readODataEntitySetIterator(ODataFormat.ATOM);
|
||||
readODataEntitySetIterator(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readODataEntitySetIteratorFromJSON() {
|
||||
readODataEntitySetIterator(ODataFormat.JSON);
|
||||
readODataEntitySetIterator(ContentType.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readODataEntitySetIteratorFromJSONFull() {
|
||||
readODataEntitySetIterator(ODataFormat.JSON_FULL_METADATA);
|
||||
readODataEntitySetIterator(ContentType.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
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 ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().
|
||||
|
@ -167,12 +167,12 @@ public class EntitySetTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void readWithNextFromAtom() {
|
||||
readWithNext(ODataFormat.ATOM);
|
||||
readWithNext(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
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.EdmPrimitiveTypeKind;
|
||||
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.Test;
|
||||
|
||||
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().
|
||||
newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order"));
|
||||
|
||||
|
@ -61,11 +61,11 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
|||
appendEntitySetSegment("Orders").appendKeySegment(9).build();
|
||||
final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
|
||||
getEntityUpdateRequest(upsertURI, updateType, order);
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
req.execute();
|
||||
try {
|
||||
final ClientEntity read = read(format, upsertURI);
|
||||
final ClientEntity read = read(contentType, upsertURI);
|
||||
assertNotNull(read);
|
||||
assertEquals(order.getProperty("OrderID"), read.getProperty("OrderID"));
|
||||
assertEquals(order.getProperty("OrderDate").getPrimitiveValue().toString(),
|
||||
|
@ -103,17 +103,17 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void atomUpsert() {
|
||||
upsert(UpdateType.PATCH, ODataFormat.ATOM);
|
||||
upsert(UpdateType.REPLACE, ODataFormat.ATOM);
|
||||
upsert(UpdateType.PATCH, ContentType.APPLICATION_ATOM_XML);
|
||||
upsert(UpdateType.REPLACE, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonUpsert() {
|
||||
upsert(UpdateType.PATCH, ODataFormat.JSON);
|
||||
upsert(UpdateType.REPLACE, ODataFormat.JSON);
|
||||
upsert(UpdateType.PATCH, ContentType.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 ClientEntity changes = getClient().getObjectFactory().newEntity(
|
||||
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument"));
|
||||
|
@ -125,7 +125,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
|||
appendNavigationSegment("MyPaymentInstruments").appendKeySegment(101901).build();
|
||||
final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
|
||||
getEntityUpdateRequest(uri, UpdateType.PATCH, changes);
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
final ODataEntityUpdateResponse<ClientEntity> res = req.execute();
|
||||
assertEquals(204, res.getStatusCode());
|
||||
|
@ -137,15 +137,15 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void atomOnContained() {
|
||||
onContained(ODataFormat.ATOM);
|
||||
onContained(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
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(
|
||||
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
|
||||
final ClientLink parent = getClient().getObjectFactory().newEntityNavigationLink("Parent",
|
||||
|
@ -157,7 +157,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
|||
appendEntitySetSegment("People").appendKeySegment(5).build();
|
||||
final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
|
||||
getEntityUpdateRequest(uri, UpdateType.PATCH, changes);
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
final ODataEntityUpdateResponse<ClientEntity> res = req.execute();
|
||||
assertEquals(204, res.getStatusCode());
|
||||
|
@ -175,11 +175,11 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void atomBindOperation() throws EdmPrimitiveTypeException {
|
||||
bindOperation(ODataFormat.ATOM);
|
||||
bindOperation(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
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.commons.api.ODataError;
|
||||
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;
|
||||
|
||||
public class ErrorResponseTestITCase extends AbstractTestITCase {
|
||||
|
@ -39,7 +39,7 @@ public class ErrorResponseTestITCase extends AbstractTestITCase {
|
|||
build();
|
||||
|
||||
try {
|
||||
read(ODataFormat.JSON, readURI);
|
||||
read(ContentType.JSON, readURI);
|
||||
fail("should have got exception");
|
||||
} catch (Exception ex) {
|
||||
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.URIBuilder;
|
||||
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;
|
||||
|
||||
public class FilterFactoryTestITCase extends AbstractTestITCase {
|
||||
|
@ -50,7 +50,7 @@ public class FilterFactoryTestITCase extends AbstractTestITCase {
|
|||
|
||||
final ODataEntitySetRequest<ClientEntitySet> req =
|
||||
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
|
||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
req.setFormat(ContentType.JSON_FULL_METADATA);
|
||||
|
||||
final ClientEntitySet feed = req.execute().getBody();
|
||||
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.edm.EdmPrimitiveTypeException;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -91,7 +91,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
|
|||
final URI uri = edmClient.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Accounts").appendKeySegment(102).build();
|
||||
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
|
||||
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]}"
|
||||
+ "}";
|
||||
|
||||
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());
|
||||
|
||||
|
@ -219,7 +219,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
|
|||
+ "}";
|
||||
|
||||
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("W/\"A1FF3E230954908F\"", entity.getMetadataETag());
|
||||
|
@ -241,7 +241,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
|
|||
+ "}";
|
||||
|
||||
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("Customers?$expand=Orders&$skipToken=5", entitySet.getPayload().getNext().toASCIIString());
|
||||
|
@ -271,7 +271,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
|
|||
+ "}";
|
||||
|
||||
final ClientEntitySet entitySet = client.getReader().
|
||||
readEntitySet(IOUtils.toInputStream(sample), ODataFormat.JSON);
|
||||
readEntitySet(IOUtils.toInputStream(sample), ContentType.JSON);
|
||||
|
||||
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.uri.URIBuilder;
|
||||
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.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -50,20 +50,20 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
|
|||
client.getConfiguration().setKeyAsSegment(false);
|
||||
}
|
||||
|
||||
private void read(final ODataFormat format) {
|
||||
private void read(final ContentType contentType) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testKeyAsSegmentServiceRootURL).
|
||||
appendEntitySetSegment("Accounts").appendKeySegment(101);
|
||||
|
||||
final ODataEntityRequest<ClientEntity> req =
|
||||
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
||||
final ClientEntity entity = res.getBody();
|
||||
assertNotNull(entity);
|
||||
|
||||
// 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(")"));
|
||||
}
|
||||
|
@ -71,25 +71,25 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void atomRead() {
|
||||
read(ODataFormat.ATOM);
|
||||
read(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonRead() {
|
||||
read(ODataFormat.JSON);
|
||||
read(ContentType.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void atomCreateAndDelete() {
|
||||
createAndDeleteOrder(testKeyAsSegmentServiceRootURL, ODataFormat.ATOM, 1000);
|
||||
createAndDeleteOrder(testKeyAsSegmentServiceRootURL, ContentType.APPLICATION_ATOM_XML, 1000);
|
||||
}
|
||||
|
||||
@Test
|
||||
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(
|
||||
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
|
||||
final ClientProperty middleName = getClient().getObjectFactory().newPrimitiveProperty("MiddleName",
|
||||
|
@ -100,7 +100,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
|
|||
appendEntitySetSegment("People").appendKeySegment(5).build();
|
||||
final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
|
||||
getEntityUpdateRequest(uri, UpdateType.PATCH, changes);
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
final ODataEntityUpdateResponse<ClientEntity> res = req.execute();
|
||||
assertEquals(204, res.getStatusCode());
|
||||
|
@ -117,11 +117,11 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void atomUpdate() {
|
||||
update(ODataFormat.ATOM);
|
||||
update(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
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.EdmPrimitiveTypeKind;
|
||||
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;
|
||||
|
||||
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).
|
||||
appendEntitySetSegment("Advertisements").
|
||||
appendKeySegment(UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7"));
|
||||
final ODataEntityRequest<ClientEntity> entityReq =
|
||||
client.getRetrieveRequestFactory().getEntityRequest(builder.build());
|
||||
entityReq.setFormat(format);
|
||||
entityReq.setFormat(contentType);
|
||||
|
||||
final ClientEntity entity = entityReq.execute().getBody();
|
||||
assertNotNull(entity);
|
||||
|
@ -83,20 +83,20 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void readAsAtom() throws IOException {
|
||||
read(client, ODataFormat.ATOM);
|
||||
read(client, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readAsJSON() throws IOException {
|
||||
read(ODataClientFactory.getEdmEnabledClient(testDemoServiceRootURL), ODataFormat.JSON);
|
||||
read(ODataClientFactory.getEdmEnabledClient(testDemoServiceRootURL), ContentType.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
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 InputStream input = IOUtils.toInputStream(random);
|
||||
|
||||
|
@ -120,7 +120,7 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
|
|||
|
||||
final ODataEntityUpdateRequest<ClientEntity> updateReq = getClient().getCUDRequestFactory().
|
||||
getEntityUpdateRequest(createdLocation, UpdateType.PATCH, changes);
|
||||
updateReq.setFormat(format);
|
||||
updateReq.setFormat(contentType);
|
||||
|
||||
final ODataEntityUpdateResponse<ClientEntity> updateRes = updateReq.execute();
|
||||
assertEquals(204, updateRes.getStatusCode());
|
||||
|
@ -137,15 +137,15 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void createAsAtom() throws IOException {
|
||||
create(ODataFormat.ATOM);
|
||||
create(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
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).
|
||||
appendEntitySetSegment("Advertisements").
|
||||
appendKeySegment(UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7")).build();
|
||||
|
@ -155,7 +155,7 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
|
|||
// 1. update providing media content
|
||||
final ODataMediaEntityUpdateRequest<ClientEntity> updateReq = client.getCUDRequestFactory().
|
||||
getMediaEntityUpdateRequest(uri, IOUtils.toInputStream(random));
|
||||
updateReq.setFormat(format);
|
||||
updateReq.setFormat(contentType);
|
||||
|
||||
final MediaEntityUpdateStreamManager<ClientEntity> streamManager = updateReq.payloadManager();
|
||||
final ODataMediaEntityUpdateResponse<ClientEntity> createRes = streamManager.getResponse();
|
||||
|
@ -173,11 +173,11 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void updateAsAtom() throws IOException, EdmPrimitiveTypeException {
|
||||
update(ODataFormat.ATOM);
|
||||
update(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
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.core.ODataClientFactory;
|
||||
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.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -76,13 +76,13 @@ public class OAuth2TestITCase extends AbstractTestITCase {
|
|||
return _edmClient;
|
||||
}
|
||||
|
||||
private void read(final ODataClient client, final ODataFormat format) {
|
||||
private void read(final ODataClient client, final ContentType contentType) {
|
||||
final URIBuilder uriBuilder =
|
||||
client.newURIBuilder(testOAuth2ServiceRootURL).appendEntitySetSegment("Orders").appendKeySegment(8);
|
||||
|
||||
final ODataEntityRequest<ClientEntity> req =
|
||||
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
||||
assertEquals(200, res.getStatusCode());
|
||||
|
@ -127,19 +127,19 @@ public class OAuth2TestITCase extends AbstractTestITCase {
|
|||
}
|
||||
|
||||
public void readAsAtom() {
|
||||
read(getLocalClient(), ODataFormat.ATOM);
|
||||
read(getLocalClient(), ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
public void readAsFullJSON() {
|
||||
read(getLocalClient(), ODataFormat.JSON_FULL_METADATA);
|
||||
read(getLocalClient(), ContentType.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
public void readAsJSON() {
|
||||
read(getEdmClient(), ODataFormat.JSON);
|
||||
read(getEdmClient(), ContentType.JSON);
|
||||
}
|
||||
|
||||
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.EdmSchema;
|
||||
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;
|
||||
|
||||
public class OpenTypeTestITCase extends AbstractTestITCase {
|
||||
|
@ -53,32 +53,32 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
|
|||
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).
|
||||
appendEntitySetSegment("Row").appendKeySegment(UUID.fromString(uuid));
|
||||
return read(format, builder.build());
|
||||
return read(contentType, builder.build());
|
||||
}
|
||||
|
||||
private void read(final ODataFormat format) {
|
||||
ClientEntity row = readRow(format, "71f7d0dc-ede4-45eb-b421-555a2aa1e58f");
|
||||
private void read(final ContentType contentType) {
|
||||
ClientEntity row = readRow(contentType, "71f7d0dc-ede4-45eb-b421-555a2aa1e58f");
|
||||
assertEquals(EdmPrimitiveTypeKind.Double, row.getProperty("Double").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());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readAsAtom() {
|
||||
read(ODataFormat.ATOM);
|
||||
read(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
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;
|
||||
|
||||
ClientEntity rowIndex = getClient().getObjectFactory().newEntity(
|
||||
|
@ -154,13 +154,13 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
|
|||
final ODataEntityCreateRequest<ClientEntity> createReq = getClient().getCUDRequestFactory().
|
||||
getEntityCreateRequest(getClient().newURIBuilder(testOpenTypeServiceRootURL).
|
||||
appendEntitySetSegment("RowIndex").build(), rowIndex);
|
||||
createReq.setFormat(format);
|
||||
createReq.setFormat(contentType);
|
||||
final ODataEntityCreateResponse<ClientEntity> createRes = createReq.execute();
|
||||
assertEquals(201, createRes.getStatusCode());
|
||||
|
||||
final URIBuilder builder = getClient().newURIBuilder(testOpenTypeServiceRootURL).
|
||||
appendEntitySetSegment("RowIndex").appendKeySegment(id);
|
||||
rowIndex = read(format, builder.build());
|
||||
rowIndex = read(contentType, builder.build());
|
||||
assertNotNull(rowIndex);
|
||||
assertEquals(EdmPrimitiveTypeKind.Int32, rowIndex.getProperty("Id").getPrimitiveValue().getTypeKind());
|
||||
assertEquals(EdmPrimitiveTypeKind.String, rowIndex.getProperty("aString").getPrimitiveValue().getTypeKind());
|
||||
|
@ -179,12 +179,12 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void cudAsAtom() {
|
||||
cud(ODataFormat.ATOM);
|
||||
cud(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
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.ClientValue;
|
||||
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;
|
||||
|
||||
public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
||||
|
||||
private void functionImports(final ODataFormat format) throws EdmPrimitiveTypeException {
|
||||
private void functionImports(final ContentType contentType) throws EdmPrimitiveTypeException {
|
||||
// GetDefaultColor
|
||||
final ODataInvokeRequest<ClientProperty> defaultColorReq = getClient().getInvokeRequestFactory().
|
||||
getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
||||
appendOperationCallSegment("GetDefaultColor").build(), ClientProperty.class);
|
||||
defaultColorReq.setFormat(format);
|
||||
defaultColorReq.setFormat(contentType);
|
||||
final ClientProperty defaultColor = defaultColorReq.execute().getBody();
|
||||
assertNotNull(defaultColor);
|
||||
assertTrue(defaultColor.hasEnumValue());
|
||||
|
@ -61,7 +61,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
|||
getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
||||
appendOperationCallSegment("GetPerson2").build(), ClientEntity.class,
|
||||
Collections.<String, ClientValue> singletonMap("city", city));
|
||||
person2Req.setFormat(format);
|
||||
person2Req.setFormat(contentType);
|
||||
final ClientEntity person2 = person2Req.execute().getBody();
|
||||
assertNotNull(person2);
|
||||
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", person2.getTypeName().toString());
|
||||
|
@ -81,7 +81,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
|||
getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
||||
appendOperationCallSegment("GetPerson").build(), ClientEntity.class,
|
||||
Collections.<String, ClientValue> singletonMap("address", address));
|
||||
personReq.setFormat(format);
|
||||
personReq.setFormat(contentType);
|
||||
final ClientEntity person = personReq.execute().getBody();
|
||||
assertNotNull(person);
|
||||
assertEquals(person2, person);
|
||||
|
@ -90,7 +90,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
|||
final ODataInvokeRequest<ClientEntitySet> productsReq = getClient().getInvokeRequestFactory()
|
||||
.getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
||||
appendOperationCallSegment("GetAllProducts").build(), ClientEntitySet.class);
|
||||
productsReq.setFormat(format);
|
||||
productsReq.setFormat(contentType);
|
||||
final ClientEntitySet products = productsReq.execute().getBody();
|
||||
assertNotNull(products);
|
||||
assertEquals(5, products.getEntities().size());
|
||||
|
@ -103,7 +103,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
|||
getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
||||
appendOperationCallSegment("GetProductsByAccessLevel").build(), ClientProperty.class,
|
||||
Collections.<String, ClientValue> singletonMap("accessLevel", accessLevel));
|
||||
prodByALReq.setFormat(format);
|
||||
prodByALReq.setFormat(contentType);
|
||||
final ClientProperty prodByAL = prodByALReq.execute().getBody();
|
||||
assertNotNull(prodByAL);
|
||||
assertTrue(prodByAL.hasCollectionValue());
|
||||
|
@ -113,12 +113,12 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void atomFunctionImports() throws EdmPrimitiveTypeException {
|
||||
functionImports(ODataFormat.ATOM);
|
||||
functionImports(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonFunctionImports() throws EdmPrimitiveTypeException {
|
||||
functionImports(ODataFormat.JSON_FULL_METADATA);
|
||||
functionImports(ContentType.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -182,14 +182,14 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
|||
assertTrue(prodByAL.getCollectionValue().asJavaCollection().contains("Car"));
|
||||
}
|
||||
|
||||
private void actionImports(final ODataFormat format) {
|
||||
private void actionImports(final ContentType contentType) {
|
||||
// Discount
|
||||
final ClientPrimitiveValue percentage = getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(22);
|
||||
final ODataInvokeRequest<ClientNoContent> discountReq = getClient().getInvokeRequestFactory().
|
||||
getActionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
||||
appendOperationCallSegment("Discount").build(), ClientNoContent.class,
|
||||
Collections.<String, ClientValue> singletonMap("percentage", percentage));
|
||||
discountReq.setFormat(format);
|
||||
discountReq.setFormat(contentType);
|
||||
final ClientNoContent discount = discountReq.execute().getBody();
|
||||
assertNotNull(discount);
|
||||
|
||||
|
@ -207,7 +207,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
|||
getActionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
||||
appendOperationCallSegment("ResetBossAddress").build(), ClientProperty.class,
|
||||
Collections.<String, ClientValue> singletonMap("address", address));
|
||||
resetBossAddressReq.setFormat(format);
|
||||
resetBossAddressReq.setFormat(contentType);
|
||||
final ClientProperty resetBossAddress = resetBossAddressReq.execute().getBody();
|
||||
assertNotNull(resetBossAddress);
|
||||
assertEquals(address, resetBossAddress.getComplexValue());
|
||||
|
@ -215,12 +215,12 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void atomActionImports() {
|
||||
actionImports(ODataFormat.ATOM);
|
||||
actionImports(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonActionImports() {
|
||||
actionImports(ODataFormat.JSON_FULL_METADATA);
|
||||
actionImports(ContentType.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -251,7 +251,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
|||
assertEquals(address.getTypeName(), resetBossAddress.getComplexValue().getTypeName());
|
||||
}
|
||||
|
||||
private void bossEmails(final ODataFormat format) {
|
||||
private void bossEmails(final ContentType contentType) {
|
||||
// ResetBossEmail
|
||||
final ClientCollectionValue<ClientValue> emails =
|
||||
getClient().getObjectFactory().newCollectionValue("Collection(Edm.String)");
|
||||
|
@ -261,7 +261,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
|||
getActionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
||||
appendOperationCallSegment("ResetBossEmail").build(), ClientProperty.class,
|
||||
Collections.<String, ClientValue> singletonMap("emails", emails));
|
||||
bossEmailsReq.setFormat(format);
|
||||
bossEmailsReq.setFormat(contentType);
|
||||
final ClientProperty bossEmails = bossEmailsReq.execute().getBody();
|
||||
assertNotNull(bossEmails);
|
||||
assertTrue(bossEmails.hasCollectionValue());
|
||||
|
@ -273,7 +273,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
|||
bossEmailsReq = getClient().getInvokeRequestFactory().getFunctionInvokeRequest(
|
||||
getClient().newURIBuilder(testStaticServiceRootURL).
|
||||
appendOperationCallSegment("GetBossEmails").build(), ClientProperty.class, params);
|
||||
bossEmailsReq.setFormat(format);
|
||||
bossEmailsReq.setFormat(contentType);
|
||||
final ClientProperty bossEmailsViaGET = bossEmailsReq.execute().getBody();
|
||||
assertNotNull(bossEmailsViaGET);
|
||||
assertTrue(bossEmailsViaGET.hasCollectionValue());
|
||||
|
@ -284,11 +284,11 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void atomBossEmails() throws EdmPrimitiveTypeException {
|
||||
bossEmails(ODataFormat.ATOM);
|
||||
bossEmails(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
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.ClientValuable;
|
||||
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.junit.Test;
|
||||
|
||||
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).
|
||||
appendEntitySetSegment("Products").appendKeySegment(5).appendPropertySegment("CoverColors");
|
||||
final ODataPropertyRequest<ClientProperty> req = client.getRetrieveRequestFactory().
|
||||
getPropertyRequest(uriBuilder.build());
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
final ClientProperty prop = req.execute().getBody();
|
||||
assertNotNull(prop);
|
||||
|
@ -59,25 +59,25 @@ public class PropertyTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void enumFromXML() {
|
||||
_enum(client, ODataFormat.XML);
|
||||
_enum(client, ContentType.APPLICATION_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void enumFromJSON() {
|
||||
_enum(edmClient, ODataFormat.JSON);
|
||||
_enum(edmClient, ContentType.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
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).
|
||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Home");
|
||||
final ODataPropertyRequest<ClientProperty> req = client.getRetrieveRequestFactory().
|
||||
getPropertyRequest(uriBuilder.build());
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
final ClientProperty prop = req.execute().getBody();
|
||||
assertNotNull(prop);
|
||||
|
@ -87,25 +87,25 @@ public class PropertyTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void geospatialFromXML() {
|
||||
geospatial(client, ODataFormat.XML);
|
||||
geospatial(client, ContentType.APPLICATION_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void geospatialFromJSON() {
|
||||
geospatial(edmClient, ODataFormat.JSON);
|
||||
geospatial(edmClient, ContentType.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
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).
|
||||
appendEntitySetSegment("Customers").appendKeySegment(2).appendPropertySegment("HomeAddress");
|
||||
final ODataPropertyRequest<ClientProperty> req = client.getRetrieveRequestFactory().
|
||||
getPropertyRequest(uriBuilder.build());
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
final ClientProperty prop = req.execute().getBody();
|
||||
assertNotNull(prop);
|
||||
|
@ -116,26 +116,26 @@ public class PropertyTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void complexFromXML() {
|
||||
complex(client, ODataFormat.XML);
|
||||
complex(client, ContentType.APPLICATION_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void complexFromJSON() {
|
||||
complex(edmClient, ODataFormat.JSON);
|
||||
complex(edmClient, ContentType.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
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).
|
||||
appendEntitySetSegment("Customers").appendKeySegment(1).appendPropertySegment("HomeAddress");
|
||||
|
||||
ODataPropertyRequest<ClientProperty> retrieveReq =
|
||||
client.getRetrieveRequestFactory().getPropertyRequest(uriBuilder.build());
|
||||
retrieveReq.setFormat(format);
|
||||
retrieveReq.setFormat(contentType);
|
||||
|
||||
ODataRetrieveResponse<ClientProperty> retrieveRes = retrieveReq.execute();
|
||||
assertEquals(200, retrieveRes.getStatusCode());
|
||||
|
@ -153,13 +153,13 @@ public class PropertyTestITCase extends AbstractTestITCase {
|
|||
} else {
|
||||
assertEquals(type.getMethod(), updateReq.getMethod());
|
||||
}
|
||||
updateReq.setFormat(format);
|
||||
updateReq.setFormat(contentType);
|
||||
|
||||
final ODataPropertyUpdateResponse updateRes = updateReq.execute();
|
||||
assertEquals(204, updateRes.getStatusCode());
|
||||
|
||||
retrieveReq = client.getRetrieveRequestFactory().getPropertyRequest(uriBuilder.build());
|
||||
retrieveReq.setFormat(format);
|
||||
retrieveReq.setFormat(contentType);
|
||||
|
||||
retrieveRes = retrieveReq.execute();
|
||||
assertEquals(200, retrieveRes.getStatusCode());
|
||||
|
@ -170,7 +170,7 @@ public class PropertyTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void patchComplexPropertyAsJSON() throws IOException {
|
||||
updateComplexProperty(ODataFormat.JSON_FULL_METADATA, UpdateType.PATCH);
|
||||
updateComplexProperty(ContentType.JSON_FULL_METADATA, UpdateType.PATCH);
|
||||
}
|
||||
|
||||
@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.uri.URIBuilder;
|
||||
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;
|
||||
|
||||
public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||
|
@ -42,7 +42,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
|||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PersonID");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
req.setFormat(ContentType.TEXT_PLAIN);
|
||||
assertEquals("5", req.execute().getBody().toString());
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
|||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("IsRegistered");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
req.setFormat(ContentType.TEXT_PLAIN);
|
||||
assertEquals("true", req.execute().getBody().toString());
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
|||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("FirstName");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
req.setFormat(ContentType.TEXT_PLAIN);
|
||||
assertEquals("Peter", req.execute().getBody().toString());
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
|||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Orders").appendKeySegment(8).appendPropertySegment("OrderDate");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
req.setFormat(ContentType.TEXT_PLAIN);
|
||||
final ClientPrimitiveValue property = req.execute().getBody();
|
||||
assertEquals("2011-03-04T16:03:57Z", property.toString());
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
|||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Height");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
req.setFormat(ContentType.TEXT_PLAIN);
|
||||
final ClientPrimitiveValue property = req.execute().getBody();
|
||||
assertEquals("179", property.toString());
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
|||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
req.setFormat(ContentType.TEXT_PLAIN);
|
||||
final ClientPrimitiveValue property = req.execute().getBody();
|
||||
assertEquals("fi653p3+MklA/LdoBlhWgnMTUUEo8tEgtbMXnF0a3CUNL9BZxXpSRiD9ebTnmNR0zWPjJ"
|
||||
+ "VIDx4tdmCnq55XrJh+RW9aI/b34wAogK3kcORw=", property.toString());
|
||||
|
@ -100,7 +100,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
|||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setAccept(ODataFormat.ATOM.getContentType().toContentTypeString());
|
||||
req.setAccept(ContentType.APPLICATION_ATOM_XML.toContentTypeString());
|
||||
req.execute().getBody();
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
|||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setAccept(ODataFormat.XML.getContentType().toContentTypeString());
|
||||
req.setAccept(ContentType.APPLICATION_XML.toContentTypeString());
|
||||
req.execute().getBody();
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
|||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Numbers");
|
||||
final ODataPropertyRequest<ClientProperty> req = client.getRetrieveRequestFactory().
|
||||
getPropertyRequest(uriBuilder.build());
|
||||
req.setFormat(ODataFormat.XML);
|
||||
req.setFormat(ContentType.APPLICATION_XML);
|
||||
final ClientProperty property = req.execute().getBody();
|
||||
// cast to workaround JDK 6 bug, fixed in JDK 7
|
||||
assertTrue(((ClientValuable) property).getValue().isCollection());
|
||||
|
@ -131,7 +131,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
|||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("HomeAddress");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
req.setFormat(ContentType.TEXT_PLAIN);
|
||||
final ClientPrimitiveValue property = req.execute().getBody();
|
||||
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.URIBuilder;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -128,12 +128,12 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
|
|||
|
||||
final ODataEntityRequest<ClientEntity> req =
|
||||
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||
req.setFormat(ODataFormat.ATOM);
|
||||
req.setFormat(ContentType.APPLICATION_ATOM_XML);
|
||||
|
||||
final ODataRetrieveResponse<ClientEntity> res = req.execute();
|
||||
assertNotNull(res);
|
||||
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.response.ODataRetrieveResponse;
|
||||
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;
|
||||
|
||||
public class ServiceDocumentTestITCase extends AbstractTestITCase {
|
||||
|
||||
private void retrieveServiceDocument(final ODataFormat format) {
|
||||
private void retrieveServiceDocument(final ContentType contentType) {
|
||||
final ODataServiceDocumentRequest req =
|
||||
client.getRetrieveRequestFactory().getServiceDocumentRequest(testStaticServiceRootURL);
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
final ODataRetrieveResponse<ClientServiceDocument> res = req.execute();
|
||||
assertEquals(200, res.getStatusCode());
|
||||
|
@ -53,11 +53,11 @@ public class ServiceDocumentTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void retrieveServiceDocumentAsXML() {
|
||||
retrieveServiceDocument(ODataFormat.XML);
|
||||
retrieveServiceDocument(ContentType.APPLICATION_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
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.commons.api.edm.EdmPrimitiveTypeException;
|
||||
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;
|
||||
|
||||
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 ODataEntityRequest<ClientSingleton> singleton =
|
||||
client.getRetrieveRequestFactory().getSingletonRequest(builder.build());
|
||||
singleton.setFormat(format);
|
||||
singleton.setFormat(contentType);
|
||||
final ClientSingleton company = singleton.execute().getBody();
|
||||
assertNotNull(company);
|
||||
|
||||
|
@ -58,26 +58,26 @@ public class SingletonTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void readFromAtom() throws EdmPrimitiveTypeException {
|
||||
read(client, ODataFormat.ATOM);
|
||||
read(client, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readFromJSON() throws EdmPrimitiveTypeException {
|
||||
read(edmClient, ODataFormat.JSON);
|
||||
read(edmClient, ContentType.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
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 {
|
||||
|
||||
final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Boss");
|
||||
final ODataEntityRequest<ClientSingleton> singleton =
|
||||
client.getRetrieveRequestFactory().getSingletonRequest(builder.build());
|
||||
singleton.setFormat(format);
|
||||
singleton.setFormat(contentType);
|
||||
singleton.setPrefer(client.newPreferences().includeAnnotations("*"));
|
||||
final ClientSingleton boss = singleton.execute().getBody();
|
||||
assertNotNull(boss);
|
||||
|
@ -89,20 +89,20 @@ public class SingletonTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void readWithAnnotationsFromAtom() throws EdmPrimitiveTypeException {
|
||||
readWithAnnotations(client, ODataFormat.ATOM);
|
||||
readWithAnnotations(client, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readWithAnnotationsFromJSON() throws EdmPrimitiveTypeException {
|
||||
readWithAnnotations(edmClient, ODataFormat.JSON);
|
||||
readWithAnnotations(edmClient, ContentType.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
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(
|
||||
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Company"));
|
||||
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 ODataEntityUpdateRequest<ClientSingleton> req = getClient().getCUDRequestFactory().
|
||||
getSingletonUpdateRequest(uri, UpdateType.PATCH, changes);
|
||||
req.setFormat(format);
|
||||
req.setFormat(contentType);
|
||||
|
||||
final ODataEntityUpdateResponse<ClientSingleton> res = req.execute();
|
||||
assertEquals(204, res.getStatusCode());
|
||||
|
@ -124,12 +124,12 @@ public class SingletonTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void atomUpdate() throws EdmPrimitiveTypeException {
|
||||
update(ODataFormat.ATOM);
|
||||
update(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
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.HttpUriRequestFactory;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
/**
|
||||
* Configuration wrapper.
|
||||
|
@ -49,16 +48,15 @@ public interface Configuration {
|
|||
* JSON_FULL_METADATA format will be used as default.
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
* @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>.
|
||||
|
@ -66,23 +64,22 @@ public interface Configuration {
|
|||
* @return configured OData format
|
||||
* @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
|
||||
* as default.
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
* @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
|
||||
|
@ -90,14 +87,14 @@ public interface Configuration {
|
|||
*
|
||||
* @return configured OData media format if specified; APPLICATION_OCTET_STREAM format otherwise.
|
||||
*/
|
||||
ODataFormat getDefaultMediaFormat();
|
||||
ContentType getDefaultMediaFormat();
|
||||
|
||||
/**
|
||||
* Sets the default OData media format.
|
||||
*
|
||||
* @param format default format.
|
||||
*/
|
||||
void setDefaultMediaFormat(ODataFormat format);
|
||||
void setDefaultMediaFormat(ContentType format);
|
||||
|
||||
/**
|
||||
* 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.invoke.InvokeRequestFactory;
|
||||
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.ODataBinder;
|
||||
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.SearchFactory;
|
||||
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.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
||||
|
||||
public interface ODataClient {
|
||||
|
||||
|
@ -47,13 +48,13 @@ public interface ODataClient {
|
|||
|
||||
ODataPreferences newPreferences();
|
||||
|
||||
ODataSerializer getSerializer(ODataFormat format);
|
||||
ODataSerializer getSerializer(ContentType contentType);
|
||||
|
||||
ODataWriter getWriter();
|
||||
|
||||
InvokeRequestFactory getInvokeRequestFactory();
|
||||
|
||||
ClientODataDeserializer getDeserializer(ODataFormat format);
|
||||
ClientODataDeserializer getDeserializer(ContentType contentType);
|
||||
|
||||
ODataReader getReader();
|
||||
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
*/
|
||||
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.InvocationTargetException;
|
||||
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Builder to create an ODataClient for the API client library.
|
||||
|
@ -142,7 +142,7 @@ public final class ODataClientBuilder {
|
|||
loadClass(EdmEnabledODataClient.class, clientImplClassName,
|
||||
new Class[] { String.class, Edm.class, String.class },
|
||||
new Object[] { serviceRoot, edm, metadataETag });
|
||||
instance.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
instance.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.olingo.client.api.communication.request;
|
|||
import java.util.concurrent.Future;
|
||||
|
||||
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.
|
||||
|
@ -45,9 +45,9 @@ public interface ODataBasicRequest<T extends ODataResponse> extends ODataRequest
|
|||
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.ODataStreamedRequest;
|
||||
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.
|
||||
|
@ -38,13 +38,12 @@ public interface ODataStreamedEntityRequest<V extends ODataResponse, T extends O
|
|||
* @return the configured format (or default if not specified).
|
||||
* @see org.apache.olingo.client.api.Configuration#getDefaultPubFormat()
|
||||
*/
|
||||
ODataFormat getFormat();
|
||||
ContentType getFormat();
|
||||
|
||||
/**
|
||||
* Override configured 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.data.Entity;
|
||||
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.LoggerFactory;
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class ClientEntitySetIterator<ES extends ClientEntitySet, E extends Clien
|
|||
|
||||
private final InputStream stream;
|
||||
|
||||
private final ODataFormat format;
|
||||
private final ContentType contentType;
|
||||
|
||||
private ES entitySet;
|
||||
|
||||
|
@ -75,17 +75,17 @@ public class ClientEntitySetIterator<ES extends ClientEntitySet, E extends Clien
|
|||
*
|
||||
* @param odataClient client instance getting this request
|
||||
* @param stream source stream.
|
||||
* @param format OData format.
|
||||
* @param contentType OData format.
|
||||
*/
|
||||
public ClientEntitySetIterator(final ODataClient odataClient, final InputStream stream,
|
||||
final ODataFormat format) {
|
||||
final ContentType contentType) {
|
||||
|
||||
this.odataClient = odataClient;
|
||||
this.stream = stream;
|
||||
this.format = format;
|
||||
this.contentType = contentType;
|
||||
this.osEntitySet = new ByteArrayOutputStream();
|
||||
|
||||
if (format == ODataFormat.ATOM) {
|
||||
|
||||
if(contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML)) {
|
||||
namespaces = getAllElementAttributes(stream, "feed", osEntitySet);
|
||||
} else {
|
||||
namespaces = null;
|
||||
|
@ -110,7 +110,7 @@ public class ClientEntitySetIterator<ES extends ClientEntitySet, E extends Clien
|
|||
@SuppressWarnings("unchecked")
|
||||
public boolean hasNext() {
|
||||
if (available && cached == null) {
|
||||
if (format == ODataFormat.ATOM) {
|
||||
if (contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML)) {
|
||||
cached = nextAtomEntityFromEntitySet(stream, osEntitySet, namespaces);
|
||||
} else {
|
||||
cached = nextJSONEntityFromEntitySet(stream, osEntitySet);
|
||||
|
@ -120,7 +120,7 @@ public class ClientEntitySetIterator<ES extends ClientEntitySet, E extends Clien
|
|||
available = false;
|
||||
try {
|
||||
entitySet = (ES) odataClient.getReader().
|
||||
readEntitySet(new ByteArrayInputStream(osEntitySet.toByteArray()), format);
|
||||
readEntitySet(new ByteArrayInputStream(osEntitySet.toByteArray()), contentType);
|
||||
} catch (final ODataDeserializerException e) {
|
||||
available = false;
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ public class ClientEntitySetIterator<ES extends ClientEntitySet, E extends Clien
|
|||
}
|
||||
|
||||
if (c >= 0) {
|
||||
jsonEntity = odataClient.getDeserializer(ODataFormat.JSON).toEntity(
|
||||
jsonEntity = odataClient.getDeserializer(ContentType.JSON).toEntity(
|
||||
new ByteArrayInputStream(entity.toByteArray()));
|
||||
}
|
||||
} else {
|
||||
|
@ -240,7 +240,7 @@ public class ClientEntitySetIterator<ES extends ClientEntitySet, E extends Clien
|
|||
entity.write(">".getBytes(Constants.UTF8));
|
||||
|
||||
if (consume(input, "</entry>", entity, true) >= 0) {
|
||||
atomEntity = odataClient.getDeserializer(ODataFormat.ATOM).
|
||||
atomEntity = odataClient.getDeserializer(ContentType.APPLICATION_ATOM_XML).
|
||||
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.EdmType;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface ClientPrimitiveValue extends ClientValue {
|
||||
|
@ -54,6 +55,8 @@ public interface ClientPrimitiveValue extends ClientValue {
|
|||
ClientPrimitiveValue buildGuid(UUID value);
|
||||
|
||||
ClientPrimitiveValue buildBinary(byte[] value);
|
||||
|
||||
ClientPrimitiveValue buildDecimal(BigDecimal value);
|
||||
}
|
||||
|
||||
EdmPrimitiveTypeKind getTypeKind();
|
||||
|
|
|
@ -21,15 +21,16 @@ package org.apache.olingo.client.api.serialization;
|
|||
import java.io.InputStream;
|
||||
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.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.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.provider.CsdlSchema;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
||||
|
||||
/**
|
||||
* OData reader.
|
||||
|
@ -60,51 +61,52 @@ public interface ODataReader {
|
|||
* Parses an OData service document.
|
||||
*
|
||||
* @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.
|
||||
* @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.
|
||||
*
|
||||
* @param input stream to de-serialize.
|
||||
* @param format de-serialize format
|
||||
* @param contentType de-serialize format
|
||||
* @return de-serialized entity set.
|
||||
* @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.
|
||||
*
|
||||
* @param input stream to de-serialize.
|
||||
* @param format de-serialize format
|
||||
* @param contentType de-serialize format
|
||||
* @return entity de-serialized.
|
||||
* @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.
|
||||
*
|
||||
* @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.
|
||||
* @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.
|
||||
*
|
||||
* @param inputStream stream to de-serialize.
|
||||
* @param format format
|
||||
* @param contentType format
|
||||
* @return OData error.
|
||||
* @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.
|
||||
|
|
|
@ -22,11 +22,11 @@ import java.io.InputStream;
|
|||
import java.net.URI;
|
||||
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.ClientProperty;
|
||||
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.
|
||||
|
@ -41,54 +41,54 @@ public interface ODataWriter {
|
|||
* Writes a collection of OData entities.
|
||||
*
|
||||
* @param entities entities to be serialized.
|
||||
* @param format serialization format.
|
||||
* @param contentType serialization format.
|
||||
* @return stream of serialized objects.
|
||||
* @throws ODataSerializerException
|
||||
*/
|
||||
InputStream writeEntities(Collection<ClientEntity> entities, ODataFormat format)
|
||||
InputStream writeEntities(Collection<ClientEntity> entities, ContentType contentType)
|
||||
throws ODataSerializerException;
|
||||
|
||||
/**
|
||||
* Serializes a single OData entity.
|
||||
*
|
||||
* @param entity entity to be serialized.
|
||||
* @param format serialization format.
|
||||
* @param contentType serialization format.
|
||||
* @return stream of serialized object.
|
||||
* @throws ODataSerializerException
|
||||
*/
|
||||
InputStream writeEntity(ClientEntity entity, ODataFormat format)
|
||||
InputStream writeEntity(ClientEntity entity, ContentType format)
|
||||
throws ODataSerializerException;
|
||||
|
||||
/**
|
||||
* Writes a single OData entity property.
|
||||
*
|
||||
* @param property entity property to be serialized.
|
||||
* @param format serialization format.
|
||||
* @param contentType serialization format.
|
||||
* @return stream of serialized object.
|
||||
* @throws ODataSerializerException
|
||||
*/
|
||||
InputStream writeProperty(ClientProperty property, ODataFormat format)
|
||||
InputStream writeProperty(ClientProperty property, ContentType format)
|
||||
throws ODataSerializerException;
|
||||
|
||||
/**
|
||||
* Writes an OData link.
|
||||
*
|
||||
* @param link link to be serialized.
|
||||
* @param format serialization format.
|
||||
* @param contentType serialization format.
|
||||
* @return stream of serialized object.
|
||||
* @throws ODataSerializerException
|
||||
*/
|
||||
InputStream writeLink(ClientLink link, ODataFormat format)
|
||||
InputStream writeLink(ClientLink link, ContentType format)
|
||||
throws ODataSerializerException;
|
||||
|
||||
/**
|
||||
* Writes a entity reference
|
||||
*
|
||||
* @param reference reference to be serialized
|
||||
* @param format serialization format
|
||||
* @param contentType serialization format
|
||||
* @return stream of serialized objects
|
||||
* @throws ODataSerializerException
|
||||
*/
|
||||
InputStream writeReference(ResWrap<URI> reference, ODataFormat format)
|
||||
InputStream writeReference(ResWrap<URI> reference, ContentType format)
|
||||
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.DefaultHttpUriRequestFactory;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
public class ConfigurationImpl implements Configuration {
|
||||
|
||||
|
@ -96,39 +95,39 @@ public class ConfigurationImpl implements Configuration {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultPubFormat() {
|
||||
return (ODataFormat) getProperty(DEFAULT_PUB_FORMAT, ODataFormat.JSON_FULL_METADATA);
|
||||
public ContentType getDefaultPubFormat() {
|
||||
return (ContentType) getProperty(DEFAULT_PUB_FORMAT, ContentType.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultPubFormat(final ODataFormat format) {
|
||||
setProperty(DEFAULT_PUB_FORMAT, format);
|
||||
public void setDefaultPubFormat(final ContentType contentType) {
|
||||
setProperty(DEFAULT_PUB_FORMAT, contentType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
final ODataFormat format = getDefaultPubFormat();
|
||||
return format == ODataFormat.ATOM ? ODataFormat.XML : format;
|
||||
public ContentType getDefaultFormat() {
|
||||
final ContentType contenType = getDefaultPubFormat();
|
||||
return contenType == ContentType.APPLICATION_ATOM_XML ? ContentType.APPLICATION_XML : contenType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultValueFormat() {
|
||||
return (ODataFormat) getProperty(DEFAULT_VALUE_FORMAT, ODataFormat.TEXT_PLAIN);
|
||||
public ContentType getDefaultValueFormat() {
|
||||
return (ContentType) getProperty(DEFAULT_VALUE_FORMAT, ContentType.TEXT_PLAIN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultValueFormat(final ODataFormat format) {
|
||||
setProperty(DEFAULT_VALUE_FORMAT, format);
|
||||
public void setDefaultValueFormat(final ContentType contentType) {
|
||||
setProperty(DEFAULT_VALUE_FORMAT, contentType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultMediaFormat() {
|
||||
return (ODataFormat) getProperty(DEFAULT_VALUE_FORMAT, ODataFormat.APPLICATION_OCTET_STREAM);
|
||||
public ContentType getDefaultMediaFormat() {
|
||||
return (ContentType) getProperty(DEFAULT_VALUE_FORMAT, ContentType.APPLICATION_OCTET_STREAM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultMediaFormat(final ODataFormat format) {
|
||||
setProperty(DEFAULT_MEDIA_FORMAT, format);
|
||||
public void setDefaultMediaFormat(final ContentType contentType) {
|
||||
setProperty(DEFAULT_MEDIA_FORMAT, contentType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.olingo.client.core;
|
|||
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
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 {
|
||||
|
||||
|
@ -38,7 +38,7 @@ public final class ODataClientFactory {
|
|||
|
||||
final EdmEnabledODataClient instance =
|
||||
new EdmEnabledODataClientImpl(serviceRoot, edm, metadataETag);
|
||||
instance.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
instance.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
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.invoke.InvokeRequestFactory;
|
||||
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.ODataBinder;
|
||||
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.invoke.InvokeRequestFactoryImpl;
|
||||
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.ClientODataDeserializerImpl;
|
||||
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.uri.FilterFactoryImpl;
|
||||
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.format.ODataFormat;
|
||||
import org.apache.olingo.client.core.domain.ClientObjectFactoryImpl;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
||||
public class ODataClientImpl implements ODataClient {
|
||||
|
||||
|
@ -125,15 +125,16 @@ public class ODataClientImpl implements ODataClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ClientODataDeserializer getDeserializer(final ODataFormat format) {
|
||||
return new ClientODataDeserializerImpl(false, format);
|
||||
public ClientODataDeserializer getDeserializer(final ContentType contentType) {
|
||||
return new ClientODataDeserializerImpl(false, contentType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataSerializer getSerializer(final ODataFormat format) {
|
||||
return format == ODataFormat.ATOM || format == ODataFormat.XML ?
|
||||
new AtomSerializer() :
|
||||
new JsonSerializer(false, format);
|
||||
public ODataSerializer getSerializer(final ContentType contentType) {
|
||||
return contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML,
|
||||
ContentType.APPLICATION_XML) ?
|
||||
new AtomSerializer() : new JsonSerializer(false, contentType);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* 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
|
||||
* 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
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "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
|
||||
* 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.communication.ODataClientErrorException;
|
||||
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.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.LoggerFactory;
|
||||
|
||||
|
@ -43,29 +44,29 @@ public final class ODataErrorResponseChecker {
|
|||
}
|
||||
|
||||
public static ODataRuntimeException checkResponse(
|
||||
final ODataClient odataClient, final StatusLine statusLine, final InputStream entity,
|
||||
final String accept) {
|
||||
final ODataClient odataClient, final StatusLine statusLine, final InputStream entity,
|
||||
final String accept) {
|
||||
|
||||
ODataRuntimeException result = null;
|
||||
|
||||
if (entity == null) {
|
||||
result = new ODataClientErrorException(statusLine);
|
||||
} 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;
|
||||
try {
|
||||
error = odataClient.getReader().readError(entity, format);
|
||||
error = odataClient.getReader().readError(entity, contentType);
|
||||
} catch (final RuntimeException e) {
|
||||
LOG.warn("Error deserializing error response", e);
|
||||
error = getGenericError(
|
||||
statusLine.getStatusCode(),
|
||||
statusLine.getReasonPhrase());
|
||||
statusLine.getStatusCode(),
|
||||
statusLine.getReasonPhrase());
|
||||
} catch (final ODataDeserializerException e) {
|
||||
LOG.warn("Error deserializing error response", e);
|
||||
error = getGenericError(
|
||||
statusLine.getStatusCode(),
|
||||
statusLine.getReasonPhrase());
|
||||
statusLine.getStatusCode(),
|
||||
statusLine.getReasonPhrase());
|
||||
}
|
||||
|
||||
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.batch.ODataBatchRequest;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -55,9 +55,9 @@ public abstract class AbstractODataBasicRequest<T extends ODataResponse>
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setFormat(final ODataFormat format) {
|
||||
if (format != null) {
|
||||
final String formatString = format.getContentType().toContentTypeString();
|
||||
public void setFormat(final ContentType contentType) {
|
||||
if (contentType != null) {
|
||||
final String formatString = contentType.toContentTypeString();
|
||||
setAccept(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.http.HttpClientException;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -102,7 +102,7 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD
|
|||
this.request = odataClient.getConfiguration().getHttpUriRequestFactory().create(this.method, uri);
|
||||
}
|
||||
|
||||
public abstract ODataFormat getDefaultFormat();
|
||||
public abstract ContentType getDefaultFormat();
|
||||
|
||||
@Override
|
||||
public URI getURI() {
|
||||
|
@ -178,7 +178,7 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD
|
|||
public String getAccept() {
|
||||
final String acceptHead = odataHeaders.getHeader(HeaderName.accept);
|
||||
return StringUtils.isBlank(acceptHead)
|
||||
? getDefaultFormat().getContentType().toContentTypeString()
|
||||
? getDefaultFormat().toContentTypeString()
|
||||
: acceptHead;
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD
|
|||
public String getContentType() {
|
||||
final String contentTypeHead = odataHeaders.getHeader(HeaderName.contentType);
|
||||
return StringUtils.isBlank(contentTypeHead)
|
||||
? getDefaultFormat().getContentType().toContentTypeString()
|
||||
? getDefaultFormat().toContentTypeString()
|
||||
: 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.core.communication.request.AbstractODataBasicRequest;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -42,7 +42,7 @@ public class ODataDeleteRequestImpl extends AbstractODataBasicRequest<ODataDelet
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
public ContentType getDefaultFormat() {
|
||||
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.communication.request.cud.ODataEntityCreateRequest;
|
||||
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.response.AbstractODataResponse;
|
||||
import org.apache.olingo.client.core.uri.URIUtils;
|
||||
import org.apache.olingo.commons.api.data.Entity;
|
||||
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.ODataSerializerException;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||
|
||||
/**
|
||||
|
@ -66,14 +66,14 @@ public class ODataEntityCreateRequestImpl<E extends ClientEntity>
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
public ContentType getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InputStream getPayload() {
|
||||
try {
|
||||
return odataClient.getWriter().writeEntity(entity, ODataFormat.fromString(getContentType()));
|
||||
return odataClient.getWriter().writeEntity(entity, ContentType.parse(getContentType()));
|
||||
} catch (final ODataSerializerException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ public class ODataEntityCreateRequestImpl<E extends ClientEntity>
|
|||
public E getBody() {
|
||||
if (resEntity == null) {
|
||||
try {
|
||||
final ResWrap<Entity> resource = odataClient.getDeserializer(ODataFormat.fromString(getAccept())).
|
||||
final ResWrap<Entity> resource = odataClient.getDeserializer(ContentType.parse(getAccept())).
|
||||
toEntity(getRawResponse());
|
||||
|
||||
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.communication.request.cud.ODataEntityUpdateRequest;
|
||||
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.response.AbstractODataResponse;
|
||||
import org.apache.olingo.client.core.uri.URIUtils;
|
||||
import org.apache.olingo.commons.api.data.Entity;
|
||||
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.ODataSerializerException;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||
|
||||
/**
|
||||
|
@ -70,14 +70,14 @@ public class ODataEntityUpdateRequestImpl<E extends ClientEntity>
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
public ContentType getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InputStream getPayload() {
|
||||
try {
|
||||
return odataClient.getWriter().writeEntity(changes, ODataFormat.fromString(getContentType()));
|
||||
return odataClient.getWriter().writeEntity(changes, ContentType.parse(getContentType()));
|
||||
} catch (final ODataSerializerException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ public class ODataEntityUpdateRequestImpl<E extends ClientEntity>
|
|||
public E getBody() {
|
||||
if (entity == null) {
|
||||
try {
|
||||
final ResWrap<Entity> resource = odataClient.getDeserializer(ODataFormat.fromString(getAccept())).
|
||||
final ResWrap<Entity> resource = odataClient.getDeserializer(ContentType.parse(getAccept())).
|
||||
toEntity(getRawResponse());
|
||||
|
||||
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.communication.request.cud.ODataPropertyUpdateRequest;
|
||||
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.response.AbstractODataResponse;
|
||||
import org.apache.olingo.client.core.uri.URIUtils;
|
||||
import org.apache.olingo.commons.api.data.Property;
|
||||
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.ODataSerializerException;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||
|
||||
/**
|
||||
|
@ -67,7 +67,7 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
public ContentType getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultFormat();
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
|
|||
@Override
|
||||
protected InputStream getPayload() {
|
||||
try {
|
||||
return odataClient.getWriter().writeProperty(property, ODataFormat.fromString(getContentType()));
|
||||
return odataClient.getWriter().writeProperty(property, ContentType.parse(getContentType()));
|
||||
} catch (final ODataSerializerException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
|
|||
public ClientProperty getBody() {
|
||||
if (resProperty == null) {
|
||||
try {
|
||||
final ResWrap<Property> resource = odataClient.getDeserializer(ODataFormat.fromString(getAccept())).
|
||||
final ResWrap<Property> resource = odataClient.getDeserializer(ContentType.parse(getAccept())).
|
||||
toProperty(getRawResponse());
|
||||
|
||||
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.uri.URIUtils;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -54,7 +54,7 @@ public class ODataReferenceAddingRequestImpl extends AbstractODataBasicRequest<O
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
public ContentType getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ public class ODataReferenceAddingRequestImpl extends AbstractODataBasicRequest<O
|
|||
} else {
|
||||
ODataWriter writer = odataClient.getWriter();
|
||||
try {
|
||||
return writer.writeReference(reference, ODataFormat.fromString(getContentType()));
|
||||
return writer.writeReference(reference, ContentType.parse(getContentType()));
|
||||
} catch (ODataSerializerException e) {
|
||||
LOG.warn("Error serializing reference {}", reference);
|
||||
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.communication.request.cud.ODataValueUpdateRequest;
|
||||
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.core.communication.request.AbstractODataBasicRequest;
|
||||
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
|
||||
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.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||
|
||||
/**
|
||||
|
@ -65,7 +65,7 @@ public class ODataValueUpdateRequestImpl extends AbstractODataBasicRequest<OData
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
public ContentType getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultValueFormat();
|
||||
}
|
||||
|
||||
|
@ -105,11 +105,11 @@ public class ODataValueUpdateRequestImpl extends AbstractODataBasicRequest<OData
|
|||
@Override
|
||||
public ClientPrimitiveValue getBody() {
|
||||
if (resValue == null) {
|
||||
final ODataFormat format = ODataFormat.fromString(getAccept());
|
||||
|
||||
final ContentType contentType = ContentType.parse(getAccept());
|
||||
|
||||
try {
|
||||
resValue = odataClient.getObjectFactory().newPrimitiveValueBuilder().
|
||||
setType(format == ODataFormat.TEXT_PLAIN
|
||||
setType(contentType.isCompatible(ContentType.TEXT_PLAIN)
|
||||
? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
|
||||
setValue(getRawResponse()).
|
||||
build();
|
||||
|
|
|
@ -31,8 +31,8 @@ import org.apache.http.client.methods.HttpPost;
|
|||
import org.apache.http.client.methods.HttpRequestBase;
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
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.ODataInvokeRequest;
|
||||
import org.apache.olingo.client.api.communication.response.ODataInvokeResponse;
|
||||
import org.apache.olingo.client.api.http.HttpClientException;
|
||||
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.ClientProperty;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -91,23 +91,24 @@ public abstract class AbstractODataInvokeRequest<T extends ClientInvokeResult>
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
public ContentType getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||
}
|
||||
|
||||
private String getActualFormat(final ODataFormat format) {
|
||||
return ((ClientProperty.class.isAssignableFrom(reference) && format == ODataFormat.ATOM)
|
||||
? ODataFormat.XML : format).getContentType().toContentTypeString();
|
||||
private String getActualFormat(final ContentType contentType) {
|
||||
return ((ClientProperty.class.isAssignableFrom(reference)
|
||||
&& contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML))
|
||||
? ContentType.APPLICATION_XML : contentType).toContentTypeString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFormat(final ODataFormat format) {
|
||||
final String _format = getActualFormat(format);
|
||||
setAccept(_format);
|
||||
setContentType(_format);
|
||||
public void setFormat(final ContentType contentType) {
|
||||
final String _contentType = getActualFormat(contentType);
|
||||
setAccept(_contentType);
|
||||
setContentType(_contentType);
|
||||
}
|
||||
|
||||
protected abstract ODataFormat getPOSTParameterFormat();
|
||||
protected abstract ContentType getPOSTParameterFormat();
|
||||
|
||||
@Override
|
||||
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;
|
||||
if (ClientEntitySet.class.isAssignableFrom(reference)) {
|
||||
invokeResult = reference.cast(odataClient.getReader().readEntitySet(responseStream,
|
||||
ODataFormat.fromString(getContentType())));
|
||||
ContentType.parse(getContentType())));
|
||||
} else if (ClientEntity.class.isAssignableFrom(reference)) {
|
||||
invokeResult = reference.cast(odataClient.getReader().readEntity(responseStream,
|
||||
ODataFormat.fromString(getContentType())));
|
||||
ContentType.parse(getContentType())));
|
||||
} else if (ClientProperty.class.isAssignableFrom(reference)) {
|
||||
invokeResult = reference.cast(odataClient.getReader().readProperty(responseStream,
|
||||
ODataFormat.fromString(getContentType())));
|
||||
ContentType.parse(getContentType())));
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -22,12 +22,12 @@ import java.net.URI;
|
|||
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
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;
|
||||
|
||||
public class ODataInvokeRequestImpl<T extends ClientInvokeResult> extends AbstractODataInvokeRequest<T> {
|
||||
|
||||
private ODataFormat format;
|
||||
private ContentType contentType;
|
||||
|
||||
public ODataInvokeRequestImpl(final ODataClient odataClient, final Class<T> reference,
|
||||
final HttpMethod method, final URI uri) {
|
||||
|
@ -36,13 +36,13 @@ public class ODataInvokeRequestImpl<T extends ClientInvokeResult> extends Abstra
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setFormat(final ODataFormat format) {
|
||||
super.setFormat(format);
|
||||
this.format = format;
|
||||
public void setFormat(final ContentType contentType) {
|
||||
super.setFormat(contentType);
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ODataFormat getPOSTParameterFormat() {
|
||||
return format == null ? getDefaultFormat() : format;
|
||||
protected ContentType getPOSTParameterFormat() {
|
||||
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.communication.request.ODataRequest;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
public abstract class AbstractMetadataRequestImpl<V> extends AbstractODataRetrieveRequest<V> {
|
||||
|
||||
|
@ -34,8 +33,8 @@ public abstract class AbstractMetadataRequestImpl<V> extends AbstractODataRetrie
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
return ODataFormat.XML;
|
||||
public ContentType getDefaultFormat() {
|
||||
return ContentType.APPLICATION_XML;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,12 +26,12 @@ import org.apache.http.client.HttpClient;
|
|||
import org.apache.olingo.client.api.ODataClient;
|
||||
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.domain.ClientDelta;
|
||||
import org.apache.olingo.client.api.http.HttpClientException;
|
||||
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
||||
import org.apache.olingo.commons.api.data.Delta;
|
||||
import org.apache.olingo.commons.api.data.ResWrap;
|
||||
import org.apache.olingo.client.api.domain.ClientDelta;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
||||
public class ODataDeltaRequestImpl extends AbstractODataRetrieveRequest<ClientDelta>
|
||||
implements ODataDeltaRequest {
|
||||
|
@ -41,7 +41,7 @@ public class ODataDeltaRequestImpl extends AbstractODataRetrieveRequest<ClientDe
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
public ContentType getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class ODataDeltaRequestImpl extends AbstractODataRetrieveRequest<ClientDe
|
|||
public ClientDelta getBody() {
|
||||
if (delta == null) {
|
||||
try {
|
||||
final ResWrap<Delta> resource = odataClient.getDeserializer(ODataFormat.fromString(getContentType())).
|
||||
final ResWrap<Delta> resource = odataClient.getDeserializer(ContentType.parse(getContentType())).
|
||||
toDelta(res.getEntity().getContent());
|
||||
|
||||
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.communication.request.retrieve.ODataEntityRequest;
|
||||
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.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.commons.api.format.ODataFormat;
|
||||
|
||||
/**
|
||||
* This class implements an OData retrieve query request returning a single entity.
|
||||
|
@ -48,7 +48,7 @@ public class ODataEntityRequestImpl<E extends ClientEntity>
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
public ContentType getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ public class ODataEntityRequestImpl<E extends ClientEntity>
|
|||
public E getBody() {
|
||||
if (entity == null) {
|
||||
try {
|
||||
final ResWrap<Entity> resource = odataClient.getDeserializer(ODataFormat.fromString(getContentType())).
|
||||
final ResWrap<Entity> resource = odataClient.getDeserializer(ContentType.parse(getContentType())).
|
||||
toEntity(getRawResponse());
|
||||
|
||||
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.communication.request.retrieve.ODataEntitySetIteratorRequest;
|
||||
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.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.
|
||||
|
@ -50,7 +50,7 @@ public class ODataEntitySetIteratorRequestImpl<ES extends ClientEntitySet, E ext
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
public ContentType getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ public class ODataEntitySetIteratorRequestImpl<ES extends ClientEntitySet, E ext
|
|||
public ClientEntitySetIterator<ES, E> getBody() {
|
||||
if (entitySetIterator == null) {
|
||||
entitySetIterator = new ClientEntitySetIterator<ES, E>(
|
||||
odataClient, getRawResponse(), ODataFormat.fromString(getContentType()));
|
||||
odataClient, getRawResponse(), ContentType.parse(getContentType()));
|
||||
}
|
||||
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.communication.request.retrieve.ODataEntitySetRequest;
|
||||
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.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.commons.api.format.ODataFormat;
|
||||
|
||||
/**
|
||||
* This class implements an OData EntitySet query request.
|
||||
|
@ -52,7 +52,7 @@ public class ODataEntitySetRequestImpl<ES extends ClientEntitySet>
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
public ContentType getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class ODataEntitySetRequestImpl<ES extends ClientEntitySet>
|
|||
if (entitySet == null) {
|
||||
try {
|
||||
final ResWrap<EntityCollection> resource =
|
||||
odataClient.getDeserializer(ODataFormat.fromString(getContentType())).
|
||||
odataClient.getDeserializer(ContentType.parse(getContentType())).
|
||||
toEntitySet(getRawResponse());
|
||||
|
||||
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.response.ODataRetrieveResponse;
|
||||
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.
|
||||
|
@ -44,12 +44,12 @@ public class ODataMediaRequestImpl extends AbstractODataRetrieveRequest<InputStr
|
|||
ODataMediaRequestImpl(final ODataClient odataClient, final URI query) {
|
||||
super(odataClient, query);
|
||||
|
||||
setAccept(ODataFormat.APPLICATION_OCTET_STREAM.toString());
|
||||
setContentType(ODataFormat.APPLICATION_OCTET_STREAM.toString());
|
||||
setAccept(ContentType.APPLICATION_OCTET_STREAM.toString());
|
||||
setContentType(ContentType.APPLICATION_OCTET_STREAM.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
public ContentType getDefaultFormat() {
|
||||
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.communication.request.retrieve.ODataPropertyRequest;
|
||||
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.serialization.ODataDeserializerException;
|
||||
import org.apache.olingo.commons.api.data.Property;
|
||||
import org.apache.olingo.commons.api.data.ResWrap;
|
||||
import org.apache.olingo.client.api.domain.ClientProperty;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
||||
/**
|
||||
* This class implements an OData entity property query request.
|
||||
|
@ -50,7 +50,7 @@ public class ODataPropertyRequestImpl<T extends ClientProperty>
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
public ContentType getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultFormat();
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ public class ODataPropertyRequestImpl<T extends ClientProperty>
|
|||
public T getBody() {
|
||||
if (property == null) {
|
||||
try {
|
||||
final ResWrap<Property> resource = odataClient.getDeserializer(ODataFormat.fromString(getContentType()))
|
||||
final ResWrap<Property> resource = odataClient.getDeserializer(ContentType.parse(getContentType()))
|
||||
.toProperty(res.getEntity().getContent());
|
||||
|
||||
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.response.AbstractODataResponse;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -51,7 +51,7 @@ public class ODataRawRequestImpl extends AbstractODataRequest implements ODataRa
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
public ContentType getDefaultFormat() {
|
||||
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.response.ODataRetrieveResponse;
|
||||
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.commons.api.data.ResWrap;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
/**
|
||||
* This class implements an OData service document request.
|
||||
|
@ -48,7 +48,7 @@ public class ODataServiceDocumentRequestImpl extends AbstractODataRetrieveReques
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
public ContentType getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultFormat();
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ public class ODataServiceDocumentRequestImpl extends AbstractODataRetrieveReques
|
|||
if (serviceDocument == null) {
|
||||
try {
|
||||
final ResWrap<ServiceDocument> resource = odataClient.
|
||||
getDeserializer(ODataFormat.fromString(getContentType())).toServiceDocument(getRawResponse());
|
||||
getDeserializer(ContentType.parse(getContentType())).toServiceDocument(getRawResponse());
|
||||
|
||||
serviceDocument = odataClient.getBinder().getODataServiceDocument(resource.getPayload());
|
||||
} 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.communication.request.retrieve.ODataValueRequest;
|
||||
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.http.HttpClientException;
|
||||
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.
|
||||
|
@ -48,7 +48,7 @@ public class ODataValueRequestImpl extends AbstractODataRetrieveRequest<ClientPr
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
public ContentType getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultValueFormat();
|
||||
}
|
||||
|
||||
|
@ -74,11 +74,11 @@ public class ODataValueRequestImpl extends AbstractODataRetrieveRequest<ClientPr
|
|||
@Override
|
||||
public ClientPrimitiveValue getBody() {
|
||||
if (value == null) {
|
||||
final ODataFormat format = ODataFormat.fromString(getContentType());
|
||||
final ContentType contentType = ContentType.parse(getContentType());
|
||||
|
||||
try {
|
||||
value = odataClient.getObjectFactory().newPrimitiveValueBuilder().
|
||||
setType(format == ODataFormat.TEXT_PLAIN
|
||||
setType(contentType.isCompatible(ContentType.TEXT_PLAIN)
|
||||
? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
|
||||
setValue(IOUtils.toString(getRawResponse())).build();
|
||||
} 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.CsdlAnnotations;
|
||||
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;
|
||||
|
||||
public class XMLMetadataRequestImpl
|
||||
|
@ -170,7 +170,7 @@ public class XMLMetadataRequestImpl
|
|||
public XMLMetadata getBody() {
|
||||
if (metadata == null) {
|
||||
try {
|
||||
metadata = odataClient.getDeserializer(ODataFormat.XML).toMetadata(getRawResponse());
|
||||
metadata = odataClient.getDeserializer(ContentType.APPLICATION_XML).toMetadata(getRawResponse());
|
||||
} finally {
|
||||
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.streamed.ODataStreamedEntityRequest;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@ public abstract class AbstractODataStreamedEntityRequest<V extends ODataResponse
|
|||
extends AbstractODataStreamedRequest<V, T>
|
||||
implements ODataStreamedEntityRequest<V, T> {
|
||||
|
||||
private ODataFormat format;
|
||||
private ContentType contentType;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -50,17 +50,17 @@ public abstract class AbstractODataStreamedEntityRequest<V extends ODataResponse
|
|||
final URI uri) {
|
||||
|
||||
super(odataClient, method, uri);
|
||||
setAccept(getFormat().getContentType().toContentTypeString());
|
||||
setAccept(getFormat().toContentTypeString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ODataFormat getFormat() {
|
||||
return format == null ? odataClient.getConfiguration().getDefaultPubFormat() : format;
|
||||
public final ContentType getFormat() {
|
||||
return contentType == null ? odataClient.getConfiguration().getDefaultPubFormat() : contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setFormat(final ODataFormat format) {
|
||||
this.format = format;
|
||||
setAccept(format.getContentType().toContentTypeString());
|
||||
public final void setFormat(final ContentType contentType) {
|
||||
this.contentType = contentType;
|
||||
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.uri.URIUtils;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||
|
||||
/**
|
||||
|
@ -78,7 +77,7 @@ public abstract class AbstractODataStreamedRequest<V extends ODataResponse, T ex
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
public ContentType getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultMediaFormat();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.apache.olingo.client.core.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.UUID;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@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.core.data.JSONServiceDocumentDeserializer;
|
||||
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.xml.ClientCsdlEdmx;
|
||||
import org.apache.olingo.commons.api.ODataError;
|
||||
import org.apache.olingo.commons.api.data.Delta;
|
||||
import org.apache.olingo.commons.api.data.Entity;
|
||||
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||
import org.apache.olingo.commons.api.data.Property;
|
||||
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.format.ODataFormat;
|
||||
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import com.fasterxml.aalto.stax.InputFactoryImpl;
|
||||
import com.fasterxml.aalto.stax.OutputFactoryImpl;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
|
@ -56,11 +55,12 @@ public class ClientODataDeserializerImpl implements ClientODataDeserializer {
|
|||
|
||||
private final ODataDeserializer deserializer;
|
||||
|
||||
private final ODataFormat format;
|
||||
private final ContentType contentType;
|
||||
|
||||
public ClientODataDeserializerImpl(final boolean serverMode, final ODataFormat format) {
|
||||
this.format = format;
|
||||
if (format == ODataFormat.XML || format == ODataFormat.ATOM) {
|
||||
public ClientODataDeserializerImpl(final boolean serverMode, final ContentType contentType) {
|
||||
this.contentType = contentType;
|
||||
if(contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML,
|
||||
ContentType.APPLICATION_XML )) {
|
||||
deserializer = new AtomDeserializer();
|
||||
} else {
|
||||
deserializer = new JsonDeserializer(serverMode);
|
||||
|
@ -119,7 +119,7 @@ public class ClientODataDeserializerImpl implements ClientODataDeserializer {
|
|||
|
||||
@Override
|
||||
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 JSONServiceDocumentDeserializer(false).toServiceDocument(input);
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ public class ClientODataDeserializerImpl implements ClientODataDeserializer {
|
|||
@Override
|
||||
public ResWrap<Delta> toDelta(final InputStream input) throws ODataDeserializerException {
|
||||
try {
|
||||
return format == ODataFormat.ATOM ?
|
||||
return contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML) ?
|
||||
new AtomDeserializer().delta(input) :
|
||||
new JsonDeltaDeserializer(false).toDelta(input);
|
||||
} 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.ResWrap;
|
||||
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 com.fasterxml.jackson.core.JsonGenerator;
|
||||
|
@ -39,12 +39,8 @@ import com.fasterxml.jackson.core.JsonGenerator;
|
|||
*/
|
||||
public class JsonEntitySerializer extends JsonSerializer {
|
||||
|
||||
public JsonEntitySerializer(final boolean serverMode) {
|
||||
super(serverMode);
|
||||
}
|
||||
|
||||
public JsonEntitySerializer(final boolean serverMode, final ODataFormat format) {
|
||||
super(serverMode, format);
|
||||
public JsonEntitySerializer(final boolean serverMode, final ContentType contentType) {
|
||||
super(serverMode, contentType);
|
||||
}
|
||||
|
||||
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,
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -100,7 +96,7 @@ public class JsonEntitySerializer extends JsonSerializer {
|
|||
}
|
||||
}
|
||||
|
||||
if (format != ODataFormat.JSON_NO_METADATA) {
|
||||
if (!isODataMetadataNone(contentType)) {
|
||||
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.ResWrap;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
|
||||
public class JsonEntitySetSerializer extends JsonSerializer {
|
||||
|
||||
public JsonEntitySetSerializer(final boolean serverMode) {
|
||||
super(serverMode);
|
||||
public JsonEntitySetSerializer(final boolean serverMode, final ContentType contentType) {
|
||||
super(serverMode, contentType);
|
||||
}
|
||||
|
||||
protected void doSerialize(final EntityCollection entitySet, final JsonGenerator jgen)
|
||||
|
@ -81,7 +82,7 @@ public class JsonEntitySetSerializer extends JsonSerializer {
|
|||
}
|
||||
|
||||
jgen.writeArrayFieldStart(Constants.VALUE);
|
||||
final JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode);
|
||||
final JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode, contentType);
|
||||
for (Entity entity : entitySet.getEntities()) {
|
||||
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.ResWrap;
|
||||
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 com.fasterxml.jackson.core.JsonGenerator;
|
||||
|
@ -36,8 +37,8 @@ import com.fasterxml.jackson.core.JsonGenerator;
|
|||
*/
|
||||
public class JsonPropertySerializer extends JsonSerializer {
|
||||
|
||||
public JsonPropertySerializer(final boolean serverMode) {
|
||||
super(serverMode);
|
||||
public JsonPropertySerializer(final boolean serverMode, final ContentType contentType) {
|
||||
super(serverMode, contentType);
|
||||
}
|
||||
|
||||
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.EdmPrimitiveTypeKind;
|
||||
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.primitivetype.EdmPrimitiveTypeFactory;
|
||||
|
||||
|
@ -64,16 +64,13 @@ public class JsonSerializer implements ODataSerializer {
|
|||
private final JsonGeoValueSerializer geoSerializer = new JsonGeoValueSerializer();
|
||||
|
||||
protected boolean serverMode;
|
||||
protected final boolean isIEEE754Compatible;
|
||||
protected ContentType contentType;
|
||||
|
||||
protected ODataFormat format;
|
||||
|
||||
public JsonSerializer(final boolean serverMode) {
|
||||
this(serverMode, ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
public JsonSerializer(final boolean serverMode, final ODataFormat format) {
|
||||
public JsonSerializer(final boolean serverMode, final ContentType contentType) {
|
||||
this.serverMode = serverMode;
|
||||
this.format = format;
|
||||
this.contentType = contentType;
|
||||
this.isIEEE754Compatible = isIEEE754Compatible();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -81,11 +78,11 @@ public class JsonSerializer implements ODataSerializer {
|
|||
try {
|
||||
final JsonGenerator json = new JsonFactory().createGenerator(writer);
|
||||
if (obj instanceof EntityCollection) {
|
||||
new JsonEntitySetSerializer(serverMode).doSerialize((EntityCollection) obj, json);
|
||||
new JsonEntitySetSerializer(serverMode, contentType).doSerialize((EntityCollection) obj, json);
|
||||
} 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) {
|
||||
new JsonPropertySerializer(serverMode).doSerialize((Property) obj, json);
|
||||
new JsonPropertySerializer(serverMode, contentType).doSerialize((Property) obj, json);
|
||||
} else if (obj instanceof Link) {
|
||||
link((Link) obj, json);
|
||||
}
|
||||
|
@ -113,11 +110,12 @@ public class JsonSerializer implements ODataSerializer {
|
|||
try {
|
||||
final JsonGenerator json = new JsonFactory().createGenerator(writer);
|
||||
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) {
|
||||
new JsonEntitySerializer(serverMode).doContainerSerialize((ResWrap<Entity>) container, json);
|
||||
new JsonEntitySerializer(serverMode, contentType).doContainerSerialize((ResWrap<Entity>) container, json);
|
||||
} 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) {
|
||||
link((Link) obj, json);
|
||||
} else if (obj instanceof URI) {
|
||||
|
@ -175,10 +173,10 @@ public class JsonSerializer implements ODataSerializer {
|
|||
|
||||
if (link.getInlineEntity() != null) {
|
||||
jgen.writeFieldName(link.getTitle());
|
||||
new JsonEntitySerializer(serverMode).doSerialize(link.getInlineEntity(), jgen);
|
||||
new JsonEntitySerializer(serverMode, contentType).doSerialize(link.getInlineEntity(), jgen);
|
||||
} else if (link.getInlineEntitySet() != null) {
|
||||
jgen.writeArrayFieldStart(link.getTitle());
|
||||
final JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode);
|
||||
final JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode, contentType);
|
||||
for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
|
||||
entitySerializer.doSerialize(subEntry, jgen);
|
||||
}
|
||||
|
@ -233,10 +231,10 @@ public class JsonSerializer implements ODataSerializer {
|
|||
|
||||
if (link.getInlineEntity() != null) {
|
||||
jgen.writeFieldName(link.getTitle());
|
||||
new JsonEntitySerializer(serverMode).doSerialize(link.getInlineEntity(), jgen);
|
||||
new JsonEntitySerializer(serverMode, contentType).doSerialize(link.getInlineEntity(), jgen);
|
||||
} else if (link.getInlineEntitySet() != null) {
|
||||
jgen.writeArrayFieldStart(link.getTitle());
|
||||
JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode);
|
||||
JsonEntitySerializer entitySerializer = new JsonEntitySerializer(serverMode, contentType);
|
||||
for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
|
||||
entitySerializer.doSerialize(subEntry, jgen);
|
||||
}
|
||||
|
@ -294,12 +292,15 @@ public class JsonSerializer implements ODataSerializer {
|
|||
} else if (isBoolean) {
|
||||
jgen.writeBoolean((Boolean) value);
|
||||
} else {
|
||||
final String serialized = kind == null
|
||||
String serialized = kind == null
|
||||
? value.toString()
|
||||
// TODO: add facets
|
||||
: EdmPrimitiveTypeFactory.getInstance(kind).
|
||||
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);
|
||||
} else {
|
||||
jgen.writeString(serialized);
|
||||
|
@ -312,7 +313,7 @@ public class JsonSerializer implements ODataSerializer {
|
|||
throws IOException, EdmPrimitiveTypeException {
|
||||
jgen.writeStartObject();
|
||||
|
||||
if (typeInfo != null && format != ODataFormat.JSON_NO_METADATA) {
|
||||
if (typeInfo != null && !isODataMetadataNone(contentType)) {
|
||||
jgen.writeStringField(Constants.JSON_TYPE, typeInfo.external());
|
||||
}
|
||||
|
||||
|
@ -359,7 +360,7 @@ public class JsonSerializer implements ODataSerializer {
|
|||
valuable.isPrimitive()) || valuable.isNull()) {
|
||||
type = EdmPrimitiveTypeKind.String.getFullQualifiedName().toString();
|
||||
}
|
||||
if (StringUtils.isNotBlank(type) && format != ODataFormat.JSON_NO_METADATA) {
|
||||
if (StringUtils.isNotBlank(type) && !isODataMetadataNone(contentType)) {
|
||||
jgen.writeFieldName(
|
||||
name + StringUtils.prependIfMissing(Constants.JSON_TYPE, "@"));
|
||||
jgen.writeString(new EdmTypeInfo.Builder().setTypeExpression(type).build().external());
|
||||
|
@ -373,4 +374,14 @@ public class JsonSerializer implements ODataSerializer {
|
|||
jgen.writeFieldName(name);
|
||||
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.ClientValuable;
|
||||
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.EdmBindingTarget;
|
||||
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.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
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.api.format.ContentType;
|
||||
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -391,7 +391,7 @@ public class ODataBinderImpl implements ODataBinder {
|
|||
if (LOG.isDebugEnabled()) {
|
||||
final StringWriter writer = new StringWriter();
|
||||
try {
|
||||
client.getSerializer(ODataFormat.JSON).write(writer, resource.getPayload());
|
||||
client.getSerializer(ContentType.JSON).write(writer, resource.getPayload());
|
||||
} catch (final ODataSerializerException e) {
|
||||
LOG.debug("EntitySet -> ODataEntitySet:\n{}", writer.toString());
|
||||
}
|
||||
|
@ -588,7 +588,7 @@ public class ODataBinderImpl implements ODataBinder {
|
|||
if (LOG.isDebugEnabled()) {
|
||||
final StringWriter writer = new StringWriter();
|
||||
try {
|
||||
client.getSerializer(ODataFormat.JSON).write(writer, resource.getPayload());
|
||||
client.getSerializer(ContentType.JSON).write(writer, resource.getPayload());
|
||||
} catch (final ODataSerializerException e) {
|
||||
LOG.debug("EntityResource -> ODataEntity:\n{}", writer.toString());
|
||||
}
|
||||
|
|
|
@ -25,25 +25,25 @@ import java.util.Map;
|
|||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
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.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.serialization.ODataDeserializerException;
|
||||
import org.apache.olingo.client.api.serialization.ODataReader;
|
||||
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.EntityCollection;
|
||||
import org.apache.olingo.commons.api.data.Property;
|
||||
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.EdmPrimitiveTypeKind;
|
||||
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.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -63,7 +63,7 @@ public class ODataReaderImpl implements ODataReader {
|
|||
|
||||
@Override
|
||||
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
|
||||
|
@ -73,16 +73,16 @@ public class ODataReaderImpl implements ODataReader {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ClientServiceDocument readServiceDocument(final InputStream input, final ODataFormat format)
|
||||
public ClientServiceDocument readServiceDocument(final InputStream input, final ContentType contentType)
|
||||
throws ODataDeserializerException {
|
||||
return client.getBinder().getODataServiceDocument(
|
||||
client.getDeserializer(format).toServiceDocument(input).getPayload());
|
||||
client.getDeserializer(contentType).toServiceDocument(input).getPayload());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataError readError(final InputStream inputStream, final ODataFormat format)
|
||||
public ODataError readError(final InputStream inputStream, final ContentType contentType)
|
||||
throws ODataDeserializerException {
|
||||
return client.getDeserializer(format).toError(inputStream);
|
||||
return client.getDeserializer(contentType).toError(inputStream);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -96,22 +96,22 @@ public class ODataReaderImpl implements ODataReader {
|
|||
(URI) null,
|
||||
null,
|
||||
reference.cast(new ClientEntitySetIterator<ClientEntitySet, ClientEntity>(
|
||||
client, src, ODataFormat.fromString(format))));
|
||||
client, src, ContentType.parse(format))));
|
||||
} 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);
|
||||
res = new ResWrap<T>(
|
||||
resource.getContextURL(),
|
||||
resource.getMetadataETag(),
|
||||
reference.cast(client.getBinder().getODataEntitySet(resource)));
|
||||
} 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>(
|
||||
container.getContextURL(),
|
||||
container.getMetadataETag(),
|
||||
reference.cast(client.getBinder().getODataEntity(container)));
|
||||
} 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>(
|
||||
container.getContextURL(),
|
||||
container.getMetadataETag(),
|
||||
|
@ -121,7 +121,7 @@ public class ODataReaderImpl implements ODataReader {
|
|||
(URI) null,
|
||||
null,
|
||||
reference.cast(client.getObjectFactory().newPrimitiveValueBuilder().
|
||||
setType(ODataFormat.fromString(format) == ODataFormat.TEXT_PLAIN
|
||||
setType(ContentType.parse(format).equals(ContentType.TEXT_PLAIN)
|
||||
? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
|
||||
setValue(IOUtils.toString(src)) // TODO: set correct value
|
||||
.build()));
|
||||
|
@ -132,7 +132,7 @@ public class ODataReaderImpl implements ODataReader {
|
|||
reference.cast(readMetadata(src)));
|
||||
} else if (ClientServiceDocument.class.isAssignableFrom(reference)) {
|
||||
final ResWrap<ServiceDocument> resource =
|
||||
client.getDeserializer(ODataFormat.fromString(format)).toServiceDocument(src);
|
||||
client.getDeserializer(ContentType.parse(format)).toServiceDocument(src);
|
||||
res = new ResWrap<T>(
|
||||
resource.getContextURL(),
|
||||
resource.getMetadataETag(),
|
||||
|
@ -141,7 +141,7 @@ public class ODataReaderImpl implements ODataReader {
|
|||
res = new ResWrap<T>(
|
||||
(URI) null,
|
||||
null,
|
||||
reference.cast(readError(src, ODataFormat.fromString(format))));
|
||||
reference.cast(readError(src, ContentType.parse(format))));
|
||||
} else {
|
||||
throw new IllegalArgumentException("Invalid reference type " + reference);
|
||||
}
|
||||
|
@ -158,20 +158,20 @@ public class ODataReaderImpl implements ODataReader {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ClientEntitySet readEntitySet(final InputStream input, final ODataFormat format)
|
||||
public ClientEntitySet readEntitySet(final InputStream input, final ContentType contentType)
|
||||
throws ODataDeserializerException {
|
||||
return client.getBinder().getODataEntitySet(client.getDeserializer(format).toEntitySet(input));
|
||||
return client.getBinder().getODataEntitySet(client.getDeserializer(contentType).toEntitySet(input));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientEntity readEntity(final InputStream input, final ODataFormat format)
|
||||
public ClientEntity readEntity(final InputStream input, final ContentType contentType)
|
||||
throws ODataDeserializerException {
|
||||
return client.getBinder().getODataEntity(client.getDeserializer(format).toEntity(input));
|
||||
return client.getBinder().getODataEntity(client.getDeserializer(contentType).toEntity(input));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientProperty readProperty(final InputStream input, final ODataFormat format)
|
||||
public ClientProperty readProperty(final InputStream input, final ContentType contentType)
|
||||
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.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.ClientLink;
|
||||
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 {
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class ODataWriterImpl implements ODataWriter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public InputStream writeEntities(final Collection<ClientEntity> entities, final ODataFormat format)
|
||||
public InputStream writeEntities(final Collection<ClientEntity> entities, final ContentType contentType)
|
||||
throws ODataSerializerException {
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
OutputStreamWriter writer;
|
||||
|
@ -58,7 +58,7 @@ public class ODataWriterImpl implements ODataWriter {
|
|||
}
|
||||
try {
|
||||
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());
|
||||
|
@ -68,13 +68,13 @@ public class ODataWriterImpl implements ODataWriter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public InputStream writeEntity(final ClientEntity entity, final ODataFormat format)
|
||||
public InputStream writeEntity(final ClientEntity entity, final ContentType contentType)
|
||||
throws ODataSerializerException {
|
||||
return writeEntities(Collections.<ClientEntity>singleton(entity), format);
|
||||
return writeEntities(Collections.<ClientEntity>singleton(entity), contentType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream writeProperty(final ClientProperty property, final ODataFormat format)
|
||||
public InputStream writeProperty(final ClientProperty property, final ContentType contentType)
|
||||
throws ODataSerializerException {
|
||||
final ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
OutputStreamWriter writer;
|
||||
|
@ -84,7 +84,7 @@ public class ODataWriterImpl implements ODataWriter {
|
|||
writer = null;
|
||||
}
|
||||
try {
|
||||
client.getSerializer(format).write(writer, client.getBinder().getProperty(property));
|
||||
client.getSerializer(contentType).write(writer, client.getBinder().getProperty(property));
|
||||
|
||||
return new ByteArrayInputStream(output.toByteArray());
|
||||
} finally {
|
||||
|
@ -93,7 +93,7 @@ public class ODataWriterImpl implements ODataWriter {
|
|||
}
|
||||
|
||||
@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();
|
||||
OutputStreamWriter writer;
|
||||
try {
|
||||
|
@ -102,7 +102,7 @@ public class ODataWriterImpl implements ODataWriter {
|
|||
writer = null;
|
||||
}
|
||||
try {
|
||||
client.getSerializer(format).write(writer, client.getBinder().getLink(link));
|
||||
client.getSerializer(contentType).write(writer, client.getBinder().getLink(link));
|
||||
|
||||
return new ByteArrayInputStream(output.toByteArray());
|
||||
} finally {
|
||||
|
@ -111,7 +111,7 @@ public class ODataWriterImpl implements ODataWriter {
|
|||
}
|
||||
|
||||
@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();
|
||||
OutputStreamWriter writer;
|
||||
|
||||
|
@ -122,7 +122,7 @@ public class ODataWriterImpl implements ODataWriter {
|
|||
}
|
||||
|
||||
try {
|
||||
client.getSerializer(format).write(writer, reference);
|
||||
client.getSerializer(contenType).write(writer, reference);
|
||||
|
||||
return new ByteArrayInputStream(output.toByteArray());
|
||||
} finally {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package org.apache.olingo.client.core;
|
||||
|
||||
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.junit.BeforeClass;
|
||||
|
||||
|
@ -43,7 +43,8 @@ public abstract class AbstractTest {
|
|||
v4Client = ODataClientFactory.getClient();
|
||||
}
|
||||
|
||||
protected String getSuffix(final ODataFormat format) {
|
||||
return format == ODataFormat.ATOM || format == ODataFormat.XML ? "xml" : "json";
|
||||
protected String getSuffix(final ContentType contentType) {
|
||||
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 org.apache.commons.io.IOUtils;
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
import org.apache.olingo.client.core.AtomLinksQualifier;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.custommonkey.xmlunit.Diff;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
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.StreamSource;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.StringWriter;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
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 {
|
||||
|
||||
|
@ -43,13 +43,13 @@ public class AtomTest extends JSONTest {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ODataFormat getODataPubFormat() {
|
||||
return ODataFormat.ATOM;
|
||||
protected ContentType getODataPubFormat() {
|
||||
return ContentType.APPLICATION_ATOM_XML;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ODataFormat getODataFormat() {
|
||||
return ODataFormat.XML;
|
||||
protected ContentType getODataFormat() {
|
||||
return ContentType.APPLICATION_XML;
|
||||
}
|
||||
|
||||
private String cleanup(final String input) throws Exception {
|
||||
|
|
|
@ -18,23 +18,23 @@
|
|||
*/
|
||||
package org.apache.olingo.client.core.v4;
|
||||
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
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.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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
import org.apache.olingo.client.api.domain.ClientEntity;
|
||||
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 {
|
||||
|
||||
|
@ -43,10 +43,10 @@ public class EntitySetTest extends AbstractTest {
|
|||
return v4Client;
|
||||
}
|
||||
|
||||
private void read(final ODataFormat format) throws IOException, ODataDeserializerException {
|
||||
final InputStream input = getClass().getResourceAsStream("Customers." + getSuffix(format));
|
||||
private void read(final ContentType contentType) throws IOException, ODataDeserializerException {
|
||||
final InputStream input = getClass().getResourceAsStream("Customers." + getSuffix(contentType));
|
||||
final ClientEntitySet entitySet = getClient().getBinder().getODataEntitySet(
|
||||
getClient().getDeserializer(format).toEntitySet(input));
|
||||
getClient().getDeserializer(contentType).toEntitySet(input));
|
||||
assertNotNull(entitySet);
|
||||
|
||||
assertEquals(2, entitySet.getEntities().size());
|
||||
|
@ -60,18 +60,18 @@ public class EntitySetTest extends AbstractTest {
|
|||
|
||||
@Test
|
||||
public void fromAtom() throws Exception {
|
||||
read(ODataFormat.ATOM);
|
||||
read(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromJSON() throws Exception {
|
||||
read(ODataFormat.JSON);
|
||||
read(ContentType.JSON);
|
||||
}
|
||||
|
||||
private void ref(final ODataFormat format) throws ODataDeserializerException {
|
||||
final InputStream input = getClass().getResourceAsStream("collectionOfEntityReferences." + getSuffix(format));
|
||||
private void ref(final ContentType contentType) throws ODataDeserializerException {
|
||||
final InputStream input = getClass().getResourceAsStream("collectionOfEntityReferences." + getSuffix(contentType));
|
||||
final ClientEntitySet entitySet = getClient().getBinder().getODataEntitySet(
|
||||
getClient().getDeserializer(format).toEntitySet(input));
|
||||
getClient().getDeserializer(contentType).toEntitySet(input));
|
||||
assertNotNull(entitySet);
|
||||
|
||||
for (ClientEntity entity : entitySet.getEntities()) {
|
||||
|
@ -87,11 +87,11 @@ public class EntitySetTest extends AbstractTest {
|
|||
|
||||
@Test
|
||||
public void atomRef() throws Exception {
|
||||
ref(ODataFormat.ATOM);
|
||||
ref(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
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.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.ClientComplexValue;
|
||||
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.ClientValuable;
|
||||
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.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.EdmDuration;
|
||||
import org.junit.Ignore;
|
||||
|
@ -78,10 +78,10 @@ public class EntityTest extends AbstractTest {
|
|||
};
|
||||
}
|
||||
|
||||
private void singleton(final ODataFormat format) throws Exception {
|
||||
final InputStream input = getClass().getResourceAsStream("VipCustomer." + getSuffix(format));
|
||||
private void singleton(final ContentType contentType) throws Exception {
|
||||
final InputStream input = getClass().getResourceAsStream("VipCustomer." + getSuffix(contentType));
|
||||
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
||||
getClient().getDeserializer(format).toEntity(input));
|
||||
getClient().getDeserializer(contentType).toEntity(input));
|
||||
assertNotNull(entity);
|
||||
|
||||
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
|
||||
|
@ -102,7 +102,7 @@ public class EntityTest extends AbstractTest {
|
|||
}
|
||||
if ("Orders".equals(link.getName())) {
|
||||
checked++;
|
||||
if (format == ODataFormat.ATOM) {
|
||||
if(contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC, ContentType.APPLICATION_ATOM_XML)) {
|
||||
assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, link.getType());
|
||||
}
|
||||
}
|
||||
|
@ -129,18 +129,18 @@ public class EntityTest extends AbstractTest {
|
|||
|
||||
@Test
|
||||
public void atomSingleton() throws Exception {
|
||||
singleton(ODataFormat.ATOM);
|
||||
singleton(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonSingleton() throws Exception {
|
||||
singleton(ODataFormat.JSON_FULL_METADATA);
|
||||
singleton(ContentType.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
private void withEnums(final ODataFormat format) throws Exception {
|
||||
final InputStream input = getClass().getResourceAsStream("Products_5." + getSuffix(format));
|
||||
private void withEnums(final ContentType contentType) throws Exception {
|
||||
final InputStream input = getClass().getResourceAsStream("Products_5." + getSuffix(contentType));
|
||||
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
||||
getClient().getDeserializer(format).toEntity(input));
|
||||
getClient().getDeserializer(contentType).toEntity(input));
|
||||
assertNotNull(entity);
|
||||
|
||||
final ClientProperty skinColor = entity.getProperty("SkinColor");
|
||||
|
@ -165,19 +165,19 @@ public class EntityTest extends AbstractTest {
|
|||
|
||||
@Test
|
||||
public void atomWithEnums() throws Exception {
|
||||
withEnums(ODataFormat.ATOM);
|
||||
withEnums(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
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(
|
||||
"Accounts_101_expand_MyPaymentInstruments." + getSuffix(format));
|
||||
"Accounts_101_expand_MyPaymentInstruments." + getSuffix(contentType));
|
||||
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
||||
getClient().getDeserializer(format).toEntity(input));
|
||||
getClient().getDeserializer(contentType).toEntity(input));
|
||||
assertNotNull(entity);
|
||||
|
||||
final ClientLink instruments = entity.getNavigationLink("MyPaymentInstruments");
|
||||
|
@ -200,19 +200,19 @@ public class EntityTest extends AbstractTest {
|
|||
|
||||
@Test
|
||||
public void atomWithInlineEntitySet() throws Exception {
|
||||
withInlineEntitySet(ODataFormat.ATOM);
|
||||
withInlineEntitySet(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
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(
|
||||
"Advertisements_f89dee73-af9f-4cd4-b330-db93c25ff3c7." + getSuffix(format));
|
||||
"Advertisements_f89dee73-af9f-4cd4-b330-db93c25ff3c7." + getSuffix(contentType));
|
||||
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
||||
getClient().getDeserializer(format).toEntity(input));
|
||||
getClient().getDeserializer(contentType).toEntity(input));
|
||||
assertNotNull(entity);
|
||||
|
||||
assertTrue(entity.isMediaEntity());
|
||||
|
@ -227,18 +227,18 @@ public class EntityTest extends AbstractTest {
|
|||
|
||||
@Test
|
||||
public void atomMediaEntity() throws Exception {
|
||||
mediaEntity(ODataFormat.ATOM);
|
||||
mediaEntity(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonMediaEntity() throws Exception {
|
||||
mediaEntity(ODataFormat.JSON_FULL_METADATA);
|
||||
mediaEntity(ContentType.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
private void withStream(final ODataFormat format) throws Exception {
|
||||
final InputStream input = getClass().getResourceAsStream("PersonDetails_1." + getSuffix(format));
|
||||
private void withStream(final ContentType contentType) throws Exception {
|
||||
final InputStream input = getClass().getResourceAsStream("PersonDetails_1." + getSuffix(contentType));
|
||||
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
||||
getClient().getDeserializer(format).toEntity(input));
|
||||
getClient().getDeserializer(contentType).toEntity(input));
|
||||
assertNotNull(entity);
|
||||
|
||||
assertFalse(entity.isMediaEntity());
|
||||
|
@ -254,18 +254,18 @@ public class EntityTest extends AbstractTest {
|
|||
|
||||
@Test
|
||||
public void atomWithStream() throws Exception {
|
||||
withStream(ODataFormat.ATOM);
|
||||
withStream(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonWithStream() throws Exception {
|
||||
withStream(ODataFormat.JSON_FULL_METADATA);
|
||||
withStream(ContentType.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
private void ref(final ODataFormat format) throws Exception {
|
||||
final InputStream input = getClass().getResourceAsStream("entityReference." + getSuffix(format));
|
||||
private void ref(final ContentType contentType) throws Exception {
|
||||
final InputStream input = getClass().getResourceAsStream("entityReference." + getSuffix(contentType));
|
||||
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
||||
getClient().getDeserializer(format).toEntity(input));
|
||||
getClient().getDeserializer(contentType).toEntity(input));
|
||||
assertNotNull(entity);
|
||||
|
||||
assertNotNull(entity.getId());
|
||||
|
@ -278,18 +278,18 @@ public class EntityTest extends AbstractTest {
|
|||
|
||||
@Test
|
||||
public void atomRef() throws Exception {
|
||||
ref(ODataFormat.ATOM);
|
||||
ref(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonRef() throws Exception {
|
||||
ref(ODataFormat.JSON);
|
||||
ref(ContentType.JSON);
|
||||
}
|
||||
|
||||
private void complexNavigationProperties(final ODataFormat format) throws Exception {
|
||||
final InputStream input = getClass().getResourceAsStream("entity.withcomplexnavigation." + getSuffix(format));
|
||||
private void complexNavigationProperties(final ContentType contentType) throws Exception {
|
||||
final InputStream input = getClass().getResourceAsStream("entity.withcomplexnavigation." + getSuffix(contentType));
|
||||
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
||||
getClient().getDeserializer(format).toEntity(input));
|
||||
getClient().getDeserializer(contentType).toEntity(input));
|
||||
assertNotNull(entity);
|
||||
|
||||
final ClientComplexValue addressValue = entity.getProperty("Address").getComplexValue();
|
||||
|
@ -306,18 +306,18 @@ public class EntityTest extends AbstractTest {
|
|||
|
||||
@Test
|
||||
public void atomComplexNavigationProperties() throws Exception {
|
||||
complexNavigationProperties(ODataFormat.ATOM);
|
||||
complexNavigationProperties(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonComplexNavigationProperties() throws Exception {
|
||||
complexNavigationProperties(ODataFormat.JSON);
|
||||
complexNavigationProperties(ContentType.JSON);
|
||||
}
|
||||
|
||||
private void annotated(final ODataFormat format) throws EdmPrimitiveTypeException, Exception {
|
||||
final InputStream input = getClass().getResourceAsStream("annotated." + getSuffix(format));
|
||||
private void annotated(final ContentType contentType) throws EdmPrimitiveTypeException, Exception {
|
||||
final InputStream input = getClass().getResourceAsStream("annotated." + getSuffix(contentType));
|
||||
final ClientEntity entity = getClient().getBinder().getODataEntity(
|
||||
getClient().getDeserializer(format).toEntity(input));
|
||||
getClient().getDeserializer(contentType).toEntity(input));
|
||||
assertNotNull(entity);
|
||||
|
||||
assertFalse(entity.getAnnotations().isEmpty());
|
||||
|
@ -353,18 +353,18 @@ public class EntityTest extends AbstractTest {
|
|||
@Test
|
||||
@Ignore
|
||||
public void atomAnnotated() throws Exception {
|
||||
annotated(ODataFormat.ATOM);
|
||||
annotated(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void jsonAnnotated() throws Exception {
|
||||
annotated(ODataFormat.JSON);
|
||||
annotated(ContentType.JSON);
|
||||
}
|
||||
|
||||
private void derived(final ODataClient client, final ODataFormat format) throws Exception {
|
||||
final InputStream input = getClass().getResourceAsStream("Customer." + getSuffix(format));
|
||||
final ClientEntity entity = client.getBinder().getODataEntity(client.getDeserializer(format).toEntity(input));
|
||||
private void derived(final ODataClient client, final ContentType contentType) throws Exception {
|
||||
final InputStream input = getClass().getResourceAsStream("Customer." + getSuffix(contentType));
|
||||
final ClientEntity entity = client.getBinder().getODataEntity(client.getDeserializer(contentType).toEntity(input));
|
||||
assertNotNull(entity);
|
||||
|
||||
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
|
||||
|
@ -375,16 +375,16 @@ public class EntityTest extends AbstractTest {
|
|||
|
||||
@Test
|
||||
public void derivedFromAtom() throws Exception {
|
||||
derived(getClient(), ODataFormat.ATOM);
|
||||
derived(getClient(), ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void derivedFromJSON() throws Exception {
|
||||
derived(getEdmEnabledClient(), ODataFormat.JSON);
|
||||
derived(getEdmEnabledClient(), ContentType.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
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;
|
||||
|
||||
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.serialization.ODataDeserializerException;
|
||||
import org.apache.olingo.client.core.AbstractTest;
|
||||
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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
public class ErrorTest extends AbstractTest {
|
||||
|
||||
@Override
|
||||
|
@ -35,15 +35,15 @@ public class ErrorTest extends AbstractTest {
|
|||
return v4Client;
|
||||
}
|
||||
|
||||
private ODataError error(final String name, final ODataFormat format) throws ODataDeserializerException {
|
||||
final ODataError error = getClient().getDeserializer(format).toError(
|
||||
getClass().getResourceAsStream(name + "." + getSuffix(format)));
|
||||
private ODataError error(final String name, final ContentType contentType) throws ODataDeserializerException {
|
||||
final ODataError error = getClient().getDeserializer(contentType).toError(
|
||||
getClass().getResourceAsStream(name + "." + getSuffix(contentType)));
|
||||
assertNotNull(error);
|
||||
return error;
|
||||
}
|
||||
|
||||
private void simple(final ODataFormat format) throws ODataDeserializerException {
|
||||
final ODataError error = error("error", format);
|
||||
private void simple(final ContentType contentType) throws ODataDeserializerException {
|
||||
final ODataError error = error("error", contentType);
|
||||
assertEquals("501", error.getCode());
|
||||
assertEquals("Unsupported functionality", error.getMessage());
|
||||
assertEquals("query", error.getTarget());
|
||||
|
@ -51,12 +51,12 @@ public class ErrorTest extends AbstractTest {
|
|||
|
||||
@Test
|
||||
public void jsonSimple() throws Exception {
|
||||
simple(ODataFormat.JSON);
|
||||
simple(ContentType.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
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