You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ra...@apache.org on 2015/07/15 04:36:57 UTC
[8/8] olingo-odata4 git commit: OLINGO-640: Adding support for
ATOM+XML Serializer and De-Serializer
OLINGO-640: Adding support for ATOM+XML Serializer and De-Serializer
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/5b99eb7b
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/5b99eb7b
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/5b99eb7b
Branch: refs/heads/OLINGO-640
Commit: 5b99eb7b63d8a9b0349f3ac70d1f52fb89c95d8b
Parents: 9674aae
Author: Ramesh Reddy <ra...@jboss.org>
Authored: Tue Jun 30 14:19:09 2015 -0500
Committer: Ramesh Reddy <ra...@jboss.org>
Committed: Tue Jul 14 21:16:50 2015 -0500
----------------------------------------------------------------------
.../olingo/fit/tecsvc/client/BasicITCase.java | 174 +-
.../fit/tecsvc/client/BasicXmlITCase.java | 45 +
.../fit/tecsvc/client/BatchClientITCase.java | 8 +-
.../fit/tecsvc/client/BatchClientXmlITCase.java | 44 +
.../olingo/fit/tecsvc/client/BindingITCase.java | 6 +-
.../fit/tecsvc/client/BindingXmlITCase.java | 51 +
.../fit/tecsvc/client/ConditionalITCase.java | 9 +-
.../fit/tecsvc/client/ConditionalXmlITCase.java | 45 +
.../fit/tecsvc/client/DeepInsertITCase.java | 44 +-
.../fit/tecsvc/client/DeepInsertXmlITCase.java | 960 ++++++++++
.../tecsvc/client/EntityReferencesITCase.java | 107 +-
.../client/EntityReferencesXmlITCase.java | 45 +
.../fit/tecsvc/client/ExpandSelectITCase.java | 60 +-
.../tecsvc/client/ExpandSelectXmlITCase.java | 45 +
.../ExpandWithSystemQueryOptionsITCase.java | 57 +-
.../ExpandWithSystemQueryOptionsXmlITCase.java | 45 +
.../tecsvc/client/FilterSystemQueryITCase.java | 165 +-
.../client/FilterSystemQueryXmlITCase.java | 45 +
.../fit/tecsvc/client/FunctionImportITCase.java | 27 +-
.../tecsvc/client/FunctionImportXmlITCase.java | 45 +
.../olingo/fit/tecsvc/client/MediaITCase.java | 13 +-
.../fit/tecsvc/client/MediaXmlITCase.java | 45 +
.../fit/tecsvc/client/NavigationITCase.java | 14 +-
.../fit/tecsvc/client/NavigationXmlITCase.java | 45 +
.../OrderBySystemQueryOptionXmlITCase.java | 45 +
.../tecsvc/client/PrimitiveComplexITCase.java | 45 +-
.../client/PrimitiveComplexXmlITCase.java | 48 +
.../client/SystemQueryOptionXmlITCase.java | 45 +
.../olingo/fit/v4/AbstractTestITCase.java | 2 +-
.../apache/olingo/fit/v4/AsyncTestITCase.java | 3 +
.../olingo/fit/v4/EntityRetrieveTestITCase.java | 3 +
.../olingo/fit/v4/MediaEntityTestITCase.java | 2 +-
.../apache/olingo/fit/v4/OAuth2TestITCase.java | 2 +-
.../olingo/client/core/ODataClientFactory.java | 19 +-
.../core/serialization/AbstractAtomDealer.java | 4 +-
.../core/serialization/AtomDeserializer.java | 18 +-
.../core/serialization/AtomSerializer.java | 208 +-
.../core/serialization/ODataBinderImpl.java | 2 +-
.../apache/olingo/client/core/v4/JSONTest.java | 2 +-
.../apache/olingo/client/core/v4/Customers.xml | 9 +-
.../apache/olingo/client/core/v4/Products_5.xml | 2 +-
.../olingo/client/core/v4/VipCustomer.xml | 2 +-
.../apache/olingo/client/core/v4/annotated.xml | 4 +-
.../core/v4/entity.withcomplexnavigation.xml | 3 +-
.../EntityCollectionSerializerOptions.java | 14 +-
.../olingo/server/core/ServiceRequest.java | 3 +-
.../olingo/server/core/ContentNegotiator.java | 4 +-
.../apache/olingo/server/core/ODataImpl.java | 16 +-
.../deserializer/xml/ODataXmlDeserializer.java | 702 +++++++
.../core/serializer/xml/ODataXmlSerializer.java | 1038 ++++++++++
.../serializer/xml/ODataXmlSerializerImpl.java | 155 --
.../xml/ServiceDocumentXmlSerializer.java | 143 ++
.../server/core/ContentNegotiatorTest.java | 3 +-
.../olingo/server/core/ODataImplTest.java | 3 +-
.../xml/MetadataDocumentXmlSerializerTest.java | 14 +-
.../xml/ServerErrorXmlSerializerTest.java | 93 +
.../xml/ServiceDocumentXmlSerializerTest.java | 105 +
.../olingo/server/tecsvc/TechnicalServlet.java | 2 +-
.../olingo/server/tecsvc/data/ActionData.java | 11 +-
.../olingo/server/tecsvc/data/DataCreator.java | 225 ++-
.../olingo/server/tecsvc/data/DataProvider.java | 8 +-
.../server/tecsvc/data/RequestValidator.java | 12 +-
.../processor/TechnicalEntityProcessor.java | 7 +-
.../tecsvc/processor/TechnicalProcessor.java | 1 -
.../ExpandSystemQueryOptionHandler.java | 2 +-
.../server/tecsvc/data/DataProviderTest.java | 20 +-
lib/server-test/pom.xml | 5 +
.../json/ODataJsonSerializerTest.java | 18 +-
.../xml/ODataXmlDeserializerTest.java | 630 ++++++
.../serializer/xml/ODataXmlSerializerTest.java | 1794 ++++++++++++++++++
.../olingo/server/core/uri/UriHelperTest.java | 2 +-
pom.xml | 2 +-
72 files changed, 7093 insertions(+), 551 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5b99eb7b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
index 96413cd..c4efe21 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
@@ -78,6 +78,7 @@ 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.Assert;
import org.junit.Ignore;
import org.junit.Test;
@@ -100,6 +101,15 @@ public class BasicITCase extends AbstractBaseTestITCase {
private static final String ES_TWO_PRIM = "ESTwoPrim";
private static final String ES_KEY_NAV = "ESKeyNav";
+
+ void assertShortOrInt(int value, Object n) {
+ if (n instanceof Number) {
+ assertEquals(value, ((Number)n).intValue());
+ } else {
+ Assert.fail();
+ }
+ }
+
@Test
public void readServiceDocument() {
ODataServiceDocumentRequest request = getClient().getRetrieveRequestFactory()
@@ -111,7 +121,6 @@ public class BasicITCase extends AbstractBaseTestITCase {
ClientServiceDocument serviceDocument = response.getBody();
assertNotNull(serviceDocument);
-
assertThat(serviceDocument.getEntitySetNames(), hasItem("ESAllPrim"));
assertThat(serviceDocument.getFunctionImportNames(), hasItem("FICRTCollCTTwoPrim"));
assertThat(serviceDocument.getSingletonNames(), hasItem("SIMedia"));
@@ -162,7 +171,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
final ODataRetrieveResponse<ClientEntitySet> response = request.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
- assertThat(response.getContentType(), containsString(ContentType.APPLICATION_JSON.toContentTypeString()));
+ assertContentType(response.getContentType());
final ClientEntitySet entitySet = response.getBody();
assertNotNull(entitySet);
@@ -180,9 +189,21 @@ public class BasicITCase extends AbstractBaseTestITCase {
final ClientProperty property = entity.getProperty("PropertyInt16");
assertNotNull(property);
assertNotNull(property.getPrimitiveValue());
- assertEquals(0, property.getPrimitiveValue().toValue());
+ if (isJson()) {
+ assertEquals(0, property.getPrimitiveValue().toValue());
+ } else {
+ assertEquals((short)0, property.getPrimitiveValue().toValue());
+ }
+ }
+
+ protected void assertContentType(String content) {
+ assertThat(content, containsString(ContentType.APPLICATION_JSON.toContentTypeString()));
}
+ private boolean isJson() {
+ return getClient().getConfiguration().getDefaultPubFormat().equals(ContentType.JSON);
+ }
+
@Test
public void readEntityCollectionCount() {
final ODataValueRequest request = getClient().getRetrieveRequestFactory()
@@ -225,7 +246,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
final ODataRetrieveResponse<ClientEntity> response = request.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
- assertThat(response.getContentType(), containsString(ContentType.APPLICATION_JSON.toContentTypeString()));
+ assertContentType(response.getContentType());
final ClientEntity entity = response.getBody();
assertNotNull(entity);
@@ -234,9 +255,15 @@ public class BasicITCase extends AbstractBaseTestITCase {
assertNotNull(property.getCollectionValue());
assertEquals(3, property.getCollectionValue().size());
Iterator<ClientValue> iterator = property.getCollectionValue().iterator();
- assertEquals(1000, iterator.next().asPrimitive().toValue());
- assertEquals(2000, iterator.next().asPrimitive().toValue());
- assertEquals(30112, iterator.next().asPrimitive().toValue());
+ if(isJson()) {
+ assertEquals(1000, iterator.next().asPrimitive().toValue());
+ assertEquals(2000, iterator.next().asPrimitive().toValue());
+ assertEquals(30112, iterator.next().asPrimitive().toValue());
+ } else {
+ assertEquals((short)1000, iterator.next().asPrimitive().toValue());
+ assertEquals((short)2000, iterator.next().asPrimitive().toValue());
+ assertEquals((short)30112, iterator.next().asPrimitive().toValue());
+ }
}
@Test
@@ -268,7 +295,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
patchEntity.getProperties().add(factory.newPrimitiveProperty("PropertyString",
factory.newPrimitiveValueBuilder().buildString("new")));
patchEntity.getProperties().add(factory.newPrimitiveProperty("PropertyDecimal",
- factory.newPrimitiveValueBuilder().buildDouble(42.875)));
+ factory.newPrimitiveValueBuilder().buildDecimal(new BigDecimal(42.875))));
patchEntity.getProperties().add(factory.newPrimitiveProperty("PropertyInt64",
factory.newPrimitiveValueBuilder().buildInt64(null)));
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESAllPrim").appendKeySegment(32767)
@@ -286,13 +313,22 @@ public class BasicITCase extends AbstractBaseTestITCase {
assertEquals("new", property1.getPrimitiveValue().toValue());
final ClientProperty property2 = entity.getProperty("PropertyDecimal");
assertNotNull(property2);
- assertEquals(42.875, property2.getPrimitiveValue().toValue());
+ if (isJson()) {
+ assertEquals(42.875, property2.getPrimitiveValue().toValue());
+ } else {
+ assertEquals(new BigDecimal(42.875), property2.getPrimitiveValue().toValue());
+ }
final ClientProperty property3 = entity.getProperty("PropertyInt64");
assertNotNull(property3);
assertNull(property3.getPrimitiveValue());
final ClientProperty property4 = entity.getProperty("PropertyDuration");
assertNotNull(property4);
- assertEquals("PT6S", property4.getPrimitiveValue().toValue());
+ if (isJson()) {
+ assertEquals("PT6S", property4.getPrimitiveValue().toValue());
+ } else {
+ assertEquals(new BigDecimal(6), property4.getPrimitiveValue().toValue());
+ }
+
}
@Test
@@ -301,7 +337,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
final ClientObjectFactory factory = client.getObjectFactory();
ClientEntity newEntity = factory.newEntity(new FullQualifiedName("olingo.odata.test1", "ETAllPrim"));
newEntity.getProperties().add(factory.newPrimitiveProperty("PropertyInt64",
- factory.newPrimitiveValueBuilder().buildInt32(42)));
+ factory.newPrimitiveValueBuilder().buildInt64((long)42)));
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESAllPrim").appendKeySegment(32767)
.build();
@@ -315,7 +351,11 @@ public class BasicITCase extends AbstractBaseTestITCase {
assertNotNull(entity);
final ClientProperty property1 = entity.getProperty("PropertyInt64");
assertNotNull(property1);
- assertEquals(42, property1.getPrimitiveValue().toValue());
+ if (isJson()) {
+ assertEquals(42, property1.getPrimitiveValue().toValue());
+ } else {
+ assertEquals((long)42, property1.getPrimitiveValue().toValue());
+ }
final ClientProperty property2 = entity.getProperty("PropertyDecimal");
assertNotNull(property2);
assertNull(property2.getPrimitiveValue());
@@ -331,7 +371,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
factory.newComplexProperty("PropertyComp",
factory.newComplexValue("olingo.odata.test1.CTTwoPrim").add(
factory.newPrimitiveProperty("PropertyInt16",
- factory.newPrimitiveValueBuilder().buildInt32(42)))))));
+ factory.newPrimitiveValueBuilder().buildInt16((short)42)))))));
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESCompComp").appendKeySegment(1).build();
final ODataEntityUpdateRequest<ClientEntity> request = client.getCUDRequestFactory().getEntityUpdateRequest(
uri, UpdateType.PATCH, patchEntity);
@@ -346,7 +386,11 @@ public class BasicITCase extends AbstractBaseTestITCase {
assertNotNull(complex);
final ClientProperty property1 = complex.get("PropertyInt16");
assertNotNull(property1);
- assertEquals(42, property1.getPrimitiveValue().toValue());
+ if (isJson()) {
+ assertEquals(42, property1.getPrimitiveValue().toValue());
+ } else {
+ assertEquals((short)42, property1.getPrimitiveValue().toValue());
+ }
final ClientProperty property2 = complex.get("PropertyString");
assertNotNull(property2);
assertEquals("String 1", property2.getPrimitiveValue().toValue());
@@ -394,7 +438,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
final ClientObjectFactory factory = client.getObjectFactory();
ClientEntity newEntity = factory.newEntity(new FullQualifiedName("olingo.odata.test1", "ETAllPrim"));
newEntity.getProperties().add(factory.newPrimitiveProperty("PropertyInt64",
- factory.newPrimitiveValueBuilder().buildInt32(42)));
+ factory.newPrimitiveValueBuilder().buildInt64((long)42)));
newEntity.addLink(factory.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_PRIM_ONE,
client.newURIBuilder(SERVICE_URI)
.appendEntitySetSegment("ESTwoPrim")
@@ -413,7 +457,11 @@ public class BasicITCase extends AbstractBaseTestITCase {
assertNotNull(createdEntity);
final ClientProperty property1 = createdEntity.getProperty("PropertyInt64");
assertNotNull(property1);
- assertEquals(42, property1.getPrimitiveValue().toValue());
+ if(isJson()) {
+ assertEquals(42, property1.getPrimitiveValue().toValue());
+ } else {
+ assertEquals((long)42, property1.getPrimitiveValue().toValue());
+ }
final ClientProperty property2 = createdEntity.getProperty("PropertyDecimal");
assertNotNull(property2);
assertNull(property2.getPrimitiveValue());
@@ -441,7 +489,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
@Test
public void readEntityWithExpandedNavigationProperty() {
- final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final ODataClient client = getClient(SERVICE_URI);
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
final URI uri = client.newURIBuilder(SERVICE_URI)
@@ -532,14 +580,22 @@ public class BasicITCase extends AbstractBaseTestITCase {
.iterator();
ClientComplexValue complexProperty = collectionIterator.next().asComplex();
- assertEquals(42, complexProperty.get("PropertyInt16").getPrimitiveValue().toValue());
+ if (isJson()) {
+ assertEquals(42, complexProperty.get("PropertyInt16").getPrimitiveValue().toValue());
+ } else {
+ assertEquals((short)42, complexProperty.get("PropertyInt16").getPrimitiveValue().toValue());
+ }
assertNotNull(complexProperty.get("PropertyComp"));
ClientComplexValue innerComplexProperty = complexProperty.get("PropertyComp").getComplexValue();
assertEquals("42", innerComplexProperty.get("PropertyString").getPrimitiveValue().toValue());
complexProperty = collectionIterator.next().asComplex();
- assertEquals(43, complexProperty.get("PropertyInt16").getPrimitiveValue().toValue());
+ if (isJson()) {
+ assertEquals(43, complexProperty.get("PropertyInt16").getPrimitiveValue().toValue());
+ } else {
+ assertEquals((short)43, complexProperty.get("PropertyInt16").getPrimitiveValue().toValue());
+ }
assertNotNull(complexProperty.get("PropertyComp"));
innerComplexProperty = complexProperty.get("PropertyComp").getComplexValue();
@@ -601,7 +657,11 @@ public class BasicITCase extends AbstractBaseTestITCase {
assertEquals(2, newEntity.getProperty("CollPropertyComp").getCollectionValue().size());
final Iterator<ClientValue> iter = newEntity.getProperty("CollPropertyComp").getCollectionValue().iterator();
final ClientComplexValue complexProperty1 = iter.next().asComplex();
- assertEquals(1, complexProperty1.get("PropertyInt16").getPrimitiveValue().toValue());
+ if (isJson()) {
+ assertEquals(1, complexProperty1.get("PropertyInt16").getPrimitiveValue().toValue());
+ } else {
+ assertEquals((short)1, complexProperty1.get("PropertyInt16").getPrimitiveValue().toValue());
+ }
assertNotNull(complexProperty1.get("PropertyComp"));
final ClientComplexValue innerComplexProperty1 = complexProperty1.get("PropertyComp").getComplexValue();
assertEquals("1", innerComplexProperty1.get("PropertyString").getPrimitiveValue().toValue());
@@ -627,8 +687,14 @@ public class BasicITCase extends AbstractBaseTestITCase {
assertNotNull(complexProperty2.get("PropertyComp"));
final ClientComplexValue innerComplexProperty2 = complexProperty2.get("PropertyComp").getComplexValue();
assertEquals("2", innerComplexProperty2.get("PropertyString").getPrimitiveValue().toValue());
- assertEquals(2, innerComplexProperty2.get("PropertyInt16").getPrimitiveValue().toValue());
- assertEquals(Double.valueOf(2), innerComplexProperty2.get("PropertySingle").getPrimitiveValue().toValue());
+ if(isJson()) {
+ assertEquals(2, innerComplexProperty2.get("PropertyInt16").getPrimitiveValue().toValue());
+ assertEquals(Double.valueOf(2), innerComplexProperty2.get("PropertySingle").getPrimitiveValue().toValue());
+ } else {
+ assertEquals((short)2, innerComplexProperty2.get("PropertyInt16").getPrimitiveValue().toValue());
+ assertEquals(Float.valueOf(2), innerComplexProperty2.get("PropertySingle").getPrimitiveValue().toValue());
+ }
+
assertTrue(innerComplexProperty2.get("PropertyBinary").hasNullValue());
assertTrue(innerComplexProperty2.get("PropertyBoolean").hasNullValue());
assertTrue(innerComplexProperty2.get("PropertyByte").hasNullValue());
@@ -649,7 +715,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
@Test
public void complexPropertyWithNotNullablePrimitiveValue() {
- final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final ODataClient client = getClient(SERVICE_URI);
final ClientObjectFactory of = client.getObjectFactory();
// PropertyComp is null, but the primitive values in PropertyComp must not be null
@@ -666,7 +732,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
@Test
public void upsert() throws EdmPrimitiveTypeException {
- final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final EdmEnabledODataClient client = getClient(SERVICE_URI);
final ClientObjectFactory of = client.getObjectFactory();
final ClientEntity entity = of.newEntity(new FullQualifiedName("olingo.odata.test1", "ETTwoPrim"));
@@ -698,7 +764,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
@Test
public void updatePropertyWithNull() {
- final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final ODataClient client = getClient(SERVICE_URI);
final ClientObjectFactory of = client.getObjectFactory();
final URI targetURI = client.newURIBuilder(SERVICE_URI)
@@ -718,12 +784,12 @@ public class BasicITCase extends AbstractBaseTestITCase {
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
assertEquals("return=representation", response.getHeader(HttpHeader.PREFERENCE_APPLIED).iterator().next());
assertTrue(response.getBody().getProperty("PropertyString").hasNullValue());
- assertEquals(34, response.getBody().getProperty("PropertyDecimal").getPrimitiveValue().toValue());
+ assertShortOrInt(34, response.getBody().getProperty("PropertyDecimal").getPrimitiveValue().toValue());
}
@Test(expected = ODataClientErrorException.class)
public void updatePropertyWithNullNotAllowed() {
- final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final EdmEnabledODataClient client = getClient(SERVICE_URI);
final ClientObjectFactory of = client.getObjectFactory();
final URI targetURI = client.newURIBuilder(SERVICE_URI)
@@ -740,9 +806,9 @@ public class BasicITCase extends AbstractBaseTestITCase {
@Test
public void updateMerge() {
- final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final EdmEnabledODataClient client = getClient(SERVICE_URI);
final ClientObjectFactory of = client.getObjectFactory();
-
+
final URI targetURI = client.newURIBuilder(SERVICE_URI)
.appendEntitySetSegment("ESKeyNav")
.appendKeySegment(1)
@@ -777,7 +843,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
final ODataRetrieveResponse<ClientEntity> entityResponse = entityRequest.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), entityResponse.getStatusCode());
- assertEquals(1, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavOne")
+ assertShortOrInt(1, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavOne")
.asInlineEntity()
.getEntity()
.getProperty("PropertyInt16")
@@ -790,7 +856,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
.getEntities()
.size());
- assertEquals(1, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
+ assertShortOrInt(1, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
.asInlineEntitySet()
.getEntitySet()
.getEntities()
@@ -799,7 +865,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
.getPrimitiveValue()
.toValue());
- assertEquals(2, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
+ assertShortOrInt(2, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
.asInlineEntitySet()
.getEntitySet()
.getEntities()
@@ -808,7 +874,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
.getPrimitiveValue()
.toValue());
- assertEquals(3, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
+ assertShortOrInt(3, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
.asInlineEntitySet()
.getEntitySet()
.getEntities()
@@ -834,7 +900,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
@Test
public void updateReplace() {
- final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final EdmEnabledODataClient client = getClient(SERVICE_URI);
final ClientObjectFactory of = client.getObjectFactory();
final URI targetURI = client.newURIBuilder(SERVICE_URI)
@@ -877,7 +943,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
final ODataRetrieveResponse<ClientEntity> entityResponse = entityRequest.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), entityResponse.getStatusCode());
- assertEquals(1, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavOne")
+ assertShortOrInt(1, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavOne")
.asInlineEntity()
.getEntity()
.getProperty("PropertyInt16")
@@ -890,7 +956,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
.getEntities()
.size());
- assertEquals(1, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
+ assertShortOrInt(1, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
.asInlineEntitySet()
.getEntitySet()
.getEntities()
@@ -899,7 +965,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
.getPrimitiveValue()
.toValue());
- assertEquals(2, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
+ assertShortOrInt(2, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
.asInlineEntitySet()
.getEntitySet()
.getEntities()
@@ -908,7 +974,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
.getPrimitiveValue()
.toValue());
- assertEquals(3, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
+ assertShortOrInt(3, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
.asInlineEntitySet()
.getEntitySet()
.getEntities()
@@ -938,7 +1004,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
.getComplexValue();
assertEquals("Must not be null", propCompTwoPrim.get("PropertyString").getPrimitiveValue().toValue());
- assertEquals(42, propCompTwoPrim.get("PropertyInt16").getPrimitiveValue().toValue());
+ assertShortOrInt(42, propCompTwoPrim.get("PropertyInt16").getPrimitiveValue().toValue());
assertNotNull(entityResponse.getBody().getProperty("PropertyCompNav").getComplexValue());
assertTrue(entityResponse.getBody()
@@ -950,7 +1016,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
@Test
public void createEntityWithIEEE754CompatibleParameter() {
- final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final ODataClient client = getClient(SERVICE_URI);
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
final ClientObjectFactory of = client.getObjectFactory();
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_ALL_PRIM).build();
@@ -977,7 +1043,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
@Test
public void createEntityWithIEEE754CompatibleParameterNull() {
- final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final ODataClient client = getClient(SERVICE_URI);
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
final ClientObjectFactory of = client.getObjectFactory();
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_ALL_PRIM).build();
@@ -1003,7 +1069,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
@Test
public void updateEntityWithIEEE754CompatibleParameter() {
- final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final ODataClient client = getClient(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();
@@ -1035,7 +1101,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
@Test
public void updateEntityWithIEEE754CompatibleParameterNull() {
- final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final ODataClient client = getClient(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();
@@ -1065,7 +1131,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
@Test
public void updateEntityWithIEEE754CompatibleParameterWithNullString() {
- final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final ODataClient client = getClient(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();
@@ -1091,7 +1157,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
@Test
public void updateEdmInt64PropertyWithIEE754CompatibleParameter() {
- final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final ODataClient client = getClient(SERVICE_URI);
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
final ClientObjectFactory of = client.getObjectFactory();
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_ALL_PRIM)
@@ -1118,7 +1184,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
@Test
public void updateComplexPropertyWithIEEE754CompatibleParamter() {
- final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final ODataClient client = getClient(SERVICE_URI);
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
final ClientObjectFactory of = client.getObjectFactory();
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
@@ -1155,7 +1221,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
@Test
public void updateProperyEdmDecimaltWithIEE754CompatibleParameter() {
- final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final ODataClient client = getClient(SERVICE_URI);
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
final ClientObjectFactory of = client.getObjectFactory();
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_ALL_PRIM)
@@ -1182,7 +1248,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
@Test
public void readESAllPrimCollectionWithIEEE754CompatibleParameter() {
- final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final ODataClient client = getClient(SERVICE_URI);
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_ALL_PRIM)
.orderBy(PROPERTY_INT16)
.build();
@@ -1213,7 +1279,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
@Test
public void readESKeyNavCheckComplexPropertyWithIEEE754CompatibleParameter() {
- final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final ODataClient client = getClient(SERVICE_URI);
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(1).build();
final ODataEntityRequest<ClientEntity> request = client.getRetrieveRequestFactory().getEntityRequest(uri);
@@ -1238,7 +1304,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
@Test
public void readESKEyNavComplexPropertyWithIEEE754CompatibleParameter() {
- final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final ODataClient client = getClient(SERVICE_URI);
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
.appendKeySegment(1)
.appendNavigationSegment(PROPERTY_COMP_ALL_PRIM)
@@ -1262,7 +1328,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
@Test
@Ignore
public void readEdmInt64PropertyWithIEEE754ComaptibleParameter() {
- final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final ODataClient client = getClient(SERVICE_URI);
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
.appendKeySegment(1)
.appendPropertySegment(PROPERTY_COMP_ALL_PRIM)
@@ -1279,7 +1345,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
@Test
@Ignore
public void readEdmDecimalPropertyWithIEEE754ComaptibleParameter() {
- final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final ODataClient client = getClient(SERVICE_URI);
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
.appendKeySegment(1)
.appendPropertySegment(PROPERTY_COMP_ALL_PRIM)
@@ -1299,4 +1365,8 @@ public class BasicITCase extends AbstractBaseTestITCase {
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
return odata;
}
+
+ protected EdmEnabledODataClient getClient(String serviceURI) {
+ return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.JSON);
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5b99eb7b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicXmlITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicXmlITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicXmlITCase.java
new file mode 100644
index 0000000..4398c60
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicXmlITCase.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * 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
+ *
+ * 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
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.fit.tecsvc.client;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertThat;
+
+import org.apache.olingo.client.api.EdmEnabledODataClient;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.core.ODataClientFactory;
+import org.apache.olingo.commons.api.format.ContentType;
+
+public class BasicXmlITCase extends BasicITCase {
+
+ @Override
+ protected ODataClient getClient() {
+ ODataClient odata = ODataClientFactory.getClient();
+ odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_ATOM_XML);
+ return odata;
+ }
+
+ protected void assertContentType(String content) {
+ assertThat(content, containsString(ContentType.APPLICATION_ATOM_XML.toContentTypeString()));
+ }
+
+ protected EdmEnabledODataClient getClient(String serviceURI) {
+ return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.APPLICATION_ATOM_XML);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5b99eb7b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
index c108d7b..f3c7e7e 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientITCase.java
@@ -18,9 +18,11 @@
*/
package org.apache.olingo.fit.tecsvc.client;
+import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.net.URI;
@@ -122,9 +124,13 @@ public class BatchClientITCase extends AbstractTestITCase {
assertTrue(changeSetResponse.isBreaking());
assertEquals(HttpStatusCode.NOT_FOUND.getStatusCode(), updateResponse.getStatusCode());
- assertEquals(ContentType.JSON.toContentTypeString(), updateResponse.getContentType());
+ assertContentType(updateResponse.getContentType());
}
+ protected void assertContentType(String content) {
+ assertThat(content, containsString(ContentType.APPLICATION_JSON.toContentTypeString()));
+ }
+
@Test
public void emptyBatchRequest() {
// create your request
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5b99eb7b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientXmlITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientXmlITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientXmlITCase.java
new file mode 100644
index 0000000..70ab164
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BatchClientXmlITCase.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * 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
+ *
+ * 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
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.fit.tecsvc.client;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertThat;
+
+import org.apache.olingo.client.api.EdmEnabledODataClient;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.core.ODataClientFactory;
+import org.apache.olingo.commons.api.format.ContentType;
+
+public class BatchClientXmlITCase extends BatchClientITCase {
+ @Override
+ protected ODataClient getClient() {
+ ODataClient odata = ODataClientFactory.getClient();
+ odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_ATOM_XML);
+ return odata;
+ }
+
+ protected void assertContentType(String content) {
+ assertThat(content, containsString(ContentType.APPLICATION_ATOM_XML.toContentTypeString()));
+ }
+
+ protected EdmEnabledODataClient getClient(String serviceURI) {
+ return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.APPLICATION_ATOM_XML);
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5b99eb7b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BindingITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BindingITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BindingITCase.java
index 9be4cc8..ca95ed6 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BindingITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BindingITCase.java
@@ -323,7 +323,7 @@ public class BindingITCase extends AbstractBaseTestITCase {
@Test
public void testDeepInsertWithBindingSameNavigationProperty() {
- final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final EdmEnabledODataClient client = getClient(SERVICE_URI);
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
final ClientObjectFactory of = client.getObjectFactory();
@@ -395,4 +395,8 @@ public class BindingITCase extends AbstractBaseTestITCase {
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
return odata;
}
+
+ protected EdmEnabledODataClient getClient(String serviceURI) {
+ return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.JSON);
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5b99eb7b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BindingXmlITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BindingXmlITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BindingXmlITCase.java
new file mode 100644
index 0000000..9e9079e
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BindingXmlITCase.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * 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
+ *
+ * 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
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.fit.tecsvc.client;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertThat;
+
+import org.apache.olingo.client.api.EdmEnabledODataClient;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.core.ODataClientFactory;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.junit.Ignore;
+
+@Ignore
+/**
+ * I believe BindingITCase was not written correctly, as they seem to use navigation property and
+ * any other property interchangeably. Once we fix that then we can remove the ignore
+ */
+public class BindingXmlITCase extends BindingITCase {
+
+ @Override
+ protected ODataClient getClient() {
+ ODataClient odata = ODataClientFactory.getClient();
+ odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_ATOM_XML);
+ return odata;
+ }
+
+ protected void assertContentType(String content) {
+ assertThat(content, containsString(ContentType.APPLICATION_ATOM_XML.toContentTypeString()));
+ }
+
+ protected EdmEnabledODataClient getClient(String serviceURI) {
+ return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.APPLICATION_ATOM_XML);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5b99eb7b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ConditionalITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ConditionalITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ConditionalITCase.java
index 1a024da..e4443fa 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ConditionalITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ConditionalITCase.java
@@ -51,6 +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.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.commons.api.http.HttpHeader;
import org.apache.olingo.commons.api.http.HttpStatusCode;
@@ -58,7 +59,7 @@ import org.apache.olingo.fit.AbstractBaseTestITCase;
import org.apache.olingo.fit.tecsvc.TecSvcConst;
import org.junit.Test;
-public final class ConditionalITCase extends AbstractBaseTestITCase {
+public class ConditionalITCase extends AbstractBaseTestITCase {
private final ODataClient client = getClient();
@@ -123,14 +124,14 @@ public final class ConditionalITCase extends AbstractBaseTestITCase {
public void updateWithoutIfMatch() throws Exception {
executeAndExpectError(
client.getCUDRequestFactory().getEntityUpdateRequest(
- uriEntity, UpdateType.PATCH, client.getObjectFactory().newEntity(null)),
+ uriEntity, UpdateType.PATCH, client.getObjectFactory().newEntity(new FullQualifiedName("olingo.Order"))),
HttpStatusCode.PRECONDITION_REQUIRED);
}
@Test
public void updateWithWrongIfMatch() throws Exception {
ODataEntityUpdateRequest<ClientEntity> request = client.getCUDRequestFactory().getEntityUpdateRequest(
- uriEntity, UpdateType.PATCH, client.getObjectFactory().newEntity(null));
+ uriEntity, UpdateType.PATCH, client.getObjectFactory().newEntity(new FullQualifiedName("olingo.Order")));
request.setIfMatch("W/\"1\"");
executeAndExpectError(request, HttpStatusCode.PRECONDITION_FAILED);
}
@@ -173,7 +174,7 @@ public final class ConditionalITCase extends AbstractBaseTestITCase {
final ODataDeleteResponse response = deleteRequest.execute();
ODataEntityUpdateRequest<ClientEntity> request = client.getCUDRequestFactory().getEntityUpdateRequest(
- uriEntity, UpdateType.PATCH, client.getObjectFactory().newEntity(null));
+ uriEntity, UpdateType.PATCH, client.getObjectFactory().newEntity(new FullQualifiedName("olingo.Order")));
request.setIfMatch(eTag);
// This request has to be in the same session as the first in order to access the same data provider.
request.addCustomHeader(HttpHeader.COOKIE, response.getHeader(HttpHeader.SET_COOKIE).iterator().next());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5b99eb7b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ConditionalXmlITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ConditionalXmlITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ConditionalXmlITCase.java
new file mode 100644
index 0000000..3afa8c9
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ConditionalXmlITCase.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * 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
+ *
+ * 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
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.fit.tecsvc.client;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertThat;
+
+import org.apache.olingo.client.api.EdmEnabledODataClient;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.core.ODataClientFactory;
+import org.apache.olingo.commons.api.format.ContentType;
+
+public class ConditionalXmlITCase extends ConditionalITCase {
+
+ @Override
+ protected ODataClient getClient() {
+ ODataClient odata = ODataClientFactory.getClient();
+ odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_ATOM_XML);
+ return odata;
+ }
+
+ protected void assertContentType(String content) {
+ assertThat(content, containsString(ContentType.APPLICATION_ATOM_XML.toContentTypeString()));
+ }
+
+ protected EdmEnabledODataClient getClient(String serviceURI) {
+ return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.APPLICATION_ATOM_XML);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5b99eb7b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
index d1b4a8d..56cd373 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/DeepInsertITCase.java
@@ -59,6 +59,19 @@ import org.apache.olingo.fit.tecsvc.TecSvcConst;
import org.junit.Ignore;
import org.junit.Test;
+/**
+ * The issue I see with this unit test, or in general with JSON metadata=minimal case is
+ * none of the navigation properties will be represented as such in deserialized form, because
+ * no navigation link information will be written when metadata=minimal. The client will
+ * interpret those results as complex properties (which I do not think is right).
+ *
+ * Where as in the atom+xml case, there is no intermediate results, it is equivalent to
+ * metadata=full, thus the navigation links and inline content is correctly represented through
+ * deserialization.
+ *
+ * For above reason, the DeepInsertXMLITCase case re-written slightly differently.
+ *
+ */
public class DeepInsertITCase extends AbstractBaseTestITCase {
private static final String SERVICE_URI = TecSvcConst.BASE_URI;
@@ -90,7 +103,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
@Test
public void testDeepInsertExpandedResponse() {
- final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final ODataClient client = getClient(SERVICE_URI);
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
final URI createURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
final ClientObjectFactory of = client.getObjectFactory();
@@ -272,7 +285,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
inlineEntitySingle.getProperties()
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("43")));
inlineEntitySingle.getProperties().add(
- of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
+ of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
+ .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 430)))));
inlineEntitySingle.getProperties()
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 431)))));
@@ -293,7 +307,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 441)))));
inlineEntityCol1.getProperties().add(
- of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
+ of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
+ .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 440)))));
inlineEntityCol1.getProperties()
.add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 442)))
@@ -308,7 +323,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 451)))));
inlineEntityCol2.getProperties().add(
- of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
+ of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
+ .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 450)))));
inlineEntityCol2.getProperties()
.add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 452)))
@@ -545,7 +561,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
@Test
public void testConsistency() throws EdmPrimitiveTypeException {
- final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final EdmEnabledODataClient client = getClient(SERVICE_URI);
final ClientObjectFactory of = client.getObjectFactory();
final String cookie = getCookie();
@@ -574,7 +590,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
@Test
public void testInvalidType() throws EdmPrimitiveTypeException {
- final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final EdmEnabledODataClient client = getClient(SERVICE_URI);
final ClientObjectFactory of = client.getObjectFactory();
final String cookie = getCookie();
@@ -613,7 +629,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
@Test
@Ignore
public void testDeepInsertOnNavigationPropertyInComplexProperty() {
- final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
+ final EdmEnabledODataClient client = getClient(SERVICE_URI);
final ClientObjectFactory of = client.getObjectFactory();
final ClientEntity inlineEntity = of.newEntity(ET_TWO_KEY_NAV);
@@ -704,8 +720,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 43)));
inlineEntitySingle.getProperties()
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("43")));
- inlineEntitySingle.getProperties().add(
- of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
+ inlineEntitySingle.getProperties().add(of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
+ .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 43)))));
inlineEntitySingle.getProperties()
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 431)))));
@@ -726,7 +742,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 441)))));
inlineEntityCol1.getProperties().add(
- of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
+ of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
+ .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 441)))));
inlineEntityCol1.getProperties()
.add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 442)))
@@ -741,7 +758,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 451)))));
inlineEntityCol2.getProperties().add(
- of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
+ of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
+ .add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 451)))));
inlineEntityCol2.getProperties()
.add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 452)))
@@ -903,4 +921,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
return odata;
}
+
+ protected EdmEnabledODataClient getClient(String serviceURI) {
+ return ODataClientFactory.getEdmEnabledClient(serviceURI,ContentType.JSON);
+ }
}