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:36 UTC
[28/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/LinkTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/LinkTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/LinkTestITCase.java
deleted file mode 100644
index 284334e..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/LinkTestITCase.java
+++ /dev/null
@@ -1,177 +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.assertNotEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNotNull;
-
-import com.msopentech.odatajclient.engine.communication.request.UpdateType;
-import com.msopentech.odatajclient.engine.communication.request.cud.ODataLinkCreateRequest;
-import com.msopentech.odatajclient.engine.communication.request.cud.ODataLinkUpdateRequest;
-import com.msopentech.odatajclient.engine.communication.request.retrieve.ODataLinkCollectionRequest;
-import com.msopentech.odatajclient.engine.communication.response.ODataLinkOperationResponse;
-import com.msopentech.odatajclient.engine.communication.response.ODataRetrieveResponse;
-import com.msopentech.odatajclient.engine.data.ODataLink;
-import com.msopentech.odatajclient.engine.data.ODataLinkCollection;
-import com.msopentech.odatajclient.engine.uri.URIBuilder;
-import com.msopentech.odatajclient.engine.format.ODataFormat;
-import java.io.IOException;
-import java.net.URI;
-import java.util.Collections;
-import java.util.List;
-import org.junit.Test;
-
-/**
- * This is the unit test class to check basic link operations.
- */
-public class LinkTestITCase extends AbstractTestITCase {
-
- protected String getServiceRoot() {
- return testStaticServiceRootURL;
- }
-
- private ODataLinkCollection doRetrieveLinkURIs(final ODataFormat format, final String linkname) throws IOException {
- final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot()).
- appendEntityTypeSegment("Customer").appendKeySegment(-10);
-
- final ODataLinkCollectionRequest req =
- client.getRetrieveRequestFactory().getLinkCollectionRequest(uriBuilder.build(), linkname);
- req.setFormat(format);
-
- final ODataRetrieveResponse<ODataLinkCollection> res = req.execute();
- assertEquals(200, res.getStatusCode());
-
- return res.getBody();
- }
-
- private void retrieveLinkURIs(final ODataFormat format) throws IOException {
- final List<URI> links = doRetrieveLinkURIs(format, "Logins").getLinks();
- assertEquals(2, links.size());
- assertTrue(links.contains(URI.create(getServiceRoot() + "/Login('1')")));
- assertTrue(links.contains(URI.create(getServiceRoot() + "/Login('4')")));
- }
-
- @Test
- public void retrieveXMLLinkURIsWithNext() throws IOException {
- final ODataLinkCollection uris = doRetrieveLinkURIs(ODataFormat.XML, "Orders");
- assertEquals(2, uris.getLinks().size());
- assertNotNull(uris.getNext());
- }
-
- @Test
- public void retrieveXMLLinkURIs() throws IOException {
- retrieveLinkURIs(ODataFormat.XML);
- }
-
- @Test
- public void retrieveJSONLinkURIs() throws IOException {
- retrieveLinkURIs(ODataFormat.JSON);
- }
-
- private void createLink(final ODataFormat format) throws IOException {
- // 1. read current Logins $links (for later usage)
- final List<URI> before = doRetrieveLinkURIs(format, "Logins").getLinks();
- assertEquals(2, before.size());
-
- // 2. create new link
- final ODataLink newLink = client.getObjectFactory().
- newAssociationLink(null, URI.create(getServiceRoot() + "/Login('3')"));
-
- final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot()).
- appendEntityTypeSegment("Customer").appendKeySegment(-10).appendLinksSegment("Logins");
-
- final ODataLinkCreateRequest req =
- client.getCUDRequestFactory().getLinkCreateRequest(uriBuilder.build(), newLink);
- req.setFormat(format);
-
- final ODataLinkOperationResponse res = req.execute();
- assertEquals(204, res.getStatusCode());
-
- final List<URI> after = doRetrieveLinkURIs(format, "Logins").getLinks();
- assertEquals(before.size() + 1, after.size());
-
- // 3. reset Logins $links as before this test was run
- after.removeAll(before);
- assertEquals(Collections.singletonList(newLink.getLink()), after);
-
- assertEquals(204, client.getCUDRequestFactory().getDeleteRequest(
- client.getURIBuilder(getServiceRoot()).appendEntityTypeSegment("Customer").
- appendKeySegment(-10).appendLinksSegment("Logins('3')").build()).execute().getStatusCode());
- }
-
- @Test
- public void createXMLLink() throws IOException {
- createLink(ODataFormat.XML);
- }
-
- @Test
- public void createJSONLink() throws IOException {
- createLink(ODataFormat.JSON);
- }
-
- private void updateLink(final ODataFormat format, final UpdateType updateType) throws IOException {
- // 1. read what is the link before the test runs
- final URI before = doRetrieveLinkURIs(format, "Info").getLinks().get(0);
-
- // 2. update the link
- ODataLink newLink =
- client.getObjectFactory().newAssociationLink(null, URI.create(getServiceRoot() + "/CustomerInfo(12)"));
-
- final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot());
- uriBuilder.appendEntityTypeSegment("Customer").appendKeySegment(-10).appendLinksSegment("Info");
-
- ODataLinkUpdateRequest req =
- client.getCUDRequestFactory().getLinkUpdateRequest(uriBuilder.build(), updateType, newLink);
- req.setFormat(format);
-
- ODataLinkOperationResponse res = req.execute();
- assertEquals(204, res.getStatusCode());
-
- URI after = doRetrieveLinkURIs(format, "Info").getLinks().get(0);
- assertNotEquals(before, after);
- assertEquals(newLink.getLink(), after);
-
- // 3. reset back the link value
- newLink = client.getObjectFactory().newAssociationLink(null, before);
- req = client.getCUDRequestFactory().getLinkUpdateRequest(uriBuilder.build(), updateType, newLink);
- req.setFormat(format);
-
- res = req.execute();
- assertEquals(204, res.getStatusCode());
-
- after = doRetrieveLinkURIs(format, "Info").getLinks().get(0);
- assertEquals(before, after);
- }
-
- @Test
- public void updateXMLLink() throws IOException {
- updateLink(ODataFormat.XML, UpdateType.MERGE);
- updateLink(ODataFormat.XML, UpdateType.PATCH);
- updateLink(ODataFormat.XML, UpdateType.REPLACE);
- }
-
- @Test
- public void updateJSONLink() throws IOException {
- updateLink(ODataFormat.JSON, UpdateType.MERGE);
- updateLink(ODataFormat.JSON, UpdateType.PATCH);
- updateLink(ODataFormat.JSON, UpdateType.REPLACE);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/19f3792f/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/MediaEntityTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/MediaEntityTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/MediaEntityTestITCase.java
deleted file mode 100644
index ceed78d..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/MediaEntityTestITCase.java
+++ /dev/null
@@ -1,210 +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 com.msopentech.odatajclient.engine.it.AbstractTestITCase.testDefaultServiceRootURL;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import com.msopentech.odatajclient.engine.client.http.HttpClientException;
-import com.msopentech.odatajclient.engine.communication.ODataClientErrorException;
-import com.msopentech.odatajclient.engine.communication.request.retrieve.ODataMediaRequest;
-import com.msopentech.odatajclient.engine.communication.request.streamed.ODataMediaEntityCreateRequest;
-import com.msopentech.odatajclient.engine.communication.request.streamed.ODataMediaEntityCreateRequest.MediaEntityCreateStreamManager;
-import com.msopentech.odatajclient.engine.communication.request.streamed.ODataMediaEntityUpdateRequest;
-import com.msopentech.odatajclient.engine.communication.request.streamed.ODataMediaEntityUpdateRequest.MediaEntityUpdateStreamManager;
-import com.msopentech.odatajclient.engine.communication.request.streamed.ODataStreamUpdateRequest;
-import com.msopentech.odatajclient.engine.communication.request.streamed.ODataStreamUpdateRequest.StreamUpdateStreamManager;
-import com.msopentech.odatajclient.engine.communication.response.ODataMediaEntityCreateResponse;
-import com.msopentech.odatajclient.engine.communication.response.ODataMediaEntityUpdateResponse;
-import com.msopentech.odatajclient.engine.communication.response.ODataRetrieveResponse;
-import com.msopentech.odatajclient.engine.communication.response.ODataStreamUpdateResponse;
-import com.msopentech.odatajclient.engine.data.ODataEntity;
-import com.msopentech.odatajclient.engine.data.ODataProperty;
-import com.msopentech.odatajclient.engine.uri.URIBuilder;
-import com.msopentech.odatajclient.engine.format.ODataMediaFormat;
-import com.msopentech.odatajclient.engine.format.ODataPubFormat;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import org.apache.commons.io.IOUtils;
-import org.junit.Test;
-
-public class MediaEntityTestITCase extends AbstractTestITCase {
-
- @Test
- public void read() throws Exception {
- final URIBuilder builder = client.getURIBuilder(testDefaultServiceRootURL).
- appendEntityTypeSegment("Car").appendKeySegment(12).appendValueSegment();
-
- final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build());
- retrieveReq.setFormat(ODataMediaFormat.WILDCARD);
-
- final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute();
- assertEquals(200, retrieveRes.getStatusCode());
-
- final byte[] actual = new byte[Integer.parseInt(retrieveRes.getHeader("Content-Length").iterator().next())];
- IOUtils.read(retrieveRes.getBody(), actual, 0, actual.length);
- }
-
- @Test(expected = ODataClientErrorException.class)
- public void readWithXmlError() throws Exception {
- final URIBuilder builder = client.getURIBuilder(testDefaultServiceRootURL).
- appendEntityTypeSegment("Car").appendKeySegment(12).appendValueSegment();
-
- final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build());
- retrieveReq.setFormat(ODataMediaFormat.APPLICATION_XML);
-
- retrieveReq.execute();
- }
-
- @Test(expected = ODataClientErrorException.class)
- public void readWithJsonError() throws Exception {
- final URIBuilder builder = client.getURIBuilder(testDefaultServiceRootURL).
- appendEntityTypeSegment("Car").appendKeySegment(12).appendValueSegment();
-
- final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build());
- retrieveReq.setFormat(ODataMediaFormat.APPLICATION_JSON);
-
- retrieveReq.execute();
- }
-
- @Test
- public void updateMediaEntityAsAtom() throws Exception {
- updateMediaEntity(ODataPubFormat.ATOM, 14);
- }
-
- @Test
- public void updateMediaEntityAsJson() throws Exception {
- updateMediaEntity(ODataPubFormat.JSON, 15);
- }
-
- @Test
- public void createMediaEntityAsAtom() throws Exception {
- createMediaEntity(ODataPubFormat.ATOM, IOUtils.toInputStream("buffered stream sample"));
- }
-
- @Test
- public void createMediaEntityAsJson() throws Exception {
- createMediaEntity(ODataPubFormat.JSON, IOUtils.toInputStream("buffered stream sample"));
- }
-
- @Test
- public void issue137() throws Exception {
- createMediaEntity(ODataPubFormat.JSON, this.getClass().getResourceAsStream("/sample.png"));
- }
-
- @Test
- public void issue136() throws Exception {
- byte[] input = new byte[65000];
- for (int i = 0; i < 65000; i++) {
- input[i] = (byte) i;
- }
- createMediaEntity(ODataPubFormat.ATOM, new ByteArrayInputStream(input));
- }
-
- @Test(expected = HttpClientException.class)
- public void issue136FailsWithException() throws Exception {
- byte[] input = new byte[68000];
- for (int i = 0; i < 68000; i++) {
- input[i] = (byte) i;
- }
- createMediaEntity(ODataPubFormat.ATOM, new ByteArrayInputStream(input));
- }
-
- @Test
- public void updateNamedStream() throws Exception {
- URIBuilder builder = client.getURIBuilder(testDefaultServiceRootURL).
- appendEntityTypeSegment("Car").appendKeySegment(16).appendStructuralSegment("Photo");
-
- final String TO_BE_UPDATED = "buffered stream sample";
- final InputStream input = new ByteArrayInputStream(TO_BE_UPDATED.getBytes());
-
- final ODataStreamUpdateRequest updateReq =
- client.getStreamedRequestFactory().getStreamUpdateRequest(builder.build(), input);
-
- final StreamUpdateStreamManager streamManager = updateReq.execute();
- final ODataStreamUpdateResponse updateRes = streamManager.getResponse();
- updateRes.close();
- assertEquals(204, updateRes.getStatusCode());
-
- final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build());
-
- final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute();
- assertEquals(200, retrieveRes.getStatusCode());
- assertEquals(TO_BE_UPDATED, IOUtils.toString(retrieveRes.getBody()));
- }
-
- private void updateMediaEntity(final ODataPubFormat format, final int id) throws Exception {
- URIBuilder builder = client.getURIBuilder(testDefaultServiceRootURL).
- appendEntityTypeSegment("Car").appendKeySegment(id).appendValueSegment();
-
- final String TO_BE_UPDATED = "new buffered stream sample";
- final InputStream input = IOUtils.toInputStream(TO_BE_UPDATED);
-
- final ODataMediaEntityUpdateRequest updateReq =
- client.getStreamedRequestFactory().getMediaEntityUpdateRequest(builder.build(), input);
- updateReq.setFormat(format);
-
- final MediaEntityUpdateStreamManager streamManager = updateReq.execute();
- final ODataMediaEntityUpdateResponse updateRes = streamManager.getResponse();
- assertEquals(204, updateRes.getStatusCode());
-
- builder = client.getURIBuilder(testDefaultServiceRootURL).
- appendEntityTypeSegment("Car").appendKeySegment(id).appendValueSegment();
-
- final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build());
-
- final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute();
- assertEquals(200, retrieveRes.getStatusCode());
- assertEquals(TO_BE_UPDATED, IOUtils.toString(retrieveRes.getBody()));
- }
-
- private void createMediaEntity(final ODataPubFormat format, final InputStream input) throws Exception {
- final URIBuilder builder = client.getURIBuilder(testDefaultServiceRootURL).
- appendEntitySetSegment("Car");
-
- final ODataMediaEntityCreateRequest createReq =
- client.getStreamedRequestFactory().getMediaEntityCreateRequest(builder.build(), input);
- createReq.setFormat(format);
-
- final MediaEntityCreateStreamManager streamManager = createReq.execute();
- final ODataMediaEntityCreateResponse createRes = streamManager.getResponse();
- assertEquals(201, createRes.getStatusCode());
-
- final ODataEntity created = createRes.getBody();
- assertNotNull(created);
- assertEquals(2, created.getProperties().size());
-
- Integer id = null;
- for (ODataProperty prop : created.getProperties()) {
- if ("VIN".equals(prop.getName())) {
- id = prop.getPrimitiveValue().<Integer>toCastValue();
- }
- }
- assertNotNull(id);
-
- builder.appendKeySegment(id).appendValueSegment();
-
- final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build());
-
- final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute();
- assertEquals(200, retrieveRes.getStatusCode());
- assertNotNull(retrieveRes.getBody());
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/19f3792f/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/MediaEntityUpdateTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/MediaEntityUpdateTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/MediaEntityUpdateTestITCase.java
deleted file mode 100644
index 3c6d1c9..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/MediaEntityUpdateTestITCase.java
+++ /dev/null
@@ -1,155 +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 com.msopentech.odatajclient.engine.communication.request.retrieve.ODataMediaRequest;
-import com.msopentech.odatajclient.engine.communication.request.streamed.ODataMediaEntityUpdateRequest;
-import com.msopentech.odatajclient.engine.communication.request.streamed.ODataMediaEntityUpdateRequest.MediaEntityUpdateStreamManager;
-import java.io.InputStream;
-import java.net.URI;
-
-import org.apache.commons.lang3.StringUtils;
-import org.junit.Test;
-
-import com.msopentech.odatajclient.engine.communication.response.ODataMediaEntityUpdateResponse;
-import com.msopentech.odatajclient.engine.communication.response.ODataRetrieveResponse;
-import com.msopentech.odatajclient.engine.format.ODataPubFormat;
-import com.msopentech.odatajclient.engine.uri.URIBuilder;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.io.input.BoundedInputStream;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-
-public class MediaEntityUpdateTestITCase extends AbstractTestITCase {
-
- private void updateMediaEntity(
- final ODataPubFormat format,
- final String prefer,
- final String image,
- final int id) throws Exception {
-
- URIBuilder builder = client.getURIBuilder(testDefaultServiceRootURL).
- appendEntityTypeSegment("Car").appendKeySegment(id).appendValueSegment();
-
- // The sample service has an upload request size of 65k
- InputStream input = new BoundedInputStream(getClass().getResourceAsStream(image), 65000);
- final byte[] expected = new byte[65000];
- IOUtils.read(input, expected, 0, expected.length);
- IOUtils.closeQuietly(input);
-
- input = new BoundedInputStream(getClass().getResourceAsStream(image), 65000);
-
- final ODataMediaEntityUpdateRequest updateReq =
- client.getStreamedRequestFactory().getMediaEntityUpdateRequest(builder.build(), input);
- updateReq.setFormat(format);
- updateReq.setPrefer(prefer);
- final URI uri = client.getURIBuilder(testDefaultServiceRootURL).
- appendEntityTypeSegment("Car").appendKeySegment(id).build();
- final String etag = getETag(uri);
- if (StringUtils.isNotBlank(etag)) {
- updateReq.setIfMatch(etag);
- }
- final MediaEntityUpdateStreamManager streamManager = updateReq.execute();
- final ODataMediaEntityUpdateResponse updateRes = streamManager.getResponse();
- assertEquals(204, updateRes.getStatusCode());
-
- builder = client.getURIBuilder(testDefaultServiceRootURL).
- appendEntityTypeSegment("Car").appendKeySegment(id).appendValueSegment();
-
- final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build());
-
- final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute();
- assertEquals(200, retrieveRes.getStatusCode());
-
- final byte[] actual = new byte[65000];
- IOUtils.read(retrieveRes.getBody(), actual, 0, actual.length);
- assertTrue(new EqualsBuilder().append(expected, actual).isEquals());
- }
- // update media with JSON full metadata
-
- @Test
- public void updateMediaWithJSON() {
- ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
- String prefer = "return-content";
- String media1 = "/images/big_buck_bunny.mp4";
- String media2 = "/images/Renault.jpg";
- String media3 = "/images/image1.png";
- String media4 = "/images/20051210-w50s.flv";
- int id = 11;
- try {
- updateMediaEntity(format, prefer, media1, id);
- updateMediaEntity(format, prefer, media2, id);
- updateMediaEntity(format, prefer, media3, id);
- updateMediaEntity(format, prefer, media4, id);
- } catch (Exception e) {
- fail(e.getMessage());
- } catch (AssertionError e) {
- fail(e.getMessage());
- }
- }
- // update media with ATOM
-
- @Test
- public void updateMediaWithATOM() {
- ODataPubFormat format = ODataPubFormat.ATOM;
- String prefer = "return-content";
- String media = "/images/big_buck_bunny.mp4";
- int id = 12;
- try {
- updateMediaEntity(format, prefer, media, id);
- } catch (Exception e) {
- fail(e.getMessage());
- } catch (AssertionError e) {
- fail(e.getMessage());
- }
- }
- // update media with JSON minimla metadata
-
- @Test
- public void updateMediaWithJSONMinimal() {
- ODataPubFormat format = ODataPubFormat.JSON;
- String prefer = "return-content";
- String media = "/images/big_buck_bunny.mp4";
- int id = 13;
- try {
- updateMediaEntity(format, prefer, media, id);
- } catch (Exception e) {
- fail(e.getMessage());
- } catch (AssertionError e) {
- fail(e.getMessage());
- }
- }
- // update media with JSON no metadata
-
- @Test
- public void updateMediaWithJSONNoMetadata() {
- ODataPubFormat format = ODataPubFormat.JSON_NO_METADATA;
- String prefer = "return-content";
- String media = "/images/big_buck_bunny.mp4";
- int id = 14;
- try {
- updateMediaEntity(format, prefer, media, id);
- } catch (Exception e) {
- fail(e.getMessage());
- } catch (AssertionError e) {
- 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/MetadataRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/MetadataRetrieveTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/MetadataRetrieveTestITCase.java
deleted file mode 100644
index d987971..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/MetadataRetrieveTestITCase.java
+++ /dev/null
@@ -1,145 +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.List;
-
-import org.junit.Test;
-
-import com.msopentech.odatajclient.engine.communication.ODataClientErrorException;
-import com.msopentech.odatajclient.engine.communication.request.retrieve.ODataV3MetadataRequest;
-import com.msopentech.odatajclient.engine.communication.response.ODataRetrieveResponse;
-import com.msopentech.odatajclient.engine.metadata.EdmType;
-import com.msopentech.odatajclient.engine.metadata.EdmV3Metadata;
-import com.msopentech.odatajclient.engine.metadata.EdmV3Type;
-import com.msopentech.odatajclient.engine.metadata.edm.AbstractEntityType;
-import com.msopentech.odatajclient.engine.metadata.edm.v3.EntityType;
-import com.msopentech.odatajclient.engine.format.ODataPubFormat;
-
-public class MetadataRetrieveTestITCase extends AbstractTestITCase {
-
- private void retreiveMetadataTest(final ODataPubFormat reqFormat, final String acceptFormat) {
- // testing entity types which are not open
- final ODataV3MetadataRequest req = client.getRetrieveRequestFactory().
- getMetadataRequest(testStaticServiceRootURL);
- req.setFormat(reqFormat);
- req.setAccept(acceptFormat);
- try {
- final ODataRetrieveResponse<EdmV3Metadata> res = req.execute();
- final EdmV3Metadata metadata = res.getBody();
- assertNotNull(metadata);
- assertEquals(24, metadata.getSchemas().get(0).getEntityContainers().get(0).getEntitySets().size());
- final EdmType productCollection =
- new EdmV3Type(metadata, "Collection(Microsoft.Test.OData.Services.AstoriaDefaultService.Product)");
- assertTrue(productCollection.isCollection());
- assertFalse(productCollection.isSimpleType());
- assertFalse(productCollection.isEnumType());
- assertFalse(productCollection.isComplexType());
- assertTrue(productCollection.isEntityType());
- final AbstractEntityType type = productCollection.getEntityType();
- assertNotNull(type);
- assertFalse(type.isOpenType());
- assertEquals("Product", type.getName());
- final EdmType stream = new EdmV3Type(metadata, "Edm.Stream");
- assertNotNull(stream);
- assertTrue(stream.isSimpleType());
- assertFalse(stream.isCollection());
- assertFalse(stream.isEnumType());
- assertFalse(stream.isComplexType());
- assertFalse(stream.isEntityType());
- final EdmType customerCollection =
- new EdmV3Type(metadata, "Collection(Microsoft.Test.OData.Services.AstoriaDefaultService.Customer)");
- final AbstractEntityType customer = customerCollection.getEntityType();
- assertNotNull(type);
- assertFalse(customer.isOpenType());
- assertEquals("Customer", customer.getName());
-
- //testing open types
- ODataV3MetadataRequest req1 =
- client.getRetrieveRequestFactory().getMetadataRequest(testOpenTypeServiceRootURL);
-
- req.setFormat(reqFormat);
- req.setAccept(acceptFormat);
- final ODataRetrieveResponse<EdmV3Metadata> res1 = req1.execute();
- final EdmV3Metadata metadata1 = res1.getBody();
- List<EntityType> types = metadata1.getSchema(0).getEntityTypes();
- for (int i = 0; i < types.size(); i++) {
- assertTrue(types.get(0).isOpenType());
- }
- } catch (ODataClientErrorException e) {
- assertEquals(415, e.getStatusLine().getStatusCode());
- }
- }
-
- @Test
- public void jsonTest() {
- retreiveMetadataTest(ODataPubFormat.JSON, "application/json");
- }
-
- @Test
- public void atomTest() {
- retreiveMetadataTest(ODataPubFormat.ATOM, "application/atom+xml");
- }
-
- @Test
- public void xmlTest() {
- retreiveMetadataTest(ODataPubFormat.JSON, "application/xml");
- }
-
- @Test
- public void fullMetadataTest() {
- retreiveMetadataTest(ODataPubFormat.JSON_FULL_METADATA, "application/json");
- }
-
- @Test
- public void noMetadataTest() {
- retreiveMetadataTest(ODataPubFormat.JSON_NO_METADATA, "application/json");
- }
-
- @Test
- public void nullAcceptTest() {
- retreiveMetadataTest(ODataPubFormat.JSON_NO_METADATA, null);
- }
-
- @Test
- public void nullFormatTest() {
- retreiveMetadataTest(null, "application/json");
- }
-
- @Test
- public void atomWithNoAcceptTest() {
- retreiveMetadataTest(ODataPubFormat.ATOM, null);
- }
-
- @Test
- public void noFormatTest() {
- retreiveMetadataTest(null, "application/xml");
- }
-
- @Test
- public void large() {
- final EdmV3Metadata metadata = client.getRetrieveRequestFactory().
- getMetadataRequest(testLargeModelServiceRootURL).execute().getBody();
- assertNotNull(metadata);
-
- assertEquals(400, metadata.getSchemas().get(0).getEntityContainers().get(0).getEntitySets().size());
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/19f3792f/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/NavigationLinkCreateTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/NavigationLinkCreateTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/NavigationLinkCreateTestITCase.java
deleted file mode 100644
index 75f0394..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/NavigationLinkCreateTestITCase.java
+++ /dev/null
@@ -1,515 +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.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.junit.Test;
-
-import com.msopentech.odatajclient.engine.client.http.HttpClientException;
-import com.msopentech.odatajclient.engine.communication.request.cud.ODataDeleteRequest;
-import com.msopentech.odatajclient.engine.communication.request.cud.ODataEntityCreateRequest;
-import com.msopentech.odatajclient.engine.communication.request.retrieve.ODataEntityRequest;
-import com.msopentech.odatajclient.engine.communication.request.retrieve.ODataEntitySetRequest;
-import com.msopentech.odatajclient.engine.communication.response.ODataDeleteResponse;
-import com.msopentech.odatajclient.engine.communication.response.ODataEntityCreateResponse;
-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.ODataEntitySet;
-import com.msopentech.odatajclient.engine.data.ODataInlineEntity;
-import com.msopentech.odatajclient.engine.data.ODataInlineEntitySet;
-import com.msopentech.odatajclient.engine.data.ODataLink;
-import com.msopentech.odatajclient.engine.data.ODataProperty;
-import com.msopentech.odatajclient.engine.data.ODataValue;
-import com.msopentech.odatajclient.engine.metadata.edm.EdmSimpleType;
-import com.msopentech.odatajclient.engine.format.ODataPubFormat;
-import com.msopentech.odatajclient.engine.uri.URIBuilder;
-import com.msopentech.odatajclient.engine.utils.URIUtils;
-import org.junit.Ignore;
-
-public class NavigationLinkCreateTestITCase extends AbstractTestITCase {
-
- // create navigation link with ATOM
- @Test
- public void createNavWithAtom() {
- final ODataPubFormat format = ODataPubFormat.ATOM;
- final String contentType = "application/atom+xml";
- final String prefer = "return-content";
- final ODataEntity actual = createNavigation(format, 20, contentType, prefer);
- delete(format, actual, false, testStaticServiceRootURL);
- }
- // create navigation link with JSON full metadata
-
- @Test
- public void createNavWithJSONFullMetadata() {
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
- final String contentType = "application/json;odata=fullmetadata";
- final String prefer = "return-content";
- final ODataEntity actual = createNavigation(format, 21, contentType, prefer);
- delete(format, actual, false, testStaticServiceRootURL);
- }
- // throws Null pointer exception when the format is JSON No metadata
-
- @Test(expected = HttpClientException.class)
- public void createNavWithJSONNoMetadata() {
- final ODataPubFormat format = ODataPubFormat.JSON_NO_METADATA;
- final String contentType = "application/json;odata=nometadata";
- final String prefer = "return-content";
- final ODataEntity actual = createNavigation(format, 22, contentType, prefer);
- delete(format, actual, false, testStaticServiceRootURL);
- }
- // test with JSON accept and atom content type
-
- @Test
- @Ignore
- public void createNavWithJSONAndATOM() {
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
- final String contentType = "application/atom+xml";
- final String prefer = "return-content";
- final ODataEntity actual = createNavigation(format, 23, contentType, prefer);
- delete(format, actual, false, testStaticServiceRootURL);
- }
- // test with JSON full metadata in format and json no metadata in content type
-
- @Test
- public void createNavWithDiffJSON() {
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
- final String contentType = "application/json;odata=nometadata";
- final String prefer = "return-content";
- final ODataEntity actual = createNavigation(format, 24, contentType, prefer);
- delete(format, actual, false, testStaticServiceRootURL);
- }
- // test with JSON no metadata format and json no metadata in content type
-
- @Test(expected = HttpClientException.class)
- public void createNavWithNoMetadata() {
- final ODataPubFormat format = ODataPubFormat.JSON_NO_METADATA;
- final String contentType = "application/json;odata=fullmetadata";
- final String prefer = "return-content";
- final ODataEntity actual = createNavigation(format, 25, contentType, prefer);
- delete(format, actual, false, testStaticServiceRootURL);
- }
- // create collection navigation link with ATOM
-
- @Test
- public void createCollectionNavWithAtom() {
- final ODataPubFormat format = ODataPubFormat.ATOM;
- final String contentType = "application/atom+xml";
- final String prefer = "return-content";
- final ODataEntity actual = createCollectionNavigation(format, 55, contentType, prefer);
- delete(format, actual, false, testStaticServiceRootURL);
- }
- // create collection navigation link with JSON
-
- @Test
- public void createCollectionNavWithJSON() {
- final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
- final String contentType = "application/json;odata=fullmetadata";
- final String prefer = "return-content";
- final ODataEntity actual = createCollectionNavigation(format, 77, contentType, prefer);
- delete(format, actual, false, testStaticServiceRootURL);
- }
-
- // create a navigation link
- public ODataEntity createNavigation(final ODataPubFormat format, final int id, final String contenttype,
- final String prefer) {
- final String name = "Customer Navigation test";
-
- final ODataEntity original = getNewCustomer(id, name, false);
- original.addLink(client.getObjectFactory().newEntityNavigationLink(
- "Info", URI.create(testStaticServiceRootURL + "/CustomerInfo(11)")));
- final ODataEntity created = createNav(testStaticServiceRootURL, format, original, "Customer", contenttype,
- prefer);
-
- final ODataEntity actual = validateEntities(testStaticServiceRootURL, format, created, id, null, "Customer");
-
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL);
- uriBuilder.appendEntityTypeSegment("Customer").appendKeySegment(id).appendEntityTypeSegment("Info");
-
- final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(format);
- req.setContentType(contenttype);
- req.setPrefer(prefer);
- final ODataRetrieveResponse<ODataEntity> res = req.execute();
- assertEquals(200, res.getStatusCode());
- assertTrue(res.getHeader("DataServiceVersion").contains("3.0;"));
- final ODataEntity entity = res.getBody();
- assertNotNull(entity);
- for (ODataProperty prop : entity.getProperties()) {
- if ("CustomerInfoId".equals(prop.getName())) {
- assertEquals("11", prop.getValue().toString());
- }
- }
- return actual;
- }
-
- // create a navigation link
- public ODataEntity createNav(final String url, final ODataPubFormat format, final ODataEntity original,
- final String entitySetName, final String contentType, final String prefer) {
- final URIBuilder uriBuilder = client.getURIBuilder(url);
- uriBuilder.appendEntitySetSegment(entitySetName);
- final ODataEntityCreateRequest createReq =
- client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), original);
- createReq.setFormat(format);
- createReq.setContentType(contentType);
- createReq.setPrefer(prefer);
- final ODataEntityCreateResponse createRes = createReq.execute();
- assertEquals(201, createRes.getStatusCode());
-
- assertEquals("Created", createRes.getStatusMessage());
-
- final ODataEntity created = createRes.getBody();
- assertNotNull(created);
- return created;
- }
- // create collection navigation link
-
- public ODataEntity createCollectionNavigation(final ODataPubFormat format, final int id,
- final String contentType, final String prefer) {
- {
- final String name = "Collection Navigation Key Customer";
- final ODataEntity original = getNewCustomer(id, name, false);
-
- final Set<Integer> navigationKeys = new HashSet<Integer>();
- navigationKeys.add(-118);
- navigationKeys.add(-119);
-
- for (Integer key : navigationKeys) {
- final ODataEntity orderEntity =
- client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Order");
-
- orderEntity.addProperty(client.getObjectFactory().newPrimitiveProperty("OrderId",
- client.getPrimitiveValueBuilder().setValue(key).setType(EdmSimpleType.Int32).build()));
- orderEntity.addProperty(client.getObjectFactory().newPrimitiveProperty("CustomerId",
- client.getPrimitiveValueBuilder().setValue(id).setType(EdmSimpleType.Int32).build()));
-
- final ODataEntityCreateRequest createReq = client.getCUDRequestFactory().getEntityCreateRequest(
- client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Order").build(),
- orderEntity);
- createReq.setFormat(format);
- createReq.setContentType(contentType);
- original.addLink(client.getObjectFactory().newFeedNavigationLink(
- "Orders",
- createReq.execute().getBody().getEditLink()));
- }
- final ODataEntity createdEntity = createNav(testStaticServiceRootURL, format, original, "Customer",
- contentType, prefer);
- final ODataEntity actualEntity =
- validateEntities(testStaticServiceRootURL, format, createdEntity, id, null, "Customer");
-
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL);
- uriBuilder.appendEntityTypeSegment("Customer").appendKeySegment(id).appendEntityTypeSegment("Orders");
-
- final ODataEntitySetRequest req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
- req.setFormat(format);
-
- final ODataRetrieveResponse<ODataEntitySet> res = req.execute();
- assertEquals(200, res.getStatusCode());
-
- final ODataEntitySet entitySet = res.getBody();
- assertNotNull(entitySet);
-
- assertEquals(2, entitySet.getCount());
-
- for (ODataEntity entity : entitySet.getEntities()) {
- final Integer key = entity.getProperty("OrderId").getPrimitiveValue().<Integer>toCastValue();
- final Integer customerId = entity.getProperty("CustomerId").getPrimitiveValue().<Integer>toCastValue();
- assertTrue(navigationKeys.contains(key));
- assertEquals(Integer.valueOf(id), customerId);
- navigationKeys.remove(key);
- final ODataDeleteRequest deleteReq = client.getCUDRequestFactory().getDeleteRequest(
- URIUtils.getURI(testStaticServiceRootURL, entity.getEditLink().toASCIIString()));
-
- deleteReq.setFormat(format);
- assertEquals(204, deleteReq.execute().getStatusCode());
- }
-
- return actualEntity;
- }
- }
- // get a Customer entity to be created
-
- public ODataEntity getNewCustomer(
- final int id, final String name, final boolean withInlineInfo) {
-
- final ODataEntity entity =
- client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Customer");
-
- // add name attribute
- entity.addProperty(client.getObjectFactory().newPrimitiveProperty("Name",
- client.getPrimitiveValueBuilder().setText(name).setType(EdmSimpleType.String).build()));
-
- // add key attribute
- if (id != 0) {
- entity.addProperty(client.getObjectFactory().newPrimitiveProperty("CustomerId",
- client.getPrimitiveValueBuilder().setText(String.valueOf(id)).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("124365426534621534423ttrf").setType(EdmSimpleType.String).
- build()));
- contactDetails.add(client.getObjectFactory().newComplexProperty("HomePhone", homePhone));
-
- backupContactInfoValue.add(contactDetails);
- entity.addProperty(client.getObjectFactory().newCollectionProperty("BackupContactInfo",
- backupContactInfoValue));
- if (withInlineInfo) {
- final ODataInlineEntity inlineInfo = client.getObjectFactory().newInlineEntity("Info", URI.create(
- "Customer(" + id
- + ")/Info"), getInfo(id, name + "_Info"));
- inlineInfo.getEntity().setMediaEntity(true);
- entity.addLink(inlineInfo);
- }
-
- return entity;
- }
- //delete an entity and associated links after creation
-
- public void delete(final ODataPubFormat format, final ODataEntity created, final boolean includeInline,
- final String baseUri) {
- final Set<URI> toBeDeleted = new HashSet<URI>();
- toBeDeleted.add(created.getEditLink());
-
- if (includeInline) {
- for (ODataLink link : created.getNavigationLinks()) {
- if (link instanceof ODataInlineEntity) {
- final ODataEntity inline = ((ODataInlineEntity) link).getEntity();
- if (inline.getEditLink() != null) {
- toBeDeleted.add(URIUtils.getURI(baseUri, inline.getEditLink().toASCIIString()));
- }
- }
-
- if (link instanceof ODataInlineEntitySet) {
- final ODataEntitySet inline = ((ODataInlineEntitySet) link).getEntitySet();
- for (ODataEntity entity : inline.getEntities()) {
- if (entity.getEditLink() != null) {
- toBeDeleted.add(URIUtils.getURI(baseUri, entity.getEditLink().toASCIIString()));
- }
- }
- }
- }
- }
- assertFalse(toBeDeleted.isEmpty());
-
- for (URI link : toBeDeleted) {
- final ODataDeleteRequest deleteReq = client.getCUDRequestFactory().getDeleteRequest(link);
- final ODataDeleteResponse deleteRes = deleteReq.execute();
-
- assertEquals(204, deleteRes.getStatusCode());
- assertEquals("No Content", deleteRes.getStatusMessage());
-
- deleteRes.close();
- }
- }
- // add Information property
-
- public ODataEntity getInfo(final int id, final String info) {
- final ODataEntity entity =
- client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.CustomerInfo");
- entity.setMediaEntity(true);
-
- entity.addProperty(client.getObjectFactory().newPrimitiveProperty("Information",
- client.getPrimitiveValueBuilder().setText(info).setType(EdmSimpleType.String).build()));
- return entity;
- }
- // validate newly created entities
-
- public ODataEntity validateEntities(final String serviceRootURL,
- final ODataPubFormat format,
- final ODataEntity original,
- final int actualObjectId,
- final Collection<String> expands, final String entitySetName) {
-
- final URIBuilder uriBuilder = client.getURIBuilder(serviceRootURL).
- appendEntityTypeSegment(entitySetName).appendKeySegment(actualObjectId);
-
- if (expands != null) {
- for (String expand : expands) {
- uriBuilder.expand(expand);
- }
- }
- final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(format);
-
- final ODataRetrieveResponse<ODataEntity> res = req.execute();
- assertEquals(200, res.getStatusCode());
-
- final ODataEntity actual = res.getBody();
- assertNotNull(actual);
-
- validateLinks(original.getAssociationLinks(), actual.getAssociationLinks());
- validateLinks(original.getEditMediaLinks(), actual.getEditMediaLinks());
- validateLinks(original.getNavigationLinks(), actual.getNavigationLinks());
-
- checkProperties(original.getProperties(), actual.getProperties());
- return actual;
- }
- // compares links of the newly created entity with the previous
-
- public void validateLinks(final Collection<ODataLink> original, final Collection<ODataLink> actual) {
- assertTrue(original.size() <= actual.size());
-
- for (ODataLink originalLink : original) {
- ODataLink foundOriginal = null;
- ODataLink foundActual = null;
-
- for (ODataLink actualLink : actual) {
-
- if (actualLink.getType() == originalLink.getType()
- && (originalLink.getLink() == null
- || actualLink.getLink().toASCIIString().endsWith(originalLink.getLink().toASCIIString()))
- && actualLink.getName().equals(originalLink.getName())) {
-
- foundOriginal = originalLink;
- foundActual = actualLink;
- }
- }
-
- assertNotNull(foundOriginal);
- assertNotNull(foundActual);
-
- if (foundOriginal instanceof ODataInlineEntity && foundActual instanceof ODataInlineEntity) {
- final ODataEntity originalInline = ((ODataInlineEntity) foundOriginal).getEntity();
- assertNotNull(originalInline);
-
- final ODataEntity actualInline = ((ODataInlineEntity) foundActual).getEntity();
- assertNotNull(actualInline);
-
- checkProperties(originalInline.getProperties(), actualInline.getProperties());
- }
- }
- }
- // compares properties of the newly created entity with the properties that were originally provided
-
- public void checkProperties(final Collection<ODataProperty> original, final Collection<ODataProperty> actual) {
- assertTrue(original.size() <= actual.size());
-
- final Map<String, ODataProperty> actualProperties = new HashMap<String, ODataProperty>(actual.size());
-
- for (ODataProperty prop : actual) {
- assertFalse(actualProperties.containsKey(prop.getName()));
- actualProperties.put(prop.getName(), prop);
- }
-
- assertTrue(actual.size() <= actualProperties.size());
-
- for (ODataProperty prop : original) {
- assertNotNull(prop);
- if (actualProperties.containsKey(prop.getName())) {
- final ODataProperty actualProp = actualProperties.get(prop.getName());
- assertNotNull(actualProp);
-
- if (prop.getValue() != null && actualProp.getValue() != null) {
- checkPropertyValue(prop.getName(), prop.getValue(), actualProp.getValue());
- }
- }
- }
- }
- // compares property value of the newly created entity with the property value that were originally provided
-
- public void checkPropertyValue(final String propertyName,
- final ODataValue original, final ODataValue actual) {
-
- assertNotNull("Null original value for " + propertyName, original);
- assertNotNull("Null actual value for " + propertyName, actual);
-
- assertEquals("Type mismatch for '" + propertyName + "'",
- original.getClass().getSimpleName(), actual.getClass().getSimpleName());
-
- if (original.isComplex()) {
- final List<ODataProperty> originalPropertyValue = new ArrayList<ODataProperty>();
- for (ODataProperty prop : original.asComplex()) {
- originalPropertyValue.add(prop);
- }
-
- final List<ODataProperty> actualPropertyValue = new ArrayList<ODataProperty>();
- for (ODataProperty prop : (ODataComplexValue) actual) {
- actualPropertyValue.add(prop);
- }
-
- checkProperties(originalPropertyValue, actualPropertyValue);
- } else if (original.isCollection()) {
- assertTrue(original.asCollection().size() <= actual.asCollection().size());
-
- boolean found = original.asCollection().isEmpty();
-
- for (ODataValue originalValue : original.asCollection()) {
- for (ODataValue actualValue : actual.asCollection()) {
- try {
- checkPropertyValue(propertyName, originalValue, actualValue);
- found = true;
- } catch (AssertionError error) {
- }
- }
- }
-
- assertTrue("Found " + actual + " and expected " + original, found);
- } else {
- assertTrue("Primitive value for '" + propertyName + "' type mismatch",
- original.asPrimitive().getTypeName().equals(actual.asPrimitive().getTypeName()));
-
- assertEquals("Primitive value for '" + propertyName + "' mismatch",
- original.asPrimitive().toString(), actual.asPrimitive().toString());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/19f3792f/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/NavigationLinkTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/NavigationLinkTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/NavigationLinkTestITCase.java
deleted file mode 100644
index 147ff52..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/NavigationLinkTestITCase.java
+++ /dev/null
@@ -1,126 +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.List;
-
-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.response.ODataRetrieveResponse;
-import com.msopentech.odatajclient.engine.data.ODataEntity;
-import com.msopentech.odatajclient.engine.data.ODataEntitySet;
-import com.msopentech.odatajclient.engine.uri.URIBuilder;
-
-public class NavigationLinkTestITCase extends AbstractTestITCase {
-
- private void getListNavigationLinks(String acceptFormat) {
- URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendNavigationLinkSegment("Customer").appendKeySegment(-10).appendLinksSegment("Orders");
- ODataEntitySetRequest req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
- req.setAccept(acceptFormat);
- ODataRetrieveResponse<ODataEntitySet> res = req.execute();
- assertEquals(200, res.getStatusCode());
- ODataEntitySet entitySet = res.getBody();
- assertNotNull(entitySet);
- List<ODataEntity> entity = entitySet.getEntities();
- assertNotNull(entity);
- for (int i = 0; i < entity.size(); i++) {
- assertNotNull(entity.get(i).getProperties().get(0).getValue());
- }
- }
-
- private void getListNavigationLinksInvalidSegment(String acceptFormat) {
- URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendNavigationLinkSegment("Customer").appendKeySegment(-10).appendLinksSegment("Address");
- ODataEntitySetRequest req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
- req.setAccept(acceptFormat);
- req.execute();
- }
-
- private void getSingleNavigationLinks(String acceptFormat) {
- URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendNavigationLinkSegment("Customer").appendKeySegment(-10).appendLinksSegment("Orders").
- appendKeySegment(-10);
- ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setAccept(acceptFormat);
- ODataRetrieveResponse<ODataEntity> res = req.execute();
- assertEquals(200, res.getStatusCode());
- ODataEntity entity = res.getBody();
- assertNotNull(entity.getProperties().get(0).getValue());
- }
-
- private void getReferenceNavigationLinks(String acceptFormat) {
- URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendNavigationLinkSegment("Customer").appendKeySegment(-10).appendLinksSegment("Logins").
- appendKeySegment(-1);
- ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setAccept(acceptFormat);
- try {
- ODataRetrieveResponse<ODataEntity> res = req.execute();
- assertEquals(200, res.getStatusCode());
- ODataEntity entity = res.getBody();
- assertNotNull(entity);
- assertNotNull(entity.getProperties().get(0).getValue());
- } catch (ODataClientErrorException e) {
- if (e.getStatusLine().getStatusCode() == 415) {
- assertEquals(415, e.getStatusLine().getStatusCode());
- }
- if (e.getStatusLine().getStatusCode() == 404) {
- assertEquals(404, e.getStatusLine().getStatusCode());
- }
- }
- }
-
- @Test
- public void withJSON() {
- getListNavigationLinks("application/json");
- getSingleNavigationLinks("application/json");
- }
-
- @Test(expected = ODataClientErrorException.class)
- public void withATOM() {
- getListNavigationLinks("application/atom+xml");
- getSingleNavigationLinks("application/atom+xml");
- getReferenceNavigationLinks("application/atom+xml");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void withXML() {
- getListNavigationLinks("application/xml");
- getSingleNavigationLinks("application/xml");
- getReferenceNavigationLinks("application/xml");
- }
-
- @Test
- public void withNull() {
- getListNavigationLinks(null);
- getSingleNavigationLinks(null);
- getReferenceNavigationLinks(null);
- }
-
- @Test(expected = ODataClientErrorException.class)
- public void withInvalidSegment() {
- getListNavigationLinksInvalidSegment("application/json");
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/19f3792f/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/OpenTypeTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/OpenTypeTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/OpenTypeTestITCase.java
deleted file mode 100644
index 26997ce..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/OpenTypeTestITCase.java
+++ /dev/null
@@ -1,240 +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.cud.ODataEntityCreateRequest;
-import com.msopentech.odatajclient.engine.communication.response.ODataDeleteResponse;
-import com.msopentech.odatajclient.engine.communication.response.ODataEntityCreateResponse;
-import com.msopentech.odatajclient.engine.data.ODataComplexValue;
-import com.msopentech.odatajclient.engine.data.ODataEntity;
-import com.msopentech.odatajclient.engine.uri.URIBuilder;
-import com.msopentech.odatajclient.engine.metadata.EdmV3Metadata;
-import com.msopentech.odatajclient.engine.metadata.edm.EdmSimpleType;
-import com.msopentech.odatajclient.engine.metadata.edm.geospatial.Geospatial;
-import com.msopentech.odatajclient.engine.metadata.edm.geospatial.GeospatialCollection;
-import com.msopentech.odatajclient.engine.metadata.edm.geospatial.LineString;
-import com.msopentech.odatajclient.engine.metadata.edm.geospatial.MultiLineString;
-import com.msopentech.odatajclient.engine.metadata.edm.geospatial.MultiPoint;
-import com.msopentech.odatajclient.engine.metadata.edm.geospatial.MultiPolygon;
-import com.msopentech.odatajclient.engine.metadata.edm.geospatial.Point;
-import com.msopentech.odatajclient.engine.metadata.edm.geospatial.Polygon;
-import com.msopentech.odatajclient.engine.format.ODataPubFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
-import org.junit.Test;
-
-public class OpenTypeTestITCase extends AbstractTestITCase {
-
- @Test
- public void checkOpenTypeEntityTypesExist() {
- final EdmV3Metadata metadata = client.getRetrieveRequestFactory().
- getMetadataRequest(testOpenTypeServiceRootURL).execute().getBody();
-
- assertTrue(metadata.getSchemas().get(0).getEntityType("Row").isOpenType());
- assertTrue(metadata.getSchemas().get(0).getEntityType("IndexedRow").isOpenType());
- assertTrue(metadata.getSchemas().get(0).getEntityType("RowIndex").isOpenType());
- }
-
- private ODataEntity readRow(final ODataPubFormat format, final String uuid) {
- final URIBuilder builder = client.getURIBuilder(testOpenTypeServiceRootURL).
- appendEntityTypeSegment("Row").appendKeySegment(UUID.fromString(uuid));
- return read(format, builder.build());
- }
-
- private void read(final ODataPubFormat format) {
- ODataEntity row = readRow(format, "71f7d0dc-ede4-45eb-b421-555a2aa1e58f");
- assertEquals(EdmSimpleType.Double.toString(), row.getProperty("Double").getPrimitiveValue().getTypeName());
- assertEquals(EdmSimpleType.Guid.toString(), row.getProperty("Id").getPrimitiveValue().getTypeName());
-
- row = readRow(format, "672b8250-1e6e-4785-80cf-b94b572e42b3");
- assertEquals(EdmSimpleType.Decimal.toString(), row.getProperty("Decimal").getPrimitiveValue().getTypeName());
- }
-
- @Test
- public void readAsAtom() {
- read(ODataPubFormat.ATOM);
- }
-
- @Test
- public void readAsJSON() {
- read(ODataPubFormat.JSON_FULL_METADATA);
- }
-
- private void cud(final ODataPubFormat format) {
- final UUID guid = UUID.randomUUID();
-
- ODataEntity row = client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.OpenTypesService.Row");
- row.addProperty(client.getObjectFactory().newPrimitiveProperty("Id",
- client.getPrimitiveValueBuilder().setType(EdmSimpleType.Guid).setValue(guid).build()));
- row.addProperty(client.getObjectFactory().newPrimitiveProperty("aString",
- client.getPrimitiveValueBuilder().setType(EdmSimpleType.String).setValue("string").build()));
- row.addProperty(client.getObjectFactory().newPrimitiveProperty("aBoolean",
- client.getPrimitiveValueBuilder().setType(EdmSimpleType.Boolean).setValue(true).build()));
- row.addProperty(client.getObjectFactory().newPrimitiveProperty("aLong",
- client.getPrimitiveValueBuilder().setType(EdmSimpleType.Int64).setValue(15L).build()));
- row.addProperty(client.getObjectFactory().newPrimitiveProperty("aDouble",
- client.getPrimitiveValueBuilder().setType(EdmSimpleType.Double).setValue(1.5D).build()));
- row.addProperty(client.getObjectFactory().newPrimitiveProperty("aByte",
- client.getPrimitiveValueBuilder().setType(EdmSimpleType.SByte).setValue(Byte.MAX_VALUE).build()));
- row.addProperty(client.getObjectFactory().newPrimitiveProperty("aDate",
- client.getPrimitiveValueBuilder().setType(EdmSimpleType.DateTime).
- setValue(new Date()).build()));
-
- final Point point = new Point(Geospatial.Dimension.GEOGRAPHY);
- point.setX(1.2);
- point.setY(2.1);
- row.addProperty(client.getObjectFactory().newPrimitiveProperty("aPoint",
- client.getGeospatialValueBuilder().setType(EdmSimpleType.GeographyPoint).
- setValue(point).build()));
- final List<Point> points = new ArrayList<Point>();
- points.add(point);
- points.add(point);
- final MultiPoint multipoint = new MultiPoint(Geospatial.Dimension.GEOMETRY, points);
- row.addProperty(client.getObjectFactory().newPrimitiveProperty("aMultiPoint",
- client.getGeospatialValueBuilder().setType(EdmSimpleType.GeometryMultiPoint).
- setValue(multipoint).build()));
- final LineString lineString = new LineString(Geospatial.Dimension.GEOMETRY, points);
- row.addProperty(client.getObjectFactory().newPrimitiveProperty("aLineString",
- client.getGeospatialValueBuilder().setType(EdmSimpleType.GeometryLineString).
- setValue(lineString).build()));
- final List<LineString> lineStrings = new ArrayList<LineString>();
- lineStrings.add(lineString);
- lineStrings.add(lineString);
- final MultiLineString multiLineString = new MultiLineString(Geospatial.Dimension.GEOGRAPHY, lineStrings);
- row.addProperty(client.getObjectFactory().newPrimitiveProperty("aMultiLineString",
- client.getGeospatialValueBuilder().setType(EdmSimpleType.GeometryMultiLineString).
- setValue(multiLineString).build()));
- final Point otherPoint = new Point(Geospatial.Dimension.GEOGRAPHY);
- otherPoint.setX(3.4);
- otherPoint.setY(4.3);
- points.set(1, otherPoint);
- points.add(otherPoint);
- points.add(point);
- final Polygon polygon =
- new Polygon(Geospatial.Dimension.GEOGRAPHY, points, points);
- row.addProperty(client.getObjectFactory().newPrimitiveProperty("aPolygon",
- client.getGeospatialValueBuilder().setType(EdmSimpleType.GeographyPolygon).
- setValue(polygon).build()));
- final List<Polygon> polygons = new ArrayList<Polygon>();
- polygons.add(polygon);
- polygons.add(polygon);
- final MultiPolygon multiPolygon = new MultiPolygon(Geospatial.Dimension.GEOGRAPHY, polygons);
- row.addProperty(client.getObjectFactory().newPrimitiveProperty("aMultiPolygon",
- client.getGeospatialValueBuilder().setType(EdmSimpleType.GeographyMultiPolygon).
- setValue(multiPolygon).build()));
- final List<Geospatial> geospatials = new ArrayList<Geospatial>();
- geospatials.add(otherPoint);
- geospatials.add(polygon);
- geospatials.add(multiLineString);
- geospatials.add(multiPolygon);
- final GeospatialCollection geoColl = new GeospatialCollection(Geospatial.Dimension.GEOGRAPHY, geospatials);
- row.addProperty(client.getObjectFactory().newPrimitiveProperty("aCollection",
- client.getGeospatialValueBuilder().setType(EdmSimpleType.GeographyCollection).
- setValue(geoColl).build()));
-
- final ODataComplexValue contactDetails =
- new ODataComplexValue("Microsoft.Test.OData.Services.OpenTypesService.ContactDetails");
- contactDetails.add(client.getObjectFactory().newPrimitiveProperty("FirstContacted",
- client.getPrimitiveValueBuilder().setType(EdmSimpleType.Binary).setValue("text".getBytes()).
- build()));
- contactDetails.add(client.getObjectFactory().newPrimitiveProperty("LastContacted",
- client.getPrimitiveValueBuilder().setType(EdmSimpleType.DateTimeOffset).
- setText("2001-04-05T05:05:05.001+00:01").build()));
- contactDetails.add(client.getObjectFactory().newPrimitiveProperty("Contacted",
- client.getPrimitiveValueBuilder().setType(EdmSimpleType.DateTime).
- setText("2001-04-05T05:05:04.001").build()));
- contactDetails.add(client.getObjectFactory().newPrimitiveProperty("GUID",
- client.getPrimitiveValueBuilder().setType(EdmSimpleType.Guid).
- setValue(UUID.randomUUID()).build()));
- contactDetails.add(client.getObjectFactory().newPrimitiveProperty("PreferedContactTime",
- client.getPrimitiveValueBuilder().setType(EdmSimpleType.Time).
- setText("-P9DT51M10.5063807S").build()));
- contactDetails.add(client.getObjectFactory().newPrimitiveProperty("Byte",
- client.getPrimitiveValueBuilder().setType(EdmSimpleType.Byte).setValue(Integer.valueOf(241)).
- build()));
- contactDetails.add(client.getObjectFactory().newPrimitiveProperty("SignedByte",
- client.getPrimitiveValueBuilder().setType(EdmSimpleType.SByte).setValue(Byte.MAX_VALUE).build()));
- contactDetails.add(client.getObjectFactory().newPrimitiveProperty("Double",
- client.getPrimitiveValueBuilder().setType(EdmSimpleType.Double).setValue(Double.MAX_VALUE).build()));
- contactDetails.add(client.getObjectFactory().newPrimitiveProperty("Single",
- client.getPrimitiveValueBuilder().setType(EdmSimpleType.Single).setValue(Float.MAX_VALUE).build()));
- contactDetails.add(client.getObjectFactory().newPrimitiveProperty("Short",
- client.getPrimitiveValueBuilder().setType(EdmSimpleType.Int16).setValue(Short.MAX_VALUE).build()));
- contactDetails.add(client.getObjectFactory().newPrimitiveProperty("Int",
- client.getPrimitiveValueBuilder().setType(EdmSimpleType.Int32).setValue(Integer.MAX_VALUE).build()));
- contactDetails.add(client.getObjectFactory().newPrimitiveProperty("Long",
- client.getPrimitiveValueBuilder().setType(EdmSimpleType.Int64).setValue(Long.MAX_VALUE).build()));
- row.addProperty(client.getObjectFactory().newComplexProperty("aContact", contactDetails));
-
- final ODataEntityCreateRequest createReq = client.getCUDRequestFactory().
- getEntityCreateRequest(client.getURIBuilder(testOpenTypeServiceRootURL).
- appendEntityTypeSegment("Row").build(), row);
- createReq.setFormat(format);
- final ODataEntityCreateResponse createRes = createReq.execute();
- assertEquals(201, createRes.getStatusCode());
-
- row = readRow(format, guid.toString());
- assertNotNull(row);
- assertEquals(EdmSimpleType.Guid.toString(), row.getProperty("Id").getPrimitiveValue().getTypeName());
- assertEquals(EdmSimpleType.String.toString(), row.getProperty("aString").getPrimitiveValue().getTypeName());
- assertEquals(EdmSimpleType.Boolean.toString(), row.getProperty("aBoolean").getPrimitiveValue().getTypeName());
- assertEquals(EdmSimpleType.Int64.toString(), row.getProperty("aLong").getPrimitiveValue().getTypeName());
- assertEquals(EdmSimpleType.Double.toString(), row.getProperty("aDouble").getPrimitiveValue().getTypeName());
- assertEquals(EdmSimpleType.SByte.toString(), row.getProperty("aByte").getPrimitiveValue().getTypeName());
- assertEquals(EdmSimpleType.DateTime.toString(), row.getProperty("aDate").getPrimitiveValue().getTypeName());
- assertEquals(EdmSimpleType.GeographyPoint.toString(),
- row.getProperty("aPoint").getPrimitiveValue().getTypeName());
- assertEquals(EdmSimpleType.GeometryMultiPoint.toString(),
- row.getProperty("aMultiPoint").getPrimitiveValue().getTypeName());
- assertEquals(EdmSimpleType.GeometryLineString.toString(),
- row.getProperty("aLineString").getPrimitiveValue().getTypeName());
- assertEquals(EdmSimpleType.GeometryMultiLineString.toString(),
- row.getProperty("aMultiLineString").getPrimitiveValue().getTypeName());
- assertEquals(EdmSimpleType.GeographyPolygon.toString(),
- row.getProperty("aPolygon").getPrimitiveValue().getTypeName());
- assertEquals(EdmSimpleType.GeographyMultiPolygon.toString(),
- row.getProperty("aMultiPolygon").getPrimitiveValue().getTypeName());
- assertEquals(EdmSimpleType.GeographyCollection.toString(),
- row.getProperty("aCollection").getPrimitiveValue().getTypeName());
- assertEquals("Microsoft.Test.OData.Services.OpenTypesService.ContactDetails",
- row.getProperty("aContact").getComplexValue().getTypeName());
- assertEquals(EdmSimpleType.SByte.toString(),
- row.getProperty("aContact").getComplexValue().get("SignedByte").getPrimitiveValue().getTypeName());
-
- final ODataDeleteResponse deleteRes = client.getCUDRequestFactory().getDeleteRequest(row.getEditLink()).
- execute();
- assertEquals(204, deleteRes.getStatusCode());
- }
-
- @Test
- public void cudAsAtom() {
- cud(ODataPubFormat.ATOM);
- }
-
- @Test
- public void cudAsJSON() {
- cud(ODataPubFormat.JSON_FULL_METADATA);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/19f3792f/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/PrimitiveKeysTestITCase.java
----------------------------------------------------------------------
diff --git a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/PrimitiveKeysTestITCase.java b/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/PrimitiveKeysTestITCase.java
deleted file mode 100644
index ad325f3..0000000
--- a/ODataJClient/engine/src/test/java/com/msopentech/odatajclient/engine/it/PrimitiveKeysTestITCase.java
+++ /dev/null
@@ -1,81 +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 com.msopentech.odatajclient.engine.it.AbstractTestITCase.client;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import com.msopentech.odatajclient.engine.communication.request.retrieve.ODataEntityRequest;
-import com.msopentech.odatajclient.engine.communication.response.ODataRetrieveResponse;
-import com.msopentech.odatajclient.engine.data.ODataDuration;
-import com.msopentech.odatajclient.engine.data.ODataEntity;
-import com.msopentech.odatajclient.engine.format.ODataPubFormat;
-import java.math.BigDecimal;
-import java.util.UUID;
-import org.junit.Test;
-
-public class PrimitiveKeysTestITCase extends AbstractTestITCase {
-
- private void readEntity(final String entityType, final Object key, final ODataPubFormat format) {
- final ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(
- client.getURIBuilder(testPrimitiveKeysServiceRootURL).appendEntityTypeSegment(entityType).
- appendKeySegment(key).
- build());
- req.setFormat(format);
- final ODataRetrieveResponse<ODataEntity> res = req.execute();
- assertEquals(200, res.getStatusCode());
- final ODataEntity entity = res.getBody();
- assertNotNull(entity);
- assertNotNull(entity.getProperty("Id"));
- }
-
- private void readPrimitiveKeys(final ODataPubFormat format) {
- // commented as per #115
- //readEntity("EdmBinarySet", new byte[] {Byte.valueOf("2"), Byte.valueOf("3"), Byte.valueOf("4")}, format);
- readEntity("EdmBooleanSet", Boolean.TRUE, format);
- readEntity("EdmByteSet", 255, format);
- readEntity("EdmDecimalSet", new BigDecimal("79228162514264337593543950335"), format);
- readEntity("EdmDoubleSet", 1.7976931348623157E+308D, format);
- readEntity("EdmSingleSet", 3.40282347E+38F, format);
- readEntity("EdmGuidSet", UUID.fromString("00000000-0000-0000-0000-000000000000"), format);
- readEntity("EdmInt16Set", 32767, format);
- readEntity("EdmInt32Set", -2147483648, format);
- readEntity("EdmInt64Set", 9223372036854775807L, format);
- readEntity("EdmStringSet", "$", format);
- readEntity("EdmTimeSet", new ODataDuration("-P10675199DT2H48M5.4775808S"), format);
- // commented as per #115
- //readEntity("EdmDateTimeSet",
- // ODataTimestamp.parse(EdmSimpleType.DATE_TIME.pattern(), "0001-01-01T00:00:00"),
- // format);
- //readEntity("EdmDateTimeOffsetSet",
- // ODataTimestamp.parse(EdmSimpleType.DATE_TIME_OFFSET.pattern(), "2013-08-14T13:33:46.1045905+02:00"),
- // format);
- }
-
- @Test
- public void readEntityAsAtom() {
- readPrimitiveKeys(ODataPubFormat.ATOM);
- }
-
- @Test
- public void readEntityAsJSON() {
- readPrimitiveKeys(ODataPubFormat.JSON);
- }
-}