You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by il...@apache.org on 2014/05/22 13:43:38 UTC
[30/51] [abbrv] [partial] Removing /ODataJClient: merge complete
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/19f3792f/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/EntitySetTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/EntitySetTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/EntitySetTestITCase.java
deleted file mode 100644
index 07adf34..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/EntitySetTestITCase.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/**
- * 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 com.msopentech.odatajclient.engine.it;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import com.msopentech.odatajclient.engine.communication.request.retrieve.ODataEntitySetIteratorRequest;
-import com.msopentech.odatajclient.engine.communication.request.retrieve.ODataEntitySetRequest;
-import com.msopentech.odatajclient.engine.communication.request.retrieve.ODataGenericRetrieveRequest;
-import com.msopentech.odatajclient.engine.communication.response.ODataRetrieveResponse;
-import com.msopentech.odatajclient.engine.data.ODataEntitySet;
-import com.msopentech.odatajclient.engine.data.ODataEntitySetIterator;
-import com.msopentech.odatajclient.engine.data.ODataObjectWrapper;
-import com.msopentech.odatajclient.engine.uri.URIBuilder;
-import com.msopentech.odatajclient.engine.data.ResourceFactory;
-import com.msopentech.odatajclient.engine.format.ODataPubFormat;
-import com.msopentech.odatajclient.engine.utils.URIUtils;
-import java.io.IOException;
-import java.net.URI;
-import org.junit.Test;
-
-/**
- * This is the unit test class to check basic feed operations.
- */
-public class EntitySetTestITCase extends AbstractTestITCase {
-
- protected String getServiceRoot() {
- return testStaticServiceRootURL;
- }
-
- @Test
- public void genericRequestAsAtom() throws IOException {
- genericRequest(ODataPubFormat.ATOM);
- }
-
- @Test
- public void genericRequestAsJSON() throws IOException {
- genericRequest(ODataPubFormat.JSON);
- }
-
- @Test
- public void readODataEntitySetIteratorFromAtom() {
- readODataEntitySetIterator(ODataPubFormat.ATOM);
- }
-
- @Test
- public void readODataEntitySetIteratorFromJSON() {
- readODataEntitySetIterator(ODataPubFormat.JSON);
- }
-
- @Test
- public void readODataEntitySetIteratorFromJSONFullMeta() {
- readODataEntitySetIterator(ODataPubFormat.JSON_FULL_METADATA);
- }
-
- @Test
- public void readODataEntitySetIteratorFromJSONNoMeta() {
- readODataEntitySetIterator(ODataPubFormat.JSON_NO_METADATA);
- }
-
- @Test
- public void readODataEntitySetWithNextFromAtom() {
- readEntitySetWithNextLink(ODataPubFormat.ATOM);
- }
-
- @Test
- public void readODataEntitySetWithNextFromJSON() {
- readEntitySetWithNextLink(ODataPubFormat.JSON_FULL_METADATA);
- }
-
- private void readEntitySetWithNextLink(final ODataPubFormat format) {
- final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot());
- uriBuilder.appendEntitySetSegment("Customer");
-
- final ODataEntitySetRequest req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
- req.setFormat(format);
-
- final ODataRetrieveResponse<ODataEntitySet> res = req.execute();
- final ODataEntitySet feed = res.getBody();
-
- assertNotNull(feed);
-
- debugFeed(client.getBinder().getFeed(feed, ResourceFactory.feedClassForFormat(format)), "Just retrieved feed");
-
- assertEquals(2, feed.getEntities().size());
- assertNotNull(feed.getNext());
-
- final URI expected = URI.create(getServiceRoot() + "/Customer?$skiptoken=-9");
- final URI found = URIUtils.getURI(getServiceRoot(), feed.getNext().toASCIIString());
-
- assertEquals(expected, found);
- }
-
- private void readODataEntitySetIterator(final ODataPubFormat format) {
- final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot());
- uriBuilder.appendEntitySetSegment("Customer");
-
- final ODataEntitySetIteratorRequest req =
- client.getRetrieveRequestFactory().getEntitySetIteratorRequest(uriBuilder.build());
- req.setFormat(format);
-
- final ODataRetrieveResponse<ODataEntitySetIterator> res = req.execute();
- final ODataEntitySetIterator feedIterator = res.getBody();
-
- assertNotNull(feedIterator);
-
- int count = 0;
-
- while (feedIterator.hasNext()) {
- assertNotNull(feedIterator.next());
- count++;
- }
- assertEquals(2, count);
- assertTrue(feedIterator.getNext().toASCIIString().endsWith("Customer?$skiptoken=-9"));
- }
-
- private void genericRequest(final ODataPubFormat format) {
- final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot());
- uriBuilder.appendEntitySetSegment("Car");
-
- final ODataGenericRetrieveRequest req =
- client.getRetrieveRequestFactory().getGenericRetrieveRequest(uriBuilder.build());
- req.setFormat(format.toString());
-
- final ODataRetrieveResponse<ODataObjectWrapper> res = req.execute();
-
- ODataObjectWrapper wrapper = res.getBody();
-
- final ODataEntitySet entitySet = wrapper.getODataEntitySet();
- assertNotNull(entitySet);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/19f3792f/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/EntityTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/EntityTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/EntityTestITCase.java
deleted file mode 100644
index 6875bf3..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/EntityTestITCase.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/**
- * 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 com.msopentech.odatajclient.engine.it;
-
-import static org.junit.Assert.*;
-
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import org.junit.Test;
-
-import com.msopentech.odatajclient.engine.communication.ODataClientErrorException;
-import com.msopentech.odatajclient.engine.communication.request.retrieve.ODataEntityRequest;
-import com.msopentech.odatajclient.engine.communication.request.retrieve.ODataEntitySetRequest;
-import com.msopentech.odatajclient.engine.communication.request.retrieve.ODataLinkCollectionRequest;
-import com.msopentech.odatajclient.engine.communication.response.ODataRetrieveResponse;
-import com.msopentech.odatajclient.engine.data.ODataEntity;
-import com.msopentech.odatajclient.engine.data.ODataEntitySet;
-import com.msopentech.odatajclient.engine.data.ODataLinkCollection;
-import com.msopentech.odatajclient.engine.data.ODataProperty;
-import com.msopentech.odatajclient.engine.format.ODataFormat;
-import com.msopentech.odatajclient.engine.uri.URIBuilder;
-import com.msopentech.odatajclient.engine.format.ODataPubFormat;
-import java.net.URI;
-
-public class EntityTestITCase extends AbstractTestITCase {
-
- private void retreiveEntityTest(final ODataPubFormat reqFormat, final String acceptFormat) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntityTypeSegment("Product").appendKeySegment(-9);
- final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(reqFormat);
- req.setAccept(acceptFormat);
- try {
- final ODataRetrieveResponse<ODataEntity> res = req.execute();
- assertEquals(200, res.getStatusCode());
- assertNotNull(res.getEtag());
- final ODataEntity entity = res.getBody();
- assertEquals("Microsoft.Test.OData.Services.AstoriaDefaultService.DiscontinuedProduct", entity.getName());
- final List<ODataProperty> properties = entity.getProperties();
- assertEquals(10, properties.size());
- } catch (ODataClientErrorException e) {
- assertEquals(415, e.getStatusLine().getStatusCode());
- }
- }
-
- private void retreiveFullMetadataEntityTest(final ODataPubFormat reqFormat, final String acceptFormat) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntityTypeSegment("Product").appendKeySegment(-9);
- final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(reqFormat);
- req.setAccept(acceptFormat);
- try {
- final ODataRetrieveResponse<ODataEntity> res = req.execute();
- assertEquals(200, res.getStatusCode());
- assertNotNull(res.getEtag());
- final ODataEntity entity = res.getBody();
- assertEquals("Microsoft.Test.OData.Services.AstoriaDefaultService.DiscontinuedProduct", entity.getName());
- assertNotNull(entity.getEditLink().toASCIIString());
- assertTrue(entity.getAssociationLinks().isEmpty());
- final List<ODataProperty> properties = entity.getProperties();
- assertEquals(10, properties.size());
- } catch (ODataClientErrorException e) {
- assertEquals(415, e.getStatusLine().getStatusCode());
- }
- }
-
- private void retreiveNoMetadataEntityTest(final ODataPubFormat reqFormat, final String acceptFormat) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntityTypeSegment("Product").appendKeySegment(-9);
- final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(reqFormat);
- req.setAccept(acceptFormat);
- try {
- final ODataRetrieveResponse<ODataEntity> res = req.execute();
- assertEquals(200, res.getStatusCode());
- final ODataEntity entity = res.getBody();
- assertNull(entity.getName());
- final List<ODataProperty> properties = entity.getProperties();
- assertEquals(10, properties.size());
- } catch (ODataClientErrorException e) {
- assertEquals(415, e.getStatusLine().getStatusCode());
- }
- }
-
- private void retreiveMinimalMetadataEntityTest(final ODataPubFormat reqFormat, final String acceptFormat) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntityTypeSegment("Product").appendKeySegment(-9);
- final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(reqFormat);
- req.setAccept(acceptFormat);
- try {
- final ODataRetrieveResponse<ODataEntity> res = req.execute();
- assertEquals(200, res.getStatusCode());
- final ODataEntity entity = res.getBody();
- assertNull(entity.getName());
- final List<ODataProperty> properties = entity.getProperties();
- } catch (ODataClientErrorException e) {
- assertEquals(415, e.getStatusLine().getStatusCode());
- }
- }
-
- private void retreiveEntityTestWithExpand(final ODataPubFormat reqFormat, final String acceptFormat) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntityTypeSegment("Customer").appendKeySegment(-10).expand("Orders");
- final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(reqFormat);
- req.setAccept(acceptFormat);
- try {
- final ODataRetrieveResponse<ODataEntity> res = req.execute();
- assertEquals(200, res.getStatusCode());
- final ODataEntity entity = res.getBody();
- assertNotNull(entity);
- assertFalse(entity.getProperties().isEmpty());
- } catch (ODataClientErrorException e) {
- assertEquals(415, e.getStatusLine().getStatusCode());
- }
- }
-
- private void retreiveEntityTestWithSelect(
- final ODataPubFormat reqFormat, final String acceptFormat, final String selectFormat) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntityTypeSegment("Customer").appendKeySegment(-10).select(selectFormat);
- final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(reqFormat);
- req.setAccept(acceptFormat);
- try {
- final ODataRetrieveResponse<ODataEntity> res = req.execute();
- assertEquals(200, res.getStatusCode());
- final ODataEntity entity = res.getBody();
- assertNotNull(entity);
- } catch (ODataClientErrorException e) {
- assertEquals(415, e.getStatusLine().getStatusCode());
- }
- }
-
- private void retreiveEntityTestWithSelectAndExpand(final ODataPubFormat reqFormat, final String acceptFormat,
- final String selectFormat, String expandFormat) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntityTypeSegment("Customer").appendKeySegment(-10).select(selectFormat).expand(expandFormat);
- final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(reqFormat);
- req.setAccept(acceptFormat);
- try {
- final ODataRetrieveResponse<ODataEntity> res = req.execute();
- assertEquals(200, res.getStatusCode());
- final ODataEntity entity = res.getBody();
- assertNotNull(entity);
- final List<ODataProperty> properties = entity.getProperties();
- } catch (ODataClientErrorException e) {
- assertEquals(415, e.getStatusLine().getStatusCode());
- }
- }
-
- private void multiKeyTest(final ODataPubFormat format, final String acceptFormat) {
- final Map<String, Object> multiKey = new LinkedHashMap<String, Object>();
- multiKey.put("FromUsername", "1");
- multiKey.put("MessageId", -10);
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntityTypeSegment("Message").appendKeySegment(multiKey);
- final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(format);
- req.setAccept(acceptFormat);
- try {
- final ODataRetrieveResponse<ODataEntity> res = req.execute();
- final ODataEntity entity = res.getBody();
- assertNotNull(entity);
- } catch (ODataClientErrorException e) {
- assertEquals(415, e.getStatusLine().getStatusCode());
- }
- }
-
- private void navigationLinks(final ODataFormat format, final String acceptFormat) {
- URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendNavigationLinkSegment("Customer").appendKeySegment(-10);
- ODataLinkCollectionRequest req =
- client.getRetrieveRequestFactory().getLinkCollectionRequest(uriBuilder.build(), "Orders");
- req.setFormat(format);
- req.setAccept(acceptFormat);
- try {
- final ODataRetrieveResponse<ODataLinkCollection> res = req.execute();
- assertEquals(200, res.getStatusCode());
- final ODataLinkCollection linkCollection = res.getBody();
- assertNotNull(linkCollection);
- final List<URI> links = linkCollection.getLinks();
- assertFalse(links.isEmpty());
- for (URI link : links) {
- assertNotNull(link);
- }
- } catch (ODataClientErrorException e) {
- assertEquals(415, e.getStatusLine().getStatusCode());
- }
- }
-
- private void generalQuery(
- final ODataPubFormat format, String acceptFormat, final String navigationQuery, final String links) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendNavigationLinkSegment(navigationQuery).appendKeySegment(-10).appendLinksSegment(links);
- final ODataEntitySetRequest req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
- req.setFormat(format);
- req.setAccept(acceptFormat);
- try {
- final ODataRetrieveResponse<ODataEntitySet> res = req.execute();
- assertEquals(200, res.getStatusCode());
- final ODataEntitySet entitySet = res.getBody();
- assertNotNull(entitySet);
- final List<ODataEntity> entity = entitySet.getEntities();
- assertNotNull(entity);
- for (int i = 0; i < entity.size(); i++) {
- assertNotNull(entity.get(0).getProperties().get(0).getValue());
- }
- } catch (ODataClientErrorException e) {
- assertEquals(415, e.getStatusLine().getStatusCode());
- }
- }
-
- @Test
- public void jsonHeader() {
- retreiveEntityTest(ODataPubFormat.JSON, "application/json;odata=fullmetadata");
- retreiveEntityTestWithExpand(ODataPubFormat.JSON, "application/json;odata=fullmetadata");
- retreiveEntityTestWithSelect(ODataPubFormat.JSON, "application/json", "CustomerId");
- retreiveEntityTestWithSelect(ODataPubFormat.JSON, "application/json", "Name");
- retreiveEntityTestWithSelect(ODataPubFormat.JSON, "application/json", "CustomerId,Name");
- retreiveEntityTestWithSelectAndExpand(
- ODataPubFormat.JSON, "application/json", "CustomerId,Name,Orders", "Orders");
- multiKeyTest(ODataPubFormat.JSON, "application/json");
- navigationLinks(ODataFormat.JSON, "application/json");
- generalQuery(ODataPubFormat.JSON, "application/json", "Customer", "Orders");
-
- multiKeyTest(ODataPubFormat.JSON, "application/json");
- navigationLinks(ODataFormat.JSON, "application/json");
- }
-
- @Test
- public void jsonFullMetaDataHeader() {
- retreiveFullMetadataEntityTest(ODataPubFormat.JSON, "application/json;odata=fullmetadata");
- }
-
- @Test
- public void jsonNoMetaDataHeader() {
- retreiveNoMetadataEntityTest(ODataPubFormat.JSON_NO_METADATA, "application/json;odata=nometadata");
- }
-
- @Test
- public void jsonMinimalMetadataDataHeader() {
- retreiveMinimalMetadataEntityTest(ODataPubFormat.JSON, "application/json;odata=minimal");
- }
-
- @Test
- public void atomHeader() {
- retreiveEntityTest(ODataPubFormat.ATOM, "application/atom+xml");
- generalQuery(ODataPubFormat.ATOM, "application/atom+xml", "Customer", "Orders");
- retreiveEntityTestWithExpand(ODataPubFormat.ATOM, "application/atom+xml");
- retreiveEntityTestWithSelect(ODataPubFormat.ATOM, "application/atom+xml", "CustomerId");
- retreiveEntityTestWithSelect(ODataPubFormat.ATOM, "application/atom+xml", "Name");
- retreiveEntityTestWithSelect(ODataPubFormat.ATOM, "application/atom+xml", "CustomerId,Name");
- retreiveEntityTestWithSelectAndExpand(
- ODataPubFormat.ATOM, "application/atom+xml", "CustomerId,Name,Orders", "Orders");
- multiKeyTest(ODataPubFormat.ATOM, "application/atom+xml");
- }
-
- @Test
- public void xmlHeader() {
- retreiveEntityTest(ODataPubFormat.ATOM, "applicationxml");
- retreiveEntityTestWithExpand(ODataPubFormat.ATOM, "application/xml");
- retreiveEntityTestWithSelect(ODataPubFormat.ATOM, "application/xml", "CustomerId");
- retreiveEntityTestWithSelect(ODataPubFormat.ATOM, "application/xml", "Name");
- retreiveEntityTestWithSelect(ODataPubFormat.ATOM, "application/xml", "CustomerId,Name");
- retreiveEntityTestWithSelectAndExpand(
- ODataPubFormat.ATOM, "application/xml", "CustomerId,Name,Orders", "Orders");
- multiKeyTest(ODataPubFormat.ATOM, "application/atom+xml");
- navigationLinks(ODataFormat.XML, "application/xml");
- }
-
- @Test
- public void nullFormat() {
- retreiveEntityTest(null, "application/xml");
- retreiveEntityTestWithExpand(null, "application/xml");
- retreiveEntityTestWithSelect(null, "application/xml", "CustomerId");
- retreiveEntityTestWithSelect(null, "application/xml", "Name");
- retreiveEntityTestWithSelect(null, "application/xml", "CustomerId,Name");
- retreiveEntityTestWithSelectAndExpand(null, "application/xml", "CustomerId,Name,Orders", "Orders");
- multiKeyTest(null, "application/xml");
- navigationLinks(null, "application/atom+xml");
- }
-
- @Test
- public void nullHeaderWithJSONFormat() {
- retreiveEntityTest(ODataPubFormat.JSON, null);
- retreiveEntityTestWithExpand(ODataPubFormat.JSON, null);
- retreiveEntityTestWithSelect(ODataPubFormat.JSON, null, "CustomerId");
- retreiveEntityTestWithSelect(ODataPubFormat.JSON, null, "Name");
- retreiveEntityTestWithSelect(ODataPubFormat.JSON, null, "CustomerId,Name");
- retreiveEntityTestWithSelectAndExpand(ODataPubFormat.JSON, null, "CustomerId,Name,Orders", "Orders");
- multiKeyTest(ODataPubFormat.JSON, null);
- navigationLinks(ODataFormat.JSON, null);
- }
-
- @Test
- public void nullHeaderWithAtomFormat() {
- retreiveEntityTest(ODataPubFormat.ATOM, null);
- retreiveEntityTestWithExpand(ODataPubFormat.ATOM, null);
- retreiveEntityTestWithExpand(ODataPubFormat.ATOM, null);
- retreiveEntityTestWithSelect(ODataPubFormat.ATOM, null, "CustomerId");
- retreiveEntityTestWithSelect(ODataPubFormat.ATOM, null, "Name");
- retreiveEntityTestWithSelect(ODataPubFormat.ATOM, null, "CustomerId,Name");
- retreiveEntityTestWithSelectAndExpand(ODataPubFormat.ATOM, null, "CustomerId,Name,Orders", "Orders");
- multiKeyTest(ODataPubFormat.ATOM, null);
- navigationLinks(ODataFormat.XML, null);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/19f3792f/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/EntityUpdateMoreTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/EntityUpdateMoreTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/EntityUpdateMoreTestITCase.java
deleted file mode 100644
index 6917212..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/EntityUpdateMoreTestITCase.java
+++ /dev/null
@@ -1,562 +0,0 @@
-/**
- * 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 com.msopentech.odatajclient.engine.it;
-
-import static org.junit.Assert.*;
-
-import java.net.URI;
-import java.util.Collections;
-import java.util.HashMap;
-
-import org.apache.commons.lang3.StringUtils;
-import org.junit.Test;
-
-import com.msopentech.odatajclient.engine.client.http.HttpMethod;
-import com.msopentech.odatajclient.engine.communication.ODataClientErrorException;
-import com.msopentech.odatajclient.engine.communication.request.UpdateType;
-import com.msopentech.odatajclient.engine.communication.request.cud.ODataEntityUpdateRequest;
-import com.msopentech.odatajclient.engine.communication.request.retrieve.ODataEntityRequest;
-import com.msopentech.odatajclient.engine.communication.response.ODataEntityUpdateResponse;
-import com.msopentech.odatajclient.engine.communication.response.ODataRetrieveResponse;
-import com.msopentech.odatajclient.engine.data.ODataCollectionValue;
-import com.msopentech.odatajclient.engine.data.ODataComplexValue;
-import com.msopentech.odatajclient.engine.data.ODataEntity;
-import com.msopentech.odatajclient.engine.data.ODataInlineEntity;
-import com.msopentech.odatajclient.engine.data.ODataProperty;
-import com.msopentech.odatajclient.engine.metadata.edm.EdmSimpleType;
-import com.msopentech.odatajclient.engine.format.ODataPubFormat;
-import com.msopentech.odatajclient.engine.uri.URIBuilder;
-
-public class EntityUpdateMoreTestITCase extends AbstractTestITCase {
- // update an entity
-
- private void updateEntity(
- final ODataPubFormat format,
- final String contentType,
- final String prefer,
- final UpdateType type,
- final boolean inlineInfo) {
- // create an entity to be updated
- final ODataEntity entity =
- client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Customer");
- // add name attribute
- entity.addProperty(client.getObjectFactory().newPrimitiveProperty("Name",
- client.getPrimitiveValueBuilder().setText("Updated Customer name").setType(EdmSimpleType.String).build()));
- // add key attribute
- entity.addProperty(client.getObjectFactory().newPrimitiveProperty("CustomerId",
- client.getPrimitiveValueBuilder().setText(String.valueOf(-10)).setType(EdmSimpleType.Int32).build()));
-
- final ODataCollectionValue backupContactInfoValue = new ODataCollectionValue(
- "Collection(Microsoft.Test.OData.Services.AstoriaDefaultService.ContactDetails)");
- final ODataComplexValue contactDetails = new ODataComplexValue(
- "Microsoft.Test.OData.Services.AstoriaDefaultService.ContactDetails");
- final ODataCollectionValue altNamesValue = new ODataCollectionValue("Collection(Edm.String)");
- altNamesValue.add(client.getPrimitiveValueBuilder().
- setText("My Alternative name").setType(EdmSimpleType.String).build());
- contactDetails.add(client.getObjectFactory().newCollectionProperty("AlternativeNames", altNamesValue));
-
- final ODataCollectionValue emailBagValue = new ODataCollectionValue("Collection(Edm.String)");
- emailBagValue.add(client.getPrimitiveValueBuilder().
- setText("altname@mydomain.com").setType(EdmSimpleType.String).build());
- contactDetails.add(client.getObjectFactory().newCollectionProperty("EmailBag", emailBagValue));
-
- final ODataComplexValue contactAliasValue = new ODataComplexValue(
- "Microsoft.Test.OData.Services.AstoriaDefaultService.Aliases");
- contactDetails.add(client.getObjectFactory().newComplexProperty("ContactAlias", contactAliasValue));
-
- final ODataCollectionValue aliasAltNamesValue = new ODataCollectionValue("Collection(Edm.String)");
- aliasAltNamesValue.add(client.getPrimitiveValueBuilder().
- setText("myAlternativeName").setType(EdmSimpleType.String).build());
- contactAliasValue.add(client.getObjectFactory().newCollectionProperty("AlternativeNames", aliasAltNamesValue));
-
- final ODataComplexValue homePhone = new ODataComplexValue(
- "Microsoft.Test.OData.Services.AstoriaDefaultService.Phone");
- homePhone.add(client.getObjectFactory().newPrimitiveProperty("PhoneNumber",
- client.getPrimitiveValueBuilder().setText("8437568356834568").setType(EdmSimpleType.String).build()));
- homePhone.add(client.getObjectFactory().newPrimitiveProperty("Extension",
- client.getPrimitiveValueBuilder().setText("1243654265346267651534423ttrf").setType(EdmSimpleType.String).
- build()));
- contactDetails.add(client.getObjectFactory().newComplexProperty("HomePhone", homePhone));
-
- backupContactInfoValue.add(contactDetails);
- entity.addProperty(client.getObjectFactory().newCollectionProperty("BackupContactInfo",
- backupContactInfoValue));
-
- if (inlineInfo) {
- final ODataInlineEntity info = client.getObjectFactory().newInlineEntity(
- "Info",
- URI.create("Customer(-10)/Info"),
- getSampleCustomerInfo(-10, "Updated customer information_Info"));
- info.getEntity().setMediaEntity(true);
- entity.addLink(info);
- }
- final URI uri = client.getURIBuilder(testStaticServiceRootURL).
- appendEntityTypeSegment("Customer").appendKeySegment(-10).build();
- final String etag = getETag(uri);
- entity.setEditLink(uri);
- // update code
- update(format, contentType, prefer, type, entity, etag);
- final ODataEntityUpdateRequest req = client.getCUDRequestFactory().getEntityUpdateRequest(type, entity);
- req.setFormat(format);
- req.setContentType(contentType);
- req.setPrefer(prefer);
- if (client.getConfiguration().isUseXHTTPMethod()) {
- assertEquals(HttpMethod.POST, req.getMethod());
- } else {
- assertEquals(UpdateType.REPLACE.getMethod(), req.getMethod());
- }
-
- if (StringUtils.isNotBlank(etag)) {
- req.setIfMatch(etag);
- }
- final ODataEntityUpdateResponse res = req.execute();
- if (prefer.equals("return-content")) {
- assertEquals(200, res.getStatusCode());
- if (inlineInfo) {
- final ODataEntity actual = compareEntities(testStaticServiceRootURL, format, entity, -10, Collections.
- <String>singleton("Info"));
- assertNotNull(actual);
- } else {
- final ODataEntity actual = compareEntities(testStaticServiceRootURL, format, entity, -10, null);
- assertNotNull(actual);
- }
- } else {
- assertEquals(204, res.getStatusCode());
- }
- }
- // update entity string property
-
- private void updateEntityStringProperty(
- final ODataPubFormat format,
- final String propertyName,
- final ODataEntity entitySetName,
- final UpdateType type,
- final String etag) {
- String newValue = "";
- newValue = "New " + propertyName + "(" + System.currentTimeMillis() + ")";
-
- ODataProperty propertyValue = entitySetName.getProperty(propertyName);
- final String oldValue;
- if (propertyValue == null) {
- oldValue = null;
- } else {
- oldValue = propertyValue.getValue().toString();
- entitySetName.removeProperty(propertyValue);
- }
- assertNotEquals(newValue, oldValue);
- entitySetName.addProperty(client.getObjectFactory().newPrimitiveProperty(propertyName,
- client.getPrimitiveValueBuilder().setText(newValue).build()));
-
- update(type, entitySetName, format, etag);
- propertyValue = null;
-
- for (ODataProperty prop : entitySetName.getProperties()) {
- if (prop.getName().equals(propertyName)) {
- propertyValue = prop;
- }
- }
- assertNotNull(propertyValue);
- assertEquals(newValue, propertyValue.getValue().toString());
- }
- // date property update operation
-
- private void updateEntityDateProperty(
- final ODataPubFormat format,
- final String propertyName,
- final ODataEntity entitySetName,
- final UpdateType type,
- final String etag) {
- String newValue = "2013-11-11T23:59:59.9999999";
-
- ODataProperty propertyValue = entitySetName.getProperty(propertyName);
- final String oldValue;
- if (propertyValue == null) {
- oldValue = null;
- } else {
- oldValue = propertyValue.getValue().toString();
- entitySetName.removeProperty(propertyValue);
- }
- assertNotEquals(newValue, oldValue);
- entitySetName.addProperty(client.getObjectFactory().newPrimitiveProperty(propertyName,
- client.getPrimitiveValueBuilder().setText(newValue).setType(EdmSimpleType.DateTime).build()));
- update(type, entitySetName, format, etag);
- propertyValue = null;
- for (ODataProperty prop : entitySetName.getProperties()) {
- if (prop.getName().equals(propertyName)) {
- propertyValue = prop;
- }
- }
- assertNotNull(propertyValue);
- assertEquals("2013-11-11T23:59:59.9999999", propertyValue.getValue().toString());
- }
- // Integer property update operation
-
- private void updateEntityIntProperty(
- final ODataPubFormat format,
- final String propertyName,
- final ODataEntity entitySetName,
- final UpdateType type,
- final String etag) {
- int newValue = 10323232;
- ODataProperty propertyValue = entitySetName.getProperty(propertyName);
- final int oldValue;
- if (Integer.parseInt(propertyValue.getValue().toString()) == 0) {
- oldValue = 0;
- } else {
- oldValue = Integer.parseInt(propertyValue.getValue().toString());
- entitySetName.removeProperty(propertyValue);
- }
- assertNotEquals(newValue, oldValue);
-
- entitySetName.addProperty(client.getObjectFactory().newPrimitiveProperty(propertyName,
- client.getPrimitiveValueBuilder().setValue(newValue).setType(EdmSimpleType.Int32).build()));
- update(type, entitySetName, format, etag);
- propertyValue = null;
- for (ODataProperty prop : entitySetName.getProperties()) {
- if (prop.getName().equals(propertyName)) {
- propertyValue = prop;
- }
- }
- assertNotNull(propertyValue);
- assertEquals(newValue, Integer.parseInt(propertyValue.getValue().toString()));
-
- // replace the old value
- ODataProperty replaceProperty = entitySetName.getProperty(propertyName);
- entitySetName.removeProperty(replaceProperty);
-
- entitySetName.addProperty(client.getObjectFactory().newPrimitiveProperty(propertyName,
- client.getPrimitiveValueBuilder().setValue(oldValue).setType(EdmSimpleType.Int32).build()));
-
- update(type, entitySetName, format, etag);
- }
-
- // update operation
- protected void update(
- final ODataPubFormat format,
- final String contentType,
- final String prefer,
- final UpdateType type,
- final ODataEntity entitySetName,
- String etag) {
- final ODataEntityUpdateRequest req = client.getCUDRequestFactory().getEntityUpdateRequest(type, entitySetName);
- if (client.getConfiguration().isUseXHTTPMethod()) {
- assertEquals(HttpMethod.POST, req.getMethod());
- } else {
- assertEquals(type.getMethod(), req.getMethod());
- }
- req.setFormat(format);
- req.setContentType(contentType);
- req.setPrefer(prefer);
- etag = entitySetName.getETag();
- if (StringUtils.isNotBlank(etag)) {
- req.setIfMatch(etag);
- }
- final ODataEntityUpdateResponse res = req.execute();
-
- if (prefer.equals("return-content")) {
- assertEquals(200, res.getStatusCode());
- } else {
- assertEquals(204, res.getStatusCode());
- }
- }
-
- //update integer with JSON full meta data header
- @Test
- public void updateIntPropertyAsJSON() {
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
- final String contentType = "application/json;odata=fullmetadata";
- final String prefer = "return-no-content";
- final String entitySet = "OrderLine";
- final String propertyType = "Quantity";
- final UpdateType replace = UpdateType.REPLACE;
- final UpdateType merge = UpdateType.MERGE;
- final UpdateType patch = UpdateType.PATCH;
- final HashMap<String, Object> multiKey = new HashMap<String, Object>();
- multiKey.put("OrderId", -10);
- multiKey.put("ProductId", -10);
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntityTypeSegment(entitySet).appendKeySegment(multiKey);
- final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(format);
- req.setAccept(contentType);
-
- final ODataRetrieveResponse<ODataEntity> res = req.execute();
- final ODataEntity entity = res.getBody();
-
- final String etag = res.getEtag();
- updateEntityIntProperty(format, propertyType, entity, replace, etag);
- updateEntityIntProperty(format, propertyType, entity, merge, etag);
- updateEntityIntProperty(format, propertyType, entity, patch, etag);
- }
- // update integer property with json minimal metadata. Its throws Illegal Argument Exception
-
- @Test
- public void updateIntPropertyAsJSONMinimal() {
- final ODataPubFormat format = ODataPubFormat.JSON;
- final String contentType = "application/json";
- final String prefer = "return-content";
- final String entitySet = "OrderLine";
- final String propertyType = "Quantity";
- final UpdateType replace = UpdateType.REPLACE;
- final UpdateType merge = UpdateType.MERGE;
- final UpdateType patch = UpdateType.PATCH;
- try {
- final HashMap<String, Object> multiKey = new HashMap<String, Object>();
- multiKey.put("OrderId", -10);
- multiKey.put("ProductId", -10);
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntityTypeSegment(entitySet).appendKeySegment(multiKey);
- final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(format);
- req.setAccept(contentType);
-
- final ODataRetrieveResponse<ODataEntity> res = req.execute();
- final ODataEntity entity = res.getBody();
-
- final String etag = res.getEtag();
- updateEntityIntProperty(format, propertyType, entity, replace, etag);
- updateEntityIntProperty(format, propertyType, entity, merge, etag);
- updateEntityIntProperty(format, propertyType, entity, patch, etag);
- } catch (Exception e) {
- if (e.getMessage().equals("No edit link found")) {
- assertTrue(true);
- } else {
- fail(e.getMessage());
- }
- }
- }
- //update date with JSON header
-
- @Test
- public void updateDatePropertyAsJSON() {
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
- final String entitySet = "ComputerDetail";
- final String propertyType = "PurchaseDate";
- final UpdateType replace = UpdateType.REPLACE;
- try {
- final URI uri = client.getURIBuilder(testStaticServiceRootURL).
- appendEntityTypeSegment(entitySet).appendKeySegment(-10).build();
- final String etag = getETag(uri);
- final ODataEntity entity = client.getObjectFactory().newEntity(
- "Microsoft.Test.OData.Services.AstoriaDefaultService.ComputerDetail");
- entity.setEditLink(uri);
- updateEntityDateProperty(format, propertyType, entity, replace, etag);
- } catch (Exception e) {
- fail(e.getMessage());
- } catch (AssertionError e) {
- fail(e.getMessage());
- }
- }
- // update base concurrency property which is tagged as ETag.
-
- @Test
- public void updateConcurrencyPropertyAsJSON() {
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
- final String entitySet = "Product";
- final String propertyType = "BaseConcurrency";
- final UpdateType replace = UpdateType.REPLACE;
- final UpdateType merge = UpdateType.MERGE;
- final UpdateType patch = UpdateType.PATCH;
- try {
- final URI uri = client.getURIBuilder(testStaticServiceRootURL).
- appendEntityTypeSegment(entitySet).appendKeySegment(-10).build();
- final String etag = getETag(uri);
- final ODataEntity entity = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
- entity.setEditLink(uri);
- entity.addProperty(client.getObjectFactory().newPrimitiveProperty("ProductId",
- client.getPrimitiveValueBuilder().setValue(-10).setType(EdmSimpleType.Int32).build()));
- updateEntityStringProperty(format, propertyType, entity, replace, etag);
- updateEntityStringProperty(format, propertyType, entity, merge, etag);
- updateEntityStringProperty(format, propertyType, entity, patch, etag);
- } catch (ODataClientErrorException e) {
- assertEquals(412, e.getStatusLine().getStatusCode());
- }
-
- }
- // test property update with JSON
-
- @Test
- public void updatePropertyAsJSON() {
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
- final String entitySet = "Product";
- final String propertyType = "Description";
- final UpdateType replace = UpdateType.REPLACE;
- final UpdateType merge = UpdateType.MERGE;
- final UpdateType patch = UpdateType.PATCH;
- try {
- final URI uri = client.getURIBuilder(testStaticServiceRootURL).
- appendEntityTypeSegment(entitySet).appendKeySegment(-10).build();
- final String etag = getETag(uri);
- final ODataEntity entity = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
- entity.setEditLink(uri);
- entity.addProperty(client.getObjectFactory().newPrimitiveProperty("ProductId",
- client.getPrimitiveValueBuilder().setValue(-10).setType(EdmSimpleType.Int32).build()));
- updateEntityStringProperty(format, propertyType, entity, replace, etag);
- updateEntityStringProperty(format, propertyType, entity, merge, etag);
- updateEntityStringProperty(format, propertyType, entity, patch, etag);
- } catch (Exception e) {
- fail(e.getMessage());
- } catch (AssertionError e) {
- fail(e.getMessage());
- }
- }
- // test property update with ATOM
-
- @Test
- public void updatePropertyAsATOM() {
- final ODataPubFormat format = ODataPubFormat.ATOM;
- final String entitySet = "Product";
- final String propertyType = "Description";
- final UpdateType replace = UpdateType.REPLACE;
- final UpdateType merge = UpdateType.MERGE;
- final UpdateType patch = UpdateType.PATCH;
- try {
- final URI uri = client.getURIBuilder(testStaticServiceRootURL).
- appendEntityTypeSegment(entitySet).appendKeySegment(-10).build();
- final String etag = getETag(uri);
- final ODataEntity entity = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
- entity.setEditLink(uri);
- entity.addProperty(client.getObjectFactory().newPrimitiveProperty("ProductId",
- client.getPrimitiveValueBuilder().setValue(-10).setType(EdmSimpleType.Int32).build()));
- updateEntityStringProperty(format, propertyType, entity, replace, etag);
- updateEntityStringProperty(format, propertyType, entity, merge, etag);
- updateEntityStringProperty(format, propertyType, entity, patch, etag);
- } catch (Exception e) {
- fail(e.getMessage());
- } catch (AssertionError e) {
- fail(e.getMessage());
- }
- }
- // test property update with JSON minimal metadata
-
- @Test
- public void updatePropertyAsJSONMinimal() {
- final ODataPubFormat format = ODataPubFormat.JSON;
- final String entitySet = "Product";
- final String propertyType = "Description";
- final UpdateType replace = UpdateType.REPLACE;
- final UpdateType merge = UpdateType.MERGE;
- final UpdateType patch = UpdateType.PATCH;
- try {
- final URI uri = client.getURIBuilder(testStaticServiceRootURL).
- appendEntityTypeSegment(entitySet).appendKeySegment(-10).build();
- final String etag = getETag(uri);
- final ODataEntity entity = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
- entity.setEditLink(uri);
- entity.addProperty(client.getObjectFactory().newPrimitiveProperty("ProductId",
- client.getPrimitiveValueBuilder().setValue(-10).setType(EdmSimpleType.Int32).build()));
- updateEntityStringProperty(format, propertyType, entity, replace, etag);
- updateEntityStringProperty(format, propertyType, entity, merge, etag);
- updateEntityStringProperty(format, propertyType, entity, patch, etag);
- } catch (Exception e) {
- fail(e.getMessage());
- } catch (AssertionError e) {
- fail(e.getMessage());
- }
- }
- // updating an entity which is not nullable should return 400 status
-
- @Test
- public void updateNonNullableProperty() {
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
- final String entitySet = "Product";
- final String propertyType = "ProductId";
- final UpdateType replace = UpdateType.REPLACE;
- try {
- final URI uri = client.getURIBuilder(testStaticServiceRootURL).
- appendEntityTypeSegment(entitySet).appendKeySegment(-10).build();
- final String etag = getETag(uri);
- final ODataEntity entity = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
- entity.setEditLink(uri);
- entity.addProperty(client.getObjectFactory().newPrimitiveProperty("ProductId",
- client.getPrimitiveValueBuilder().setValue(-10).setType(EdmSimpleType.Int32).build()));
- updateEntityStringProperty(format, propertyType, entity, replace, etag);
- } catch (Exception e) {
- if (e.getMessage().equals("An error occurred while processing this request. [HTTP/1.1 400 Bad Request]")) {
- assertTrue(true);
- } else {
- fail(e.getMessage());
- }
- } catch (AssertionError e) {
- fail(e.getMessage());
- }
- }
- // test property update with JSON no metadata
-
- @Test
- public void updatePropertyAsJSONNoMetadata() {
- final ODataPubFormat format = ODataPubFormat.JSON_NO_METADATA;
- final String propertyType = "Product";
- final UpdateType replace = UpdateType.REPLACE;
- try {
- final URI uri = client.getURIBuilder(testStaticServiceRootURL).
- appendEntityTypeSegment(propertyType).appendKeySegment(-10).build();
- final String etag = getETag(uri);
- final ODataEntity entity = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
- entity.setEditLink(uri);
- entity.addProperty(client.getObjectFactory().newPrimitiveProperty("ProductId",
- client.getPrimitiveValueBuilder().setValue(-10).setType(EdmSimpleType.Int32).build()));
- updateEntityStringProperty(format, "Description", entity, replace, etag);
- } catch (Exception e) {
- fail(e.getMessage());
- } catch (AssertionError e) {
- fail(e.getMessage());
- }
- }
- // update an entity with JSON full metadata
-
- @Test
- public void updateAsJSONWithReplace() {
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
- final String contentType = "application/json;odata=fullmetadata";
- final String prefer = "return-content";
- final UpdateType type = UpdateType.REPLACE;
- try {
- updateEntity(format, contentType, prefer, type, false);
- } catch (Exception e) {
- if (e.getMessage().equals(
- "Error processing request stream. Deep updates are not supported in PUT, MERGE, or PATCH operations. [HTTP/1.1 400 Bad Request]")) {
- assertTrue(true);
- } else {
- fail(e.getMessage());
- }
- } catch (AssertionError e) {
- fail(e.getMessage());
- }
- }
- // update an entity with ATOM
-
- @Test
- public void updateAsATOMWithReplace() {
- final ODataPubFormat format = ODataPubFormat.ATOM;
- final String contentType = "application/atom+xml";
- final String prefer = "return-content";
- final UpdateType type = UpdateType.REPLACE;
- try {
- updateEntity(format, contentType, prefer, type, true);
- } catch (Exception e) {
- if (e.getMessage().equals(
- "Error processing request stream. Deep updates are not supported in PUT, MERGE, or PATCH operations. [HTTP/1.1 400 Bad Request]")) {
- assertTrue(true);
- } else {
- fail(e.getMessage());
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/19f3792f/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/EntityUpdateTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/EntityUpdateTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/EntityUpdateTestITCase.java
deleted file mode 100644
index b7c6756..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/EntityUpdateTestITCase.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/**
- * 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 com.msopentech.odatajclient.engine.it;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import com.msopentech.odatajclient.engine.communication.ODataClientErrorException;
-import com.msopentech.odatajclient.engine.communication.header.ODataHeaderValues;
-import com.msopentech.odatajclient.engine.communication.header.ODataHeaders;
-import com.msopentech.odatajclient.engine.communication.request.UpdateType;
-import com.msopentech.odatajclient.engine.communication.request.cud.ODataEntityUpdateRequest;
-import com.msopentech.odatajclient.engine.communication.request.retrieve.ODataEntityRequest;
-import com.msopentech.odatajclient.engine.communication.response.ODataEntityUpdateResponse;
-import com.msopentech.odatajclient.engine.data.ODataEntity;
-import com.msopentech.odatajclient.engine.metadata.edm.EdmSimpleType;
-import com.msopentech.odatajclient.engine.format.ODataPubFormat;
-import java.net.URI;
-import java.util.LinkedHashMap;
-import org.junit.Test;
-
-/**
- * This is the unit test class to check entity update operations.
- */
-public class EntityUpdateTestITCase extends AbstractTestITCase {
-
- protected String getServiceRoot() {
- return testStaticServiceRootURL;
- }
-
- @Test
- public void mergeAsAtom() {
- final ODataPubFormat format = ODataPubFormat.ATOM;
- final URI uri = client.getURIBuilder(getServiceRoot()).
- appendEntityTypeSegment("Product").appendKeySegment(-10).build();
- final String etag = getETag(uri);
- final ODataEntity merge = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
- merge.setEditLink(uri);
- updateEntityDescription(format, merge, UpdateType.MERGE, etag);
- }
-
- @Test
- public void mergeAsJSON() {
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
- final URI uri = client.getURIBuilder(getServiceRoot()).
- appendEntityTypeSegment("Product").appendKeySegment(-10).build();
- final String etag = getETag(uri);
- final ODataEntity merge = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
- merge.setEditLink(uri);
- updateEntityDescription(format, merge, UpdateType.MERGE, etag);
- }
-
- @Test
- public void patchAsAtom() {
- final ODataPubFormat format = ODataPubFormat.ATOM;
- final URI uri = client.getURIBuilder(getServiceRoot()).
- appendEntityTypeSegment("Product").appendKeySegment(-10).build();
- final String etag = getETag(uri);
- final ODataEntity patch = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
- patch.setEditLink(uri);
- updateEntityDescription(format, patch, UpdateType.PATCH, etag);
- }
-
- @Test
- public void patchAsJSON() {
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
- final URI uri = client.getURIBuilder(getServiceRoot()).
- appendEntityTypeSegment("Product").appendKeySegment(-10).build();
- final String etag = getETag(uri);
- final ODataEntity patch = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
- patch.setEditLink(uri);
- updateEntityDescription(format, patch, UpdateType.PATCH, etag);
- }
-
- @Test
- public void replaceAsAtom() {
- final ODataPubFormat format = ODataPubFormat.ATOM;
- final ODataEntity changes = read(format, client.getURIBuilder(getServiceRoot()).
- appendEntityTypeSegment("Car").appendKeySegment(14).build());
- updateEntityDescription(format, changes, UpdateType.REPLACE);
- }
-
- @Test
- public void replaceAsJSON() {
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
- final ODataEntity changes = read(format, client.getURIBuilder(getServiceRoot()).
- appendEntityTypeSegment("Car").appendKeySegment(14).build());
- updateEntityDescription(format, changes, UpdateType.REPLACE);
- }
-
- @Test
- public void patchLinkAsAtom() {
- patchLink(ODataPubFormat.ATOM);
- }
-
- @Test
- public void patchLinkAsJSON() {
- patchLink(ODataPubFormat.JSON_FULL_METADATA);
- }
-
- public void patchLink(final ODataPubFormat format) {
- final URI uri = client.getURIBuilder(getServiceRoot()).
- appendEntityTypeSegment("Customer").appendKeySegment(-10).build();
-
- final ODataEntity patch =
- client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Customer");
- patch.setEditLink(uri);
-
- // ---------------------------------------
- // Update to CustomerInfo(12)
- // ---------------------------------------
- URI customerInfoURI = client.getURIBuilder(getServiceRoot()).
- appendEntityTypeSegment("CustomerInfo").appendKeySegment(12).build();
-
- patch.addLink(client.getObjectFactory().newEntityNavigationLink("Info", customerInfoURI));
-
- update(UpdateType.PATCH, patch, format, null);
-
- customerInfoURI = client.getURIBuilder(getServiceRoot()).
- appendEntityTypeSegment("Customer").appendKeySegment(-10).appendStructuralSegment("Info").build();
-
- ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(customerInfoURI);
- req.setFormat(format);
-
- ODataEntity newInfo = req.execute().getBody();
-
- assertEquals(Integer.valueOf(12),
- newInfo.getProperty("CustomerInfoId").getPrimitiveValue().<Integer>toCastValue());
- // ---------------------------------------
-
- // ---------------------------------------
- // Restore to CustomerInfo(11)
- // ---------------------------------------
- patch.getNavigationLinks().clear();
-
- customerInfoURI = client.getURIBuilder(getServiceRoot()).
- appendEntityTypeSegment("CustomerInfo").appendKeySegment(11).build();
- read(format, customerInfoURI);
-
- patch.addLink(client.getObjectFactory().newEntityNavigationLink("Info", customerInfoURI));
-
- update(UpdateType.PATCH, patch, format, null);
-
- customerInfoURI = client.getURIBuilder(getServiceRoot()).
- appendEntityTypeSegment("Customer").appendKeySegment(-10).appendStructuralSegment("Info").build();
-
- req = client.getRetrieveRequestFactory().getEntityRequest(customerInfoURI);
- req.setFormat(format);
-
- newInfo = req.execute().getBody();
-
- assertEquals(Integer.valueOf(11),
- newInfo.getProperty("CustomerInfoId").getPrimitiveValue().<Integer>toCastValue());
- // ---------------------------------------
- }
-
- private ODataEntityUpdateRequest buildMultiKeyUpdateReq(final ODataPubFormat format) {
- final LinkedHashMap<String, Object> multiKey = new LinkedHashMap<String, Object>();
- multiKey.put("FromUsername", "1");
- multiKey.put("MessageId", -10);
- final ODataEntity message = read(format, client.getURIBuilder(getServiceRoot()).
- appendEntityTypeSegment("Message").appendKeySegment(multiKey).build());
- message.getAssociationLinks().clear();
- message.getNavigationLinks().clear();
-
- final boolean before = message.getProperty("IsRead").getPrimitiveValue().<Boolean>toCastValue();
- message.getProperties().remove(message.getProperty("IsRead"));
- message.addProperty(client.getObjectFactory().newPrimitiveProperty("IsRead",
- client.getPrimitiveValueBuilder().setValue(!before).setType(EdmSimpleType.Boolean).build()));
-
- return client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.MERGE, message);
- }
-
- private void mergeMultiKey(final ODataPubFormat format) {
- final ODataEntityUpdateResponse res = buildMultiKeyUpdateReq(format).execute();
- assertEquals(204, res.getStatusCode());
- }
-
- @Test
- public void mergeMultiKeyAsAtom() {
- mergeMultiKey(ODataPubFormat.ATOM);
- }
-
- @Test
- public void mergeMultiKeyAsJSON() {
- mergeMultiKey(ODataPubFormat.JSON_FULL_METADATA);
- }
-
- @Test
- public void updateReturnContent() {
- final ODataEntityUpdateRequest req = buildMultiKeyUpdateReq(client.getConfiguration().getDefaultPubFormat());
- req.setPrefer(ODataHeaderValues.preferReturnContent);
-
- final ODataEntityUpdateResponse res = req.execute();
- assertEquals(200, res.getStatusCode());
- assertEquals(ODataHeaderValues.preferReturnContent,
- res.getHeader(ODataHeaders.HeaderName.preferenceApplied).iterator().next());
- assertNotNull(res.getBody());
- }
-
- @Test
- public void concurrentModification() {
- final URI uri = client.getURIBuilder(getServiceRoot()).
- appendEntityTypeSegment("Product").appendKeySegment(-10).build();
- String etag = getETag(uri);
- final ODataEntity product = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE);
- product.setEditLink(uri);
- updateEntityStringProperty("BaseConcurrency",
- client.getConfiguration().getDefaultPubFormat(), product, UpdateType.MERGE, etag);
-
- try {
- etag += "-invalidone";
- updateEntityStringProperty("BaseConcurrency",
- client.getConfiguration().getDefaultPubFormat(), product, UpdateType.MERGE, etag);
- fail();
- } catch (ODataClientErrorException e) {
- assertEquals(412, e.getStatusLine().getStatusCode());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/19f3792f/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ErrorTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ErrorTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ErrorTestITCase.java
deleted file mode 100644
index afe5259..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/ErrorTestITCase.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/**
- * 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 com.msopentech.odatajclient.engine.it;
-
-import static org.junit.Assert.fail;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import com.msopentech.odatajclient.engine.client.ODataClient;
-import com.msopentech.odatajclient.engine.client.http.HttpMethod;
-import com.msopentech.odatajclient.engine.communication.ODataClientErrorException;
-import com.msopentech.odatajclient.engine.communication.response.ODataResponseImpl;
-import com.msopentech.odatajclient.engine.communication.request.AbstractODataBasicRequestImpl;
-import com.msopentech.odatajclient.engine.communication.request.invoke.ODataInvokeRequest;
-import com.msopentech.odatajclient.engine.communication.request.retrieve.ODataEntityRequest;
-import com.msopentech.odatajclient.engine.communication.response.ODataEntityCreateResponse;
-import com.msopentech.odatajclient.engine.communication.response.ODataInvokeResponse;
-import com.msopentech.odatajclient.engine.data.ODataEntity;
-import com.msopentech.odatajclient.engine.data.ODataEntitySet;
-import com.msopentech.odatajclient.engine.uri.URIBuilder;
-import com.msopentech.odatajclient.engine.metadata.EdmV3Metadata;
-import com.msopentech.odatajclient.engine.metadata.edm.v3.EntityContainer;
-import com.msopentech.odatajclient.engine.metadata.edm.v3.FunctionImport;
-import com.msopentech.odatajclient.engine.format.ODataPubFormat;
-import com.msopentech.odatajclient.engine.utils.URIUtils;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.net.URI;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
-import org.junit.Test;
-
-/**
- * This is the unit test class to check basic entity operations.
- */
-public class ErrorTestITCase extends AbstractTestITCase {
-
- private class ErrorGeneratingRequest
- extends AbstractODataBasicRequestImpl<ODataEntityCreateResponse, ODataPubFormat> {
-
- public ErrorGeneratingRequest(final HttpMethod method, final URI uri) {
- super(client, ODataPubFormat.class, method, uri);
- }
-
- @Override
- protected InputStream getPayload() {
- return new ByteArrayInputStream(new byte[0]);
- }
-
- @Override
- public ODataEntityCreateResponse execute() {
- final HttpResponse res = doExecute();
- return new ErrorResponseImpl(client, httpClient, res);
- }
-
- private class ErrorResponseImpl extends ODataResponseImpl implements ODataEntityCreateResponse {
-
- private final ODataClient odataClient;
-
- public ErrorResponseImpl(
- final ODataClient odataClient, final HttpClient client, final HttpResponse res) {
-
- super(client, res);
- this.odataClient = odataClient;
- }
-
- @Override
- public ODataEntity getBody() {
- return odataClient.getObjectFactory().newEntity("Invalid");
- }
- }
- }
-
- private void stacktraceError(final ODataPubFormat format) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL);
- uriBuilder.appendEntitySetSegment("Customer");
-
- final ErrorGeneratingRequest errorReq = new ErrorGeneratingRequest(HttpMethod.POST, uriBuilder.build());
- errorReq.setFormat(format);
-
- try {
- errorReq.execute();
- fail();
- } catch (ODataClientErrorException e) {
- LOG.error("ODataClientErrorException found", e);
- assertEquals(400, e.getStatusLine().getStatusCode());
- assertNotNull(e.getCause());
- assertNotNull(e.getODataError());
- }
- }
-
- @Test
- public void xmlStacktraceError() {
- stacktraceError(ODataPubFormat.ATOM);
- }
-
- @Test
- public void jsonStacktraceError() {
- stacktraceError(ODataPubFormat.JSON);
- }
-
- private void notfoundError(final ODataPubFormat format) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL);
- uriBuilder.appendEntitySetSegment("Customer(154)");
-
- final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(format);
-
- try {
- req.execute();
- fail();
- } catch (ODataClientErrorException e) {
- LOG.error("ODataClientErrorException found", e);
- assertEquals(404, e.getStatusLine().getStatusCode());
- assertNull(e.getCause());
- assertNotNull(e.getODataError());
- }
- }
-
- @Test
- public void xmlNotfoundError() {
- notfoundError(ODataPubFormat.ATOM);
- }
-
- @Test
- public void jsonNotfoundError() {
- notfoundError(ODataPubFormat.JSON);
- }
-
- private void instreamError(final ODataPubFormat format) {
- final EdmV3Metadata metadata =
- client.getRetrieveRequestFactory().getMetadataRequest(testStaticServiceRootURL).execute().getBody();
- assertNotNull(metadata);
-
- final EntityContainer container = metadata.getSchema(0).getEntityContainers().get(0);
- final FunctionImport funcImp = container.getFunctionImport("InStreamErrorGetCustomer");
-
- final URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL).
- appendFunctionImportSegment(URIUtils.rootFunctionImportURISegment(container, funcImp));
-
- final ODataInvokeRequest<ODataEntitySet> req =
- client.getInvokeRequestFactory().getInvokeRequest(builder.build(), metadata, funcImp);
- req.setFormat(format);
-
- final ODataInvokeResponse<ODataEntitySet> res = req.execute();
- res.getBody();
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void atomInstreamError() {
- instreamError(ODataPubFormat.ATOM);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void jsonInstreamError() {
- instreamError(ODataPubFormat.JSON);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/19f3792f/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/FilterFactoryTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/FilterFactoryTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/FilterFactoryTestITCase.java
deleted file mode 100644
index c125431..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/FilterFactoryTestITCase.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
- * 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 com.msopentech.odatajclient.engine.it;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import com.msopentech.odatajclient.engine.data.ODataEntitySet;
-import com.msopentech.odatajclient.engine.uri.URIBuilder;
-import com.msopentech.odatajclient.engine.uri.filter.ODataFilter;
-import com.msopentech.odatajclient.engine.uri.filter.ODataFilterArgFactory;
-import org.junit.Test;
-
-public class FilterFactoryTestITCase extends AbstractTestITCase {
-
- private void match(final String entitySet, final ODataFilter filter, final int expected) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment(entitySet).filter(filter);
-
- final ODataEntitySet feed = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build()).
- execute().getBody();
- assertNotNull(feed);
- assertEquals(expected, feed.getEntities().size());
- }
-
- @Test
- public void simple() {
- match("Car", client.getFilterFactory().lt("VIN", 16), 5);
- }
-
- @Test
- public void and() {
- final ODataFilter filter =
- client.getFilterFactory().and(
- client.getFilterFactory().lt("VIN", 16),
- client.getFilterFactory().gt("VIN", 12));
-
- match("Car", filter, 3);
- }
-
- @Test
- public void not() {
- final ODataFilter filter =
- client.getFilterFactory().not(
- client.getFilterFactory().or(
- client.getFilterFactory().ge("VIN", 16),
- client.getFilterFactory().le("VIN", 12)));
-
- match("Car", filter, 3);
- }
-
- @Test
- public void operator() {
- ODataFilter filter =
- client.getFilterFactory().eq(
- ODataFilterArgFactory.add(ODataFilterArgFactory.property("VIN"), ODataFilterArgFactory.
- literal(1)),
- ODataFilterArgFactory.literal(16));
-
- match("Car", filter, 1);
-
- filter =
- client.getFilterFactory().eq(
- ODataFilterArgFactory.add(ODataFilterArgFactory.literal(1), ODataFilterArgFactory.
- property("VIN")),
- ODataFilterArgFactory.literal(16));
-
- match("Car", filter, 1);
-
- filter =
- client.getFilterFactory().eq(
- ODataFilterArgFactory.literal(16),
- ODataFilterArgFactory.add(ODataFilterArgFactory.literal(1), ODataFilterArgFactory.
- property("VIN")));
-
- match("Car", filter, 1);
- }
-
- @Test
- public void function() {
- final ODataFilter filter =
- client.getFilterFactory().match(
- ODataFilterArgFactory.startswith(
- ODataFilterArgFactory.property("Description"), ODataFilterArgFactory.literal("cen")));
-
- match("Car", filter, 1);
- }
-
- @Test
- public void composed() {
- final ODataFilter filter =
- client.getFilterFactory().gt(
- ODataFilterArgFactory.length(ODataFilterArgFactory.property("Description")),
- ODataFilterArgFactory.add(ODataFilterArgFactory.property("VIN"), ODataFilterArgFactory.literal(
- 10)));
-
- match("Car", filter, 5);
- }
-
- @Test
- public void propertyPath() {
- ODataFilter filter =
- client.getFilterFactory().eq(
- ODataFilterArgFactory.indexof(
- ODataFilterArgFactory.property("PrimaryContactInfo/HomePhone/PhoneNumber"),
- ODataFilterArgFactory.literal("ODataJClient")),
- ODataFilterArgFactory.literal(1));
-
- match("Customer", filter, 0);
-
- filter =
- client.getFilterFactory().ne(
- ODataFilterArgFactory.indexof(
- ODataFilterArgFactory.property("PrimaryContactInfo/HomePhone/PhoneNumber"),
- ODataFilterArgFactory.literal("lccvussrv")),
- ODataFilterArgFactory.literal(-1));
-
- match("Customer", filter, 2);
- }
-
- @Test
- public void datetime() {
- final ODataFilter filter =
- client.getFilterFactory().eq(
- ODataFilterArgFactory.month(
- ODataFilterArgFactory.property("PurchaseDate")),
- ODataFilterArgFactory.literal(12));
-
- match("ComputerDetail", filter, 1);
- }
-
- @Test
- public void isof() {
- final ODataFilter filter =
- client.getFilterFactory().match(
- ODataFilterArgFactory.isof(
- ODataFilterArgFactory.literal(
- "Microsoft.Test.OData.Services.AstoriaDefaultService.SpecialEmployee")));
-
- match("Person", filter, 4);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/19f3792f/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/FilterTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/FilterTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/FilterTestITCase.java
deleted file mode 100644
index 4bfe60c..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/FilterTestITCase.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * 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 com.msopentech.odatajclient.engine.it;
-
-import static org.junit.Assert.*;
-import org.junit.Test;
-
-import com.msopentech.odatajclient.engine.data.ODataEntitySet;
-import com.msopentech.odatajclient.engine.uri.URIBuilder;
-
-public class FilterTestITCase extends AbstractTestITCase {
-
- private void filterQueryTest(final String entity, final String filter, final int expected) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment(entity).filter(filter);
- final ODataEntitySet entitySet = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build()).
- execute().getBody();
- assertNotNull(entitySet);
- assertEquals(expected, entitySet.getEntities().size());
- }
-
- @Test
- public void withId() {
- filterQueryTest("Customer", "CustomerId eq -10", 1);
- }
-
- @Test
- public void logical() {
- filterQueryTest("Customer", "CustomerId gt -10", 2);
- filterQueryTest("Customer", "CustomerId lt -10", 0);
- filterQueryTest("Customer", "not endswith(Name,'Chandan')", 2);
- filterQueryTest("Car", "VIN le 18 and VIN gt 12", 6);
- }
-
- @Test
- public void arithmetic() {
- filterQueryTest("Car", "VIN add 5 lt 11", 0);
- filterQueryTest("Car", "VIN div 2 le 8", 7);
- filterQueryTest("Car", "VIN mul 2 le 30", 5);
- filterQueryTest("Person", "PersonId sub 2 lt -10", 2);
- }
-
- @Test
- public void stringOperations() {
- filterQueryTest("Product", "length(Description) eq 7", 1);
- filterQueryTest("Product", "length(Description) eq 7", 1);
- filterQueryTest("Product", "substringof('kdcuklu', Description) eq true", 1);
- filterQueryTest("Product", "startswith(Description, 'k') eq true", 2);
- filterQueryTest("Product", "startswith(Description, 'k') eq true", 2);
- filterQueryTest("Product", "indexof(Description, 'k') eq 0", 2);
- filterQueryTest("Product", "toupper(Description) eq 'KDCUKLU'", 1);
- filterQueryTest("Product", "concat(Description, ', newname') eq 'kdcuklu, newname'", 1);
- }
-
- @Test
- public void math() {
- filterQueryTest("Product", "round(Dimensions/Width) eq 7338", 1);
- filterQueryTest("Product", "round(Dimensions/Width) eq 7338", 1);
- filterQueryTest("Product", "floor(Dimensions/Width) eq 7337", 1);
- filterQueryTest("Product", "ceiling(Dimensions/Width) eq 7338", 1);
- }
-
- @Test
- public void date() {
- filterQueryTest("ComputerDetail", "day(PurchaseDate) eq 15", 1);
- filterQueryTest("ComputerDetail", "month(PurchaseDate) eq 12", 2);
- filterQueryTest("ComputerDetail", "hour(PurchaseDate) eq 1", 1);
- filterQueryTest("ComputerDetail", "minute(PurchaseDate) eq 33", 1);
- filterQueryTest("ComputerDetail", "second(PurchaseDate) eq 35", 1);
- filterQueryTest("ComputerDetail", "year(PurchaseDate) eq 2020", 1);
- }
-
- @Test
- public void isOfTest() {
- filterQueryTest("Customer", "isof(Name,'Edm.String') eq true", 2);
- }
-}